Skip to content

Commit

Permalink
Include a 'Run PyTSEB' button to avoid some user confusion in the jup…
Browse files Browse the repository at this point in the history
…yter notebooks
  • Loading branch information
hectornieto committed May 11, 2016
1 parent 8f21dad commit 3c9cf65
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 54 deletions.
36 changes: 8 additions & 28 deletions ProcessLocalImage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"scrolled": true
"collapsed": true
},
"source": [
"# Run TSEB\n",
"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",
"Once TSEB is configured we parse all the information in the widgets and run the selected model. \n",
"\n",
"Once the processing is done two GeoTiff files will be saved:\n",
"\n",
"- < Main Output File > whose name is specified in the cell *Output File* will contain the bulk estimated fluxes:\n",
" 1. Sensible heat flux (W m-2)\n",
Expand All @@ -64,29 +65,8 @@
" 6. Net shortwave radiation (W m-2)\n",
" 7. Net longwave radiation (W m-2)\n",
" 8. Friction velocity (m s-1)\n",
" 9. Monin-Obukhov lenght (m)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Get the data from the widgets\n",
"setup.GetDataTSEBWidgets(isImage = True)\n",
"# Run TSEB\n",
"setup.RunTSEBLocalImage()"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
" 9. Monin-Obukhov lenght (m)\n",
"\n",
"# Display results\n",
"Now we can open the image and display the TSEB outputs:"
]
Expand Down Expand Up @@ -162,7 +142,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "IPython (Python 3)",
"language": "python",
"name": "python3"
},
Expand All @@ -176,7 +156,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.4"
"version": "3.5.1"
}
},
"nbformat": 4,
Expand Down
42 changes: 16 additions & 26 deletions ProcessPointTimeSeries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,16 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"metadata": {},
"source": [
"# Run TSEB\n",
"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",
"Once TSEB is configured we parsed all the information in the widgets and run the selected model. \n",
"\n",
"Once the processing is done an ASCII table with the following variables will be written in the output txt file:\n",
">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",
"\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Get the data from the widgets\n",
"setup.GetDataTSEBWidgets(isImage = False)\n",
"#run TSEB\n",
"setup.RunTSEBPointSeriesArray()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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",
"\n",
"# Display results\n",
"Now we can open the output and plot the TSEB outputs:"
]
Expand Down Expand Up @@ -135,11 +116,20 @@
"\n",
"show(p);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "IPython (Python 3)",
"language": "python",
"name": "python3"
},
Expand Down
25 changes: 25 additions & 0 deletions src/pyTSEB.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def PointTimeSeriesWidget(self):
self.w_inputtxt=widgets.Text(description='Input File :', value=self.InputFile, width=500)
self.w_output=widgets.Button(description='Select Output File')
self.w_outputtxt=widgets.Text(description='Output File :', value=self.OutputTxtFile,width=500)

self.w_runmodel=widgets.Button(description='Run pyTSEB', background_color='green')

# Create TSEB options widgets
self.SelectModel()
self.DefineSiteDescription()
Expand All @@ -160,13 +163,15 @@ def PointTimeSeriesWidget(self):
display(widgets.HBox([self.w_output,self.w_outputtxt]))
display(tabs)
display(self.w_saveconfig)
display(self.w_runmodel)
# Handle interactions
self.w_CalcG.on_trait_change(self._on_G_change, 'value')
self.w_input.on_click(self._on_input_clicked)
self.w_output.on_click(self._on_output_clicked)
self.isImage=False
self.w_loadconfig.on_click(self._on_loadconfig_clicked)
self.w_saveconfig.on_click(self._on_saveconfig_clicked)
self.w_runmodel.on_click(self._on_runmodel_clicked)

def LocalImageWidget(self):
'''Creates a jupyter notebook GUI for running TSEB for an image'''
Expand Down Expand Up @@ -194,6 +199,8 @@ def LocalImageWidget(self):
self.w_masktxt=widgets.Text(description='Mask:',value='0', width=500)
self.w_output=widgets.Button(description='Select Output File')
self.w_outputtxt=widgets.Text(description='Output File :', value=self.OutputImageFile, width=500)

self.w_runmodel=widgets.Button(description='Run pyTSEB', background_color='green')
# Create TSEB options widgets
self.SelectModel()
self.DefineSiteDescription()
Expand Down Expand Up @@ -230,6 +237,8 @@ def LocalImageWidget(self):
display(widgets.HBox([self.w_output,self.w_outputtxt]))
display(tabs)
display(self.w_saveconfig)
display(self.w_runmodel)

# Handle interactions
self.w_LST.on_click(self._on_inputLST_clicked)
self.w_VZA.on_click(self._on_inputVZA_clicked)
Expand All @@ -244,6 +253,7 @@ def LocalImageWidget(self):
self.w_CalcG.on_trait_change(self._on_G_change, 'value')
self.w_loadconfig.on_click(self._on_loadconfig_clicked)
self.w_saveconfig.on_click(self._on_saveconfig_clicked)
self.w_runmodel.on_click(self._on_runmodel_clicked)

self.isImage=True

Expand Down Expand Up @@ -635,6 +645,21 @@ def _on_G_change(self,name, value):
self.w_Gphase.visible=True
self.w_Gshape.visible=True

def _on_runmodel_clicked(self, b):
# Change the colour of the button to know it is running
self.w_runmodel.background_color='yellow'
# Get the data from the widgets
self.GetDataTSEBWidgets(isImage = self.isImage)
#run TSEB
if self.isImage:
self.RunTSEBLocalImage()
else:
self.RunTSEBPointSeriesArray()
# Change the colour of the button to know it is running
self.w_runmodel.background_color='green'



def GetDataTSEBWidgets(self,isImage):
'''Parses the parameters in the GUI to TSEB variables for running TSEB'''
self.TSEB_MODEL=self.w_model.value
Expand Down

0 comments on commit 3c9cf65

Please sign in to comment.