f311.filetypes package¶
Submodules¶
f311.filetypes.datafile module¶
Ancestor class for all classes that represent an input file.
- class f311.filetypes.datafile.DataFile¶
Bases:
AttrsPart
Class representing a file in disk
- Attention For subclasses, filetype check is strongly advised. Two ways of doing this:
inherit _test_magic() (recommended);
if there are no testable magic characters, test for absurd within _do_load(). Try to crash early.
- default_filename = None¶
- description = 'Class representing a file in disk'¶
- editors = None¶
- flag_collect = True¶
- flag_txt = True¶
- init_default()¶
Initializes object with its default values
Tries to load self.default_filename from default data directory. For safety, filename is reset to None so that it doesn’t point to the original file.
- load(filename=None)¶
Loads file and registers filename as attribute.
- save_as(filename=None)¶
Dumps object contents into file on disk.
- Parameters:
filename (optional) – defaults to self.filename. If passed, self.filename will be updated to filename.
- validate()¶
f311.filetypes.filefits module¶
- class f311.filetypes.filefits.FileFits¶
Bases:
DataFile
Generic representation of a FITS file
Note normally, the DataFile classes load operation reads all contents and closes the file, however this class keeps the file open as an astropy.io.fits.HDUList object in self.hdulist, because apparently many HDUList methods need the file open to work, even after calling HDUList.readall()
- attrs = ['hdulist']¶
- flag_collect = False¶
- flag_txt = False¶
- f311.filetypes.filefits.test_fits_magic(filename)¶
For FITS files, we assume that they must start with “SIMPLE”.
This may not be specified in the standard, but I have seen this in all the files I opened
f311.filetypes.filepy module¶
- class f311.filetypes.filepy.ConfigDict(*args, **kwargs)¶
Bases:
dict
Data class to store config options as dictionary
- class f311.filetypes.filepy.FilePy¶
Bases:
DataFile
Configuration file saved as a .py Python source script
This class is not intendend to be instantialized. It is an ancestor class for other classes.
- class f311.filetypes.filepy.FilePyConfig¶
Bases:
FilePy
Base class for config files. Inherit and set class variable ‘modulevarname’ besides usual
- attrs = ['obj']¶
- init_default()¶
Initializes object with its default values
Tries to load self.default_filename from default data directory. For safety, filename is reset to None so that it doesn’t point to the original file.
- modulevarname = 'obj'¶
f311.filetypes.filespectrum module¶
Classes FileSpectrum and descendants
- class f311.filetypes.filespectrum.FileSpectrum¶
Bases:
DataFile
Base class for all files representing a single 1D spectrum
- attrs = ['spectrum']¶
- editors = ['splisted.py']¶
- load(filename=None)¶
Method was overriden to set spectrum.filename as well
- class f311.filetypes.filespectrum.FileSpectrumFits¶
Bases:
FileSpectrum
FITS Spectrum
- flag_txt = False¶
- class f311.filetypes.filespectrum.FileSpectrumXY¶
Bases:
FileSpectrum
“Lambda-flux” Spectrum (2-column text file)
File may have comment lines; these will be ignored altogether, because the file is read with numpy.loadtxt()
f311.filetypes.filesqlitedb module¶
- class f311.filetypes.filesqlitedb.FileSQLiteDB¶
Bases:
DataFile
Represents a SQLite database file.
This class is not supposed to be instantialized. It serves as an ancestor for other classes that implement specific database schemas.
- attrs = ['classname', 'filename', 'tables']¶
- close_if_open()¶
- commit()¶
- create_schema()¶
Creates database schema
- delete()¶
Removes .sqlite file. CAREFUL needless say
- ensure_schema()¶
Create file and schema if it does not exist yet.
- flag_txt = False¶
- get_column_names(tablename)¶
- get_conn(flag_force_new=False)¶
Returns sqlite3.Connection object with a non-default row factory.
- Parameters:
flag_force_new – returns a new connection irrespective of one already being open. Does not close existing open connection
- get_table_info(tablename)¶
Returns information about fields of a specific table
Returns: OrderedDict((“fieldname”, MyDBRow), …))
Note Fields “caption” and “tooltip” are added to rows using information in moldb.gui_info
- gui_info = {}¶
- init_default()¶
Overriden to take default database and save locally
The issue was that init_default() sets self.filename to None; however there can be no SQLite database without a corresponding file (not using memory here)
Should not keep default file open either (as it is in the API directory and shouldn’t be messed by user)
- populate()¶
Series of INSERT statements to populate database with its initial contents
- property tables¶
Return a list of the database table names
f311.filetypes.spectrum module¶
- class f311.filetypes.spectrum.Spectrum(x=None, y=None)¶
Bases:
object
Spectrum with several in-place operations, conversion utilities etc.
Routines that have the term in place: it means that the spectrum itself is changed and nothing is returned
- clear_more_headers()¶
Clears .more_headers dictionary, except for X-UNIT and Y-UNIT
- convert_x(new_unit)¶
Converts x-axis to new unit
- cut(l0, l1)¶
Cuts in place to wavelength interval [l0, l1]. Cut is done within the array objects thus keeping the same objects
- cut_idxs(i0, i1)¶
Cuts in place to slice i0:i1 (pythonic, interval = [i0, i1[
- property delta_lambda¶
Returns delta lambda or NaN if found not to be constant
- property flux¶
Flux vector. Equivalent to y
- from_hdu(hdu)¶
- property l0¶
Lower bound of wavelength vector
- property lf¶
Upper bound of wavelength vector
- property llfin¶
Upper bound of wavelength vector. Synonym with lf
- property llzero¶
Lower bound of wavelength vector. Synonym with l0
- one_liner_str()¶
- property pixel_x¶
- property pixel_y¶
- resample(new_wavelength, kind='linear')¶
Resamples in-place to new wavelength vector using interpolation
- Parameters:
new_wavelength – new wavelength vector
kind – interpolation kind to be passed to scipy.interpolate.interp1d
- property title¶
“Title” of the spectrum. Returns self._title or if None, other options
- to_hdu()¶
Converts to FITS HDU. delta_lambda must be a constant
- property wavelength¶
Wavelength vector. Equivalent to wavelenght
- property xunit¶
Unit of the wavelength axis (some unit from astropy.units)
- property ylabel¶
Y-label for plotting purposes
- property yunit¶
Unit of the wavelength axis (some unit from astropy.units)
- property z_start¶
Module contents¶
Data representations.