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 | ; :func:`interp_erai_dewt`, |
---|
66 | ; :func:`interp_erai_lwr`, |
---|
67 | ; :func:`interp_erai_sst`, |
---|
68 | ; :func:`interp_erai_t2m`, |
---|
69 | ; :func:`interp_erai_ws`, |
---|
70 | ; :func:`interp_olr_30n30s` |
---|
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 | ; |
---|
90 | ; - written now : OAFLUX mask over the Indian Ocean: 40E-120E, 30S-30N |
---|
91 | ; - while data latitude=[-29.5,+29.5] longitude=[30.5,379.5] |
---|
92 | ; |
---|
93 | ; 30n30s in name vs future global output ... parameters lat and long max |
---|
94 | ; |
---|
95 | ; KNOWN ISSUES |
---|
96 | ; ============ |
---|
97 | ; |
---|
98 | ; test of existence of fullfilename_in not very efficient because |
---|
99 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
100 | ; |
---|
101 | ; EVOLUTIONS |
---|
102 | ; ========== |
---|
103 | ; |
---|
104 | ; $Id$ |
---|
105 | ; |
---|
106 | ; $URL$ |
---|
107 | ; |
---|
108 | ; - fplod 20120319 |
---|
109 | ; |
---|
110 | ; * taking project_overwite into account |
---|
111 | ; |
---|
112 | ; - fplod 20120306 |
---|
113 | ; |
---|
114 | ; * try to add compile_opt |
---|
115 | ; |
---|
116 | ; - fplod 20120305 |
---|
117 | ; |
---|
118 | ; * pro -> function |
---|
119 | ; |
---|
120 | ; - fplod 20110411T140133Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
121 | ; |
---|
122 | ; * usage of tropflux_init and cm_project |
---|
123 | ; * replace 30N30S by 30n30s |
---|
124 | ; |
---|
125 | ; - fplod 20101217T081915Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
126 | ; |
---|
127 | ; * remove hard coded directory - usage of ${PROJECT_ID} and ${PROJECT_OD} |
---|
128 | ; * add IO test |
---|
129 | ; |
---|
130 | ; - fplod 20101216T141137Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
131 | ; |
---|
132 | ; * minimal header |
---|
133 | ; |
---|
134 | ; - jv 2010 |
---|
135 | ; |
---|
136 | ; * creation |
---|
137 | ; |
---|
138 | ;- |
---|
139 | ; |
---|
140 | FUNCTION oaflux_mask_30n30s |
---|
141 | ; |
---|
142 | ;++ compile_opt idl2, strictarrsubs, logical_predicate |
---|
143 | ; |
---|
144 | @cm_4cal |
---|
145 | @cm_4data |
---|
146 | @cm_4mesh |
---|
147 | @cm_4data |
---|
148 | @cm_project |
---|
149 | |
---|
150 | ; Return to caller if errors |
---|
151 | on_error, 2 |
---|
152 | ; |
---|
153 | result = -1 |
---|
154 | ; |
---|
155 | usage = 'result=oaflux_mask_30n30s()' |
---|
156 | nparam = N_PARAMS() |
---|
157 | IF (nparam NE 0) THEN BEGIN |
---|
158 | ras = report(['Incorrect number of arguments.' $ |
---|
159 | + '!C' $ |
---|
160 | + 'Usage : ' + usage]) |
---|
161 | return, result |
---|
162 | ENDIF |
---|
163 | ; |
---|
164 | ; check for input file |
---|
165 | ; build input filename |
---|
166 | yyyy=2004 |
---|
167 | cy=string(yyyy,format='(i4.4)') |
---|
168 | filename_in='lh_oaflux_'+cy+'.nc' |
---|
169 | ; |
---|
170 | ; check if this file exists |
---|
171 | fullfilename_in = isafile(project_id_env + filename_in, NEW=0, /MUST_EXIST) |
---|
172 | IF fullfilename_in[0] EQ '' THEN BEGIN |
---|
173 | msg = 'eee : the file ' + fullfilename_in + ' was not found.' |
---|
174 | ras = report(msg) |
---|
175 | return, result |
---|
176 | ENDIF |
---|
177 | ; |
---|
178 | fullfilename_out=project_od_env+'mask_oaflux_30N30S.nc' |
---|
179 | ; in order to avoid unexpected overwritten |
---|
180 | PRINT, 'project_overwrite : ',project_overwrite |
---|
181 | IF ((FILE_TEST(fullfilename_out) EQ 1) AND (project_overwrite EQ 0)) THEN BEGIN |
---|
182 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
183 | ras = report(msg) |
---|
184 | return, result |
---|
185 | ENDIF |
---|
186 | ; |
---|
187 | ; Read oaflux grid and mask |
---|
188 | initncdf, fullfilename_in |
---|
189 | lh=ncdf_lec(fullfilename_in,var='lhtfl',count=[jpi,jpj,1]) |
---|
190 | lh=float(lh) |
---|
191 | valmask=1.e20 |
---|
192 | ind=where(lh ge 32000,compl=nind) |
---|
193 | lh[ind]=valmask |
---|
194 | lh[nind]=-0.1*lh[nind] |
---|
195 | mask_out=(lh ne valmask) |
---|
196 | domdef, 0.,360.,-30.,30. |
---|
197 | |
---|
198 | lon=reform(glamt[*,0]) |
---|
199 | ind1=where(lon le 20.) |
---|
200 | ind2=where(lon ge 30.) |
---|
201 | |
---|
202 | lat_out=reform(gphit[0,firstyt:lastyt]) |
---|
203 | |
---|
204 | lon_out=[reform(glamt[ind2,0]),reform(glamt[ind1,0])+360] |
---|
205 | |
---|
206 | ; ++ this line is incompatible with |
---|
207 | ; compile_opt idl2, strictarrsubs, logical_predicate |
---|
208 | mask_out=mask_out([ind2,ind1],firstyt:lastyt)*1. |
---|
209 | |
---|
210 | ncfile='!'+fullfilename_out |
---|
211 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
212 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
213 | msk_attr={long_name:'land sea mask',short_name:'msk',axis:'YX'} |
---|
214 | globattr={description:'OAFLUX mask over the Indian Ocean: 40E-120E, 30S-30N'} |
---|
215 | |
---|
216 | ncfields = 'msk[longitude,latitude]=mask_out:msk_attr; ' $ |
---|
217 | + 'longitude[]=lon_out:lon_attr; ' $ |
---|
218 | + 'latitude[]=lat_out:lat_attr; ' $ |
---|
219 | + ' @ globattr' |
---|
220 | |
---|
221 | @ncdf_quickwrite |
---|
222 | ; |
---|
223 | result = 0 |
---|
224 | return, result |
---|
225 | ; |
---|
226 | END |
---|