source: trunk/src/oaflux_mask_30n30s.pro @ 153

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

pro oaflux_mask_30n30s is now a function

  • Property svn:keywords set to Id URL
File size: 5.1 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; :ref:`interp_erai_t2m_1989_2009.pro`,
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 20120305
108;
109;   * pro -> function
110;
111; - fplod 20110411T140133Z aedon.locean-ipsl.upmc.fr (Darwin)
112;
113;   * usage of tropflux_init and cm_project
114;   * replace 30N30S by 30n30s
115;
116; - fplod 20101217T081915Z aedon.locean-ipsl.upmc.fr (Darwin)
117;
118;   * remove hard coded directory - usage of ${PROJECT_ID} and ${PROJECT_OD}
119;   * add IO test
120;
121; - fplod 20101216T141137Z aedon.locean-ipsl.upmc.fr (Darwin)
122;
123;   * minimal header
124;
125; - jv 2010
126;
127;   * creation
128;
129;-
130;
131FUNCTION oaflux_mask_30n30s
132;
133@cm_4cal
134@cm_4data
135@cm_4mesh
136@cm_4data
137@cm_project
138
139; Return to caller if errors
140on_error, 2
141;
142result = -1
143;
144usage = 'result=oaflux_mask_30n30s()'
145nparam = N_PARAMS()
146IF (nparam NE 0) THEN BEGIN
147   ras = report(['Incorrect number of arguments.' $
148         + '!C' $
149         + 'Usage : ' + usage])
150   return, -1
151ENDIF
152;
153; check for input file
154; build input filename
155yyyy=2004
156cy=string(yyyy,format='(i4.4)')
157filename_in='lh_oaflux_'+cy+'.nc'
158;
159; check if this file exists
160fullfilename_in = isafile(project_id_env + filename_in, NEW=0, /MUST_EXIST)
161IF fullfilename_in[0] EQ '' THEN BEGIN
162   msg = 'eee : the file ' + fullfilename_in + ' was not found.'
163   ras = report(msg)
164   return, -1
165ENDIF
166;
167fullfilename_out=project_od_env+'mask_oaflux_30N30S.nc'
168; in order to avoid unexpected overwritten
169IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
170   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
171   ras = report(msg)
172   return, -1
173ENDIF
174;
175; Read oaflux grid and mask
176initncdf, fullfilename_in
177lh=ncdf_lec(fullfilename_in,var='lhtfl',count=[jpi,jpj,1])
178lh=float(lh)
179valmask=1.e20
180ind=where(lh ge 32000,compl=nind)
181lh(ind)=valmask
182lh(nind)=-0.1*lh(nind)
183mask_out=(lh ne valmask)
184domdef, 0.,360.,-30.,30.
185
186lon=reform(glamt(*,0))
187ind1=where(lon le 20.)
188ind2=where(lon ge 30.)
189
190lat_out=reform(gphit(0,firstyt:lastyt))
191
192lon_out=[reform(glamt(ind2,0)),reform(glamt(ind1,0))+360]
193
194mask_out=mask_out([ind2,ind1],firstyt:lastyt)*1.
195
196ncfile='!'+fullfilename_out
197lon_attr={units:'degrees_east',long_name:'Longitude'}
198lat_attr={units:'degrees_north',long_name:'Latitude'}
199msk_attr={long_name:'land sea mask',short_name:'msk',axis:'YX'}
200globattr={description:'OAFLUX mask over the Indian Ocean: 40E-120E, 30S-30N'}
201
202ncfields = 'msk[longitude,latitude]=mask_out:msk_attr; ' $
203                      + 'longitude[]=lon_out:lon_attr; ' $
204                      + 'latitude[]=lat_out:lat_attr; ' $
205                      + ' @ globattr'
206
207@ncdf_quickwrite
208
209result = 0
210
211return, result
212END
Note: See TracBrowser for help on using the repository browser.