SMRT

smrt.utils package

Submodules

smrt.utils.dmrt_qms_legacy module

Wrapper to the original DMRT_QMS matlab code using the SMRT framework. To use this module, extra installation are needed:

  • get DMRT_QMS from http://web.eecs.umich.edu/~leutsang/Available%20Resources.html and extract the model somewhere
  • install the oct2py module using pip install oct2py or easy_install install oct2py
  • install Octave version 3.6 or above.
  • for convenience you can set 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 check 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)

set the path where dmrt_qms archive has been uncompressed, i.e. where the file dmrt_qmsmain.m is located.

run(sensor, snowpack, dmrt_qms_path=None, snowpack_dimension=None, full_output=False)

call DMRT-QMS for the snowpack and sensor configuration given as argument. The sticky_hard_spheres microstructure model must be used.

Parameters:
  • snowpack – describe the snowpack.
  • sensor – describe the sensor configuration.
  • full_output – determine if ks, ka and effective permittivity are return in addition to the result object
dmrt_qms_active(sensor, snowpack)
dmrt_qms_emmodel(sensor, layer, dmrt_qms_path=None)

Compute scattering and absorption coefficients using DMRT QMS

Parameters:
  • layer – describe the layer.
  • sensor – describe the sensor configuration.

smrt.utils.hut_legacy module

Wrapper to original HUT matlab using SMRT framework. To use this module, extra installation are needed:

  • get HUT. Decompress the archive somewhere on your disk.
  • in the file snowemis_nlayers change the 6 occurences of the “do” variable into “dos” because it causes a syntax error in Octave.
  • install the oct2py module using pip install oct2py or easy_install install oct2py.
  • install Octave version 3.6 or above.
  • for convenience you can set 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 check the instructions given in http://blink1073.github.io/oct2py/source/installation.html

set_hut_path(path)

set the path where MEMLS archive has been uncompressed, i.e. where the file memlsmain.m is located.

run(sensor, snowpack, ke_option=0, grainsize_option=1, hut_path=None)

call HUT for the snowpack and sensor configuration given as argument. Any microstructure model that defines the “radius” parameter is valid.

Parameters:
  • snowpack – describe the snowpack.
  • sensor – describe the sensor configuration.
  • ke_option – see HUT snowemis_nlayers.m code
  • grainsize_option – see HUT snowemis_nlayers.m code

smrt.utils.memls_legacy module

Wrapper to the original MEMLS matlab code using the SMRT framework. To use this module, extra installation are needed:

  • download MEMLS from http://www.iapmw.unibe.ch/research/projects/snowtools/memls.html. Decompress the archive somewhere on your disk.
  • install the oct2py module using pip install oct2py or easy_install install oct2py
  • install Octave version 3.6 or above.
  • for convenience you can set 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 check the instructions given in http://blink1073.github.io/oct2py/source/installation.html

set_memls_path(path)

set the path where MEMLS archive has been uncompressed, i.e. where the file memlsmain.m is located.

run(sensor, snowpack, scattering_choice=12, atmosphere=None, memls_path=None, memls_driver=None, snowpack_dimension=None)

call 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.

Parameters:
  • snowpack – describe the snowpack.
  • sensor – describe the sensor configuration.
  • 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.
  • atmosphere – describe the atmosphere. Only tbdown is used for the Tsky argument of memlsmain.
  • memls_path – directory path to the memls Matlab scripts
  • 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.
  • 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

plot_snowpack(sp, show_vars=None, show_shade=False, ax=None)
plot_streams(sp, emmodel, sensor, ilayer=None, ax=None)
format_vars(lay, show_vars, delimiter=' ')
class CosineComputor

Bases: object

solve(snowpack, emmodel_instances, sensor, atmosphere)
class ReciprocalScale(axis)

Bases: matplotlib.scale.LinearScale

name = 'stickiness_reciprocal'
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: matplotlib.transforms.Transform

input_dims = 1
output_dims = 1
is_separable = True
transform_non_affine(a)

Apply only the non-affine part of this transformation.

transform(values) is always equivalent to transform_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.

values : array
The input values as NumPy array of length input_dims or shape (N x input_dims).
array
The output values as NumPy array of length output_dims or shape (N x output_dims), depending on the input.
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
class InvertedReciprocalTransform(shorthand_name=None)

Bases: matplotlib.transforms.Transform

input_dims = 1
output_dims = 1
is_separable = True
transform_non_affine(a)

Apply only the non-affine part of this transformation.

transform(values) is always equivalent to transform_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.

values : array
The input values as NumPy array of length input_dims or shape (N x input_dims).
array
The output values as NumPy array of length output_dims or shape (N x output_dims), depending on the input.
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

smrt.utils.repo_tools module

General tools related to code repository

get_hg_rev(file_path)

get_hg_rev is a tool to print out which commit of the model you are using.

This is useful when revisiting ipython notebooks, can be used to compare the original model commit ID with the latest version.

Usage:

from smrt.utils.repo_tools import get_hg_rev
path_to_file = "/path/to/your/repository"
get_hg_rev(path_to_file)

Note

This is for a mercurial repository

Module contents

This packages contain various utilities that works 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.

invdB(x)

computes the dB value x in natural value.