[6] | 1 | ;+ |
---|
| 2 | ; |
---|
| 3 | ; .. _q2m_correction_ncdf.pro: |
---|
| 4 | ; |
---|
| 5 | ; ======================= |
---|
| 6 | ; q2m_correction_ncdf.pro |
---|
| 7 | ; ======================= |
---|
| 8 | ; |
---|
[72] | 9 | ; Correction of q2m on OAFLUX grid |
---|
| 10 | ; |
---|
| 11 | ; :file:`${PROJECT_OD}/erai_q2m_19890101_20091231_oafluxgrid.nc` have been |
---|
| 12 | ; produced by :ref:`d2m_to_q2m.pro`. |
---|
| 13 | ; |
---|
| 14 | ; Corrected q2m on OAFLUX grid is written in |
---|
| 15 | ; :file:`${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc` |
---|
| 16 | ; if this file not already exists. |
---|
| 17 | ; |
---|
| 18 | ; This file will be used by :ref:`TropFlux_19890101_20091231.pro`. |
---|
| 19 | ; |
---|
[9] | 20 | ; .. graphviz:: |
---|
| 21 | ; |
---|
| 22 | ; digraph q2m_correction_ncdf { |
---|
| 23 | ; graph [ |
---|
| 24 | ; rankdir="LR", |
---|
| 25 | ; ] |
---|
| 26 | ; |
---|
[72] | 27 | ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_q2m_19890101_20091231_oafluxgrid.nc"]; |
---|
| 28 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc"]; |
---|
[9] | 29 | ; |
---|
| 30 | ; q2m_correction_ncdf [shape=box, |
---|
| 31 | ; fontname=Courier, |
---|
| 32 | ; color=blue, |
---|
| 33 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/q2m_correction_ncdf.pro", |
---|
[50] | 34 | ; label="${PROJECT}/src/q2m_correction_ncdf.pro"]; |
---|
[9] | 35 | ; |
---|
[72] | 36 | ; {file_in} -> {q2m_correction_ncdf} -> {file_out} |
---|
[9] | 37 | ; |
---|
| 38 | ; } |
---|
| 39 | ; |
---|
[6] | 40 | ; SEE ALSO |
---|
| 41 | ; ======== |
---|
| 42 | ; |
---|
[72] | 43 | ; :ref:`project_profile.sh` |
---|
| 44 | ; |
---|
| 45 | ; :ref:`mooring_corrections` |
---|
| 46 | ; |
---|
[77] | 47 | ; :ref:`d2m_to_q2m_erai.pro` |
---|
[72] | 48 | ; |
---|
[20] | 49 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 50 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
| 51 | ; :func:`grossemoyenne <saxo:grossemoyenne>` |
---|
| 52 | ; :func:`julday <saxo:julday>` |
---|
| 53 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
| 54 | ; |
---|
[6] | 55 | ; EXAMPLES |
---|
| 56 | ; ======== |
---|
| 57 | ; |
---|
| 58 | ; :: |
---|
| 59 | ; |
---|
| 60 | ; IDL> q2m_correction_ncdf |
---|
| 61 | ; |
---|
| 62 | ; TODO |
---|
| 63 | ; ==== |
---|
| 64 | ; |
---|
[72] | 65 | ; can be tested because d2m_to_q2m.pro pb |
---|
[6] | 66 | ; |
---|
| 67 | ; coding rules |
---|
| 68 | ; |
---|
| 69 | ; EVOLUTIONS |
---|
| 70 | ; ========== |
---|
| 71 | ; |
---|
[72] | 72 | ; - fplod 20110808T143129Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 73 | ; |
---|
| 74 | ; * usage of ${PROJECT_OD} |
---|
| 75 | ; * remove v20 in output filename |
---|
| 76 | ; |
---|
[9] | 77 | ; - fplod 20101215T113945Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 78 | ; |
---|
| 79 | ; * add graph in header |
---|
| 80 | ; |
---|
[6] | 81 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 82 | ; |
---|
| 83 | ; * minimal header |
---|
| 84 | ; |
---|
| 85 | ; - pbk 2008 |
---|
| 86 | ; |
---|
| 87 | ; * creation |
---|
| 88 | ; |
---|
| 89 | ;- |
---|
[5] | 90 | pro q2m_correction_ncdf |
---|
[72] | 91 | ; |
---|
| 92 | @cm_4cal |
---|
| 93 | @cm_4data |
---|
| 94 | @cm_4mesh |
---|
| 95 | @cm_4data |
---|
| 96 | @cm_project |
---|
| 97 | ; |
---|
| 98 | ; |
---|
| 99 | ; test if ${PROJECT_OD} defined |
---|
| 100 | CASE project_od_env OF |
---|
| 101 | '' : BEGIN |
---|
| 102 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 103 | ras = report(msg) |
---|
| 104 | STOP |
---|
| 105 | END |
---|
| 106 | ELSE: BEGIN |
---|
| 107 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 108 | ras = report(msg) |
---|
| 109 | END |
---|
| 110 | ENDCASE |
---|
| 111 | ; |
---|
| 112 | ; check if output data will be possible |
---|
| 113 | iodirout = isadirectory(project_od_env) |
---|
| 114 | ; |
---|
| 115 | ; existence and protection for reading |
---|
| 116 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 117 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
| 118 | ras = report(msg) |
---|
| 119 | STOP |
---|
| 120 | ENDIF |
---|
| 121 | ; |
---|
| 122 | ; existence and protection for writing |
---|
| 123 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 124 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 125 | ras = report(msg) |
---|
| 126 | STOP |
---|
| 127 | ENDIF |
---|
| 128 | ; |
---|
[5] | 129 | da1=19880101 & da2=20101231 |
---|
[72] | 130 | ; |
---|
| 131 | ; build data filename |
---|
| 132 | filename='erai_q2m_19890101_20091231_oafluxgrid.nc' |
---|
| 133 | ; |
---|
| 134 | ; check if this file exists |
---|
| 135 | fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) |
---|
| 136 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
| 137 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
| 138 | ras = report(msg) |
---|
| 139 | STOP |
---|
| 140 | ENDIF |
---|
| 141 | ; |
---|
| 142 | ; build output filename |
---|
| 143 | filename_out = 'TropFlux_q2m_19890101_20091231.nc' |
---|
| 144 | fullfilename_out = iodirout + filename_out |
---|
| 145 | ; in order to avoid unexpected overwritten |
---|
| 146 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
| 147 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 148 | ras = report(msg) |
---|
| 149 | STOP |
---|
| 150 | ENDIF |
---|
| 151 | ; |
---|
| 152 | initncdf, fullfilename |
---|
| 153 | q2m=read_ncdf('q2m',da1,da2,file=fullfilename,/nostr) |
---|
[5] | 154 | help, q2m |
---|
| 155 | |
---|
| 156 | q2m_mean=grossemoyenne(q2m,'t',/nan) |
---|
| 157 | help, q2m_mean |
---|
| 158 | |
---|
| 159 | tt=time & jpt=n_elements(time) |
---|
| 160 | caldat, time,mon,day,yea |
---|
| 161 | q2m_m=q2m*0. |
---|
| 162 | |
---|
| 163 | for jt=0,jpt-1 do begin |
---|
| 164 | jtt=(time(jt)-julday(1,1,yea(jt))) < 364 |
---|
| 165 | q=reform(q2m_mean(*,*)) |
---|
| 166 | q2m_m(*,*,jt)=q |
---|
| 167 | endfor |
---|
| 168 | help, q2m_m |
---|
| 169 | |
---|
| 170 | q2m_ano=q2m-q2m_m |
---|
| 171 | |
---|
| 172 | ;; correction for mean based on scatter |
---|
| 173 | ;q2m_m=q2m_m+0.815445 ;; (2000-2008) |
---|
| 174 | q2m_m=q2m_m+0.792717 ;; (2000-2009) |
---|
| 175 | help, q2m_ano |
---|
| 176 | |
---|
[7] | 177 | ;; applying the correction for variability based on the scatter |
---|
[5] | 178 | ;q2m_ano=q2m_ano*(1/0.919333) ;; (2000-2008) |
---|
| 179 | q2m_ano=q2m_ano*(1/0.924674) ;; (2000-2009) |
---|
| 180 | |
---|
| 181 | q2m_new=q2m_m+q2m_ano |
---|
| 182 | help, q2m_new |
---|
| 183 | |
---|
| 184 | ;writing field |
---|
| 185 | lat=reform(gphit(0,0:jpj-1)) |
---|
| 186 | lon=reform(glamt(0:jpi-1,0)) |
---|
| 187 | time=timegen(7670, units='days', start=julday(1,1,1989,0)) & jpt=n_elements(time) |
---|
| 188 | |
---|
| 189 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
| 190 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
| 191 | |
---|
| 192 | time=time-julday(1,1,1950) & jpt=n_elements(time) |
---|
| 193 | |
---|
[72] | 194 | ncfile='!' + fullfilename_out |
---|
[5] | 195 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 196 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
| 197 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
| 198 | q2m_attr={units:'g/kg',missing_value:1.e20,long_name:'Specific humidity at 2m height',short_name:'q2m',axis:'TYX'} |
---|
| 199 | globattr={source:'Basic data obtained from ERAI. Mean correction for bias and correction for variability are applied',timerange:cda0+' - '+cda1} |
---|
| 200 | |
---|
| 201 | ncfields = 'q2m[longitude,latitude,time]=q2m_new:q2m_attr; ' $ |
---|
| 202 | + 'longitude[]=lon:lon_attr; ' $ |
---|
| 203 | + 'latitude[]=lat:lat_attr; ' $ |
---|
| 204 | + 'time[*time]=time:time_attr ' $ |
---|
| 205 | + ' @ globattr' |
---|
| 206 | |
---|
| 207 | @ncdf_quickwrite |
---|
| 208 | |
---|
| 209 | end |
---|