source: trunk/src/cronin_gustiness_ncdf.pro @ 79

Last change on this file since 79 was 72, checked in by pinsard, 13 years ago

start to work on correction tools

File size: 5.2 KB
Line 
1;+
2;
3; .. _cronin_gustiness_ncdf.pro:
4;
5; =========================
6; cronin_gustiness_ncdf.pro
7; =========================
8;
9; Cronin gustiness correction on corrected sst on OAFLUX grid
10;
11; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` have been produced by
12; :ref:`sst_correction_ncdf.pro`.
13;
14; Cronin gustiness corrected ++ on corrected sst on OAFLUX grid
15; is written in
16; :file:`${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc`
17; if this file not already exists.
18;
19; This file will be used by :ref:`TropFlux_swr_BLND_19890101_20091231.pro` and
20; :ref:`TropFlux_19890101_20091231.pro`.
21;
22;     .. graphviz::
23;
24;        digraph cronin_gustiness_ncdf {
25;           graph [
26;           rankdir="LR",
27;           ]
28;
29;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc"];
30;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc"];
31;
32;           cronin_gustiness_ncdf [shape=box,
33;           fontname=Courier,
34;           color=blue,
35;           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/cronin_gustiness_ncdf.pro",
36;           label="${PROJECT}/src/cronin_gustiness_ncdf.pro"];
37;
38;           {file_in} -> {cronin_gustiness_ncdf} -> {file_out}
39;        }
40;
41; EXAMPLES
42; ========
43;
44; ::
45;
46;  IDL> cronin_gustiness_ncdf
47;
48; SEE ALSO
49; ========
50;
51; :ref:`project_profile.sh`
52;
53; :ref:`mooring_corrections`
54;
55; :ref:`sst_correction_ncdf.pro`.
56;
57; :func:`initncdf <saxo:initncdf>`
58; :func:`julday <saxo:julday>`
59; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
60;
61; TODO
62; ====
63;
64; coding rules
65;
66; why writing more than 1 timestep ?
67;
68; KNOWN ISSUES
69; ============
70;
71; test of existence of fullfilename_in not very efficient because
72; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented
73;
74; EVOLUTIONS
75; ==========
76;
77; - fplod 20110808T144208Z aedon.locean-ipsl.upmc.fr (Darwin)
78;
79;   * usage of ${PROJECT_OD}
80;   * complete description
81;   * remove v50 in output filename
82;   * remove return statement
83;
84; - fplod 20101215T092619Z aedon.locean-ipsl.upmc.fr (Darwin)
85;
86;   * add graph in header
87;
88; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin)
89;
90;   * minimal header
91;
92; - pbk 2008
93;
94;   * creation
95;
96;-
97pro cronin_gustiness_ncdf
98;
99@cm_4cal
100@cm_4data
101@cm_4mesh
102@cm_4data
103@cm_project
104;
105; test if ${PROJECT_OD} defined
106CASE project_od_env OF
107  '' : BEGIN
108         msg = 'eee : ${PROJECT_OD} is not defined'
109         ras = report(msg)
110       STOP
111       END
112  ELSE: BEGIN
113          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
114          ras = report(msg)
115        END
116 ENDCASE
117;
118; check if output data will be possible
119iodirout = isadirectory(project_od_env)
120;
121; existence and protection for reading
122IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
123   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
124   ras = report(msg)
125   STOP
126ENDIF
127;
128; existence and protection for writing
129IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
130    msg = 'eee : the directory' + iodirout  + ' was not found.'
131    ras = report(msg)
132    STOP
133ENDIF
134;
135da1=19880101 & da2=20101231
136date1=19890101 & date2=20081231
137;
138; build data filename
139filename='TropFlux_sst_19890101_20091231.nc'
140;
141; check if this file exists
142fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST)
143IF fullfilename[0] EQ '' THEN BEGIN
144   msg = 'eee : the file ' + fullfilename + ' was not found.'
145   ras = report(msg)
146   STOP
147ENDIF
148;
149; build output filename
150filename_out = 'TropFlux_gustiness_19890101_20091231.nc'
151fullfilename_out = iodirout + filename_out
152; in order to avoid unexpected overwritten
153IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
154   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
155   ras = report(msg)
156   STOP
157ENDIF
158;
159initncdf, fullfilename
160sst=read_ncdf('sst',da1,da2,file=fullfilename,/nostr) & sst=reform(sst-273.15)
161help, sst
162
163sst_clim=grossemoyenne(sst, 't',/nan)
164;wg=0.175*sst_clim-3.17  ;; line fit obtained from the scatter (Cronin gustiness Vs ERAI SST)
165;help, wg
166
167jpt=n_elements(time)
168
169wg_tot=sst*0.
170for jt=0, jpt-1 do begin
171    wg_tot(*,*,jt)=(((sst_clim(*,*)-23.7)*2.1/(29.8-23.7)) > 1.) <2.1
172endfor
173help, wg_tot
174
175;; writing field
176time=timegen(7670, units='days', start=julday(1,1,1989,0)) & jpt=n_elements(time)
177
178cda0=string(jul2date(time(0)),format='(i8.8)')
179cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
180tt=time-julday(1,1,1950,00,00,00)
181xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*))
182
183ncfile='!' + fullfilename_out
184lon_attr={units:'degrees_east',long_name:'Longitude'}
185lat_attr={units:'degrees_north',long_name:'Latitude'}
186time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'}
187gust_attr={units:'m/s',missing_value:valmask,long_name:'Climatological gustiness',short_name:'wg',axis:'TYX'}
188globattr={source:'Climatological wind gustiness obtained by fitting cronins gustiness values against sst ',timerange:cda0+' - '+cda1}
189
190ncfields = 'wg[longitude,latitude,time]=wg_tot:gust_attr; ' $
191                      + 'longitude[]=xlon:lon_attr; ' $
192                      + 'latitude[]=ylat:lat_attr; ' $
193                      + 'tt[*time]=tt:time_attr ' $
194                      + ' @ globattr'
195
196@ncdf_quickwrite
197
198end
Note: See TracBrowser for help on using the repository browser.