source: trunk/src/ws_tropflux_1d_to_1m_ncdf.pro @ 85

Last change on this file since 85 was 83, checked in by pinsard, 13 years ago

complete doc in new tools from PK

  • Property svn:keywords set to URL
File size: 4.5 KB
Line 
1;+
2;
3; .. _ws_tropflux_1d_to_1m_ncdf.pro:
4;
5; =============================
6; ws_tropflux_1d_to_1m_ncdf.pro
7; =============================
8;
9; DESCRIPTION
10; ===========
11;
12; convert wind daily file to monthly file
13;
14; :file:`${PROJECT_OD}/ws_tropflux_1d_1989_2010.nc`
15; containing daily ++
16; has been produced by ++
17;
18; Montly ++
19; is written in
20; :file:`${PROJECT_OD}/ws_tropflux_1m_1989_2010.nc`
21; if this file not already exists.
22;
23;     .. graphviz::
24;
25;        digraph ws_tropflux_1d_to_1m_ncdf {
26;
27;           file_1d [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/ws_tropflux_1d_1989_2010.nc"];
28;           file_1m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/ws_tropflux_1m_1989_2010.nc"];
29;
30;           ws_tropflux_1d_to_1m_ncdf [shape=box,
31;           fontname=Courier,
32;           color=blue,
33;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/ws_tropflux_1d_to_1m_ncdf.pro",
34;           label="${PROJECT}/src/ws_tropflux_1d_to_1m_ncdf.pro"];
35;
36;           {file_1d} -> {ws_tropflux_1d_to_1m_ncdf} -> {file_1m}
37;
38;         }
39;
40; SEE ALSO
41; ========
42;
43; :ref:`project_profile.sh`
44;
45; EXAMPLES
46; ========
47;
48; ::
49;
50;  IDL> ws_tropflux_1d_to_1m_ncdf
51;
52; TODO
53; ====
54;
55; remove hard coded creation date
56;
57; include in the whole process
58;
59; any NCO or CDO equivalent ?
60;
61; EVOLUTIONS
62; ==========
63;
64; $Id$
65;
66; $URL$
67;
68; - fplod 20110817T084001Z aedon.locean-ipsl.upmc.fr (Darwin)
69;
70;   * usage of ${PROJECT_OD}
71;   * header
72;
73; - pk 20110815
74;
75;   * provided to fp
76;
77;-
78pro ws_tropflux_1d_to_1m_ncdf
79;
80@cm_4cal
81@cm_4data
82@cm_4mesh
83@cm_4data
84@cm_project
85;
86; test if ${PROJECT_OD} defined
87CASE project_od_env OF
88  '' : BEGIN
89         msg = 'eee : ${PROJECT_OD} is not defined'
90         ras = report(msg)
91       STOP
92       END
93  ELSE: BEGIN
94          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
95          ras = report(msg)
96        END
97 ENDCASE
98;
99; check if output data will be possible
100iodirout = isadirectory(project_od_env)
101;
102; existence and protection for reading
103IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
104   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
105   ras = report(msg)
106   STOP
107ENDIF
108;
109; existence and protection for writing
110IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
111    msg = 'eee : the directory' + iodirout  + ' was not found.'
112    ras = report(msg)
113    STOP
114ENDIF
115;
116; build 1d filename
117filename="ws_tropflux_1d_1989_2010.nc"
118;
119; check if this file exists
120fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST)
121IF fullfilename[0] EQ '' THEN BEGIN
122   msg = 'eee : the file ' + fullfilename + ' was not found.'
123   ras = report(msg)
124   STOP
125ENDIF
126;
127; build output filename
128filename_out = 'ws_tropflux_1m_1989_2010.nc'
129fullfilename_out = iodirout + filename_out
130; in order to avoid unexpected overwritten
131IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
132   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
133   ras = report(msg)
134   STOP
135ENDIF
136;
137initncdf, fullfilename
138st=19890101 & en=20101231
139ws=read_ncdf("ws", st, en, file=fullfilename,/nostr)
140
141help, ws
142
143tt=time
144;
145;; Monthly data
146;
147jpt=22*12. & time=timegen(jpt,start=julday(1,15,1989),units='Months')
148caldat, tt,m,d,y
149caldat, time, mon,day,yea
150
151wsm=fltarr(nxt,nyt,jpt)
152
153for jt=0,jpt-1 do begin
154
155   ind=where((m eq mon(jt)) and (y eq yea(jt)))
156   wsm(*,*,jt)=total(ws(*,*,ind),3)/n_elements(ind)
157
158endfor
159
160
161;-----------------------------------------------------------------------------
162cda0=string(jul2date(time(0)),format='(i8.8)')
163cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
164time=time-julday(1,1,1950,00,00,00)
165xlon=reform(glamt(firstxt:lastxt,0) ) & ylat=reform(gphit(0,firstyt:lastyt))
166
167ncfile='!' + fullfilename_out
168
169lon_attr={units:'degrees_east',long_name:'Longitude'}
170lat_attr={units:'degrees_north',long_name:'Latitude'}
171
172time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'}
173ws_attr={units:'m/s',missing_value:1.e20,long_name:'Mean wind speed at 10m height',short_name:'ws',axis:'TYX'}
174globattr={Source:'TropFlux - Air-Sea Fluxes for the Global Tropics', Metodology:'Praveen Kumar et al., Clim. Dyn 2011', Producer_Agency:'Joint research colloboration between IPSL, Paris and NIO, India', Time_range:cda0+' - '+cda1, Creation_date:'20110815', Website:'http://www.locean-ipsl.upmc.fr/tropflux/'}
175
176
177ncfields = 'ws[longitude,latitude,time]=wsm:ws_attr; ' $
178                      + 'longitude[]=xlon:lon_attr; ' $
179                      + 'latitude[]=ylat:lat_attr; ' $
180                      + 'time[*time]=time:time_attr ' $
181                      + ' @ globattr'
182
183@ncdf_quickwrite
184
185return
186
187end
188
Note: See TracBrowser for help on using the repository browser.