source: trunk/src/cronin_gustiness_ncdf.pro @ 169

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

start to homogenize (to be cont.)

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