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 | ; |
---|
89 | PRO oaflux_mask_30N30S |
---|
90 | ; |
---|
91 | @common |
---|
92 | ; |
---|
93 | ; check for input file |
---|
94 | ; |
---|
95 | ; test if ${TROPFLUX_ID} defined |
---|
96 | tropflux_id_env=GETENV('TROPFLUX_ID') |
---|
97 | CASE 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 |
---|
107 | ENDCASE |
---|
108 | ; |
---|
109 | iodirin = isadirectory(tropflux_id_env) |
---|
110 | ; |
---|
111 | ; existence and protection of ${TROPFLUX_ID} |
---|
112 | IF (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 |
---|
116 | ENDIF |
---|
117 | ; |
---|
118 | ; build input filename |
---|
119 | yyyy=2004 |
---|
120 | cy=string(yyyy,format='(i4.4)') |
---|
121 | filename_in='lh_oaflux_'+cy+'.nc' |
---|
122 | ; |
---|
123 | ; check if this file exists |
---|
124 | fullfilename_in = isafile(iodirin + filename_in, NEW=0, /MUST_EXIST) |
---|
125 | IF fullfilename_in[0] EQ '' THEN BEGIN |
---|
126 | msg = 'eee : the file ' + fullfilename_in + ' was not found.' |
---|
127 | ras = report(msg) |
---|
128 | STOP |
---|
129 | ENDIF |
---|
130 | ; |
---|
131 | ; test if ${TROPFLUX_OD} defined |
---|
132 | tropflux_od_env=GETENV('TROPFLUX_OD') |
---|
133 | CASE tropflux_od_env OF |
---|
134 | '' : BEGIN |
---|
135 | msg = 'eee : ${TROPFLUX_OD} is not defined' |
---|
136 | ras = report(msg) |
---|
137 | STOP |
---|
138 | END |
---|
139 | ELSE: BEGIN |
---|
140 | msg = 'iii : ${TROPFLUX_OD} is ' + tropflux_od_env |
---|
141 | ras = report(msg) |
---|
142 | END |
---|
143 | ENDCASE |
---|
144 | ; |
---|
145 | ; check if output data will be possible |
---|
146 | iodirout = isadirectory(tropflux_od_env) |
---|
147 | ; |
---|
148 | ; existence and protection |
---|
149 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
150 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
151 | ras = report(msg) |
---|
152 | STOP |
---|
153 | ENDIF |
---|
154 | ; |
---|
155 | fullfilename_out=iodirout+'mask_oaflux_30N30S.nc' |
---|
156 | ; in order to avoid unexpected overwritten |
---|
157 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
158 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
159 | ras = report(msg) |
---|
160 | STOP |
---|
161 | ENDIF |
---|
162 | ; |
---|
163 | ; Read oaflux grid and mask |
---|
164 | initncdf, fullfilename_in |
---|
165 | lh=ncdf_lec(fullfilename_in,var='lhtfl',count=[jpi,jpj,1]) & lh=float(lh) |
---|
166 | valmask=1.e20 |
---|
167 | ind=where(lh ge 32000,compl=nind) & lh(ind)=valmask & lh(nind)=-0.1*lh(nind) |
---|
168 | mask_out=(lh ne valmask) |
---|
169 | domdef, 0.,360.,-30.,30. |
---|
170 | |
---|
171 | lon=reform(glamt(*,0)) |
---|
172 | ind1=where(lon le 20.) |
---|
173 | ind2=where(lon ge 30.) |
---|
174 | |
---|
175 | lat_out=reform(gphit(0,firstyt:lastyt)) |
---|
176 | |
---|
177 | lon_out=[reform(glamt(ind2,0)),reform(glamt(ind1,0))+360] |
---|
178 | |
---|
179 | mask_out=mask_out([ind2,ind1],firstyt:lastyt)*1. |
---|
180 | |
---|
181 | |
---|
182 | ncfile='!'+fullfilename_out |
---|
183 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
184 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
185 | msk_attr={long_name:'land sea mask',short_name:'msk',axis:'YX'} |
---|
186 | globattr={description:'OAFLUX mask over the Indian Ocean: 40E-120E, 30S-30N'} |
---|
187 | |
---|
188 | ncfields = '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 | |
---|
195 | END |
---|