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 | ; ws_tropflux_1d_to_1m_ncdf |
---|
51 | ; |
---|
52 | ; KNOWN ISSUES |
---|
53 | ; ============ |
---|
54 | ; |
---|
55 | ; test of existence of fullfilename_in not very efficient because |
---|
56 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
57 | ; |
---|
58 | ; TODO |
---|
59 | ; ==== |
---|
60 | ; |
---|
61 | ; coding rules |
---|
62 | ; |
---|
63 | ; get rid of hard coded yyyymmdd and nb month |
---|
64 | ; |
---|
65 | ; include in the whole process |
---|
66 | ; |
---|
67 | ; any NCO or CDO equivalent ? |
---|
68 | ; |
---|
69 | ; EVOLUTIONS |
---|
70 | ; ========== |
---|
71 | ; |
---|
72 | ; $Id$ |
---|
73 | ; |
---|
74 | ; $URL$ |
---|
75 | ; |
---|
76 | ; - fplod 20110826T151225Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
77 | ; |
---|
78 | ; * remove hard coded creation date |
---|
79 | ; |
---|
80 | ; - fplod 20110817T084001Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
81 | ; |
---|
82 | ; * usage of ${PROJECT_OD} |
---|
83 | ; * header |
---|
84 | ; |
---|
85 | ; - pk 20110815 |
---|
86 | ; |
---|
87 | ; * provided to fp |
---|
88 | ; |
---|
89 | ;- |
---|
90 | pro ws_tropflux_1d_to_1m_ncdf |
---|
91 | ; |
---|
92 | @cm_4cal |
---|
93 | @cm_4data |
---|
94 | @cm_4mesh |
---|
95 | @cm_4data |
---|
96 | @cm_project |
---|
97 | ; |
---|
98 | ; test if ${PROJECT_OD} defined |
---|
99 | CASE project_od_env OF |
---|
100 | '' : BEGIN |
---|
101 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
102 | ras = report(msg) |
---|
103 | STOP |
---|
104 | END |
---|
105 | ELSE: BEGIN |
---|
106 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
107 | ras = report(msg) |
---|
108 | END |
---|
109 | ENDCASE |
---|
110 | ; |
---|
111 | ; check if output data will be possible |
---|
112 | iodirout = isadirectory(project_od_env) |
---|
113 | ; |
---|
114 | ; existence and protection for reading |
---|
115 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
116 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
117 | ras = report(msg) |
---|
118 | STOP |
---|
119 | ENDIF |
---|
120 | ; |
---|
121 | ; existence and protection for writing |
---|
122 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
123 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
124 | ras = report(msg) |
---|
125 | STOP |
---|
126 | ENDIF |
---|
127 | ; |
---|
128 | ; build 1d filename |
---|
129 | filename="ws_tropflux_1d_1989_2010.nc" |
---|
130 | ; |
---|
131 | ; check if this file exists |
---|
132 | msg='iii : looking for ' + filename |
---|
133 | ras = report(msg) |
---|
134 | fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) |
---|
135 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
136 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
137 | ras = report(msg) |
---|
138 | STOP |
---|
139 | ENDIF |
---|
140 | ; |
---|
141 | ; build output filename |
---|
142 | filename_out = 'ws_tropflux_1m_1989_2010.nc' |
---|
143 | fullfilename_out = iodirout + filename_out |
---|
144 | ; in order to avoid unexpected overwritten |
---|
145 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
146 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
147 | ras = report(msg) |
---|
148 | STOP |
---|
149 | ENDIF |
---|
150 | ; |
---|
151 | initncdf, fullfilename |
---|
152 | st=19890101 |
---|
153 | en=20101231 |
---|
154 | ws=read_ncdf("ws", st, en, file=fullfilename,/nostr) |
---|
155 | ; |
---|
156 | help, ws |
---|
157 | ; |
---|
158 | ; Monthly data |
---|
159 | ; |
---|
160 | jpt=22*12. |
---|
161 | time=timegen(jpt, start=julday(1,15,1989,0), units='Months') |
---|
162 | caldat, time, m, d, y |
---|
163 | caldat, time, mon, day, yea |
---|
164 | ; |
---|
165 | wsm=fltarr(nxt,nyt,jpt) |
---|
166 | ; |
---|
167 | for jt=0,jpt-1 do begin |
---|
168 | ; |
---|
169 | ind=where((m eq mon(jt)) and (y eq yea(jt))) |
---|
170 | wsm(*,*,jt)=total(ws(*,*,ind),3)/n_elements(ind) |
---|
171 | ; |
---|
172 | endfor |
---|
173 | ; |
---|
174 | ;----------------------------------------------------------------------------- |
---|
175 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
176 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
177 | time=time-julday(1,1,1950,00,00,00) |
---|
178 | xlon=reform(glamt(firstxt:lastxt,0)) |
---|
179 | ylat=reform(gphit(0,firstyt:lastyt)) |
---|
180 | ; |
---|
181 | ncfile='!' + fullfilename_out |
---|
182 | ; |
---|
183 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
184 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
185 | ; |
---|
186 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
187 | ws_attr={units:'m/s',missing_value:1.e20,long_name:'Mean wind speed at 10m height',short_name:'ws',axis:'TYX'} |
---|
188 | ; |
---|
189 | creation_date=string(jul2date(SYSTIME( /JULIAN , /UTC )), format='(I8)') |
---|
190 | ; |
---|
191 | globattr={Source:'TropFlux - Air-Sea Fluxes for the Global Tropics' $ |
---|
192 | , Methodology:'Praveen Kumar et al., Clim. Dyn 2011' $ |
---|
193 | , Producer_Agency:'Joint research colloboration between IPSL, Paris and NIO, India' $ |
---|
194 | , Time_range:cda0+' - '+cda1 $ |
---|
195 | , Creation_date:creation_date $ |
---|
196 | , Website:'http://www.locean-ipsl.upmc.fr/tropflux/'} |
---|
197 | ; |
---|
198 | ncfields = 'ws[longitude,latitude,time]=wsm:ws_attr; ' $ |
---|
199 | + 'longitude[]=xlon:lon_attr; ' $ |
---|
200 | + 'latitude[]=ylat:lat_attr; ' $ |
---|
201 | + 'time[*time]=time:time_attr ' $ |
---|
202 | + ' @ globattr' |
---|
203 | ; |
---|
204 | @ncdf_quickwrite |
---|
205 | ; |
---|
206 | end |
---|