1 | ;+ |
---|
2 | ; |
---|
3 | ; .. _interp_erai_sst_1989_2009.pro: |
---|
4 | ; |
---|
5 | ; ============================= |
---|
6 | ; interp_erai_sst_1989_2009.pro |
---|
7 | ; ============================= |
---|
8 | ; |
---|
9 | ; .. graphviz:: |
---|
10 | ; |
---|
11 | ; digraph interp_erai_sst_1989_2009 { |
---|
12 | ; graph [ |
---|
13 | ; rankdir="LR", |
---|
14 | ; ] |
---|
15 | ; file_in [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/ERAI_global/20c3m_erai_sstk_TROP_1989_2009.nc"]; |
---|
16 | ; |
---|
17 | ; mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; |
---|
18 | ; |
---|
19 | ; ncfile [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/TropFlux/input_uncor/erai_sst_19890101_20091231_oafluxgrid.nc"]; |
---|
20 | ; |
---|
21 | ; interp_erai_sst_1989_2009 [shape=box, |
---|
22 | ; fontname=Courier, |
---|
23 | ; color=blue, |
---|
24 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_sst_1989_2009.pro", |
---|
25 | ; label="${PROJECT}/src/interp_erai_sst_1989_2009.pro"]; |
---|
26 | ; |
---|
27 | ; {file_in mask} -> {interp_erai_sst_1989_2009} -> {ncfile} |
---|
28 | ; } |
---|
29 | ; |
---|
30 | ; SEE ALSO |
---|
31 | ; ======== |
---|
32 | ; |
---|
33 | ; :ref:`project_profile.sh` |
---|
34 | ; |
---|
35 | ; :func:`report <saxo:report>` |
---|
36 | ; :func:`isadirectory <saxo:isadirectory>` |
---|
37 | ; :func:`isafile <saxo:isafile>` |
---|
38 | ; :func:`initncdf <saxo:initncdf>` |
---|
39 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
40 | ; :func:`domdef <saxo:domdef>` |
---|
41 | ; :func:`call_interp2d <saxo:call_interp2d>` |
---|
42 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
43 | ; |
---|
44 | ; EXAMPLES |
---|
45 | ; ======== |
---|
46 | ; |
---|
47 | ; :: |
---|
48 | ; |
---|
49 | ; IDL> interp_erai_sst_1989_2009 |
---|
50 | ; |
---|
51 | ; TODO |
---|
52 | ; ==== |
---|
53 | ; |
---|
54 | ; hard coded directory - usage of ${PROJECT_ID} |
---|
55 | ; |
---|
56 | ; coding rules |
---|
57 | ; |
---|
58 | ; KNOWN ISSUES |
---|
59 | ; ============ |
---|
60 | ; |
---|
61 | ; test of existence of fullfilename_msk not very efficient because |
---|
62 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
63 | ; |
---|
64 | ; EVOLUTIONS |
---|
65 | ; ========== |
---|
66 | ; |
---|
67 | ; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
68 | ; |
---|
69 | ; * remove hard coded directory for mask_oaflux_30N30S.nc |
---|
70 | ; |
---|
71 | ; - fplod 20101215T100932Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
72 | ; |
---|
73 | ; * add graph in header |
---|
74 | ; |
---|
75 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
76 | ; |
---|
77 | ; * minimal header |
---|
78 | ; |
---|
79 | ; - pbk 2008 |
---|
80 | ; |
---|
81 | ; |
---|
82 | ; * creation |
---|
83 | ; |
---|
84 | ;- |
---|
85 | pro interp_erai_sst_1989_2009 |
---|
86 | @common |
---|
87 | @cm_project |
---|
88 | ; |
---|
89 | ; check for input directory |
---|
90 | ; |
---|
91 | ; test if ${PROJECT_ID} defined |
---|
92 | CASE project_id_env OF |
---|
93 | '' : BEGIN |
---|
94 | msg = 'eee : ${PROJECT_ID} is not defined' |
---|
95 | ras = report(msg) |
---|
96 | STOP |
---|
97 | END |
---|
98 | ELSE: BEGIN |
---|
99 | msg = 'iii : ${PROJECT_ID} is ' + project_id_env |
---|
100 | ras = report(msg) |
---|
101 | END |
---|
102 | ENDCASE |
---|
103 | ; |
---|
104 | iodirin = isadirectory(project_id_env) |
---|
105 | ; |
---|
106 | ; existence and protection of ${PROJECT_ID} |
---|
107 | IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
108 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
109 | ras = report(msg) |
---|
110 | STOP |
---|
111 | ENDIF |
---|
112 | ; |
---|
113 | ; build mask filename |
---|
114 | filename_msk='mask_oaflux_30N30S.nc' |
---|
115 | ; |
---|
116 | ; check if this file exists |
---|
117 | fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST) |
---|
118 | IF fullfilename_msk[0] EQ '' THEN BEGIN |
---|
119 | msg = 'eee : the file ' + fullfilename_msk + ' was not found.' |
---|
120 | ras = report(msg) |
---|
121 | STOP |
---|
122 | ENDIF |
---|
123 | |
---|
124 | filein='/Volumes/PRAVEEN/ERAI_global/20c3m_erai_sstk_TROP_1989_2009.nc' |
---|
125 | |
---|
126 | initncdf, filein |
---|
127 | domdef |
---|
128 | latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0)) |
---|
129 | print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0) |
---|
130 | print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0) |
---|
131 | sstkin=read_ncdf("sstk",19871201,20100930,file=filein,/nostr) |
---|
132 | |
---|
133 | timein=time & jptin=jpt |
---|
134 | tab=sstkin(*,*,0) |
---|
135 | mskin=glamt*0.+1. & ind=where((tab eq 1.e9) or finite(tab,/nan)) & mskin(ind)=0. |
---|
136 | ;mskin=glamt*0.+1. |
---|
137 | |
---|
138 | initncdf, fullfilename_msk |
---|
139 | domdef |
---|
140 | latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0)) |
---|
141 | print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0) |
---|
142 | print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0) |
---|
143 | mskout=read_ncdf("msk", file=fullfilename_msk,/nostr) |
---|
144 | ;stop |
---|
145 | help, sstkin,lonin,latin,mskin,lonout,latout,mskout |
---|
146 | |
---|
147 | si=size(sstkin) |
---|
148 | sstkout=fltarr(jpi,jpj,jptin) |
---|
149 | for jt=0,jptin-1 do begin |
---|
150 | print, 'Interpolation jt=',jt,' / ',jptin-1 |
---|
151 | tab=reform(sstkin(*,*,jt)) |
---|
152 | sstkout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin,lonout,latout,method='bilinear') |
---|
153 | sstkout(*,*,jt)=sstkout(*,*,jt)*mskout+(1.-mskout)*1.e20 |
---|
154 | endfor |
---|
155 | |
---|
156 | |
---|
157 | timein=timein & jptin=jpt |
---|
158 | |
---|
159 | initncdf, fullfilename_msk |
---|
160 | time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time) |
---|
161 | tt=time |
---|
162 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
163 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
164 | timein=timein-julday(1,1,1950,00,00) |
---|
165 | |
---|
166 | lat=latout |
---|
167 | lon=lonout |
---|
168 | ncfile='/Volumes/PRAVEEN/TropFlux/input_uncor/erai_sst_19890101_20091231_oafluxgrid.nc' |
---|
169 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
170 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
171 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'} |
---|
172 | sstk_attr={units:'degK',missing_value:1e20,long_name:'Sea Surface Temperature',short_name:'sst',axis:'TYX'} |
---|
173 | globattr={source:'Data are from ECMWF ERA-Interim reanalysis', timerange:cda0+' - '+cda1} |
---|
174 | |
---|
175 | |
---|
176 | ncfields = 'sst[longitude,latitude,time]=sstkout:sstk_attr; ' $ |
---|
177 | + 'longitude[]=lon:lon_attr; ' $ |
---|
178 | + 'latitude[]=lat:lat_attr; ' $ |
---|
179 | + 'time[*time]=timein:time_attr ' $ |
---|
180 | + ' @ globattr' |
---|
181 | |
---|
182 | @ncdf_quickwrite |
---|
183 | |
---|
184 | |
---|
185 | end |
---|