isofit.core.common¶
-
class
VectorInterpolator(grid_input, data_input, lut_interp_types)[source]¶ Bases:
objectLinear look up table interpolator. Support linear interpolation through radial space by expanding the look up tables with sin and cos dimensions.
Parameters: - grid_input (
List[List[float]]) – list of lists of floats, indicating the gridpoint elements in each grid dimension - data_input (
array) – n dimensional array of radiative transfer engine outputs (each dimension size corresponds to the given grid_input list length, with the last dimensions equal to the number of sensor channels) - lut_interp_types (
List[str]) – a list indicating if each dimension is in radiance (r), degrees (r), or normal (n) units.
- grid_input (
-
load_wavelen(wavelength_file)[source]¶ Load a wavelength file, and convert to nanometers if needed.
Parameters: wavelength_file ( str) – file to read wavelengths fromReturns: wavelengths, full-width-half-max Return type: (np.array, np.array)
-
emissive_radiance(emissivity, T, wl)[source]¶ Calcluate the radiance of a surface due to emission.
Parameters: - emissivity (
array) – surface emissivity. - T (
array) – surface temperature [K] - wl (
array) – emmissivity wavelengths [nm]
Returns: surface upwelling radiance in uW $cm^{-2} sr^{-1} nm^{-nm}$ np.array: partial derivative of radiance with respect to temperature uW $cm^{-2} sr^{-1} nm^{-1} k^{-1}$
Return type: np.array
- emissivity (
-
svd_inv(C, hashtable=None)[source]¶ Matrix inversion, based on decomposition. Built to be stable, and positive.
Parameters: - C (
array) – matrix to invert - hashtable (
Optional[OrderedDict]) – if used, the hashtable to store/retrieve results in/from
Returns: inverse of C
Return type: np.array
- C (
-
svd_inv_sqrt(C, hashtable=None)[source]¶ Matrix inversion, based on decomposition. Built to be stable, and positive.
Parameters: - C (
array) – matrix to invert - hashtable (
Optional[OrderedDict]) – if used, the hashtable to store/retrieve results in/from
Returns: inverse of C and square root of the inverse of C
Return type: (np.array, np.array)
- C (
-
expand_path(directory, subpath)[source]¶ Expand a path variable to an absolute path, if it is not one already.
Parameters: Returns: expanded path
Return type:
-
recursive_replace(obj, key, val)[source]¶ Find and replace a vector in a nested (mutable) structure.
Parameters: - obj – object to replace within
- key – key to replace
- val – value to replace with
Return type: None
-
get_absorption(wl, absfile)[source]¶ Calculate water and ice absorption coefficients using indices of refraction, and interpolate them to new wavelengths (user specifies nm).
Parameters: - wl (
array) – wavelengths to interpolate to - absfile (
str) – file containing indices of refraction
Returns: interpolated, wavelength-specific water absorption coefficients np.array: interpolated, wavelength-specific ice absorption coefficients
Return type: np.array
- wl (
-
recursive_reencode(j, shell_replace=True)[source]¶ Recursively re-encode a mutable object (ascii->str).
Parameters: - j – object to reencode
- shell_replace (
bool) – boolean helper for recursive calls
Returns: expanded, reencoded object
Return type: Object
-
json_load_ascii(filename, shell_replace=True)[source]¶ Load a hierarchical structure, convert all unicode to ASCII and expand environment variables.
Parameters: Returns: encoded dictionary
Return type:
-
expand_all_paths(to_expand, absdir)[source]¶ - Expand any dictionary entry containing the string ‘file’ into
- an absolute path, if needed.
Parameters: Returns: dictionary with expanded paths
Return type:
-
find_header(imgfile)[source]¶ Safely return the header associated with an image file.
Parameters: imgfile ( str) – file name of base imageReturns: header filename if one exists Return type: str
-
resample_spectrum(x, wl, wl2, fwhm2, fill=False)[source]¶ - Resample a spectrum to a new wavelength / FWHM.
- Assumes Gaussian SRFs.
Parameters: - x (
array) – radiance vector - wl (
array) – sample starting wavelengths - wl2 (
array) – wavelengths to resample to - fwhm2 (
array) – full-width-half-max at resample resolution - fill (
bool) – boolean indicating whether to fill in extrapolated regions
Returns: interpolated radiance vector
Return type: np.array
-
load_spectrum(spectrum_file)[source]¶ - Load a single spectrum from a text file with initial columns giving
- wavelength and magnitude, respectively.
Parameters: spectrum_file ( str) – file to load spectrum fromReturns: spectrum values np.array: wavelengths, if available in the file Return type: np.array
-
spectral_response_function(response_range, mu, sigma)[source]¶ Calculate the spectral response function.
Parameters: Returns: spectral response function
Return type: np.array
-
combos(inds)[source]¶ Return all combinations of indices in a list of index sublists. For example, the call:
combos([[1, 2], [3, 4, 5]]) ...[[1, 3], [2, 3], [1, 4], [2, 4], [1, 5], [2, 5]]
This is used for interpolation in the high-dimensional LUT.
Parameters: inds ( List[List[float]]) – list of lists of values to expandReturns: meshgrid array of combinations Return type: np.array
-
conditional_gaussian(mu, C, window, remain, x)[source]¶ Define the conditional Gaussian distribution for convenience.
len(window)+len(remain)=len(x)
Parameters: - mu (
array) – mean values - C (
array) – matrix for conditioning - window (
array) – contains all indices not in remain - remain (
array) – contains indices of the observed part x1 - x (
array) – values to condition with
Returns: conditional mean, conditional covariance
Return type: (np.array, np.array)
- mu (