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.

open_map_with_retries()[source]

Try to open a memory map, handling Beowulf I/O issues.

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.

read_spectrum(row, col)[source]

Get a spectrum from the frame list or ASCII file. Note that if we are an ASCII file, we have already read the single spectrum and return it as-is (ignoring the row/column indices).

flush_buffers()[source]

Write to file, and refresh the memory map object.

class IO(config, forward, inverse, active_rows, active_cols)[source]

Bases: object

get_components_at_index(index)[source]

Get the spectrum from the file at the specified index. Helper/ parallel enabling function.

Parameters:index (int) – reference location for iter_inds
Returns:success: boolean flag indicating if data present
Returns:r: row index
Returns:c: column index
Returns:meas: measured radiance file
Return type:(<class ‘int’>, <class ‘int’>, <built-in function array>, <class ‘isofit.core.geometry.Geometry’>)
Returns:geom: set up specified geometry files
check_wavelengths(wl)[source]

Make sure an input wavelengths align to the instrument definition.

flush_buffers()[source]

Write all buffered output data to disk, and erase read buffers.

write_spectrum(row, col, states, meas, geom, flush_immediately=False)[source]

Write data from a single inversion to all output buffers.