python idle (integrated development and learning environment) for remote sensing, hydrological and...

6
4/14/2016 Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications | Ramesh Dhungel | L… https://www.linkedin.com/pulse/pythonidleintegrateddevelopmentlearningremotesensingdhungel?trk=profpost 1/30 H1B visa needed? We specialize exclusively in employment based immigration visas. Call us. Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications Apr 14, 2016 87 views 0 Likes 0 Comments This post will discuss about Python IDLE (Integrated Development Environment or Integrated Development and Learning Environment), especially for the meteorological and hydrological applications. Image processing environment like ERDAS Imagine, ENVI had been widely used in remote sensing community as well as Matlab and R. But, there is a very little discussion about the Python IDLE integrated with ArcGIS, basically with ArcScrit or ArcPy. It can be difficult to implement looping and iterative process in ModelBuilder of ArcGIS, ERDAS Imagine and ENVI, then the role comes of the Python IDLE. ERDAS Image Model Maker can also be messy if you are developing complex algorithms. Python IDLE not only can handle these complex processes in elegant way, but it will provide a dynamic environment for advance algorithm development. I have been working on the algorithm development of Land surface model using Python IDLE to compute evapotranspiration (ET), agricultural water management, irrigation Ramesh Dhungel Water Resources, Remote Sensing and Land Surface Modeler (LSM) (Ph.D. Civil Engineering) Edit post View stats Python IDLE (Integrated Development and Learning Environment) for remote… Ramesh Dhungel The Pros and Cons of Being Super Rich Ben Casnocha What Happens When The Internet Gets a Body? John Battelle Personification: The Future of Marketing is Near…And It is Facebook!? David Yuan Microsoft Sues the DOJ: Why and What You Should Know Greg Leffler Trump is wrong about unemployment, but he's not the only one Zachary Karabell The Voyeur's Motel: the place Pulse Publish a post Home Profile My Network Jobs Interests Business Services Try Premium for free Advanced 1 Search for people, jobs, companies, and more...

Upload: ramesh-dhungel

Post on 22-Jan-2017

174 views

Category:

Engineering


3 download

TRANSCRIPT

Page 1: Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications

4/14/2016 Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications | Ramesh Dhungel | L…

https://www.linkedin.com/pulse/python­idle­integrated­development­learning­remote­sensing­dhungel?trk=prof­post 1/30

H­1B visa needed? ­ We specialize exclusively in employment based immigration visas. Call us.

Python IDLE (Integrated Development and LearningEnvironment) for remote sensing, hydrological andmeteorological applicationsApr 14, 2016 87 views 0 Likes 0 Comments

This post will discuss about Python IDLE (Integrated Development Environment

or Integrated Development and Learning Environment), especially for the

meteorological and hydrological applications. Image processing environment like

ERDAS Imagine, ENVI had been widely used in remote sensing community as

well as Matlab and R. But, there is a very little discussion about the Python IDLE

integrated with ArcGIS, basically with ArcScrit or ArcPy. It can be difficult to

implement looping and iterative process in ModelBuilder of ArcGIS, ERDAS

Imagine and ENVI, then the role comes of the Python IDLE. ERDAS Image

Model Maker can also be messy if you are developing complex algorithms. Python

IDLE not only can handle these complex processes in elegant way, but it will

provide a dynamic environment for advance algorithm development. I have been

working on the algorithm development of Land surface model using Python IDLE

to compute evapotranspiration (ET), agricultural water management, irrigation

Ramesh DhungelWater Resources, Remote Sensing and LandSurface Modeler (LSM) (Ph.D. Civil Engineering)

Edit post View stats

Python IDLE (IntegratedDevelopment and LearningEnvironment) for remote…sensing, hydrological andRamesh Dhungel

The Pros and Cons of BeingSuper RichBen Casnocha

What Happens When TheInternet Gets a Body?John Battelle

Personification: The Future ofMarketing is Near…And It isFacebook!?David Yuan

Microsoft Sues the DOJ: Whyand What You Should KnowGreg Leffler

Trump is wrong aboutunemployment, but he's not theonly oneZachary Karabell

The Voyeur's Motel: the place

Pulse Publish a post

Home Profile My Network Jobs Interests Business Services Try Premium for free

Advanced 1 Search for people, jobs, companies, and more...

Page 2: Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications

4/14/2016 Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications | Ramesh Dhungel | L…

https://www.linkedin.com/pulse/python­idle­integrated­development­learning­remote­sensing­dhungel?trk=prof­post 2/30

scheduling, precision agriculture, geospatial modeling etc., which virtually

includes many boundary layer processes. This post will show some of the

important steps for developing complex algorithms using Python IDLE. These

algorithms are implemented while estimating ET for 3­hour time period.

Figure 1: Estimation of ET using NARR and METRIC model for 3­hour time

period for the entire months ( i.e.,  3 * 8 * 30 ) images of ET 

For two source surface energy balance model, please follow the

cartoon in the following post.

https://www.linkedin.com/pulse/pixel­scale­validation­ground­truth­satellite­

based­surface­dhungel?trk=pulse_spock­articles

Importing necessary modules:

import arcgisscripting

import os

import time

import sys

# Create a geoprocessor object, for example gp or rdh or something

gp = arcgisscripting.create(9.3)

Page 3: Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications

4/14/2016 Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications | Ramesh Dhungel | L…

https://www.linkedin.com/pulse/python­idle­integrated­development­learning­remote­sensing­dhungel?trk=prof­post 3/30

# Check out ArcGIS Spatial Analyst extension license

gp.CheckOutExtension("Spatial")

# Overwrite existing outputs

gp.OverWriteOutput = 1

Here are some of the examples: As usual, these codes are part of codes developed

in this process, so only a portion is shown. 

 a) Reading the image  using Python IDLE:

ComDir = r'I:\Papers\Meterological_applications\Common'

DEM =os.path.join(ComDir, 'DEM_clipped_large.img')

b) Conditional sentences:

Theta_ref=os.path.join(ComDir,'theta_ref_.img')

Theta_ref_eqn = 'con( '+Soil_final+' == 0 , 0.360, con( '+Soil_final+' == 1 , 0.36,

con( '+Soil_final+' == 2 , 0.34, con( '+Soil_final+' == 3 , 0.329,'

Theta_ref_eqn+= 'con( '+Soil_final+' == 4 , 0.2, con( '+Soil_final+' == 5 , 0.2,

con( '+Soil_final+' == 6 , 0.30, con( '+Soil_final+' == 7, 0.360,'

Theta_ref_eqn+= 'con( '+Soil_final+' == 8 , 0.36, 0.36 ) ) ) ) ) ) ) ) )'

gp.SingleOutputMapAlgebra_sa(Theta_ref_eqn,Theta_ref)

c) Writing equations:

workDir =

r'I:\Papers\Meterological_applications\Combined_Ess_Ec_interpolation_06112010'

 Water_flag = os.path.join(workDir, 'Water_flag.img')

 Water_flg_eqn= 'con(('+Landuse+' == 11) or ( '+NDVI+' 0), 1, 0)'

Page 4: Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications

4/14/2016 Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications | Ramesh Dhungel | L…

https://www.linkedin.com/pulse/python­idle­integrated­development­learning­remote­sensing­dhungel?trk=prof­post 4/30

  gp.SingleOutputMapAlgebra_sa(Water_flg_eqn, Water_flag)

d) For and while looping (multi looping):

i= Current_satellite_passing_Index + 1

proceed with all the algorithms

H_Flux_new_soil = os.path.join(workDir,'sheat_new_soil_'+ str(i)+'.img') 

G_Flux_new_soil = os.path.join(workDir,'gheat_new_soil_'+ str(i)+'.img')

 while i = Next_satellite_passing_Index + 1 :

 else:

 Figure 2 shows an example the algorithm developed in the process:

e) Monitoring pixels in the simulation process using python shell:

   if DEBUG:

      PrintCellValue(gp,ETsoil_sec_pre,'\tResult ­­ ETsoil_sec_pre: ')

      PrintCellValue(gp,ETveg_sec_pre,'\tResult ­­ ETveg_sec_pre: ')

      PrintCellValue(gp,soilm_pre,'\tResult ­­ soilm_pre: ')

Page 5: Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications

4/14/2016 Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications | Ramesh Dhungel | L…

https://www.linkedin.com/pulse/python­idle­integrated­development­learning­remote­sensing­dhungel?trk=prof­post 5/30

Figure 3 shows the python shell while running the algorithm:

f) Extracting pixel or cell value from directory:

R_Rgl=(gp.GetCellValue( Rgl,'2601776.501 1325307.224  ', '1').getoutput(0))

myRgl = 'Rgl: '+ R_Rgl + '\n'

myfile.write(myRgl)

Write a table for certain cell value for entire simulation period:

 for i in range (i, 1359, 1):

   myOut = ','.join((str(i), R_Date, R_precip, R_irrigation, R_NDVI, R_fc,

R_In_short, R_EThour_com, R_EThour_com_final, R_ETrF_com, R_ETcor,

R_ETveg_hour, R_ETsoil_hour, R_ETcor_veg, R_ETcor_soil,

R_ETcor_com,'\n'))

   myfile.write(myOut)

 myfile.close()

g) For real­time plotting options in Python IDLE, please look my

previous post:

Page 6: Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications

4/14/2016 Python IDLE (Integrated Development and Learning Environment) for remote sensing, hydrological and meteorological applications | Ramesh Dhungel | L…

https://www.linkedin.com/pulse/python­idle­integrated­development­learning­remote­sensing­dhungel?trk=prof­post 6/30

Real­time simulation of the iterative calculation of thesatellite based surface energy fluxeshttps://www.linkedin.com

White paper An iterative procedure is still used to converge fluxes in evapotranspiration (ET)calculation in many ET models like METRIC (Allen et al., 2007), SEBAL (Bastiaanssen et al.,1998) and SEBS (Su, 2002). In this post, a real­time simulation is shown to expedite the satellitebased surface energy balance fluxes in low wind speed condition.

Finally, once the image is processed, you can use ArcGIS or any other image

viewer to analyze the results. One of the drawbacks of Python IDLE might be the

need of ArcGIS license as it is integrated into ArcGIS.

For the further reading, please look these references:

Dhungel R, Allen R.G., Trezza R., Robison C. W., 2014. Comparison of Latent

Heat Flux Using Aerodynamic Methods and Using the Penman–Monteith

Method with Satellite­Based Surface Energy Balance. Remote Sensing.

6(9):8844­8877.

Using a Two Source Energy Balance model to compute evapotranspiration

between satellite overpasses: Simulation of ET using weather and Satellite data

(Under Review). Meteorological Applications (MET­15­0095).

Dhungel, R., 2014. Time integration of evapotranspiration using a two source

surface energy balance model using NARR reanalysis weather data and satellite

based METRIC data. D. Dissertation, University of Idaho.

http://digital.lib.uidaho.edu/cdm/ref/collection/etd/id/829

Please keep on following for the updates of the post!!!!!!!!!!!