- 积分
- 696
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-4-9
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
#-----------------------------------------------------# Author: Yaqiang Wang
# Date: 2015-9-30
# Purpose: Run HYSPLIT trajectory model - days
# Note: Sample
#-----------------------------------------------------
# Set working directory
metDir = 'C:/Users/ASUS/Desktop/cs'
outDir = 'C:/Users/ASUS/Desktop/jg'
workingDir = 'C:/hysplit4/working'
os.chdir(workingDir)
print 'Current directory: ' + os.getcwd()
# Set parameters
lon = '115.2'
lat = '40.1'
shour = '06'
heights = ['100.0','500.0','1000.0']
hnum = len(heights)
hours = '-24'
vertical = '0'
top = '10000.0'
# Get month abstract string
def getmonthstr(m):
mmm = 'jan'
if m == 1:
mmm = 'jan'
elif m == 2:
mmm = 'feb'
elif m == 3:
mmm = 'mar'
elif m == 4:
mmm = 'apr'
elif m == 5:
mmm = 'may'
elif m == 6:
mmm = 'jun'
elif m == 7:
mmm = 'jul'
elif m == 8:
mmm = 'aug'
elif m == 9:
mmm = 'sep'
elif m == 10:
mmm = 'oct'
elif m == 11:
mmm = 'nov'
elif m == 12:
mmm = 'dec'
return mmm
# Get GDAS1 meteorological data files by time
def getmeteofiles(t):
y = t.year
ystr = t.strftime('%y')
m = t.month
mmm = getmonthstr(m)
fns = []
# The meteo files of this month
for i in range(1,6):
fn = 'gdas1.' + mmm + ystr + '.w' + str(i)
if os.path.exists(os.path.join(metDir, fn)):
fns.append(fn)
# The last two meteo files of last month
m = m - 1
if m == 0:
m = 12
ystr = str(y - 1)[2:]
mmm = getmonthstr(m)
fn = 'gdas1.' + mmm + ystr + '.w4'
fns.append(fn)
fn = 'gdas1.' + mmm + ystr + '.w5'
if os.path.exists(os.path.join(metDir, fn)):
fns.append(fn)
else:
fns.append('gdas1.' + mmm + ystr + '.w3')
return fns
# Set start/end time
import datetime
stime = datetime.datetime(2013,7,10)
etime = datetime.datetime(2013,7,20)
# Loop
ctFile = './CONTROL'
while stime <= etime:
print stime.strftime('%Y-%m-%d ') + shour + ':00'
ctf = open(ctFile, 'w')
ctf.write(stime.strftime('%y %m %d ') + shour + "\n")
ctf.write(str(hnum) + '\n')
for j in range(0,hnum):
ctf.write(lat + ' ' + lon + ' ' + heights[j] + '\n')
ctf.write(hours + '\n')
ctf.write(vertical + '\n')
ctf.write(top + '\n')
fns = getmeteofiles(stime)
fnnum = len(fns)
ctf.write(str(fnnum) + '\n')
for j in range(0,fnnum):
ctf.write(metDir + '/' + '\n')
ctf.write(fns[j] + '\n')
ctf.write(outDir + '/' + '\n')
outfn = stime.strftime('traj_%Y%m%d')
ctf.write(outfn)
ctf.close()
os.system('c:/hysplit4/exec/hyts_std.exe')
stime = stime + datetime.timedelta(days=1)
print 'Finish...'
这是我参照老师您的脚本编写的计算气团轨迹,没有报错,可是不知道为啥没有生成文件
(这是我的测试所用的arl数据,测试时间是2013,7,10-7,20)
谢谢老师您的解答!
|
|