source: trunk/src/oaflux_mask_30n30s.pro @ 162

Last change on this file since 162 was 156, checked in by pinsard, 12 years ago

try to add compile_opt but seems to be incompatible with ncdf_quickwrite

  • Property svn:keywords set to Id URL
File size: 5.4 KB
Line 
1;+
2;
3; ======================
4; oaflux_mask_30n30s.pro
5; ======================
6;
7; .. function:: oaflux_mask_30n30s()
8;
9; DESCRIPTION
10; ===========
11;
12; Produce a NetCDF file with OAFLUX mask over global tropical oceans (30N-30S)
13;
14; .. note::
15;
16;    Longitude range [30.5,379.5] was choosen in order not to make any cut in
17;    the Atlantic Ocean.
18;    Otherwise if we choose longitude range to [0.5,359.5], Atlantic Ocean
19;    will be split to two and will appear on right and left sides of the map.
20;
21; .. graphviz::
22;
23;    digraph oaflux_mask_30n30s {
24;
25;       file_oaflux [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/lh_oaflux_2004.nc"];
26;       mask [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/mask_oaflux_30N30S.nc"];
27;
28;       oaflux_mask_30n30s [shape=box,
29;       fontname=Courier,
30;       color=blue,
31;       URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/oaflux_mask_30n30s.pro",
32;       label="${PROJECT}/src/oaflux_mask_30n30s.pro"];
33;
34;       {file_oaflux} -> {oaflux_mask_30n30s} -> {mask}
35;
36;      }
37;
38; :returns: 0 if ok,  -1 if error
39; :rtype: integer
40;
41; SEE ALSO
42; ========
43;
44; :ref:`guide Gather data <gather_data>`
45;
46; :ref:`guide data OAFLUX <data_in_oaflux>`
47;
48; Environement :
49; :ref:`project_profile.sh`,
50; :ref:`project_init.pro`,
51; :ref:`cm_project.pro`
52;
53; Previous step : :ref:`get_oaflux.sh`
54;
55; Use :
56; :func:`report <saxo:report>`,
57; :func:`initncdf <saxo:initncdf>`,
58; :func:`ncdf_lec <saxo:ncdf_lec>`,
59; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`,
60; :func:`isadirectory <saxo:isadirectory>`,
61; :func:`isafile <saxo:isafile>`
62;
63; Following program use :func:`oaflux_mask_30n30s` output:
64; :ref:`TropFlux_19890101_20091231.pro`,
65; :ref:`interp_erai_dewt_1989_2009.pro`,
66; :ref:`interp_erai_lwr_1989_2009.pro`,
67; :ref:`interp_erai_sst_1989_2009.pro`,
68; :func:`interp_erai_t2m`,
69; :ref:`interp_erai_ws_1989_2009.pro`,
70; :ref:`interp_olr_30n30s_1989_2009.pro`
71;
72; EXAMPLES
73; ========
74;
75; ::
76;
77;  IDL> result = oaflux_mask_30n30s()
78;
79; TODO
80; ====
81;
82; SAXO new (keep compatibility false)
83;
84; coding rules
85;
86; NetCDF CF (may be area_type)
87;
88; global attributes corrections :
89;  - written now : OAFLUX mask over the Indian Ocean: 40E-120E, 30S-30N
90;  - while data latitude=[-29.5,+29.5] longitude=[30.5,379.5]
91;
92; 30n30s in name vs future global output ... parameters lat and long max
93;
94; KNOWN ISSUES
95; ============
96;
97; test of existence of fullfilename_in not very efficient because
98; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
99;
100; EVOLUTIONS
101; ==========
102;
103; $Id$
104;
105; $URL$
106;
107; - fplod 20120306
108;
109;   * try to add compile_opt
110;
111; - fplod 20120305
112;
113;   * pro -> function
114;
115; - fplod 20110411T140133Z aedon.locean-ipsl.upmc.fr (Darwin)
116;
117;   * usage of tropflux_init and cm_project
118;   * replace 30N30S by 30n30s
119;
120; - fplod 20101217T081915Z aedon.locean-ipsl.upmc.fr (Darwin)
121;
122;   * remove hard coded directory - usage of ${PROJECT_ID} and ${PROJECT_OD}
123;   * add IO test
124;
125; - fplod 20101216T141137Z aedon.locean-ipsl.upmc.fr (Darwin)
126;
127;   * minimal header
128;
129; - jv 2010
130;
131;   * creation
132;
133;-
134;
135FUNCTION oaflux_mask_30n30s
136;
137;++ compile_opt idl2, strictarrsubs, logical_predicate
138;
139@cm_4cal
140@cm_4data
141@cm_4mesh
142@cm_4data
143@cm_project
144
145; Return to caller if errors
146on_error, 2
147;
148result = -1
149;
150usage = 'result=oaflux_mask_30n30s()'
151nparam = N_PARAMS()
152IF (nparam NE 0) THEN BEGIN
153   ras = report(['Incorrect number of arguments.' $
154         + '!C' $
155         + 'Usage : ' + usage])
156   return, result
157ENDIF
158;
159; check for input file
160; build input filename
161yyyy=2004
162cy=string(yyyy,format='(i4.4)')
163filename_in='lh_oaflux_'+cy+'.nc'
164;
165; check if this file exists
166fullfilename_in = isafile(project_id_env + filename_in, NEW=0, /MUST_EXIST)
167IF fullfilename_in[0] EQ '' THEN BEGIN
168   msg = 'eee : the file ' + fullfilename_in + ' was not found.'
169   ras = report(msg)
170   return, result
171ENDIF
172;
173fullfilename_out=project_od_env+'mask_oaflux_30N30S.nc'
174; in order to avoid unexpected overwritten
175IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
176   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
177   ras = report(msg)
178   return, result
179ENDIF
180;
181; Read oaflux grid and mask
182initncdf, fullfilename_in
183lh=ncdf_lec(fullfilename_in,var='lhtfl',count=[jpi,jpj,1])
184lh=float(lh)
185valmask=1.e20
186ind=where(lh ge 32000,compl=nind)
187lh[ind]=valmask
188lh[nind]=-0.1*lh[nind]
189mask_out=(lh ne valmask)
190domdef, 0.,360.,-30.,30.
191
192lon=reform(glamt[*,0])
193ind1=where(lon le 20.)
194ind2=where(lon ge 30.)
195
196lat_out=reform(gphit[0,firstyt:lastyt])
197
198lon_out=[reform(glamt[ind2,0]),reform(glamt[ind1,0])+360]
199
200; ++ this line is incompatible with
201; compile_opt idl2, strictarrsubs, logical_predicate
202mask_out=mask_out([ind2,ind1],firstyt:lastyt)*1.
203
204ncfile='!'+fullfilename_out
205lon_attr={units:'degrees_east',long_name:'Longitude'}
206lat_attr={units:'degrees_north',long_name:'Latitude'}
207msk_attr={long_name:'land sea mask',short_name:'msk',axis:'YX'}
208globattr={description:'OAFLUX mask over the Indian Ocean: 40E-120E, 30S-30N'}
209
210ncfields = 'msk[longitude,latitude]=mask_out:msk_attr; ' $
211                      + 'longitude[]=lon_out:lon_attr; ' $
212                      + 'latitude[]=lat_out:lat_attr; ' $
213                      + ' @ globattr'
214
215@ncdf_quickwrite
216
217result = 0
218
219return, result
220END
Note: See TracBrowser for help on using the repository browser.