source: trunk/src/interp_erai_lwr_1989_2009.pro @ 19

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

remove hard coded directory for mask_oaflux_30N30S.nc

File size: 4.9 KB
Line 
1;+
2;
3; .. _interp_erai_lwr_1989_2009.pro:
4;
5; =============================
6; interp_erai_lwr_1989_2009.pro
7; =============================
8;
9;     .. graphviz::
10;
11;        digraph interp_erai_lwr_1989_2009 {
12;           graph [
13;           rankdir="LR",
14;           ]
15;           mask [shape=ellipse,fontname=Courier,label="${TROPFLUX_ID}/mask_oaflux_30N30S.nc"];
16;
17;           file_in [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/ERAI_global/20c3m_erai_str_TROP_1989_2009.nc"];
18;
19;           ncfile [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/TropFlux/input_uncor/erai_lwr_19890102_20091231_oafluxgrid.nc"];
20;
21;           interp_erai_lwr_1989_2009 [shape=box,
22;           fontname=Courier,
23;           color=blue,
24;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_lwr_1989_2009.pro",
25;           label="${TROPFLUX}/src/interp_erai_lwr_1989_2009.pro"];
26;
27;           {mask file_in} -> {interp_erai_lwr_1989_2009} -> {ncfile}
28;
29;         }
30;
31; SEE ALSO
32; ========
33;
34; :ref:`tropflux_profile.sh`
35;
36; EXAMPLES
37; ========
38;
39; ::
40;
41;  IDL> interp_erai_lwr_1989_2009
42;
43; TODO
44; ====
45;
46; hard coded directory - usage of ${TROPFLUX_ID}
47;
48; coding rules
49;
50; KNOWN ISSUES
51; ============
52;
53; test of existence of fullfilename_msk not very efficient because
54; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
55;
56; EVOLUTIONS
57; ==========
58;
59; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin)
60;
61;   * remove hard coded directory for mask_oaflux_30N30S.nc
62;
63; - fplod 20101215T094137Z aedon.locean-ipsl.upmc.fr (Darwin)
64;
65;   * add graph in header
66;
67; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
68;
69;   * minimal header
70;
71; - pbk 2008
72;
73;   * creation
74;
75;-
76pro interp_erai_lwr_1989_2009
77@common
78;
79; check for input directory
80;
81; test if ${TROPFLUX_ID} defined
82tropflux_id_env=GETENV('TROPFLUX_ID')
83CASE tropflux_id_env OF
84    ''  :  BEGIN
85     msg = 'eee : ${TROPFLUX_ID} is not defined'
86     ras = report(msg)
87     STOP
88           END
89 ELSE: BEGIN
90     msg = 'iii : ${TROPFLUX_ID} is ' + tropflux_id_env
91     ras = report(msg)
92       END
93ENDCASE
94;
95iodirin = isadirectory(tropflux_id_env)
96;
97; existence and protection of ${TROPFLUX_ID}
98IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
99   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
100   ras = report(msg)
101   STOP
102ENDIF
103;
104; build mask filename
105filename_msk='mask_oaflux_30N30S.nc'
106;
107; check if this file exists
108fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST)
109IF fullfilename_msk[0] EQ '' THEN BEGIN
110   msg = 'eee : the file ' + fullfilename_msk + ' was not found.'
111   ras = report(msg)
112   STOP
113ENDIF
114
115st=19890101 & en=20090801
116
117filein='/Volumes/PRAVEEN/ERAI_global/20c3m_erai_str_TROP_1989_2009.nc'
118initncdf, filein
119lwrin=read_ncdf("str",0,7668,/timestep,file=filein,/nostr)
120lwrin=-1*lwrin
121help, lwrin
122
123initncdf, filein
124domdef
125latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
126print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
127print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
128
129timein=time & jptin=jpt
130tab=lwrin(*,*,0)
131mskin=glamt*0.+1.
132
133initncdf, fullfilename_msk
134domdef
135latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
136print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
137print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
138mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
139
140help, lwrin
141
142si=size(swrin)
143lwrout=fltarr(jpi,jpj,jptin)
144
145for jt=0,jptin-1 do begin
146  print, 'Interpolation jt=',jt,' / ',jptin-1
147
148  tab=reform(lwrin(*,*,jt))
149  lwrout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin,lonout,latout,method='bilinear')
150  lwrout(*,*,jt)=lwrout(*,*,jt)*mskout+(1.-mskout)*1.e20
151
152endfor
153
154time=timegen(7669, start=julday(1,2,1989,0), units='days') & jpt=n_elements(time)
155tt=time & jptin=jpt
156cda0=string(jul2date(tt(0)),format='(i8.8)')
157cda1=string(jul2date(tt(jpt-1)),format='(i8.8)')
158tt=tt-julday(1,1,1950,00,00,00)
159xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*))
160
161initncdf, fullfilename_msk
162valmask=1.e20
163
164ylat=latout
165xlon=lonout
166ncfile='!/Volumes/PRAVEEN/TropFlux/input_uncor/erai_lwr_19890102_20091231_oafluxgrid.nc'
167
168lon_attr={units:'degrees_east',long_name:'Longitude'}
169lat_attr={units:'degrees_north',long_name:'Latitude'}
170time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
171
172lwr_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net longwave radiation ',short_name:'lwr',axis:'TYX'}
173time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
174globattr={source:'Tropical ocean fluxes obtained from ERA Interim',timerange:cda0+' - '+cda1}
175
176help,lwrout
177
178ncfields = 'lwr[longitude,latitude,time]=lwrout:lwr_attr; ' $
179                      + 'longitude[]=xlon:lon_attr; ' $
180                      + 'latitude[]=ylat:lat_attr; ' $
181                      + 'tt[*time]=tt:time_attr ' $
182                      + ' @ globattr'
183
184@ncdf_quickwrite
185
186return
187end
Note: See TracBrowser for help on using the repository browser.