isofit.core.common
- class VectorInterpolator(grid_input, data_input, lut_interp_types, version='nds-1')[source]
Bases:
object
Linear 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 dimensiondata_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.version – version to use: ‘rg’ for scipy RegularGridInterpolator, ‘mlg’ for multilinear grid interpolator
- load_wavelen(wavelength_file)[source]
Load a wavelength file, and convert to nanometers if needed.
- Parameters:
wavelength_file (
str
) – file to read wavelengths from- Returns:
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
- svd_inv(C, hashtable=None, max_hash_size=None)[source]
Matrix inversion, based on decomposition. Built to be stable, and positive.
- Parameters:
C (
array
) – matrix to inverthashtable (
Optional
[OrderedDict
]) – if used, the hashtable to store/retrieve results in/from
- Returns:
inverse of C
- Return type:
np.array
- svd_inv_sqrt(C, hashtable=None, max_hash_size=None)[source]
Matrix inversion, based on decomposition. Built to be stable, and positive.
- Parameters:
C (
array
) – matrix to inverthashtable (
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)
- expand_path(directory, subpath)[source]
Expand a path variable to an absolute path, if it is not one already.
- 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:
- 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 toabsfile (
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
- get_refractive_index(k_wi, a, b, col_wvl, col_k)[source]
Convert refractive index table entries to numpy array.
- Parameters:
k_wi – variable
a – start line
b – end line
col_wvl – wavelength column in pandas table
col_k – k column in pandas table
- Returns:
array of wavelengths k_arr: array of imaginary parts of refractive index
- Return type:
wvl_arr
- 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.
- expand_all_paths(to_expand, absdir)[source]
- Expand any dictionary entry containing the string ‘file’ into
an absolute path, if needed.
- resample_spectrum(x, wl, wl2, fwhm2, fill=False)[source]
- Resample a spectrum to a new wavelength / FWHM.
Assumes Gaussian SRFs.
- Parameters:
x (
array
) – radiance vectorwl (
array
) – sample starting wavelengthswl2 (
array
) – wavelengths to resample tofwhm2 (
array
) – full-width-half-max at resample resolutionfill (
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 from- Returns:
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.
- 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.
- 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 valuesC (
array
) – matrix for conditioningwindow (
array
) – contains all indices not in remainremain (
array
) – contains indices of the observed part x1x (
array
) – values to condition with
- Returns:
conditional mean, conditional covariance
- Return type:
(np.array, np.array)