sicor.AC package

Submodules

sicor.AC.ACG module

sicor.AC.ACG.ac_for_line(i1, **opt_args)[source]
sicor.AC.ACG.adjust_sample_definition()[source]
sicor.AC.ACG.aux_data_to_p0_e0(data, aux_data)[source]

Follow aux data protocol :param data: input data field, needed for shape :param aux_data: dict of dict :return: 2D fields for p0,e0 for each key in aux_data, content defined by aux data protocol

sicor.AC.ACG.clean_up_memmaps()[source]
sicor.AC.ACG.convert_data_to_reflectance(data, pt, fo, args)[source]
sicor.AC.ACG.copy_anything(src, dst)[source]
sicor.AC.ACG.copy_results(i1, res)[source]
sicor.AC.ACG.get_arguments()[source]
sicor.AC.ACG.get_fo_dims(fos)[source]
sicor.AC.ACG.get_instruments(rtfo, metadata=None, expand_wvl=20.0, wvl_rsp_resolution=0.2)[source]

set up of the instruments dictionary :return: dict with instrument spec for rt_fo

sicor.AC.ACG.get_logger(msg=None, fmt='%(asctime)s - %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S')[source]

Init a logger and set formater. :param msg: string, first call to info :param fmt: format to set the Formater :param datefmt: format for Formater :return: logging instance

sicor.AC.ACG.get_output_fields(data)[source]
sicor.AC.ACG.get_point_and_error_fields(data, metadata, pt_dims, default_value=-999.0)[source]
sicor.AC.ACG.get_pt_names_and_indexes(fos, settings)[source]
sicor.AC.ACG.get_settings()[source]
sicor.AC.ACG.instrument_subset(instrument, subset)[source]
sicor.AC.ACG.log_memory()[source]
sicor.AC.ACG.opt(i1, i2, fo='flags', raise_flag=True, wvl_idxs=slice(None, None, None), **opt_args)[source]
sicor.AC.ACG.processing(**opt_args)[source]
sicor.AC.ACG.processing_multi(**opt_args)[source]
sicor.AC.ACG.processing_single(**opt_args)[source]
sicor.AC.ACG.rho_models_to_kwargs(rtfo, rho_model, wvls, logger)[source]
Parameters:
  • wvls

  • rtfo

  • rho_model – dict with opts

Returns:

list of instances of rho to ry and vice versa

sicor.AC.ACG.sample_optimization_and_upscale_results(data, p0)[source]
sicor.AC.ACG.test_for_memmap(data)[source]

if data is memmao, append it to global variable memmaps for delete on done :param data: :return:

sicor.AC.RtFo module

class sicor.AC.RtFo.FF(fo, optimize_dims_atm, weight=None, wvl_sel=slice(None, None, None))[source]

Bases: object

static apply_bounds(xii, bounds_up, bounds_dn)[source]
x0(p0=None, data=None, first_guess=None)[source]

Estimation of the first guess solution x0. x0 contains a first guess solution of parameter concentration as well as estimated reflectance values at the two continuum levels of the chosen absorption feature. :param p0: :param data: :param first_guess: :return:

x_phys_to_scaled(xx)[source]
x_scaled_to_phys(xx)[source]
class sicor.AC.RtFo.Rho2Rj(rho_wvl)[source]

Bases: object

class sicor.AC.RtFo.Rho2Rj_LinInterp(**kwargs)[source]

Bases: object

class sicor.AC.RtFo.Rho2Rj_PCA(components, mean, rho_wvl, bounds=None)[source]

Bases: object

class sicor.AC.RtFo.Rho2Rj_const(rho_wvl)[source]

Bases: object

class sicor.AC.RtFo.Rj2RhoJ(rho_wvl)[source]

Bases: object

class sicor.AC.RtFo.Rj2RhoJ_LinInterp(**kwargs)[source]

Bases: object

class sicor.AC.RtFo.Rj2RhoJ_PCA(components, mean, rho_wvl, bounds=None)[source]

Bases: Rho2Rj_PCA

class sicor.AC.RtFo.Rj2RhoJ_const(rho_wvl)[source]

Bases: object

class sicor.AC.RtFo.RtFo(atm_tables_fn, dim_scat, dim_atm=('spr', 'coz', 'cwv', 'tmp'), dim_vza='vza', dim_sza='sza', dim_azi='azi', dim_pca='pca', dim_wvl='wvl', dim_layer='layer', table_path='', buffer_tables=None, only_toa=False, n_pcs=99, dtype=<class 'numpy.float32'>, slices=None, hash_formats=None, hash_format_default='%.3f, ', interpol_dim_range=range(1, 12), sensors=None, response_function_threshold=1e-05, sensor_interpolation_reference='sensor', sol_irr_pca=None, default_sensor=None, **_)[source]

Bases: object

  1. Build Forward Operator Object including relevant data from LUT

2. Interpolation of atmospheric functions for a specific spectral subset, returns object which can be used to compute toa reflectance, radiance and surface reflectance :param atm_tables_fn: path to LUT :param dim_scat: key of relevant scattering parameter (tau) :param dim_atm: keys of relevant atmospheric parameters :param dim_vza: key of viewing zenith angle :param dim_sza: key of sun zenith angle :param dim_azi: key of sun azimuth angle :param dim_pca: key of principle components :param dim_wvl: key of wavelengths :param dim_layer: key of atmospheric layer :param table_path: path to aerosol table within LUT :param buffer_tables: AC table for specific sensors (smile) :param only_toa: use only TOA fluxes :param n_pcs: number of principle components :param dtype: data type of values stored in dimensions dictionary :param slices: part of LUT which should be considered :param hash_formats: fixed length of the parameter values :param hash_format_default: default length of the parameter values :param interpol_dim_range: maximum dimension of interpolation :param sensors: dict containing wavelength, response function and solar irradiances of input sensor :param response_function_threshold: threshold for sensor response function :param sensor_interpolation_reference: interpolation reference :param sol_irr_pca: principle components of solar irradiance :param default_sensor: default sensor :param _:

ee(pt)[source]

Interpolate E_DN for a given atmospheric state pt. :param pt: atmospheric state :return: solar downward reflection at the surface

get_wvl_idx(data_wvls, sensor_name=None)[source]
Parameters:
  • sensor_name

  • data_wvls – numpy array with wavelength as used in the data

Returns:

numpy array with ints which give the closest indices to the wavelength in data_wvls

interpolation_settings(jacobean, caching)[source]

Set Jacobean and/or caching to True or False. :param jacobean: True or False :param caching: True or False :return: None

l0(pt)[source]

Interpolate L0 for a given atmospheric state pt. :param pt: atmospheric state :return: atmospheric path reflectance

mu_sun(pt)[source]

Compute cosine of solar incidence angle for given background state pt. :param pt: pt numpy ndarray which holds background information for data, e.g. 1-D array with state (water vapor, observation angles, …) or e.g. 3-D array with first two dimensions for the ‘image’ and the last for the state :return: cosine of solar angle

pt(**kwargs)[source]
ptrh2x(pt, rj)[source]
radiance_to_reflectance(radiance, pt, in_place=False)[source]

Convert TOA radiance to reflectance. :param radiance: TOA radiance :param pt: atmospheric state :param in_place: if True, convert input radiance array without returning a new one :return: if in_place=False, TOA reflectance, else None

radiance_toa(pt, rho)[source]

Convert TOA reflectance, calculated by the simplified solution of the RTE, to radiance. :param pt: atmospheric state :param rho: surface reflectance :return: TOA radiance

radiance_toa_j(pt)[source]

Convert TOA reflectance, calculated by the simplified solution of the RTE, to radiance. Additionally, the Jacobian is calculated. :param pt: atmospheric state :return: TOA radiance and the Jacobian

reduce_luts(reduce_suffix, reduce_dims, set_new_luts=True)[source]

Function to call for reducing dimension of LUT. :param reduce_suffix: suffix of the name for LUT subset :param reduce_dims: state parameters to be fixed :param set_new_luts: :return: None

reflectance_boa(pt, toa_radiance=None, toa_reflectance=None)[source]

Calculate surface reflectance for a given atmospheric state and for given TOA reflectance or radiance by interpolating in the LUT and applying the simplified solution of the RTE. :param pt: atmospheric state :param toa_radiance: TOA radiance :param toa_reflectance: TOA reflectance :return: surface reflectance

reflectance_boa_j(pt, toa_radiance=None, toa_reflectance=None)[source]

Calculate surface reflectance for a given atmospheric state and for given TOA reflectance or radiance by interpolating in the LUT and applying the simplified solution of the RTE. Additionally, the Jacobian is calculated. :param pt: atmospheric state :param toa_radiance: TOA radiance :param toa_reflectance: TOA reflectance :return: surface reflectance and the Jacobian

reflectance_to_radiance(reflectance, pt)[source]

Convert TOA reflectance to radiance. :param reflectance: TOA reflectance :param pt: atmospheric state :return: TOA radiance

reflectance_toa(pt, rho)[source]

Calculate TOA reflectance for a given atmospheric state and for given surface reflectance by interpolating in the LUT and applying the simplified solution of the RTE. :param pt: atmospheric state :param rho: surface reflectance :return: TOA reflectance

reflectance_toa_j(pt)[source]

Calculate TOA reflectance for a given atmospheric state by interpolating in the LUT and applying the simplified solution of the RTE. The needed surface reflectance value is derived from the predefined surface reflectance model. Additionally, the Jacobian is calculated. :param pt: atmospheric state :return: TOA reflectance and the Jacobian

set_jacobean_switch(**kwargs)[source]

update self.jacobean_switch and update function jacobean switch matrices

set_luts(suffix)[source]

Assigns a LUT to the forward operator. :param suffix: suffix of the LUT’s name :return: None

set_rho_lin(Rho2Rj, Rj2RhoJ)[source]

Assign the surface reflectance model to the forward operator. :param Rho2Rj: Model to obtain a first guess of surface reflectance values for selected absorption feature wavelengths. :param Rj2RhoJ: Surface reflectance model. Following models can be chosen: Rj2RhoJ_LinInterp, Rj2RhoJ_PCA or Rj2RhoJ_const for Sentinel-2; Rj2RhoJ_LinX1X2 for EnMAP single CH4/CWV Retrieval or Rj2RhoJ_Beer_Lambert for EnMAP simultaneous 3 phases of water retrieval. :return: None

set_sensor(sensor_name=None)[source]
ss(pt)[source]

Interpolate SS for a given atmospheric state pt. :param pt: atmospheric state :return: spherical albedo

tt(pt)[source]

Interpolate T_UP for a given atmospheric state pt. :param pt: atmospheric state :return: upward transmittance

x_phys_to_scaled(xx, offset_scaling=1.0)[source]

Convert physical values of atmospheric state parameters to scaled values with respect to the upper bounds.. :param xx: array containing physical values of atmospheric state parameters :param offset_scaling: offset scaling :return: array containing scaled values of atmospheric state parameters (ratio of the max. value as defined in LUT)

x_scaled_to_phys(xx, offset_scaling=1.0)[source]

Convert scaled values of atmospheric parameters to physical values. :param xx: array containing scaled values of atmospheric state parameters (ratio of the max. value as defined in LUT) :param offset_scaling: offset scaling :return: array containing physical values of atmospheric state parameters

sicor.AC.RtFo.apply_bounds(xii, xi, bounds_up, bounds_dn)[source]
sicor.AC.RtFo.int_rho(n_inp, xx_inp, yy_inp, n_int, xx_int, yy_out, jac_out)[source]
Parameters:
  • n_inp

  • xx_inp

  • yy_inp

  • n_int

  • xx_int

  • yy_out

  • jac_out

Returns:

sicor.AC.RtFo.nrm(aa, bb)[source]
sicor.AC.RtFo.opt(self, y_rfl, pt0, rho_0={'method': 'const', 'value': 0.1}, ftol=None, ftol_rel=None, ee=1.05, n_iter=55, n_bad=5, debug=False, g=0.0, ssei=None, ssai=None, instrument_error_model=None, compute_errors=True, sc_oe_thres=0.01, optimization=True, se_jj_sa=CPUDispatcher(<function __se_jj_sa_jit__>), rho_fg=None)[source]
sicor.AC.RtFo.rho_wvl_lin_int(wvl, rho_wvl=None, n_rho_max=None, extra_points=None, linear_segments=None, min_wvl_difference=1.0)[source]
sicor.AC.RtFo.sat(wvl_inst, wvl_rsp, solar, rspf_type='gaussian', sigma=None, width=None)[source]

Calculate normalized sensor specific response function with respect to given instrument wavelengths. :param wvl_inst: instrument wavelengths :param wvl_rsp: response wavelengths :param solar: solar irradiances :param rspf_type: type of response function, either “gaussian” or “box” :param sigma: fwhm of instrument bands (only for type “gaussian”) :param width: fwhm of instrument bands (only for type “box”) :return: dictionary containing instrument wavelengths, response wavelengths, sensor specific response function and solar irradiances

sicor.AC.RtFo_3_phases module

class sicor.AC.RtFo_3_phases.Fo(enmap_l1b, options, logger=None)[source]

Bases: object

Forward operator for input TOA radiance data in standard EnMAP L1B format.

Instance of forward operator object.

Parameters:
  • enmap_l1b – EnMAP Level-1B object

  • options – dictionary with EnMAP specific options

  • logger – None or logging instance

calc_kb(xx, pt, num_bd, sb)[source]

Derivative of measurement with respect to unmodeled & unretrieved unknown variables, e.g. S_b. This is the concatenation of Jacobians with respect to parameters of the surface and the forward model.

Parameters:
  • xx – state vector

  • pt – forward model parameter vector

  • num_bd – number of instrument bands

  • sb – unknown forward model parameter error covariance matrix

Returns:

Jacobian of unknown forward model parameters

calc_se(xx, dt, pt, sb, num_bd, snr, unknowns)[source]

Calculate the total uncertainty of the observation, including both the instrument noise and the uncertainty due to unmodeled variables. This is the S_epsilon matrix of Rodgers et al.

Parameters:
  • xx – state vector

  • dt – measurement vector

  • pt – forward model parameter vector

  • sb – error covariance matrix of unknown forward model parameters

  • num_bd – number of instrument bands

  • snr – signal-to-noise ratio for each instrument band

  • unknowns – if True, uncertainties due to unknown forward model parameters are added to S_epsilon; default: False

Returns:

measurement error covariance matrix

drdn_drtb(xx, pt, rdn)[source]

Calculate Jacobian of radiance with respect to unknown forward model parameters.

Parameters:
  • xx – state vector

  • pt – forward model parameter vector

  • rdn – modeled TOA radiance for the current state vector xx

Returns:

Jacobian of unknown forward model parameters

drdn_dsurfaceb(xx, pt, rdn)[source]

Calculate Jacobian of radiance with respect to unknown surface model parameters.

Parameters:
  • xx – state vector

  • pt – forward model parameter vector

  • rdn – modeled TOA radiance for the current state vector xx

Returns:

Jacobian of unknown surface model parameters

surf_ref(dt, xx, pt, mode=None)[source]

Invert the simplified solution of the RTE algebraically to calculate the surface reflectance for a given atmospheric state by interpolating in the multidimensional LUT.

Parameters:
  • dt – measurement vector

  • xx – estimated water vapor

  • pt – forward model parameter vector

  • mode – if vnir, interpolation is done for EnMAP vnir bands; if swir, it is done for swir bands

Returns:

modeled surface reflectance

surface_model(xx)[source]

Nonlinear surface reflectance model using the Beer-Lambert attenuation law for the retrieval of liquid water and ice path lengths.

Parameters:

xx – state vector, must be in the order [vapor, intercept, slope, liquid, ice]

Returns:

modeled surface reflectance

toa_rad(xx, pt, perturb=None)[source]

Forward model for calculating TOA radiance for a given atmospheric state by interpolating in the LUT and applying the simplified solution of the RTE. The needed surface reflectance values are derived from the nonlinear Beer-Lambert surface reflectance model.

Parameters:
  • xx – state vector

  • pt – forward model parameter vector

  • perturb – perturbance factor for calculating perturbed TOA radiance; default None

Returns:

modeled TOA radiance

class sicor.AC.RtFo_3_phases.FoFunc(fo)[source]

Bases: object

Forward operator function function including the nonlinear Beer-Lambert model for the surface reflectance.

Instance of forward operator function.

Parameters:

fo – Forward operator

class sicor.AC.RtFo_3_phases.FoGen(data, options, dem=None, logger=None)[source]

Bases: object

Forward operator for input TOA radiance data formatted according to options file (i.e., not in standard EnMAP L1B format).

Instance of forward operator object.

Parameters:
  • data – ndarray containing data

  • options – dictionary with EnMAP specific options

  • logger – None or logging instance

  • dem – digital elevation model to be provided in advance; default: None

calc_kb(xx, pt, num_bd, sb)[source]

Derivative of measurement with respect to unmodeled & unretrieved unknown variables, e.g. S_b. This is the concatenation of Jacobians with respect to parameters of the surface and the radiative transfer model.

Parameters:
  • xx – state vector

  • pt – model parameter vector

  • num_bd – number of instrument bands

  • sb – unknown model parameter error covariance matrix

Returns:

Jacobian of unknown model parameters

calc_se(xx, dt, pt, sb, num_bd, snr, unknowns)[source]
Calculate the total uncertainty of the observation, including both the instrument noise and the uncertainty

due to unmodeled variables. This is the S_epsilon matrix of Rodgers et al.

Parameters:
  • xx – state vector

  • dt – measurement vector

  • pt – model parameter vector

  • sb – unknown model parameter error covariance matrix

  • num_bd – number of instrument bands

  • snr – signal-to-noise ratio for each instrument band

  • unknowns – if True, uncertainties due to unknown forward model parameters are added to S_epsilon; default: False

Returns:

measurement error covariance matrix

drdn_drtb(xx, pt, rdn)[source]

Calculate Jacobian of radiance with respect to unknown radiative transfer model parameters.

Parameters:
  • xx – state vector

  • pt – model parameter vector

  • rdn – forward modeled TOA radiance for the current state vector xx

Returns:

Jacobian of unknown radiative transfer model parameters

drdn_dsurfaceb(xx, pt, rdn)[source]

Calculate Jacobian of radiance with respect to unknown surface model parameters.

Parameters:
  • xx – state vector

  • pt – model parameter vector

  • rdn – forward modeled TOA radiance for the current state vector xx

Returns:

Jacobian of unknown surface model parameters

surf_ref(dt, xx, pt, mode=None)[source]
Model surface reflectance for a given atmospheric state by interpolating in the LUT and applying the

simplified solution of the RTE. Here, the atmospheric state also contains path lengths of liquid water and ice.

Parameters:
  • dt – measurement vector

  • xx – water vapor from state vector

  • pt – model parameter vector

  • mode – if vnir, interpolation is done for EnMAP vnir bands; if swir, it is done for swir bands

Returns:

modeled surface reflectance

surface_model(xx)[source]
Nonlinear surface reflectance model using the Beer-Lambert attenuation law for the retrieval of liquid water

and ice path lengths.

Parameters:

xx – state vector, must be in the order [vapor, intercept, slope, liquid, ice]

Returns:

modeled surface reflectance

toa_rad(xx, pt, perturb=None)[source]
Model TOA radiance for a given atmospheric state by interpolating in the LUT and applying the simplified

solution of the RTE. Here, the atmospheric state also contains path lengths of liquid water and ice. The needed surface reflectance values are derived from the nonlinear Beer-Lambert surface reflectance model.

Parameters:
  • xx – state vector

  • pt – model parameter vector

  • perturb – perturbance factor for calculating perturbed TOA radiance; default None

Returns:

modeled TOA radiance, modeled surface reflectance

sicor.AC.RtFo_snow module

Module contents