The following procedure explains how to get SMRT running on your personal computer.
SMRT is developed with one of the highest stable version of Python (3.9 as of July 2022) but also work with python 3.6 or higher. Anaconda is the recommended distribution to get Python as it contains numerous packages needed for scientific computations and analysis. This is an open source distribution available for Linux, Windows and MacOS. Alternatively, you can install Python with the main package manager of your system (e.g. apt-get on Debian/Ubuntu, rpm on Fedora, homebrew on MacOS, ...) or visit https://wwww.python.org/ for more information. Anaconda provides good performance because it distributes numpy and scipy using the MKL library which provides highly-optimized LAPACK functions. These functions are heavily used in SMRT. Actually >80% of the computation time is for solving eigenvalue problems with LAPACK, the reason why SMRT is only slightly slower than a RT Fortran code.
To keep your system clean we highly recommend to create a virtual environment for the following installation either via conda create or virtualenv.
The main python packages to install are: numpy, scipy, pandas, xarray. With the Anaconda distribution, use the Anaconda navigator or the conda command:
conda install numpy scipy xarray pandasUsing pip, it is similar:
pip install numpy scipy xarray pandasIn addition, it is likely you will want to plot graph with for instance matplotlib, bokeh or plot.ly.
To download and keep up-to-date SMRT, it is recommended to use the version control software Git that can be installed using the package manager of your system. Here are some instructions for installing git. This simple guide to using git may also be helpful but the two needed commands are given below.
SMRT code is hosted on github. To get the code clone the repository with:
git clone https://github.com/smrt-model/smrt.gitAlternatively, download directly the code with the large green button on github.
Please note the Licence (LGPL) and disclaimer as this governs what you are allowed to do with SMRT! To get ready for using SMRT, you must install the required external packages.
Because SMRT is not formally installed in your system, it is necessary to inform Python where the code is. Under Linux, this is done by using the following command (in every terminal or better to put in ~/.bashrc file)
export PYTHONPATH=$PYTHONPATH:/the/full/path/to/smrtwhere /the/full/path/to/smrt is the SMRT top directory, i.e. the directory that contains README.md, requirements.txt, etc.
This simple script sets up a simple, one-layer snowpack with exponential microstructure. The Improved Born Approximation (IBA) and Discrete Ordinates Radiative Transfer model (DORT) are used to simulate the AMSR-E 37V channel:
from smrt import make_snowpack, make_model, sensor_list
# prepare inputs
thickness = [100]
corr_length = [5e-5]
temperature = [270]
density = [320]
# create the snowpack
snowpack = make_snowpack(thickness=thickness,
microstructure_model="exponential",
density=density,
temperature=temperature,
corr_length=corr_length)
# create the sensor
radiometer = sensor_list.amsre('37V')
# create the model
m = make_model("iba", "dort")
# run the model
result = m.run(radiometer, snowpack)
# outputs
print(result.TbV())Copy this code into a new file called "first-smrt.py" somewhere on your filesystem (generally NOT in the smrt directory) and execute the code with the python command or by clicking on the file depending on your system:
python first-smrt.pyIf you get an ImportError, it is likely that python does not find the smrt directory. Check that $PYTHONPATH is properly set.
The result of this computation should be 268.21 K. To adapt this to multiple layers, extend the size of the snowpack parameter arrays (e.g. below should give a brightness temperature of 240.12 K if used in place of the snowpack above)
thickness = [1, 99]
corr_length = [5e-5, 3e-4]
temperature = [270, 260]
density = [320, 350]Note
- Layer numbers are from the top to the bottom i.e. first in the list is the top.
- SI units are always used: metres, Kelvin, kilograms, Hertz.
- Different parameters are needed for each microstructure model. See documentation for details
If you have cloned SMRT with git, you don't need to use clone again to get the last version, just move to the smrt directory and execute:
git pullWe recommend to always get the latest version as we constantly correct bugs and improve the code. See git documentation how to revert to a past version.
There are many ways in which to use SMRT. Here's a list of examples: