-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetstarted.html
More file actions
170 lines (151 loc) · 20.5 KB
/
getstarted.html
File metadata and controls
170 lines (151 loc) · 20.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article#
" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Getting started with SMRT | SMRT Home</title>
<link href="assets/css/all-nocdn.css" rel="stylesheet" type="text/css">
<link href="assets/css/ipython.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/nikola_ipython.css" rel="stylesheet" type="text/css">
<meta name="theme-color" content="#56d470">
<meta name="generator" content="Nikola (getnikola.com)">
<link rel="alternate" type="application/rss+xml" title="RSS" hreflang="en" href="rss.xml">
<link rel="canonical" href="https://www.smrt-model.science/getstarted.html">
<!--[if lt IE 9]><script src="assets/js/html5.js"></script><![endif]--><meta name="author" content="Ghislain Picard, Melody Sandells and Henning Löwe">
<meta property="og:site_name" content="SMRT Home">
<meta property="og:title" content="Getting started with SMRT">
<meta property="og:url" content="https://www.smrt-model.science/getstarted.html">
<meta property="og:description" content="The following procedure explains how to get SMRT running on your personal computer.
Step 1. Install Python and dependencies
SMRT is developed with one of the highest stable version of Python (3.9 as ">
<meta property="og:type" content="article">
<meta property="article:published_time" content="2018-01-09T00:00:00Z">
</head>
<body>
<a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
<!-- Menubar -->
<nav class="navbar navbar-expand-md static-top mb-4
navbar-dark
bg-dark
"><div class="container">
<!-- This keeps the margins nice -->
<a class="navbar-brand" href=".">
<span id="blog-title">SMRT Home</span>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bs-navbar" aria-controls="bs-navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="bs-navbar">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a href="#" class="nav-link">Getting Started <span class="sr-only">(active)</span></a>
</li>
<li class="nav-item">
<a href="documentation.html" class="nav-link">Documentation</a>
</li>
<li class="nav-item">
<a href="contribute.html" class="nav-link">Contribute</a>
</li>
</ul>
<ul class="navbar-nav navbar-right"></ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav><!-- End of Menubar --><div class="container" id="content" role="main">
<div class="body-content">
<!--Body content-->
<article class="post-text storypage" itemscope="itemscope" itemtype="http://schema.org/Article"><header><h1 class="p-name entry-title" itemprop="headline name"><a href="#" class="u-url">Getting started with SMRT</a></h1>
</header><div class="e-content entry-content" itemprop="articleBody text">
<p>The following procedure explains how to get SMRT running on your personal computer.</p>
<section id="step-1-install-python-and-dependencies"><h2>Step 1. Install Python and dependencies</h2>
<p>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. <a class="reference external" href="https://www.anaconda.com/distribution/">Anaconda</a> 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 <a class="reference external" href="https://wwww.python.org/">https://wwww.python.org/</a> 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.</p>
<p>To keep your system clean we highly recommend to create a virtual environment for the following installation either via <a class="reference external" href="https://conda.io/docs/user-guide/tasks/manage-environments.html">conda create</a> or <a class="reference external" href="https://virtualenv.pypa.io/en/stable/">virtualenv</a>.</p>
<p>The main python packages to install are: <a class="reference external" href="http://www.numpy.org/">numpy</a>, <a class="reference external" href="https://www.scipy.org">scipy</a>, <a class="reference external" href="https://pandas.pydata.org/">pandas</a>, <a class="reference external" href="http://xarray.pydata.org/en/stable/">xarray</a>. With the Anaconda distribution, use the Anaconda navigator or the conda command:</p>
<div class="code"><pre class="code bash"><a id="rest_code_ef99e1611c794319823942aa6bc3a017-1" name="rest_code_ef99e1611c794319823942aa6bc3a017-1" href="getstarted.html#rest_code_ef99e1611c794319823942aa6bc3a017-1"></a>conda<span class="w"> </span>install<span class="w"> </span>numpy<span class="w"> </span>scipy<span class="w"> </span>xarray<span class="w"> </span>pandas
</pre></div>
<p>Using pip, it is similar:</p>
<div class="code"><pre class="code bash"><a id="rest_code_b99fd97c0ef842c7b0a6f24e5c88692d-1" name="rest_code_b99fd97c0ef842c7b0a6f24e5c88692d-1" href="getstarted.html#rest_code_b99fd97c0ef842c7b0a6f24e5c88692d-1"></a>pip<span class="w"> </span>install<span class="w"> </span>numpy<span class="w"> </span>scipy<span class="w"> </span>xarray<span class="w"> </span>pandas
</pre></div>
<p>In addition, it is likely you will want to plot graph with for instance <a class="reference external" href="https://matplotlib.org/">matplotlib</a>, <a class="reference external" href="https://bokeh.pydata.org/">bokeh</a> or <a class="reference external" href="https://plot.ly/python/">plot.ly</a>.</p>
<p>To download and keep up-to-date SMRT, it is recommended to use the version control software <a class="reference external" href="https://git-scm.com/">Git</a> that can be installed using the package manager of your system. <a class="reference external" href="https://www.atlassian.com/git/tutorials/install-git">Here are some instructions for installing git</a>. This <a class="reference external" href="http://rogerdudler.github.io/git-guide/">simple guide to using git</a> may also be helpful but the two needed commands are given below.</p>
</section><section id="step-2-get-smrt-code"><h2>Step 2. Get SMRT code</h2>
<p>SMRT code is hosted on <a class="reference external" href="https://github.com/smrt-model/smrt">github</a>. To get the code clone the repository with:</p>
<div class="code"><pre class="code bash"><a id="rest_code_d2960304e4c34addb772c1cc6ec0f624-1" name="rest_code_d2960304e4c34addb772c1cc6ec0f624-1" href="getstarted.html#rest_code_d2960304e4c34addb772c1cc6ec0f624-1"></a>git<span class="w"> </span>clone<span class="w"> </span>https://github.com/smrt-model/smrt.git
</pre></div>
<p>Alternatively, download directly the code with the large green button on <a class="reference external" href="https://github.com/smrt-model/smrt">github</a>.</p>
<p><strong>Please note the Licence (LGPL) and disclaimer</strong> as this governs what you are allowed to do with SMRT! To get ready for using SMRT, you must install the required external packages.</p>
<p>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)</p>
<div class="code"><pre class="code bash"><a id="rest_code_3702be691a4742b4b5be62062882202c-1" name="rest_code_3702be691a4742b4b5be62062882202c-1" href="getstarted.html#rest_code_3702be691a4742b4b5be62062882202c-1"></a><span class="nb">export</span><span class="w"> </span><span class="nv">PYTHONPATH</span><span class="o">=</span><span class="nv">$PYTHONPATH</span>:/the/full/path/to/smrt
</pre></div>
<p>where /the/full/path/to/smrt is the SMRT top directory, i.e. the directory that contains README.md, requirements.txt, etc.</p>
</section><section id="step-3-a-first-example"><h2>Step 3. A first example</h2>
<p>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:</p>
<div class="code"><pre class="code python"><a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-1" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-1" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-1"></a><span class="kn">from</span><span class="w"> </span><span class="nn">smrt</span><span class="w"> </span><span class="kn">import</span> <span class="n">make_snowpack</span><span class="p">,</span> <span class="n">make_model</span><span class="p">,</span> <span class="n">sensor_list</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-2" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-2" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-2"></a>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-3" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-3" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-3"></a><span class="c1"># prepare inputs</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-4" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-4" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-4"></a><span class="n">thickness</span> <span class="o">=</span> <span class="p">[</span><span class="mi">100</span><span class="p">]</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-5" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-5" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-5"></a><span class="n">corr_length</span> <span class="o">=</span> <span class="p">[</span><span class="mf">5e-5</span><span class="p">]</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-6" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-6" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-6"></a><span class="n">temperature</span> <span class="o">=</span> <span class="p">[</span><span class="mi">270</span><span class="p">]</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-7" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-7" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-7"></a><span class="n">density</span> <span class="o">=</span> <span class="p">[</span><span class="mi">320</span><span class="p">]</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-8" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-8" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-8"></a>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-9" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-9" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-9"></a><span class="c1"># create the snowpack</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-10" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-10" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-10"></a><span class="n">snowpack</span> <span class="o">=</span> <span class="n">make_snowpack</span><span class="p">(</span><span class="n">thickness</span><span class="o">=</span><span class="n">thickness</span><span class="p">,</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-11" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-11" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-11"></a> <span class="n">microstructure_model</span><span class="o">=</span><span class="s2">"exponential"</span><span class="p">,</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-12" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-12" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-12"></a> <span class="n">density</span><span class="o">=</span><span class="n">density</span><span class="p">,</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-13" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-13" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-13"></a> <span class="n">temperature</span><span class="o">=</span><span class="n">temperature</span><span class="p">,</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-14" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-14" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-14"></a> <span class="n">corr_length</span><span class="o">=</span><span class="n">corr_length</span><span class="p">)</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-15" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-15" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-15"></a>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-16" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-16" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-16"></a><span class="c1"># create the sensor</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-17" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-17" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-17"></a><span class="n">radiometer</span> <span class="o">=</span> <span class="n">sensor_list</span><span class="o">.</span><span class="n">amsre</span><span class="p">(</span><span class="s1">'37V'</span><span class="p">)</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-18" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-18" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-18"></a>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-19" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-19" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-19"></a><span class="c1"># create the model</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-20" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-20" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-20"></a><span class="n">m</span> <span class="o">=</span> <span class="n">make_model</span><span class="p">(</span><span class="s2">"iba"</span><span class="p">,</span> <span class="s2">"dort"</span><span class="p">)</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-21" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-21" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-21"></a>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-22" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-22" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-22"></a><span class="c1"># run the model</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-23" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-23" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-23"></a><span class="n">result</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">radiometer</span><span class="p">,</span> <span class="n">snowpack</span><span class="p">)</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-24" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-24" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-24"></a>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-25" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-25" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-25"></a><span class="c1"># outputs</span>
<a id="rest_code_3835002562b9460f9e3c5ac5d45978d4-26" name="rest_code_3835002562b9460f9e3c5ac5d45978d4-26" href="getstarted.html#rest_code_3835002562b9460f9e3c5ac5d45978d4-26"></a><span class="nb">print</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">TbV</span><span class="p">())</span>
</pre></div>
<p>Copy this code into a new file called "first-smrt.py" somewhere on your filesystem (generally <strong>NOT</strong> in the smrt directory) and execute the code with the python command or by clicking on the file depending on your system:</p>
<div class="code"><pre class="code bash"><a id="rest_code_3d51c965f02a41e38abfc8c914bd3f87-1" name="rest_code_3d51c965f02a41e38abfc8c914bd3f87-1" href="getstarted.html#rest_code_3d51c965f02a41e38abfc8c914bd3f87-1"></a>python<span class="w"> </span>first-smrt.py
</pre></div>
<p>If you get an ImportError, it is likely that python does not find the smrt directory. Check that $PYTHONPATH is properly set.</p>
<p>The result of this computation should be <code class="docutils literal">268.21</code> K. To adapt this to multiple layers, extend the size of the snowpack parameter arrays (e.g. below should give a brightness temperature of <code class="docutils literal">240.12</code> K if used in place of the snowpack above)</p>
<div class="code"><pre class="code python"><a id="rest_code_a976eedec0524246bb2cd89b2dec338f-1" name="rest_code_a976eedec0524246bb2cd89b2dec338f-1" href="getstarted.html#rest_code_a976eedec0524246bb2cd89b2dec338f-1"></a><span class="n">thickness</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">99</span><span class="p">]</span>
<a id="rest_code_a976eedec0524246bb2cd89b2dec338f-2" name="rest_code_a976eedec0524246bb2cd89b2dec338f-2" href="getstarted.html#rest_code_a976eedec0524246bb2cd89b2dec338f-2"></a><span class="n">corr_length</span> <span class="o">=</span> <span class="p">[</span><span class="mf">5e-5</span><span class="p">,</span> <span class="mf">3e-4</span><span class="p">]</span>
<a id="rest_code_a976eedec0524246bb2cd89b2dec338f-3" name="rest_code_a976eedec0524246bb2cd89b2dec338f-3" href="getstarted.html#rest_code_a976eedec0524246bb2cd89b2dec338f-3"></a><span class="n">temperature</span> <span class="o">=</span> <span class="p">[</span><span class="mi">270</span><span class="p">,</span> <span class="mi">260</span><span class="p">]</span>
<a id="rest_code_a976eedec0524246bb2cd89b2dec338f-4" name="rest_code_a976eedec0524246bb2cd89b2dec338f-4" href="getstarted.html#rest_code_a976eedec0524246bb2cd89b2dec338f-4"></a><span class="n">density</span> <span class="o">=</span> <span class="p">[</span><span class="mi">320</span><span class="p">,</span> <span class="mi">350</span><span class="p">]</span>
</pre></div>
<aside class="admonition note"><p class="admonition-title">Note</p>
<ul class="simple">
<li><p>Layer numbers are from the top to the bottom i.e. first in the list is the top.</p></li>
<li><p>SI units are always used: metres, Kelvin, kilograms, Hertz.</p></li>
<li><p>Different parameters are needed for each microstructure model. See documentation for details</p></li>
</ul></aside></section><section id="last-recommendations-staying-up-to-date"><h2>Last Recommendations: Staying up to date</h2>
<p>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:</p>
<div class="code"><pre class="code bash"><a id="rest_code_9f4185926f9a4b47a6d1687335faaff3-1" name="rest_code_9f4185926f9a4b47a6d1687335faaff3-1" href="getstarted.html#rest_code_9f4185926f9a4b47a6d1687335faaff3-1"></a>git<span class="w"> </span>pull
</pre></div>
<p>We 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.</p>
</section><section id="going-further-with-the-tutorials"><h2>Going further with the tutorials</h2>
<p>There are many ways in which to use SMRT. Here's a list of examples:</p>
<ol class="arabic simple">
<li><p><a class="reference external" href="sensitivity_study/index.html">Sensitivity study with a list of snowpacks</a></p></li>
<li><p><a class="reference external" href="memls_legacy/index.html">Use wrapper to call MEMLS</a></p></li>
<li><p><a class="reference external" href="https://github.com/smrt-model/smrt1paper">Figure in the GMD paper</a></p></li>
</ol></section>
</div>
</article><!--End of body content--><footer id="footer">
Contents © 2025 <a href="mailto:n.tesla@example.com">Ghislain Picard, Melody Sandells and Henning Löwe</a> - Powered by <a href="https://getnikola.com" rel="nofollow">Nikola</a>
</footer>
</div>
</div>
<script src="assets/js/all-nocdn.js"></script><script>
baguetteBox.run('div#content', {
ignoreClass: 'islink',
captions: function(element){var i=element.getElementsByTagName('img')[0];return i===undefined?'':i.alt;}});
</script>
</body>
</html>