source: trunk/src/oaflux_mask_30N30S.pro @ 17

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

oaflux_mask_30N30S.pro no more hard coded directories

File size: 4.8 KB
Line 
1;+
2;
3; .. _oaflux_mask_30N30S.pro:
4;
5; ======================
6; oaflux_mask_30N30S.pro
7; ======================
8;
9; Produce a NetCDF file with  OAFLUX mask over global tropical oceans
10;
11;     .. graphviz::
12;
13;        digraph oaflux_mask_30N30S {
14;           graph [
15;           rankdir="LR",
16;           ]
17;           file_oaflux [shape=ellipse,fontname=Courier,label="${TROPFLUX_ID}/lh_oaflux_2004.nc"];
18;           mask [shape=ellipse,fontname=Courier,label="${TROPFLUX_OD}/mask_oaflux_30N30S.nc"];
19;
20;           oaflux_mask_30N30S [shape=box,
21;           fontname=Courier,
22;           color=blue,
23;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/oaflux_mask_30N30S.pro",
24;           label="${TROPFLUX}/src/oaflux_mask_30N30S.pro"];
25;
26;           {file_oaflux} -> {oaflux_mask_30N30S} -> {mask}
27;
28;          }
29;
30; SEE ALSO
31; ========
32;
33; :ref:`guide data OAFLUX <data_in_oaflux>`
34;
35; :ref:`tropflux_profile.sh`
36;
37; :func:`report`
38; :func:`initncdf`
39; :func:`ncdf_lec`
40; :ref:`ncdf_quickwrite`
41; :func:`isadirectory`
42;
43; EXAMPLES
44; ========
45;
46; ::
47;
48;  IDL> oaflux_mask_30N30S
49;
50; TODO
51; ====
52;
53; SAXO new (keep compatibility false)
54;
55; coding rules
56;
57; pro -> function
58;
59; NetCDF CF (may be area_type)
60;
61; global attributes corrections :
62;  - written now : OAFLUX mask over the Indian Ocean: 40E-120E, 30S-30N
63;  - while data latitude=[-29.5,+29.5] longitude=[30.5,379.5]
64;
65; KNOWN ISSUES
66; ============
67;
68; test of existence of fullfilename_in not very efficient because
69; MUST_EXIST keyword of :func:`isafile` not yet implemented
70;
71; EVOLUTIONS
72; ==========
73;
74; - fplod 20101217T081915Z aedon.locean-ipsl.upmc.fr (Darwin)
75;
76;   * remove hard coded directory - usage of ${TROPFLUX_ID} and ${TROPFLUX_OD}
77;   * add IO test
78;
79; - fplod 20101216T141137Z aedon.locean-ipsl.upmc.fr (Darwin)
80;
81;   * minimal header
82;
83; - jv 2010
84;
85;   * creation
86;
87;-
88;
89PRO oaflux_mask_30N30S
90;
91@common
92;
93; check for input file
94;
95; test if ${TROPFLUX_ID} defined
96tropflux_id_env=GETENV('TROPFLUX_ID')
97CASE tropflux_id_env OF
98    ''  :  BEGIN
99     msg = 'eee : ${TROPFLUX_ID} is not defined'
100     ras = report(msg)
101     STOP
102           END
103 ELSE: BEGIN
104     msg = 'iii : ${TROPFLUX_ID} is ' + tropflux_id_env
105     ras = report(msg)
106       END
107ENDCASE
108;
109iodirin = isadirectory(tropflux_id_env)
110;
111; existence and protection of ${TROPFLUX_ID}
112IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
113   msg = 'eee : the directory' + iodirin  + ' is not accessible.'
114   ras = report(msg)
115   STOP
116ENDIF
117;
118; build input filename
119yyyy=2004
120cy=string(yyyy,format='(i4.4)')
121filename_in='lh_oaflux_'+cy+'.nc'
122;
123; check if this file exists
124fullfilename_in = isafile(iodirin + filename_in, NEW=0, /MUST_EXIST)
125IF fullfilename_in[0] EQ '' THEN BEGIN
126   msg = 'eee : the file ' + fullfilename_in + ' was not found.'
127   ras = report(msg)
128   STOP
129ENDIF
130;
131; test if ${TROPFLUX_OD} defined
132tropflux_od_env=GETENV('TROPFLUX_OD')
133CASE tropflux_od_env OF
134  '' : BEGIN
135   msg = 'eee : ${TROPFLUX_OD} is not defined'
136   ras = report(msg)
137   STOP
138       END
139ELSE: BEGIN
140   msg = 'iii : ${TROPFLUX_OD} is ' + tropflux_od_env
141   ras = report(msg)
142        END
143ENDCASE
144;
145; check if output data will be possible
146iodirout = isadirectory(tropflux_od_env)
147;
148; existence and protection
149IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
150   msg = 'eee : the directory' + iodirout  + ' was not found.'
151   ras = report(msg)
152   STOP
153ENDIF
154;
155fullfilename_out=iodirout+'mask_oaflux_30N30S.nc'
156; in order to avoid unexpected overwritten
157IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
158   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
159   ras = report(msg)
160   STOP
161ENDIF
162;
163; Read oaflux grid and mask
164initncdf, fullfilename_in
165lh=ncdf_lec(fullfilename_in,var='lhtfl',count=[jpi,jpj,1]) & lh=float(lh)
166valmask=1.e20
167ind=where(lh ge 32000,compl=nind) & lh(ind)=valmask & lh(nind)=-0.1*lh(nind)
168mask_out=(lh ne valmask)
169domdef, 0.,360.,-30.,30.
170
171lon=reform(glamt(*,0))
172ind1=where(lon le 20.)
173ind2=where(lon ge 30.)
174
175lat_out=reform(gphit(0,firstyt:lastyt))
176
177lon_out=[reform(glamt(ind2,0)),reform(glamt(ind1,0))+360]
178
179mask_out=mask_out([ind2,ind1],firstyt:lastyt)*1.
180
181
182ncfile='!'+fullfilename_out
183lon_attr={units:'degrees_east',long_name:'Longitude'}
184lat_attr={units:'degrees_north',long_name:'Latitude'}
185msk_attr={long_name:'land sea mask',short_name:'msk',axis:'YX'}
186globattr={description:'OAFLUX mask over the Indian Ocean: 40E-120E, 30S-30N'}
187
188ncfields = 'msk[longitude,latitude]=mask_out:msk_attr; ' $
189                      + 'longitude[]=lon_out:lon_attr; ' $
190                      + 'latitude[]=lat_out:lat_attr; ' $
191                      + ' @ globattr'
192
193@ncdf_quickwrite
194
195END
Note: See TracBrowser for help on using the repository browser.