Planetary Boundary Layer Height

hdelattre
Posts: 3
Joined: March 19th, 2014, 4:00 am
Registered HYSPLIT User: No

Re: Planetary Boundary Layer Height

Post by hdelattre »

Thanks for your answers.

Unfortunately, I don’t work on Linux but on Windows. Do you know a similar program for Windows?

I tried to run the python script again with other modifications, but it seems that tNum = mydata.GetTimeNumber() is equal to zero as I have the following error message:
ZeroDivisionError: Attempted to divide by zero.
I don’t understand why.

Here is the modified code:

Code: Select all

#--------------------------------------------------------        
# Author: Yaqiang Wang                                           
# Date: 2012-11-29                                                 
# Purpose: Derive station PBL data from ARL meteorological data  
# Note: Sample                                                   
#-----------------------------------------------------------
import clr
from System import *
from System.Globalization import *
clr.AddReference("MeteoInfoC.dll")
from MeteoInfoC import *
from MeteoInfoC.Data import *
from MeteoInfoC.Data.MeteoData import *

import os.path

#---- Set directories
dataDir = "C:\\Users\\hdelattre\\Documents\\Doctorat\\GlobalDataAssimilationSystem\\"

#---- Set times - this case show seasonal variation
sTime = DateTime.Parse("2011-07-01")
eTime = DateTime.Parse("2011-08-31")
aTime = sTime

#---- Create a MeteoDataInfo object 
mydata = MeteoDataInfo()
#---- Set lon/lat of the location
lon = 4.0
lat = 44.0
#---- Set output text file
outpath = dataDir + 'PBL_data.txt'
outf = open(outpath, 'w')
outf.write('Time,PBLH')
#---- Loop
i = 0
sum = 0.0
while aTime <= eTime:
     for w in range(5):
        inFile = dataDir + "gdas1." + aTime.ToString("MMM", CultureInfo("en-us")).ToLower() + aTime.ToString("yy") + ".w" + (w + 1).ToString()
        print "inFile", inFile
        if os.path.isfile(inFile):
         arldata = mydata.OpenARLData(inFile)  #Open ARL data file
         print "arldata",arldata
         tNum = mydata.GetTimeNumber() 
         print mydata.GetTimeNumber() 
         print "tNum", tNum
         for t in range(tNum): 
            dTime = mydata.GetTime(t)
            print "dTime.ToString", dTime.ToString("yyyy-MM-dd HH:00")
            mydata.TimeIndex = t   #Set time index
            gData = mydata.GetGridData("PBLH")  #Get PBLH grid data
            pblh = gData.ToStation(lon, lat)  #Intepolate PBLH data to the location
            print 'PBLH = %10.2f' %pblh
            outf.write(os.linesep)
            outf.write(dTime.ToString("yyyyMMddHH") + ',%-7.2f ' %pblh)
            sum += pblh
            i += 1
                
     aTime = aTime.AddMonths(1)

outf.close()
#---- Calculate seasonal average PBLH value
ave = sum / i   
print 'Average PBLH: %10.2f' %ave

print 'Finished!'
hdelattre
Posts: 3
Joined: March 19th, 2014, 4:00 am
Registered HYSPLIT User: No

Re: Planetary Boundary Layer Height

Post by hdelattre »

The update files solved the problem, thanks a lot !
Hélène
villebm
Posts: 6
Joined: March 28th, 2014, 3:29 am
Registered HYSPLIT User: No

Re: Planetary Boundary Layer Height

Post by villebm »

Hi @yaqiang!
Is it possible to upload this latest update to fix the bug o your personal hosting of MeteoInfo? it seems I am having the same problem with the script (I get tNum=0)
Thank you,
Ville
jia11
Posts: 7
Joined: November 20th, 2012, 2:35 am
Registered HYSPLIT User: Yes

Re: Planetary Boundary Layer Height

Post by jia11 »

This problem has been resolved by updating the MeteoInfo software. Thanks!
------------------------------
Hi Yaqiang, I tried to run the demo_pbl_station.py script but the tNum is always 0 as shown below. The file path is correct. Could you suggest how to resolve it? Many thanks!

C:\hysplit4\Mdata\2012\gdas1.jul12.w1
0
C:\hysplit4\Mdata\2012\gdas1.jul12.w2
0
C:\hysplit4\Mdata\2012\gdas1.jul12.w3
0
C:\hysplit4\Mdata\2012\gdas1.jul12.w4
0
C:\hysplit4\Mdata\2012\gdas1.jul12.w5
0
Traceback (most recent call last):
File "<string>", line 61, in <module>
ZeroDivisionError: Attempted to divide by zero.
Post Reply

Return to “General questions on meteorological data needed for HYSPLIT”