source: trunk/src/d2m_to_q2m_erai.pro @ 16

Last change on this file since 16 was 12, checked in by pinsard, 13 years ago

fix for graph in PDF

File size: 3.7 KB
Line 
1;+
2;
3; .. _d2m_to_q2m_erai.pro:
4;
5; ===================
6; d2m_to_q2m_erai.pro
7; ===================
8;
9;     .. graphviz::
10;
11;        digraph d2m_to_q2m_erai {
12;           graph [
13;           rankdir="LR",
14;           ]
15;           file_d2m [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/TropFlux/input_uncor/erai_d2m_19890101_20091231_oafluxgrid.nc"];
16;           file_t2m [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/TropFlux/input_uncor/erai_t2m_19890101_20091231_oafluxgrid.nc"];
17;           file_msl [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/TropFlux/input_uncor/erai_msl_19890101_20091231_oafluxgrid.nc"];
18
19;           file_q2m [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/TropFlux/input_uncor/q2m_erai_19890101_20091231_oafluxgrid.nc"];
20;
21;           d2m_to_q2m_erai [shape=box,
22;           fontname=Courier,
23;           color=blue,
24;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/d2m_to_q2m_erai.pro",
25;           label="${TROPFLUX}/src/d2m_to_q2m_erai.pro"];
26;           {file_d2m file_t2m file_msl} -> {d2m_to_q2m_erai} -> {file_q2m}
27;        }
28;
29; SEE ALSO
30; ========
31;
32; :func:`rh_to_spechum`
33;
34; EXAMPLES
35; ========
36;
37; ::
38;
39;  IDL> d2m_to_q2m_erai
40;
41; TODO
42; ====
43;
44; hard coded directory - usage of ${TROPFLUX_ID}
45;
46; coding rules
47;
48; EVOLUTIONS
49; ==========
50;
51; - fplod 20101215T162933Z aedon.locean-ipsl.upmc.fr (Darwin)
52;
53;   * graph correction
54;
55; - fplod 20101215T093141Z aedon.locean-ipsl.upmc.fr (Darwin)
56;
57;   * add graph in header
58;
59; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
60;
61;   * minimal header
62;
63; - pbk 2008
64;
65;   * creation
66;
67;-
68pro d2m_to_q2m_erai
69@common
70;; reading erai dew point temperature
71d1=19881001 & d2=20101231
72
73file='/Volumes/PRAVEEN/TropFlux/input_uncor/erai_d2m_19890101_20091231_oafluxgrid.nc'
74initncdf, file
75td=read_ncdf("d2m", d1,d2, file=file,/nostr)
76
77;; reading erai air temperature
78file='/Volumes/PRAVEEN/TropFlux/input_uncor/erai_t2m_19890101_20091231_oafluxgrid.nc'
79initncdf, file
80t=read_ncdf("t2m", d1,d2, file=file,/nostr)
81tt=time &jpt=n_elements(time)
82help, t, td
83
84;;since the t2m and d2m are already in K, no need for conversion
85
86e=es0*exp((25.e5/461.5)*((1/273.15)-(1/td)))
87es=es0*exp((25.e5/461.5)*((1/273.15)-(1/t)))
88
89rh=(e/es)*100
90
91;; conversion of relative humidity to sp. humidity
92;; Ref.1 -  Gill, Appendix 4,
93;; Ref.2 - http://efdl.cims.nyu.edu/project_aomip/forcing_data/atmosphere/humidity.html
94
95t=t-273.15
96
97file='/Volumes/PRAVEEN/TropFlux/input_uncor/erai_msl_19890101_20091231_oafluxgrid.nc'
98initncdf, file
99P=read_ncdf("msl", d1, d2, file=file,/nostr)
100help, P
101q2m=rh_to_spechum(rh,t,P)
102
103;;writing field
104ncfile='!/Volumes/PRAVEEN/TropFlux/input_uncor/q2m_erai_19890101_20091231_oafluxgrid.nc'
105time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time)
106cda0=string(jul2date(time(0)),format='(i8.8)')
107cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
108
109
110tt=time-julday(1,1,1950,00,00,00)
111xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*))
112valmask=1.e20
113
114lon_attr={units:'degrees_east',long_name:'Longitude'}
115lat_attr={units:'degrees_north',long_name:'Latitude'}
116q2m_attr={units:'kg/kg',missing_value:valmask,long_name:'Surface specific humidity at 2m ',short_name:'q2m',axis:'TYX'}
117time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
118globattr={source:'Surface specific humidity at 2m calculated from dew point temperature',timerange:cda0+' - '+cda1}
119
120ncfields = 'q2m[longitude,latitude,time]=q2m:q2m_attr; ' $
121                      + 'longitude[]=xlon:lon_attr; ' $
122                      + 'latitude[]=ylat:lat_attr; ' $
123                      + 'tt[*time]=tt:time_attr ' $
124                      + ' @ globattr'
125
126@ncdf_quickwrite
127return
128end
Note: See TracBrowser for help on using the repository browser.