Export RH2m from ARL GDAS data

Post Reply
scarlett.boiardi
Posts: 3
Joined: September 9th, 2015, 6:13 am
Registered HYSPLIT User: Yes

Export RH2m from ARL GDAS data

Post by scarlett.boiardi »

Hi,

I have many weekly GDAS meteorological data and I'd like to extract the T02m and RH2m variables from these arl files using meteoinfo. I can do it manually with the software's "Open Data" option but it would take me ages to do it since each variables is recoreded every 3h.
I am not familiar with computing languages (I only know matlab) and I was wondering if any of you has a script written to extract variables from arl files using meteoinfo (or matlab). Even if it's not for GDAS or the variables I want, any help would be much appreciated ! :)

Thanks a lot,
Scarlett
ariel.stein
Posts: 660
Joined: November 7th, 2012, 3:14 pm
Registered HYSPLIT User: Yes

Re: Export RH2m from ARL GDAS data

Post by ariel.stein »

Below is an example of a shell script to extract data from a gdas file. Replace PBLH by the variable name you want to extract. Also, change the latitude and longitude ( in my case I used 36.15 -5.35). Make sure you point to the location of your executrable (xtrct_stn) (replace ../exec by the directory where you have your executable).


#!/bin/sh
DAT='/pub/archives/gdas1'
EXE='../exec'
ODAT='./'

rm -f file.txt
rm -f f.txt

array=(jan feb mar apr may jun jul aug sep oct nov dec)
for yr in 03 04 05 06 07 08 09 10 11 12 13 14; do
for mo in 00 01 02 03 04 05 06 07 08 09 10 11 ; do

let uno=1
let mt=10#${mo}+${uno}
mt=`printf %02d ${mt}`
echo ${mt}

let num=0
let mo=10#${mo}
mn=`printf "%d\n" "${mo}"`

for week in w1 w2 w3 w4 w5 ; do
if [ -f ${DAT}/gdas1.${array[$mn]}${yr}.${week} ] ; then
${EXE}/xtrct_stn -i << EOF
${DAT}/
gdas1.${array[$mn]}${yr}.${week}
1
PBLH 01 1.0
36.15 -5.35
0
f.txt
1
99999
EOF

echo "gdas1.${array[$mn]}${yr}.${week}"
cat f.txt >> file.txt
fi
done
done
done
yaqiang
Posts: 59
Joined: October 5th, 2015, 10:20 pm
Registered HYSPLIT User: Yes

Re: Export RH2m from ARL GDAS data

Post by yaqiang »

It's easy to extract meteorological data in MeteoInfoLab with script. Firstly create a data file object using 'addfile' function, and then get data by sepcific dimensions. For example, T02M has 4 dimensions (time, level, lat, lon), 2 dimension array can be extracted by fixing time and level dimension. T02M only has one level, so the level index is allways 0. ':' means read all range data of the dimension.

Code: Select all

#Open an ARL data file
f = addfile('D:/Temp/arl/gdas1.jul09.w5')
#Read a 2 dimension (lat, lon) data array from the file
tidx = 0
t = f.gettime(tidx)
lidx = 0
data = f['T02M'][tidx,lidx,:,:]
#Plot
axesm()
mlayer = shaperead('D:/Temp/map/country1.shp')
geoshow(mlayer, linecolor=[0,0,255])
layer = contourfm(data)
title('Temperature at 2m (' + t.strftime('%Y-%m-%d %Hh') + ')')
colorbar(layer)


The result figure from above script:
ARL_T02M_global.png
Dimension range can also be given by min/max indexes, or by exactly min/max longitude/latitude (only for lonlat projection data).

Code: Select all

#Set dimension range by indexes
data = f['T02M'][tidx,lidx,80:100,20:50]
#Set dimension range by lon/lat
data = f['T02M'][tidx,lidx,[-10,10],[20,50]]
The result figure from above script:
ARL_T02M_region.png
'tostation' function was used to extract the data at specific location.

Code: Select all

f = addfile('D:/Temp/arl/gdas1.jul09.w5')
tidx = 0
t = f.gettime(tidx)
lidx = 0
data = f['T02M'][tidx,lidx,[25,35],[100,110]]
lon = 104.15
lat = 30.01
d = data.tostation(lon, lat)
print d
ARL_T02M_station.png
cobzac
Posts: 5
Joined: September 3rd, 2015, 4:43 pm
Registered HYSPLIT User: No

Re: Export RH2m from ARL GDAS data

Post by cobzac »

yaqiang wrote:
Dimension range can also be given by min/max indexes, or by exactly min/max longitude/latitude (only for lonlat projection data).

Code: Select all

#Set dimension range by indexes
data = f['T02M'][tidx,lidx,80:100,20:50]
#Set dimension range by lon/lat
data = f['T02M'][tidx,lidx,[-10,10],[20,50]]
Why does it give me 3 values when I try smth like this

Code: Select all

f = addfile('I:/job/20151031_gdas0p5')
tidx = 0
t = f.gettime(tidx)
lidx = 50
data = f['UWND'][tidx,lidx,0,[0,1]]
print data

>>> run script...
array([-3.336771, -3.336771, -3.336771])
what exactly it did?
yaqiang
Posts: 59
Joined: October 5th, 2015, 10:20 pm
Registered HYSPLIT User: Yes

Re: Export RH2m from ARL GDAS data

Post by yaqiang »

The resolution of the data is 0.5 degree, so you got 3 data at 0, 0.5 and 1 degree east of longitude with [0, 1] longitude range.
Post Reply

Return to “MeteoInfo Software”