smrt.utils package
Contains various utilities that work with/for SMRT.
The wrappers to legacy snow radiative transfer models can be used to run DMRT-QMS (passive mode), HUT and MEMLS (passive mode). Other tools are listed below.
- dB(x)
Computes the ratio x in dB. Any small value is converted to -200dB.
- Parameters:
x – Input value or array.
- Returns:
The value(s) in dB.
- invdB(x)
Computes the dB value x in natural value.
- Parameters:
x – Value(s) in dB.
- Returns:
The value(s) in natural units.
smrt.utils.dmrt_qms_legacy module
Wraps the original DMRT_QMS matlab code using the SMRT framework.
To use this module, extra installations are needed:
Gets DMRT_QMS from http://web.eecs.umich.edu/~leutsang/Available%20Resources.html and extracts the model somewhere.
Installs the oct2py module using
pip install oct2pyoreasy_install install oct2py.Installs Octave version 3.6 or above.
For convenience, sets the DMRT_QMS_DIR environment variable to point to DMRT-QMS path. This path can also be programmatically set with and use
set_dmrt_qms_path()function.
In case of problem, checks the instructions given in http://blink1073.github.io/oct2py/source/installation.html.
You may also want to increase the number of streams in passive/DMRT_QMS_passive.m
- set_dmrt_qms_path(path)
Sets the path where dmrt_qms archive has been uncompressed, i.e. where the file dmrt_qmsmain.m is located.
- Parameters:
path – Path to the DMRT_QMS directory.
- run(sensor, snowpack, dmrt_qms_path=None, snowpack_dimension=None, full_output=False)
Calls DMRT-QMS for the snowpack and sensor configuration given as argument. The
sticky_hard_spheresmicrostructure model must be used.- Parameters:
sensor – Sensor configuration.
snowpack – Snowpack description.
dmrt_qms_path – Optional path to DMRT_QMS.
snowpack_dimension – Optional dimension for results when a list of snowpacks is provided.
full_output – If True, returns ks, ka, and effective permittivity in addition to the result object.
- Returns:
PassiveResult or tuple with additional outputs if full_output is True.
- dmrt_qms_emmodel(sensor, layer, dmrt_qms_path=None)
Computes scattering and absorption coefficients using DMRT QMS.
- Parameters:
sensor – Sensor configuration.
layer – Layer description.
dmrt_qms_path – Optional path to DMRT_QMS.
- Returns:
namedtuple with ks and ka.
smrt.utils.hut_legacy module
Wraps the original HUT matlab using SMRT framework.
To use this module, extra installations are needed:
Gets HUT. Decompresses the archive somewhere on your disk.
In the file snowemis_nlayers, changes the 6 occurrences of the “do” variable into “dos” because it causes a syntax error in Octave.
Installs the oct2py module using
pip install oct2pyoreasy_install install oct2py.Installs Octave version 3.6 or above.
For convenience, sets the HUT_DIR environment variable to point to HUT path. This path can also be programmatically set with
set_hut_path().
In case of problem, checks the instructions given in http://blink1073.github.io/oct2py/source/installation.html.
- set_hut_path(path)
Sets the path where HUT archive has been uncompressed, i.e. where the file memlsmain.m is located.
- Parameters:
path – Path to the HUT directory.
- run(sensor, snowpack, ke_option=0, grainsize_option=1, hut_path=None)
Calls HUT for the snowpack and sensor configuration given as argument. Any microstructure model that defines the “radius” parameter is valid.
- Parameters:
sensor – Sensor configuration.
snowpack – Snowpack description.
ke_option – Option for HUT snowemis_nlayers.m code.
grainsize_option – Option for HUT snowemis_nlayers.m code.
hut_path – Optional path to HUT.
- Returns:
Result object.
smrt.utils.memls_legacy module
Wraps the original MEMLS matlab code using the SMRT framework.
To use this module, extra installations are needed:
Downloads MEMLS from http://www.iapmw.unibe.ch/research/projects/snowtools/memls.html. Decompresses the archive somewhere on your disk.
Installs the oct2py module using
pip install oct2pyoreasy_install install oct2py.Installs Octave version 3.6 or above.
For convenience, sets the MEMLS_DIR environment variable to point to MEMLS path. This path can also be programmatically set with
set_memls_path().
In case of problem, checks the instructions given in http://blink1073.github.io/oct2py/source/installation.html.
- set_memls_path(path)
Sets the path where MEMLS archive has been uncompressed, i.e. where the file memlsmain.m is located.
- Parameters:
path – Path to the MEMLS directory.
- run(sensor, snowpack, scattering_choice=12, atmosphere=None, memls_path=None, memls_driver=None, snowpack_dimension=None)
Calls MEMLS for the snowpack and sensor configuration given as argument. Any microstructure model that defines the “corr_length” parameter is valid, but it must be clear that MEMLS only considers exponential autocorrelation.
- param snowpack:
describe the snowpack.
- param sensor:
describe the sensor configuration.
- param scattering_choice:
MEMLS proposes several formulation to compute scattering_function. scattering_choice=ABORN (equals 12) is the default here and is recommended choice to compare with IBA. Note that some comments in memlsmain.m suggest to use scattering_choice=MEMLS_RECOMMENDED (equals 11). Note also that the default grain type in memlsmain is graintype=1 corresponding to oblate spheroidal calculation of effective permittivity from the empirical representation of depolarization factors. To use a Polder-Van Santen representation of effective permittivity for small spheres, graintype=2 must be set in your local copy of MEMLS.
- param atmosphere:
describe the atmosphere. Only tbdown is used for the Tsky argument of memlsmain.
- param memls_path:
directory path to the memls Matlab scripts
- param memls_driver:
matlab function to call to run memls. memlsmain.m is the default driver in the original MEMLS distribution for the passive case and amemlsmain.m for the active case.
- param snowpack_dimension:
name and values (as a tuple) of the dimension to create for the results when a list of snowpack is provided. E.g. time, point, longitude, latitude. By default the dimension is called ‘snowpack’ and the values are from 1 to the number of snowpacks.
- memls_emmodel(sensor, layer, scattering_choice=12, graintype=2)
Compute scattering (gs6) and absorption coefficients (gai) using MEMLS
- Parameters:
layer – describe the layer.
sensor – describe the sensor configuration.
scattering_choice – MEMLS proposes several formulation to compute scattering_function. scattering_choice=ABORN (equals 12) is the defaut here and is recommended choice to compare with IBA.
smrt.utils.mpl_plots module
- class ReciprocalScale(axis)
Bases:
LinearScale- set_default_locators_and_formatters(axis)
Set the locators and formatters of axis to instances suitable for this scale.
- get_transform()
Return the transform for linear scaling, which is just the ~matplotlib.transforms.IdentityTransform.
- class ReciprocalTransform(shorthand_name=None)
Bases:
Transform- input_dims = 1
The number of input dimensions of this transform. Must be overridden (with integers) in the subclass.
- output_dims = 1
The number of output dimensions of this transform. Must be overridden (with integers) in the subclass.
- is_separable = True
True if this transform is separable in the x- and y- dimensions.
- transform_non_affine(a)
Apply only the non-affine part of this transformation.
transform(values)is always equivalent totransform_affine(transform_non_affine(values)).In non-affine transformations, this is generally equivalent to
transform(values). In affine transformations, this is always a no-op.- Parameters:
values (array) – The input values as an array of length
input_dimsor shape (N,input_dims).- Returns:
The output values as an array of length
output_dimsor shape (N,output_dims), depending on the input.- Return type:
array
- inverted()
Return the corresponding inverse transformation.
It holds
x == self.inverted().transform(self.transform(x)).The return value of this method should be treated as temporary. An update to self does not cause a corresponding update to its inverted copy.
- has_inverse = True
True if this transform has a corresponding inverse transform.
- class InvertedReciprocalTransform(shorthand_name=None)
Bases:
Transform- input_dims = 1
The number of input dimensions of this transform. Must be overridden (with integers) in the subclass.
- output_dims = 1
The number of output dimensions of this transform. Must be overridden (with integers) in the subclass.
- is_separable = True
True if this transform is separable in the x- and y- dimensions.
- transform_non_affine(a)
Apply only the non-affine part of this transformation.
transform(values)is always equivalent totransform_affine(transform_non_affine(values)).In non-affine transformations, this is generally equivalent to
transform(values). In affine transformations, this is always a no-op.- Parameters:
values (array) – The input values as an array of length
input_dimsor shape (N,input_dims).- Returns:
The output values as an array of length
output_dimsor shape (N,output_dims), depending on the input.- Return type:
array
- inverted()
Return the corresponding inverse transformation.
It holds
x == self.inverted().transform(self.transform(x)).The return value of this method should be treated as temporary. An update to self does not cause a corresponding update to its inverted copy.
- has_inverse = True
True if this transform has a corresponding inverse transform.