isofit.core.fileio
Attributes
Classes
A buffered file object that contains configuration information about formatting, etc. |
|
Functions
|
Write a chunk of data to a binary, BIL formatted data cube. |
|
Initialize output file by updating metadata and creating object. |
Module Contents
- class SpectrumFile(fname, write=False, n_rows=None, n_cols=None, n_bands=None, interleave=None, dtype=np.float32, wavelengths=None, fwhm=None, band_names=None, bad_bands='[]', zrange='{0.0, 1.0}', flag=-9999.0, ztitles='{Wavelength (nm), Magnitude}', map_info='{}', engine_name=None, isofit_version=None)[source]
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: Config, forward: ForwardModel, full_statevec: list = [])[source]
…
- get_components_at_index(row: int, col: int) InputData[source]
Load data from input files at the specified (row, col) index.
- Parameters:
row – row to retrieve data from
col – column to retrieve data from
- Returns:
object containing all current data reads
- Return type:
- write_datasets(row: int, col: int, output: dict, states: List, flush_immediately=False)[source]
Write all valid datasets to disk (possibly buffered).
- Parameters:
row – row to write to
col – column to write to
output – dictionary with keys corresponding to config.input file references
states – results states from inversion. In the MCMC case, these are interpreted as samples from the
posterior
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: List, input_data: InputData, fm: ForwardModel, iv: Inversion, fill_value=-9999.0)[source]
Build the output to be written to disk as a dictionary
- Parameters:
states – results states from inversion. In the MCMC case, these are interpreted as samples from the
posterior
converged (otherwise they are a gradient descent trajectory (with the last spectrum being the)
solution).
input_data – an InputData object
fm – the forward model used to solve the inversion
iv – the inversion object
- write_spectrum(row: int, col: int, states: List, fm: ForwardModel, iv: Inversion, flush_immediately=False, input_data: InputData = None)[source]
Convenience function to build and write output in one step
- Parameters:
row – data row to write
col – data column to write
states – results states from inversion. In the MCMC case, these are interpreted as samples from the
posterior
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 – the forward model used to solve the inversion
iv – the inversion object
flush_immediately – IO argument telling us to immediately write to disk, ignoring config settings
input_data – optionally overwride self.current_input_data
- write_bil_chunk(dat: numpy.array, outfile: str, line: int, shape: tuple, dtype: str = 'float32') None[source]
Write a chunk of data to a binary, BIL formatted data cube. :param dat: data to write :param outfile: output file to write to :param line: line of the output file to write to :param shape: shape of the output file :param dtype: output data type
- Returns:
None
- initialize_output(output_metadata, outpath, out_shape, **kwargs)[source]
Initialize output file by updating metadata and creating object.
- Parameters:
output_metadata (kwargs - key-argument pairs to add to) – dict - Dictionary with envi header information
outpath – str - path to output file
out_shape – tuple - dimensions of initialized file
keys_to_del – list - keys to remove from output_metadata
output_metadata