source: trunk/src/TropFlux_NRT_ncdf.pro @ 152

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

start to homogenize (to be cont.)

  • Property svn:keywords set to URL
File size: 6.8 KB
Line 
1;+
2;
3; .. _TropFlux_NRT_ncdf.pro:
4;
5; =====================
6; TropFlux_NRT_ncdf.pro
7; =====================
8;
9; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc`
10; containing
11; ws corrected on OAFLUX grid
12; has been produced by
13; :ref:`TropFlux_swr_BLND_19890101_20091231.pro`.
14;
15; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc`
16; containing
17; lwr corrected on OAFLUX grid
18; has been produced by
19; :ref:`lwr_correction_ncdf.pro`.
20;
21; :file:`${PROJECT_OD}/TropFlux_19890101_20091231_coare3.nc`
22; containing
23; ++
24; has been produced by
25; :ref:`TropFlux_19890101_20091231.pro`.
26;
27; ++ are written
28; in :file:`${PROJECT_OD}/TropFlux_19890101_20091231.nc`
29; if this file not already exists.
30;
31;     .. graphviz::
32;
33;        digraph tropflux_nrt_ncdf {
34;
35;           file_swr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc"];
36;           file_lwr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_19890101_200912310.nc"];
37;           file_coare [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc"];
38;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_19890101_20091231.nc"];
39;
40;           tropflux_nrt_ncdf [shape=box,
41;           fontname=Courier,
42;           color=blue,
43;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_NRT_ncdf.pro",
44;           label="${PROJECT}/src/TropFlux_NRT_ncdf.pro" ];
45;
46;           {file_swr file_lwr file_coare} -> {tropflux_nrt_ncdf} -> {file_out}
47;
48;        }
49;
50; SEE ALSO
51; ========
52;
53; :func:`initncdf <saxo:initncdf>`
54; :func:`read_ncdf <saxo:read_ncdf>`
55; :func:`julday <saxo:julday>`
56; :func:`jul2date <saxo:jul2date>`
57; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
58;
59; EXAMPLES
60; ========
61;
62; ::
63;
64;  IDL> .compile TropFlux_NRT_ncdf
65;  IDL> tropflux_nrt_ncdf
66;
67; TODO
68; ====
69;
70; coding rules
71;
72; get rid of uppercase to avoid compile
73;
74; create 4 files instead of one now
75;
76; EVOLUTIONS
77; ==========
78;
79; $Id: TropFlux_NRT_ncdf.pro 88 2011-08-19 15:40:14Z pinsard $
80;
81; $URL$
82;
83; - fplod 20110809T133815Z cratos (Linux)
84;
85;   * remove v50 from pro name and in the graph
86;   * add coarev3 to the file coming from TropFlux_19890101_20091231.pro
87;   * use $PROJECT_OD
88;
89; - fplod 20101214T112526Z aedon.locean-ipsl.upmc.fr (Darwin)
90;
91;   * add graph
92;
93; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
94;
95;   * minimal header
96;
97; - pbk 2008
98;
99;   * creation
100;
101;-
102pro TropFlux_NRT_ncdf
103;
104@cm_4cal
105@cm_4data
106@cm_4mesh
107@cm_4data
108@cm_project
109;
110; test if ${PROJECT_OD} defined
111CASE project_od_env OF
112  '' : BEGIN
113         msg = 'eee : ${PROJECT_OD} is not defined'
114         ras = report(msg)
115       STOP
116       END
117  ELSE: BEGIN
118          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
119          ras = report(msg)
120        END
121 ENDCASE
122;
123; check if output data will be possible
124iodirout = isadirectory(project_od_env)
125;
126; existence and protection for reading
127IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
128   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
129   ras = report(msg)
130   STOP
131ENDIF
132;
133; existence and protection for writing
134IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
135    msg = 'eee : the directory' + iodirout  + ' was not found.'
136    ras = report(msg)
137    STOP
138ENDIF
139;
140; build SWR blnd data filename
141filename_swr_blnd="TropFlux_swr_19890101_20091231_BLND.nc"
142;
143; check if this file exists
144msg='iii : looking for ' + filename_swr_blnd
145ras = report(msg)
146fullfilename_swr_blnd = isafile(iodirout + filename_swr_blnd, NEW=0, /MUST_EXIST)
147IF fullfilename_swr_blnd[0] EQ '' THEN BEGIN
148   msg = 'eee : the file ' + fullfilename_swr_blnd + ' was not found.'
149   ras = report(msg)
150   STOP
151ENDIF
152;
153; build LWR data filename
154filename_lwr="TropFlux_lwr_19890101_20091231.nc"
155;
156; check if this file exists
157msg='iii : looking for ' + filename_lwr
158ras = report(msg)
159fullfilename_lwr = isafile(iodirout + filename_lwr, NEW=0, /MUST_EXIST)
160IF fullfilename_lwr[0] EQ '' THEN BEGIN
161   msg = 'eee : the file ' + fullfilename_lwr + ' was not found.'
162   ras = report(msg)
163   STOP
164ENDIF
165;
166;  build COARE data filename
167filename_coare="TropFlux_19890101_20091231_coarev3.nc"
168;
169; check if this file exists
170msg='iii : looking for ' + filename_lwr
171ras = report(msg)
172fullfilename_coare = isafile(iodirout + filename_coare, NEW=0, /MUST_EXIST)
173IF fullfilename_coare[0] EQ '' THEN BEGIN
174   msg = 'eee : the file ' + fullfilename_coare + ' was not found.'
175   ras = report(msg)
176   STOP
177ENDIF
178;
179filename_out='TropFlux_19890101_20091231.nc'
180fullfilename_out = iodirout + filename_out
181; in order to avoid unexpected overwritten
182IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
183   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
184   ras = report(msg)
185   STOP
186ENDIF
187;
188st=19800101
189en=20101231
190;
191initncdf, fullfilename_swr_blnd
192;
193swr=read_ncdf("swr", st, en, file=fullfilename_swr_blnd,/nostr)
194;
195initncdf, fullfilename_lwr
196lwr=read_ncdf("lwr", st, en, file=fullfilename_lwr,/nostr)
197;
198initncdf, fullfilename_coare
199lhf=read_ncdf("lhf", st, en, file=fullfilename_coare,/nostr)
200shf=read_ncdf("shf", st, en, file=fullfilename_coare,/nostr)
201;
202help, swr, lwr, lhf, shf
203;
204time=timegen(7670, start=julday(1,1,1989,0), units='days')
205jpt=n_elements(time)
206;
207cda0=string(jul2date(time(0)),format='(i8.8)')
208cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
209;
210time=time-julday(1,1,1950,00,00)
211;
212lat=reform(gphit(0,0:jpj-1))
213lon=reform(glamt(0:jpi-1,0))
214;
215ncfile='!' + fullfilename_out
216lon_attr={units:'degrees_east',long_name:'Longitude'}
217lat_attr={units:'degrees_north',long_name:'Latitude'}
218time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'}
219globattr={Source:'TropFlux - Air-Sea Fluxes for the Global Tropics', Resolution:'1 x 1 degree and daily', IDL_program_name:'TropFlux_ncdf.pro',Timerange:cda0+' - '+cda1, More_Info:'ISCCP based SWR until 2007 and OLR based SWR after that with a 90 day linear transition between the two'}
220sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'}
221lw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Longwave Radiation',short_name:'lwr',axis:'TYX'}
222sh_attr={units:'w/m^2',missing_value:1.e20,long_name:'Sensible Heat Flux',short_name:'shf',axis:'TYX'}
223lh_attr={units:'w/m^2',missing_value:1.e20,long_name:'Latent Heat Flux',short_name:'lhf',axis:'TYX'}
224;
225ncfields = 'swr[longitude,latitude,time]=swr:sw_attr; ' $
226          +'lwr[longitude,latitude,time]=lwr:lw_attr; ' $
227          +'lhf[longitude,latitude,time]=lhf:lh_attr; ' $
228          +'shf[longitude,latitude,time]=shf:sh_attr; ' $
229                      + 'longitude[]=lon:lon_attr; ' $
230                      + 'latitude[]=lat:lat_attr; ' $
231                      + 'time[*time]=time:time_attr ' $
232                      + ' @ globattr'
233;
234@ncdf_quickwrite
235;
236end
Note: See TracBrowser for help on using the repository browser.