[6] | 1 | ;+ |
---|
| 2 | ; |
---|
| 3 | ; ========================= |
---|
| 4 | ; cronin_gustiness_ncdf.pro |
---|
| 5 | ; ========================= |
---|
| 6 | ; |
---|
[174] | 7 | ; .. function:: cronin_gustiness_ncdf(yyyymmddb,yyyymmdde) |
---|
| 8 | ; |
---|
| 9 | ; DESCRIPTION |
---|
| 10 | ; =========== |
---|
| 11 | ; |
---|
[72] | 12 | ; Cronin gustiness correction on corrected sst on OAFLUX grid |
---|
| 13 | ; |
---|
| 14 | ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` have been produced by |
---|
[175] | 15 | ; :func:`sst_correction_ncdf`. |
---|
[72] | 16 | ; |
---|
| 17 | ; Cronin gustiness corrected ++ on corrected sst on OAFLUX grid |
---|
| 18 | ; is written in |
---|
[174] | 19 | ; :file:`${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc` |
---|
[72] | 20 | ; if this file not already exists. |
---|
| 21 | ; |
---|
[100] | 22 | ; This file will be used by |
---|
[174] | 23 | ; :func:`tropflux_swr_blnd` |
---|
[100] | 24 | ; and |
---|
[175] | 25 | ; :func:`tropflux`. |
---|
[72] | 26 | ; |
---|
[8] | 27 | ; .. graphviz:: |
---|
| 28 | ; |
---|
| 29 | ; digraph cronin_gustiness_ncdf { |
---|
[72] | 30 | ; |
---|
[204] | 31 | ; file_in [shape=ellipse, |
---|
| 32 | ; fontname=Courier, |
---|
| 33 | ; label="${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc"]; |
---|
[174] | 34 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc"]; |
---|
[72] | 35 | ; |
---|
[8] | 36 | ; cronin_gustiness_ncdf [shape=box, |
---|
| 37 | ; fontname=Courier, |
---|
| 38 | ; color=blue, |
---|
| 39 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/cronin_gustiness_ncdf.pro", |
---|
[50] | 40 | ; label="${PROJECT}/src/cronin_gustiness_ncdf.pro"]; |
---|
[72] | 41 | ; |
---|
| 42 | ; {file_in} -> {cronin_gustiness_ncdf} -> {file_out} |
---|
[8] | 43 | ; } |
---|
| 44 | ; |
---|
[6] | 45 | ; EXAMPLES |
---|
| 46 | ; ======== |
---|
| 47 | ; |
---|
[203] | 48 | ; .. code-block:: idl |
---|
[6] | 49 | ; |
---|
[203] | 50 | ; yyyymmddb = 20000101L |
---|
| 51 | ; yyyymmdde = 20001231L |
---|
| 52 | ; result = cronin_gustiness_ncdf(yyyymmddb, yyyymmdde) |
---|
| 53 | ; print, result |
---|
[6] | 54 | ; |
---|
[20] | 55 | ; SEE ALSO |
---|
| 56 | ; ======== |
---|
| 57 | ; |
---|
[72] | 58 | ; :ref:`project_profile.sh` |
---|
| 59 | ; |
---|
| 60 | ; :ref:`mooring_corrections` |
---|
| 61 | ; |
---|
[175] | 62 | ; :func:`sst_correction_ncdf`. |
---|
[72] | 63 | ; |
---|
[20] | 64 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 65 | ; :func:`julday <saxo:julday>` |
---|
| 66 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
| 67 | ; |
---|
[6] | 68 | ; TODO |
---|
| 69 | ; ==== |
---|
| 70 | ; |
---|
[174] | 71 | ; going on time parametrization |
---|
| 72 | ; |
---|
[6] | 73 | ; coding rules |
---|
| 74 | ; |
---|
[94] | 75 | ; why da1=19880101 and da2=20101231 ? should be 19890101 and 20091231 or better |
---|
[88] | 76 | ; deduce from reading sst |
---|
[72] | 77 | ; |
---|
| 78 | ; KNOWN ISSUES |
---|
| 79 | ; ============ |
---|
| 80 | ; |
---|
| 81 | ; test of existence of fullfilename_in not very efficient because |
---|
| 82 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
| 83 | ; |
---|
[6] | 84 | ; EVOLUTIONS |
---|
| 85 | ; ========== |
---|
| 86 | ; |
---|
[81] | 87 | ; $Id$ |
---|
| 88 | ; |
---|
| 89 | ; $URL$ |
---|
| 90 | ; |
---|
[174] | 91 | ; - fplod 20120321 |
---|
| 92 | ; |
---|
| 93 | ; * pro -> func |
---|
[204] | 94 | ; * taking project_overwrite into account |
---|
[174] | 95 | ; |
---|
[98] | 96 | ; - fplod 20110830T140029Z cratos (Linux) |
---|
| 97 | ; |
---|
| 98 | ; * replace tt by time |
---|
| 99 | ; |
---|
[72] | 100 | ; - fplod 20110808T144208Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 101 | ; |
---|
| 102 | ; * usage of ${PROJECT_OD} |
---|
| 103 | ; * complete description |
---|
| 104 | ; * remove v50 in output filename |
---|
| 105 | ; * remove return statement |
---|
| 106 | ; |
---|
[8] | 107 | ; - fplod 20101215T092619Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 108 | ; |
---|
| 109 | ; * add graph in header |
---|
| 110 | ; |
---|
[6] | 111 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 112 | ; |
---|
| 113 | ; * minimal header |
---|
| 114 | ; |
---|
| 115 | ; - pbk 2008 |
---|
| 116 | ; |
---|
| 117 | ; * creation |
---|
| 118 | ; |
---|
| 119 | ;- |
---|
[174] | 120 | function cronin_gustiness_ncdf $ |
---|
[203] | 121 | , yyyymmddb $ |
---|
| 122 | , yyyymmdde |
---|
[72] | 123 | ; |
---|
[174] | 124 | ;++ compile_opt idl2, strictarrsubs, logical_predicate |
---|
| 125 | ; |
---|
[72] | 126 | @cm_4cal |
---|
| 127 | @cm_4data |
---|
| 128 | @cm_4mesh |
---|
| 129 | @cm_4data |
---|
| 130 | @cm_project |
---|
| 131 | ; |
---|
[174] | 132 | ; Return to caller if errors |
---|
| 133 | ON_ERROR, 2 |
---|
| 134 | ; |
---|
| 135 | result = -1 |
---|
| 136 | ; |
---|
| 137 | usage = 'result = tropflux_swr_nrt(yyyymmddb, yyyymmdde)' |
---|
| 138 | nparam = N_PARAMS() |
---|
| 139 | IF (nparam NE 2) THEN BEGIN |
---|
| 140 | ras = report(['Incorrect number of arguments.' $ |
---|
| 141 | + '!C' $ |
---|
| 142 | + 'Usage : ' + usage]) |
---|
| 143 | return, result |
---|
| 144 | ENDIF |
---|
| 145 | ; |
---|
[72] | 146 | ; test if ${PROJECT_OD} defined |
---|
| 147 | CASE project_od_env OF |
---|
[204] | 148 | '' : BEGIN |
---|
| 149 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 150 | ras = report(msg) |
---|
| 151 | return, result |
---|
| 152 | END |
---|
| 153 | ELSE : BEGIN |
---|
| 154 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 155 | ras = report(msg) |
---|
| 156 | END |
---|
| 157 | ENDCASE |
---|
[72] | 158 | ; |
---|
| 159 | ; check if output data will be possible |
---|
| 160 | iodirout = isadirectory(project_od_env) |
---|
| 161 | ; |
---|
| 162 | ; existence and protection for reading |
---|
| 163 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
[204] | 164 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
| 165 | ras = report(msg) |
---|
| 166 | return, result |
---|
[72] | 167 | ENDIF |
---|
| 168 | ; |
---|
| 169 | ; existence and protection for writing |
---|
| 170 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 171 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 172 | ras = report(msg) |
---|
[174] | 173 | return, result |
---|
[72] | 174 | ENDIF |
---|
| 175 | ; |
---|
[97] | 176 | da1=19880101 |
---|
[94] | 177 | da2=20101231 |
---|
[72] | 178 | ; |
---|
| 179 | ; build data filename |
---|
| 180 | filename='TropFlux_sst_19890101_20091231.nc' |
---|
| 181 | ; |
---|
| 182 | ; check if this file exists |
---|
| 183 | fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) |
---|
| 184 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
[204] | 185 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
| 186 | ras = report(msg) |
---|
| 187 | return, result |
---|
[72] | 188 | ENDIF |
---|
| 189 | ; |
---|
| 190 | ; build output filename |
---|
[174] | 191 | filename_out = 'TropFlux_gustiness' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') + '.nc' |
---|
[72] | 192 | fullfilename_out = iodirout + filename_out |
---|
| 193 | ; in order to avoid unexpected overwritten |
---|
[174] | 194 | IF ((FILE_TEST(fullfilename_out) EQ 1) AND (project_overwrite EQ 0)) THEN BEGIN |
---|
[204] | 195 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 196 | ras = report(msg) |
---|
| 197 | return, result |
---|
[72] | 198 | ENDIF |
---|
| 199 | ; |
---|
| 200 | initncdf, fullfilename |
---|
[97] | 201 | sst=read_ncdf('sst',da1,da2,file=fullfilename,/nostr) |
---|
[94] | 202 | sst=reform(sst-273.15) |
---|
[5] | 203 | help, sst |
---|
[97] | 204 | ; |
---|
[5] | 205 | sst_clim=grossemoyenne(sst, 't',/nan) |
---|
[97] | 206 | ;wg=0.175*sst_clim-3.17 ; line fit obtained from the scatter (Cronin gustiness Vs ERAI SST) |
---|
[5] | 207 | ;help, wg |
---|
[97] | 208 | ; |
---|
[5] | 209 | jpt=n_elements(time) |
---|
[97] | 210 | ; |
---|
[5] | 211 | wg_tot=sst*0. |
---|
| 212 | for jt=0, jpt-1 do begin |
---|
| 213 | wg_tot(*,*,jt)=(((sst_clim(*,*)-23.7)*2.1/(29.8-23.7)) > 1.) <2.1 |
---|
| 214 | endfor |
---|
| 215 | help, wg_tot |
---|
[97] | 216 | ; |
---|
| 217 | ; writing field |
---|
[100] | 218 | time=timegen(7670, start=julday(1,1,1989,0), units='days') |
---|
[94] | 219 | jpt=n_elements(time) |
---|
[97] | 220 | ; |
---|
[5] | 221 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
| 222 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
[98] | 223 | time=time-julday(1,1,1950,00,00,00) |
---|
[97] | 224 | xlon=reform(glamt(*,0) ) |
---|
[94] | 225 | ylat=reform(gphit(0,*)) |
---|
[97] | 226 | ; |
---|
[72] | 227 | ncfile='!' + fullfilename_out |
---|
[5] | 228 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 229 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
[100] | 230 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
[5] | 231 | gust_attr={units:'m/s',missing_value:valmask,long_name:'Climatological gustiness',short_name:'wg',axis:'TYX'} |
---|
| 232 | globattr={source:'Climatological wind gustiness obtained by fitting cronins gustiness values against sst ',timerange:cda0+' - '+cda1} |
---|
[97] | 233 | ; |
---|
[5] | 234 | ncfields = 'wg[longitude,latitude,time]=wg_tot:gust_attr; ' $ |
---|
| 235 | + 'longitude[]=xlon:lon_attr; ' $ |
---|
| 236 | + 'latitude[]=ylat:lat_attr; ' $ |
---|
[98] | 237 | + 'time[*time]=time:time_attr ' $ |
---|
[5] | 238 | + ' @ globattr' |
---|
[97] | 239 | ; |
---|
[5] | 240 | @ncdf_quickwrite |
---|
[97] | 241 | ; |
---|
[174] | 242 | result = 0 |
---|
| 243 | return, result |
---|
| 244 | ; |
---|
[5] | 245 | end |
---|