[6] | 1 | ;+ |
---|
| 2 | ; |
---|
| 3 | ; .. _d2m_to_q2m_erai.pro: |
---|
| 4 | ; |
---|
| 5 | ; =================== |
---|
| 6 | ; d2m_to_q2m_erai.pro |
---|
| 7 | ; =================== |
---|
| 8 | ; |
---|
[72] | 9 | ; Converstion of d2m to q2m on OAFLUX grid |
---|
| 10 | ; |
---|
| 11 | ; :file:`${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc` have been |
---|
| 12 | ; produced by :ref:`interp_erai_dewt_1989_2009.pro`. |
---|
| 13 | ; |
---|
| 14 | ; :file:`${PROJECT_OD}/erai_t2m_19890101_20091231_oafluxgrid.nc` have been |
---|
| 15 | ; produced by :ref:`interp_erai_t2m_1989_2009.pro`. |
---|
| 16 | ; |
---|
| 17 | ; :file:`${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc` have been |
---|
| 18 | ; produced by ++. |
---|
| 19 | ; |
---|
| 20 | ; q2m on OAFLUX grid is written in |
---|
| 21 | ; :file:`${PROJECT_OD}/q2m_erai_19890101_20091231_oafluxgrid.nc` |
---|
| 22 | ; if this file not already exists. |
---|
| 23 | ; |
---|
| 24 | ; This file will be used by :ref:`q2m_correction_ncdf.pro`. |
---|
| 25 | ; |
---|
[8] | 26 | ; .. graphviz:: |
---|
| 27 | ; |
---|
| 28 | ; digraph d2m_to_q2m_erai { |
---|
| 29 | ; graph [ |
---|
| 30 | ; rankdir="LR", |
---|
| 31 | ; ] |
---|
| 32 | ; |
---|
[72] | 33 | ; file_d2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_d2m_19890101_20091231_oafluxgrid.nc"]; |
---|
| 34 | ; file_t2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_t2m_19890101_20091231_oafluxgrid.nc"]; |
---|
| 35 | ; file_msl [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc"]; |
---|
| 36 | ; file_q2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/q2m_erai_19890101_20091231_oafluxgrid.nc"]; |
---|
| 37 | ; |
---|
[8] | 38 | ; d2m_to_q2m_erai [shape=box, |
---|
| 39 | ; fontname=Courier, |
---|
| 40 | ; color=blue, |
---|
| 41 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/d2m_to_q2m_erai.pro", |
---|
[50] | 42 | ; label="${PROJECT}/src/d2m_to_q2m_erai.pro"]; |
---|
[72] | 43 | ; |
---|
[12] | 44 | ; {file_d2m file_t2m file_msl} -> {d2m_to_q2m_erai} -> {file_q2m} |
---|
[8] | 45 | ; } |
---|
| 46 | ; |
---|
[6] | 47 | ; SEE ALSO |
---|
| 48 | ; ======== |
---|
| 49 | ; |
---|
[72] | 50 | ; :ref:`project_profile.sh` |
---|
| 51 | ; |
---|
| 52 | ; :ref:`mooring_corrections` |
---|
| 53 | ; |
---|
| 54 | ; :ref:`interp_erai_dewt_1989_2009.pro` |
---|
| 55 | ; :ref:`interp_erai_t2m_1989_2009.pro` |
---|
| 56 | ; |
---|
| 57 | ; :ref:`d2m_to_q2m_erai.pro` |
---|
| 58 | ; |
---|
[12] | 59 | ; :func:`rh_to_spechum` |
---|
[20] | 60 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 61 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
| 62 | ; :func:`julday <saxo:julday>` |
---|
| 63 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
[7] | 64 | ; |
---|
[6] | 65 | ; EXAMPLES |
---|
| 66 | ; ======== |
---|
| 67 | ; |
---|
| 68 | ; :: |
---|
| 69 | ; |
---|
| 70 | ; IDL> d2m_to_q2m_erai |
---|
| 71 | ; |
---|
| 72 | ; TODO |
---|
| 73 | ; ==== |
---|
| 74 | ; |
---|
[72] | 75 | ; I (fp) do not know how |
---|
| 76 | ; ${PROJECT_OD}/erai_msl_19890101_20091231_oafluxgrid.nc is produced. |
---|
[6] | 77 | ; |
---|
[72] | 78 | ; es0 undefined |
---|
| 79 | ; |
---|
[6] | 80 | ; coding rules |
---|
| 81 | ; |
---|
| 82 | ; EVOLUTIONS |
---|
| 83 | ; ========== |
---|
| 84 | ; |
---|
[72] | 85 | ; - fplod 20110808T120234Z cratos (Linux) |
---|
| 86 | ; |
---|
| 87 | ; * usage of ${PROJECT_OD} |
---|
| 88 | ; * complete description |
---|
| 89 | ; * remove return statement |
---|
| 90 | ; |
---|
[12] | 91 | ; - fplod 20101215T162933Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 92 | ; |
---|
| 93 | ; * graph correction |
---|
| 94 | ; |
---|
[8] | 95 | ; - fplod 20101215T093141Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 96 | ; |
---|
| 97 | ; * add graph in header |
---|
| 98 | ; |
---|
[6] | 99 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 100 | ; |
---|
| 101 | ; * minimal header |
---|
| 102 | ; |
---|
| 103 | ; - pbk 2008 |
---|
| 104 | ; |
---|
| 105 | ; * creation |
---|
| 106 | ; |
---|
| 107 | ;- |
---|
[5] | 108 | pro d2m_to_q2m_erai |
---|
[72] | 109 | ; |
---|
| 110 | @cm_4cal |
---|
| 111 | @cm_4data |
---|
| 112 | @cm_4mesh |
---|
| 113 | @cm_4data |
---|
| 114 | @cm_project |
---|
| 115 | ; |
---|
| 116 | ; test if ${PROJECT_OD} defined |
---|
| 117 | CASE project_od_env OF |
---|
| 118 | '' : BEGIN |
---|
| 119 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 120 | ras = report(msg) |
---|
| 121 | STOP |
---|
| 122 | END |
---|
| 123 | ELSE: BEGIN |
---|
| 124 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 125 | ras = report(msg) |
---|
| 126 | END |
---|
| 127 | ENDCASE |
---|
| 128 | ; |
---|
| 129 | ; check if output data will be possible |
---|
| 130 | iodirout = isadirectory(project_od_env) |
---|
| 131 | ; |
---|
| 132 | ; existence and protection for reading |
---|
| 133 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 134 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
| 135 | ras = report(msg) |
---|
| 136 | STOP |
---|
| 137 | ENDIF |
---|
| 138 | ; |
---|
| 139 | ; existence and protection for writing |
---|
| 140 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 141 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 142 | ras = report(msg) |
---|
| 143 | STOP |
---|
| 144 | ENDIF |
---|
| 145 | ; |
---|
[5] | 146 | d1=19881001 & d2=20101231 |
---|
[72] | 147 | ; |
---|
| 148 | ; build d2m filename |
---|
| 149 | filename_d2m='erai_d2m_19890101_20091231_oafluxgrid.nc' |
---|
| 150 | ; |
---|
| 151 | ; check if this file exists |
---|
| 152 | fullfilename_d2m = isafile(iodirout + filename_d2m, NEW=0, /MUST_EXIST) |
---|
| 153 | IF fullfilename_d2m[0] EQ '' THEN BEGIN |
---|
| 154 | msg = 'eee : the file ' + fullfilename_d2m + ' was not found.' |
---|
| 155 | ras = report(msg) |
---|
| 156 | STOP |
---|
| 157 | ENDIF |
---|
| 158 | ; |
---|
| 159 | ; build t2m filename |
---|
| 160 | filename_t2m='erai_t2m_19890101_20091231_oafluxgrid.nc' |
---|
| 161 | ; |
---|
| 162 | ; check if this file exists |
---|
| 163 | fullfilename_t2m = isafile(iodirout + filename_t2m, NEW=0, /MUST_EXIST) |
---|
| 164 | IF fullfilename_t2m[0] EQ '' THEN BEGIN |
---|
| 165 | msg = 'eee : the file ' + fullfilename_t2m + ' was not found.' |
---|
| 166 | ras = report(msg) |
---|
| 167 | STOP |
---|
| 168 | ENDIF |
---|
| 169 | ; |
---|
| 170 | ; build msl filename |
---|
| 171 | filename_msl='erai_msl_19890101_20091231_oafluxgrid.nc' |
---|
| 172 | ; |
---|
| 173 | ; check if this file exists |
---|
| 174 | fullfilename_msl = isafile(iodirout + filename_msl, NEW=0, /MUST_EXIST) |
---|
| 175 | IF fullfilename_msl[0] EQ '' THEN BEGIN |
---|
| 176 | msg = 'eee : the file ' + fullfilename_msl + ' was not found.' |
---|
| 177 | ras = report(msg) |
---|
| 178 | STOP |
---|
| 179 | ENDIF |
---|
| 180 | ; |
---|
| 181 | ; build output filename |
---|
| 182 | filename_out = 'q2m_erai_19890101_20091231_oafluxgrid.nc' |
---|
| 183 | fullfilename_out = iodirout + filename_out |
---|
| 184 | ; in order to avoid unexpected overwritten |
---|
| 185 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
| 186 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 187 | ras = report(msg) |
---|
| 188 | STOP |
---|
| 189 | ENDIF |
---|
| 190 | ; |
---|
| 191 | ; reading erai dew point temperature |
---|
| 192 | initncdf, fullfilename_d2m |
---|
| 193 | td=read_ncdf("d2m", d1,d2, file=fullfilename_d2m,/nostr) |
---|
[5] | 194 | |
---|
[72] | 195 | ; reading erai air temperature |
---|
| 196 | initncdf, fullfilename_t2m |
---|
| 197 | t=read_ncdf("t2m", d1,d2, file=fullfilename_t2m,/nostr) |
---|
[5] | 198 | tt=time &jpt=n_elements(time) |
---|
| 199 | help, t, td |
---|
| 200 | |
---|
| 201 | ;;since the t2m and d2m are already in K, no need for conversion |
---|
| 202 | |
---|
| 203 | e=es0*exp((25.e5/461.5)*((1/273.15)-(1/td))) |
---|
| 204 | es=es0*exp((25.e5/461.5)*((1/273.15)-(1/t))) |
---|
| 205 | |
---|
| 206 | rh=(e/es)*100 |
---|
| 207 | |
---|
| 208 | ;; conversion of relative humidity to sp. humidity |
---|
[6] | 209 | ;; Ref.1 - Gill, Appendix 4, |
---|
[5] | 210 | ;; Ref.2 - http://efdl.cims.nyu.edu/project_aomip/forcing_data/atmosphere/humidity.html |
---|
| 211 | |
---|
| 212 | t=t-273.15 |
---|
| 213 | |
---|
[72] | 214 | initncdf, fullfilename_msl |
---|
| 215 | P=read_ncdf("msl", d1, d2, file=fullfilename_msl,/nostr) |
---|
[5] | 216 | help, P |
---|
| 217 | q2m=rh_to_spechum(rh,t,P) |
---|
| 218 | |
---|
[72] | 219 | ;writing field |
---|
| 220 | ncfile='!' + fullfilename_out |
---|
[5] | 221 | time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time) |
---|
| 222 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
| 223 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
| 224 | |
---|
| 225 | |
---|
| 226 | tt=time-julday(1,1,1950,00,00,00) |
---|
| 227 | xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*)) |
---|
| 228 | valmask=1.e20 |
---|
| 229 | |
---|
| 230 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 231 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
| 232 | q2m_attr={units:'kg/kg',missing_value:valmask,long_name:'Surface specific humidity at 2m ',short_name:'q2m',axis:'TYX'} |
---|
| 233 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'} |
---|
| 234 | globattr={source:'Surface specific humidity at 2m calculated from dew point temperature',timerange:cda0+' - '+cda1} |
---|
| 235 | |
---|
| 236 | ncfields = 'q2m[longitude,latitude,time]=q2m:q2m_attr; ' $ |
---|
| 237 | + 'longitude[]=xlon:lon_attr; ' $ |
---|
| 238 | + 'latitude[]=ylat:lat_attr; ' $ |
---|
| 239 | + 'tt[*time]=tt:time_attr ' $ |
---|
| 240 | + ' @ globattr' |
---|
| 241 | |
---|
| 242 | @ncdf_quickwrite |
---|
| 243 | end |
---|