1。数据命名是anth+4位年+2位月+‘.dat’,如anth200012.dat
这些数据我原来画都是使用相同的ctl和gs文件,但是在画每一个文件时要每次修改它的输入数据名称和输出的图像名称,具体修的地方见如下ctl和gs文件;
********************************************************************
ctl文件
dset E:/MODIS_anth_dust_3/data/anth200012.dat
title data in grads format
options little_endian
title data in grads format
options little_endian
undef -9999.0
xdef 360 linear -179.5 1
ydef 180 linear -89.5 1
zdef 1 linear 1 1
tdef 73 linear dec2000 1mo
vars 1
anth 1 0 ANH4(microgram/m3)
endvars
xdef 360 linear -179.5 1
ydef 180 linear -89.5 1
zdef 1 linear 1 1
tdef 73 linear dec2000 1mo
vars 1
anth 1 0 ANH4(microgram/m3)
endvars
*********************************************************************
gs文件
'c'
'reinit'
'open E:/MODIS_anth_dust_3/anth_1.ctl'
'set lon 110 150'
'set lat 10 50'
'set gxout shaded'
'set grads off'
'set clevs 0.05 0.10 0.15 0.2 0.25 0.3 0.35 0.40 0.45 0.50 0.55 0.60 0.65 '
'd anth'
'cbarn 1 1 9.2 4.3'
'set string 1 c 4 90'
'set strsiz 0.2 0.2'
'draw string 2 4 Latitude'
'set string 1 c 4 0'
'set strsiz 0.2 0.2'
'draw string 5.5 0.2 Longitude'
'enable print E:/MODIS_anth_dust_3/picture/aot200012.gmf'
'print'
'disable print'
'reinit'
'reinit'
'open E:/MODIS_anth_dust_3/anth_1.ctl'
'set lon 110 150'
'set lat 10 50'
'set gxout shaded'
'set grads off'
'set clevs 0.05 0.10 0.15 0.2 0.25 0.3 0.35 0.40 0.45 0.50 0.55 0.60 0.65 '
'd anth'
'cbarn 1 1 9.2 4.3'
'set string 1 c 4 90'
'set strsiz 0.2 0.2'
'draw string 2 4 Latitude'
'set string 1 c 4 0'
'set strsiz 0.2 0.2'
'draw string 5.5 0.2 Longitude'
'enable print E:/MODIS_anth_dust_3/picture/aot200012.gmf'
'print'
'disable print'
'reinit'
**********************************************************************
2。如果这样要是画6年每个月的图,会很烦琐,所以必须用批处理
在师姐的帮助下,我顺利的完成了这个工作。
首先对ctl文件进行修改,在grads手册中说明ctl的
options的template是支持批处理的。对于时间连续或有规律的文件,是可以处理的。
***************************************************************
修改后的ctl文件
dset E:/MODIS_anth_dust_3/data/anth%y4%m2.dat
title data in grads format
options template
undef -9999.0
xdef 360 linear -179.5 1
ydef 180 linear -89.5 1
zdef 1 linear 1 1
tdef 73 linear dec2000 1mo
vars 1
anth 1 0 ANH4(microgram/m3)
endvars
title data in grads format
options template
undef -9999.0
xdef 360 linear -179.5 1
ydef 180 linear -89.5 1
zdef 1 linear 1 1
tdef 73 linear dec2000 1mo
vars 1
anth 1 0 ANH4(microgram/m3)
endvars
文件说明,我的文件共有73个,从anth200012.dat--anth200612.dat.
1 anth%y4%m2.dat
是对一批数据进行说明,他们的文件名是有规律的,%y4代表4位2年,%m2代表2位月。这个格式还有很多,可以在手册里找到。
2 template代表options的一个选项,用于大量的时间序列文件公用一个ctl。
3 ‘tdef 73 linear dec2000 1mo'中的73代表共有73个时间序列文件,开始时间是200012。
4 至于
读取文件顺序是按照文件名的时间顺序读取的,所以不是乱读,而是有顺序和规律的读的。
这样的话我们的ctl文件就修改成功,所有的73各时间序列文件共用这一个ctl.
********************************************************************
修改后的gs文件
'c'
'reinit'
'open E:/MODIS_anth_dust_3/grads_1/anth_1.ctl' *打开上面的ctl
year=2000 *设定开始的时间,年
month=12 *开始的月
t=1 *从第几个时间序列开始
while(year<2007) *循环如果年小于2007则循环继续
while(month<13) *循环如果月小于13则循环继续
if(month<10) *设定输出的字符,输出的格式是4位年+2位月
aaa=year%0%month *如果月小于10,则在月前加0,保证月是两位
else
aaa=year%month *如果月大于等于10,则原样输出,因为它已经是2位了
endif
'set lon 110 150'
'set lat 10 50'
'set t 't *这里就是设置时间,每次循环都会改变t,也就是输出不同时刻的图,一定要注意第一个t后面有一个空各。
'set gxout shaded'
'set grads off'
'set clevs 0.05 0.10 0.15 0.2 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65' *设置输出的色表
'd anth'
'cbarn 1 1 9.2 4.3'
'set string 1 c 4 90'
'set strsiz 0.2 0.2'
'draw string 2 4 Latitude'
'set string 1 c 4 0'
'set strsiz 0.2 0.2'
'draw string 5.5 0.2 Longitude'
'enable print E:/MODIS_anth_dust_3/picture/anth'%aaa%'.gmf'*这里的'%aaa%'是把数字转化为字符。得到一个完整的输出文件名
'print'
'disable print'
'c'
month=month+1
t=t+1
endwhile
month=1
year=year+1
endwhile
'reinit'
'c'
'reinit'
'open E:/MODIS_anth_dust_3/grads_1/anth_1.ctl' *打开上面的ctl
year=2000 *设定开始的时间,年
month=12 *开始的月
t=1 *从第几个时间序列开始
while(year<2007) *循环如果年小于2007则循环继续
while(month<13) *循环如果月小于13则循环继续
if(month<10) *设定输出的字符,输出的格式是4位年+2位月
aaa=year%0%month *如果月小于10,则在月前加0,保证月是两位
else
aaa=year%month *如果月大于等于10,则原样输出,因为它已经是2位了
endif
'set lon 110 150'
'set lat 10 50'
'set t 't *这里就是设置时间,每次循环都会改变t,也就是输出不同时刻的图,一定要注意第一个t后面有一个空各。
'set gxout shaded'
'set grads off'
'set clevs 0.05 0.10 0.15 0.2 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65' *设置输出的色表
'd anth'
'cbarn 1 1 9.2 4.3'
'set string 1 c 4 90'
'set strsiz 0.2 0.2'
'draw string 2 4 Latitude'
'set string 1 c 4 0'
'set strsiz 0.2 0.2'
'draw string 5.5 0.2 Longitude'
'enable print E:/MODIS_anth_dust_3/picture/anth'%aaa%'.gmf'*这里的'%aaa%'是把数字转化为字符。得到一个完整的输出文件名
'print'
'disable print'
'c'
month=month+1
t=t+1
endwhile
month=1
year=year+1
endwhile
'reinit'