isofit.core.fileio
- class SpectrumFile(fname, write=False, n_rows=None, n_cols=None, n_bands=None, interleave=None, dtype=<class 'numpy.float32'>, wavelengths=None, fwhm=None, band_names=None, bad_bands='[]', zrange='{0.0, 1.0}', flag=-9999.0, ztitles='{Wavelength (nm), Magnitude}', map_info='{}')[source]
Bases:
object
A buffered file object that contains configuration information about formatting, etc.
- get_frame(row)[source]
The frame is a 2D array, essentially a list of spectra. The self.frames list acts as a hash table to avoid storing the entire cube in memory. So we read them or create them on an as-needed basis. When the buffer flushes via a call to flush_buffers, they will be deleted.
- write_spectrum(row, col, x)[source]
We write a spectrum. If a binary format file, we simply change the data cached in self.frames and defer file I/O until flush_buffers is called.
- class IO(config, forward)[source]
Bases:
object
…
- get_components_at_index(row, col)[source]
Load data from input files at the specified (row, col) index.
- write_datasets(row, col, output, states, flush_immediately=False)[source]
Write all valid datasets to disk (possibly buffered).
- Parameters:
row (
int
) – row to write tocol (
int
) – column to write tooutput (
dict
) – dictionary with keys corresponding to config.input file referencesstates (
List
) – results states from inversion. In the MCMC case, these are interpreted as samples from theposterior –
converged (otherwise they are a gradient descent trajectory (with the last spectrum being the) –
solution). –
flush_immediately – IO argument telling us to immediately write to disk, ignoring config settings
- build_output(states, input_data, fm, iv)[source]
Build the output to be written to disk as a dictionary
- Parameters:
states (
List
) – results states from inversion. In the MCMC case, these are interpreted as samples from theposterior –
converged (otherwise they are a gradient descent trajectory (with the last spectrum being the) –
solution). –
input_data (
InputData
) – an InputData objectfm (
ForwardModel
) – the forward model used to solve the inversioniv (
Inversion
) – the inversion object
- write_spectrum(row, col, states, fm, iv, flush_immediately=False, input_data=None)[source]
Convenience function to build and write output in one step
- Parameters:
row (
int
) – data row to writecol (
int
) – data column to writestates (
List
) – results states from inversion. In the MCMC case, these are interpreted as samples from theposterior –
converged (otherwise they are a gradient descent trajectory (with the last spectrum being the) –
solution). –
meas – measurement radiance
geom – geometry object of the observation
fm (
ForwardModel
) – the forward model used to solve the inversioniv (
Inversion
) – the inversion objectflush_immediately – IO argument telling us to immediately write to disk, ignoring config settings
input_data (
Optional
[InputData
]) – optionally overwride self.current_input_data
- write_bil_chunk(dat, outfile, line, shape, dtype='float32')[source]
Write a chunk of data to a binary, BIL formatted data cube. :type dat:
array
:param dat: data to write :type outfile:str
:param outfile: output file to write to :type line:int
:param line: line of the output file to write to :type shape:tuple
:param shape: shape of the output file :type dtype:str
:param dtype: output data type- Return type:
- Returns:
None