Skip to content

Commit 3c9cf65

Browse files
committed
Include a 'Run PyTSEB' button to avoid some user confusion in the jupyter notebooks
1 parent 8f21dad commit 3c9cf65

File tree

3 files changed

+49
-54
lines changed

3 files changed

+49
-54
lines changed

ProcessLocalImage.ipynb

+8-28
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@
4141
{
4242
"cell_type": "markdown",
4343
"metadata": {
44-
"collapsed": false,
45-
"scrolled": true
44+
"collapsed": true
4645
},
4746
"source": [
4847
"# Run TSEB\n",
49-
"Once TSEB is configured we will parse all the information in the widgets and run the selected model. A progress bar will show up and once the processing is done two GeoTiff files will be saved:\n",
48+
"Once TSEB is configured we parse all the information in the widgets and run the selected model. \n",
49+
"\n",
50+
"Once the processing is done two GeoTiff files will be saved:\n",
5051
"\n",
5152
"- < Main Output File > whose name is specified in the cell *Output File* will contain the bulk estimated fluxes:\n",
5253
" 1. Sensible heat flux (W m-2)\n",
@@ -64,29 +65,8 @@
6465
" 6. Net shortwave radiation (W m-2)\n",
6566
" 7. Net longwave radiation (W m-2)\n",
6667
" 8. Friction velocity (m s-1)\n",
67-
" 9. Monin-Obukhov lenght (m)"
68-
]
69-
},
70-
{
71-
"cell_type": "code",
72-
"execution_count": null,
73-
"metadata": {
74-
"collapsed": false
75-
},
76-
"outputs": [],
77-
"source": [
78-
"# Get the data from the widgets\n",
79-
"setup.GetDataTSEBWidgets(isImage = True)\n",
80-
"# Run TSEB\n",
81-
"setup.RunTSEBLocalImage()"
82-
]
83-
},
84-
{
85-
"cell_type": "markdown",
86-
"metadata": {
87-
"collapsed": true
88-
},
89-
"source": [
68+
" 9. Monin-Obukhov lenght (m)\n",
69+
"\n",
9070
"# Display results\n",
9171
"Now we can open the image and display the TSEB outputs:"
9272
]
@@ -162,7 +142,7 @@
162142
],
163143
"metadata": {
164144
"kernelspec": {
165-
"display_name": "Python 3",
145+
"display_name": "IPython (Python 3)",
166146
"language": "python",
167147
"name": "python3"
168148
},
@@ -176,7 +156,7 @@
176156
"name": "python",
177157
"nbconvert_exporter": "python",
178158
"pygments_lexer": "ipython3",
179-
"version": "3.4.4"
159+
"version": "3.5.1"
180160
}
181161
},
182162
"nbformat": 4,

ProcessPointTimeSeries.ipynb

+16-26
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,16 @@
4242
},
4343
{
4444
"cell_type": "markdown",
45-
"metadata": {
46-
"collapsed": false
47-
},
45+
"metadata": {},
4846
"source": [
4947
"# Run TSEB\n",
50-
"Once TSEB is configured we will parse all the information in the widgets and run the selected model. A progress bar will show up and once the processing is done an ASCII table with the following variables will be written in the output txt file:\n",
48+
"Once TSEB is configured we parsed all the information in the widgets and run the selected model. \n",
49+
"\n",
50+
"Once the processing is done an ASCII table with the following variables will be written in the output txt file:\n",
5151
">Year, DOY, Time, LAI, f_g, skyl, VZA, SZA, SAA, Ldn, Rn_model, Rn_sw_veg, Rn_sw_soil, Rn_lw_veg, Rn_lw_soil, Tc, Ts, Tac, LE_model, H_model, LE_c, H_c, LE_s, H_s, flag, zo, d, G_model, R_s, R_x, R_a, u_friction, L, n_iterations\n",
5252
"\n",
53-
"where variables with the same name as input variables have the same meaning, and for the others: *skyl* is the ratio of diffuse radiation, *Rn_model* is net radiation (W m-2; *sw* and *lw* subscripts stand for shortwave and longwave, *veg* and *soil* for canopy and soil), *Tc*, *Ts* and *Tac* are canopy, soil and inter-canopy-air temperatures (K), *LE_model* is latent heat flux and *H_model* is sensible heat flux (W m-2; subscripts *c* and *s* stand for canopy and soil respectively), *flag* is a quality flag (255==BAD), *zo* and *d* are roughness length and zero-plane displacement height (m), *R_s*, *R_x* and *R_a* are resistances to heat and momentum transport (s m-1), *u_friction* is friction velocity (m s-1), *L* is the Monin-Obukhov length (m) and *n_iterations* is the number of iterations of TSEB needed to achieve model convergence."
54-
]
55-
},
56-
{
57-
"cell_type": "code",
58-
"execution_count": null,
59-
"metadata": {
60-
"collapsed": false
61-
},
62-
"outputs": [],
63-
"source": [
64-
"# Get the data from the widgets\n",
65-
"setup.GetDataTSEBWidgets(isImage = False)\n",
66-
"#run TSEB\n",
67-
"setup.RunTSEBPointSeriesArray()"
68-
]
69-
},
70-
{
71-
"cell_type": "markdown",
72-
"metadata": {},
73-
"source": [
53+
"where variables with the same name as input variables have the same meaning, and for the others: *skyl* is the ratio of diffuse radiation, *Rn_model* is net radiation (W m-2; *sw* and *lw* subscripts stand for shortwave and longwave, *veg* and *soil* for canopy and soil), *Tc*, *Ts* and *Tac* are canopy, soil and inter-canopy-air temperatures (K), *LE_model* is latent heat flux and *H_model* is sensible heat flux (W m-2; subscripts *c* and *s* stand for canopy and soil respectively), *flag* is a quality flag (255==BAD), *zo* and *d* are roughness length and zero-plane displacement height (m), *R_s*, *R_x* and *R_a* are resistances to heat and momentum transport (s m-1), *u_friction* is friction velocity (m s-1), *L* is the Monin-Obukhov length (m) and *n_iterations* is the number of iterations of TSEB needed to achieve model convergence.\n",
54+
"\n",
7455
"# Display results\n",
7556
"Now we can open the output and plot the TSEB outputs:"
7657
]
@@ -135,11 +116,20 @@
135116
"\n",
136117
"show(p);"
137118
]
119+
},
120+
{
121+
"cell_type": "code",
122+
"execution_count": null,
123+
"metadata": {
124+
"collapsed": true
125+
},
126+
"outputs": [],
127+
"source": []
138128
}
139129
],
140130
"metadata": {
141131
"kernelspec": {
142-
"display_name": "Python 3",
132+
"display_name": "IPython (Python 3)",
143133
"language": "python",
144134
"name": "python3"
145135
},

src/pyTSEB.py

+25
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ def PointTimeSeriesWidget(self):
140140
self.w_inputtxt=widgets.Text(description='Input File :', value=self.InputFile, width=500)
141141
self.w_output=widgets.Button(description='Select Output File')
142142
self.w_outputtxt=widgets.Text(description='Output File :', value=self.OutputTxtFile,width=500)
143+
144+
self.w_runmodel=widgets.Button(description='Run pyTSEB', background_color='green')
145+
143146
# Create TSEB options widgets
144147
self.SelectModel()
145148
self.DefineSiteDescription()
@@ -160,13 +163,15 @@ def PointTimeSeriesWidget(self):
160163
display(widgets.HBox([self.w_output,self.w_outputtxt]))
161164
display(tabs)
162165
display(self.w_saveconfig)
166+
display(self.w_runmodel)
163167
# Handle interactions
164168
self.w_CalcG.on_trait_change(self._on_G_change, 'value')
165169
self.w_input.on_click(self._on_input_clicked)
166170
self.w_output.on_click(self._on_output_clicked)
167171
self.isImage=False
168172
self.w_loadconfig.on_click(self._on_loadconfig_clicked)
169173
self.w_saveconfig.on_click(self._on_saveconfig_clicked)
174+
self.w_runmodel.on_click(self._on_runmodel_clicked)
170175

171176
def LocalImageWidget(self):
172177
'''Creates a jupyter notebook GUI for running TSEB for an image'''
@@ -194,6 +199,8 @@ def LocalImageWidget(self):
194199
self.w_masktxt=widgets.Text(description='Mask:',value='0', width=500)
195200
self.w_output=widgets.Button(description='Select Output File')
196201
self.w_outputtxt=widgets.Text(description='Output File :', value=self.OutputImageFile, width=500)
202+
203+
self.w_runmodel=widgets.Button(description='Run pyTSEB', background_color='green')
197204
# Create TSEB options widgets
198205
self.SelectModel()
199206
self.DefineSiteDescription()
@@ -230,6 +237,8 @@ def LocalImageWidget(self):
230237
display(widgets.HBox([self.w_output,self.w_outputtxt]))
231238
display(tabs)
232239
display(self.w_saveconfig)
240+
display(self.w_runmodel)
241+
233242
# Handle interactions
234243
self.w_LST.on_click(self._on_inputLST_clicked)
235244
self.w_VZA.on_click(self._on_inputVZA_clicked)
@@ -244,6 +253,7 @@ def LocalImageWidget(self):
244253
self.w_CalcG.on_trait_change(self._on_G_change, 'value')
245254
self.w_loadconfig.on_click(self._on_loadconfig_clicked)
246255
self.w_saveconfig.on_click(self._on_saveconfig_clicked)
256+
self.w_runmodel.on_click(self._on_runmodel_clicked)
247257

248258
self.isImage=True
249259

@@ -635,6 +645,21 @@ def _on_G_change(self,name, value):
635645
self.w_Gphase.visible=True
636646
self.w_Gshape.visible=True
637647

648+
def _on_runmodel_clicked(self, b):
649+
# Change the colour of the button to know it is running
650+
self.w_runmodel.background_color='yellow'
651+
# Get the data from the widgets
652+
self.GetDataTSEBWidgets(isImage = self.isImage)
653+
#run TSEB
654+
if self.isImage:
655+
self.RunTSEBLocalImage()
656+
else:
657+
self.RunTSEBPointSeriesArray()
658+
# Change the colour of the button to know it is running
659+
self.w_runmodel.background_color='green'
660+
661+
662+
638663
def GetDataTSEBWidgets(self,isImage):
639664
'''Parses the parameters in the GUI to TSEB variables for running TSEB'''
640665
self.TSEB_MODEL=self.w_model.value

0 commit comments

Comments
 (0)