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 | ;- |
---|
78 | pro 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 |
---|
87 | CASE 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 |
---|
100 | iodirout = isadirectory(project_od_env) |
---|
101 | ; |
---|
102 | ; existence and protection for reading |
---|
103 | IF (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 |
---|
107 | ENDIF |
---|
108 | ; |
---|
109 | ; existence and protection for writing |
---|
110 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
111 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
112 | ras = report(msg) |
---|
113 | STOP |
---|
114 | ENDIF |
---|
115 | ; |
---|
116 | ; build 1d filename |
---|
117 | filename="ws_tropflux_1d_1989_2010.nc" |
---|
118 | ; |
---|
119 | ; check if this file exists |
---|
120 | fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) |
---|
121 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
122 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
123 | ras = report(msg) |
---|
124 | STOP |
---|
125 | ENDIF |
---|
126 | ; |
---|
127 | ; build output filename |
---|
128 | filename_out = 'ws_tropflux_1m_1989_2010.nc' |
---|
129 | fullfilename_out = iodirout + filename_out |
---|
130 | ; in order to avoid unexpected overwritten |
---|
131 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
132 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
133 | ras = report(msg) |
---|
134 | STOP |
---|
135 | ENDIF |
---|
136 | ; |
---|
137 | initncdf, fullfilename |
---|
138 | st=19890101 & en=20101231 |
---|
139 | ws=read_ncdf("ws", st, en, file=fullfilename,/nostr) |
---|
140 | |
---|
141 | help, ws |
---|
142 | |
---|
143 | tt=time |
---|
144 | ; |
---|
145 | ;; Monthly data |
---|
146 | ; |
---|
147 | jpt=22*12. & time=timegen(jpt,start=julday(1,15,1989),units='Months') |
---|
148 | caldat, tt,m,d,y |
---|
149 | caldat, time, mon,day,yea |
---|
150 | |
---|
151 | wsm=fltarr(nxt,nyt,jpt) |
---|
152 | |
---|
153 | for 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 | |
---|
158 | endfor |
---|
159 | |
---|
160 | |
---|
161 | ;----------------------------------------------------------------------------- |
---|
162 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
163 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
164 | time=time-julday(1,1,1950,00,00,00) |
---|
165 | xlon=reform(glamt(firstxt:lastxt,0) ) & ylat=reform(gphit(0,firstyt:lastyt)) |
---|
166 | |
---|
167 | ncfile='!' + fullfilename_out |
---|
168 | |
---|
169 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
170 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
171 | |
---|
172 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
173 | ws_attr={units:'m/s',missing_value:1.e20,long_name:'Mean wind speed at 10m height',short_name:'ws',axis:'TYX'} |
---|
174 | globattr={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 | |
---|
177 | ncfields = '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 | |
---|
185 | return |
---|
186 | |
---|
187 | end |
---|
188 | |
---|