source: trunk/src/cronin_gustiness_ncdf.pro @ 88

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

progress on coare correction

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