- Timestamp:
- 07/26/13 20:19:25 (11 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/change_creation_date.sh
r201 r202 33 33 # base location of the dataset to be changed 34 34 # 35 # Modify creation_date global attribute i fthe dataset based under dirin parameter35 # Modify creation_date global attribute in the dataset based under dirin parameter 36 36 # 37 37 # Log file is written on :file:`${PROJECT_LOG}/change_creation_date.sh.log.{YYYYMMDDTHHMMSSZ}` … … 83 83 # debug not used 84 84 # 85 # terminology march2013 non normative85 # terminology 1979_2013 hard coded 86 86 # 87 87 # EVOLUTIONS … … 246 246 suffix=1m 247 247 fi 248 filein=${dirin}/${period}/${var}_tropflux_${suffix}_1979_ march2013.nc248 filein=${dirin}/${period}/${var}_tropflux_${suffix}_1979_2013.nc 249 249 if [ ! -f ${filein} ] 250 250 then -
trunk/src/change_time_range.sh
r201 r202 37 37 # base location of the dataset to be changed 38 38 # 39 # Modify time_range global attribute i fthe dataset based under dirin parameter39 # Modify time_range global attribute in the dataset based under dirin parameter 40 40 # 41 41 # Log file is written on :file:`${PROJECT_LOG}/change_time_range.sh.log.{YYYYMMDDTHHMMSSZ}` … … 87 87 # debug not used 88 88 # 89 # terminology march2013 non normative89 # terminology 1979_2013 hardcoded 90 90 # 91 91 # build time period according to time in the file instead of parameter … … 257 257 suffix=1m 258 258 fi 259 filein=${dirin}/${period}/${var}_tropflux_${suffix}_1979_ march2013.nc259 filein=${dirin}/${period}/${var}_tropflux_${suffix}_1979_2013.nc 260 260 if [ ! -f ${filein} ] 261 261 then -
trunk/src/correct_terminology.sh
r199 r202 3 3 #+ 4 4 # 5 # .. program:: add_19890101.sh6 # 7 # .. _ add_19890101.sh:8 # 9 # ================== 10 # add_19890101.sh11 # ================== 5 # .. program:: correct_terminology.sh 6 # 7 # .. _correct_terminology.sh: 8 # 9 # ======================= 10 # correct_terminology.sh 11 # ======================= 12 12 # 13 13 # SYNOPSIS … … 16 16 # :: 17 17 # 18 # $ add_19890101.sh [--debug]18 # $ correct_terminology.sh [--debug] -good goodend -bad badend -d directory 19 19 # 20 20 # DESCRIPTION … … 25 25 # If this option is set, :samp:`ncdump -v tt` will be added to log file 26 26 # 27 # Artificialy add 19890101 to lwr interpolated on OAFLUX grid dataset. 28 # 29 # :file:`${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc` 30 # containing 31 # ++ 32 # has been produced by 33 # :func:`interp_erai_lwr`. 34 # repeat the first time step in 35 # 36 # File :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` 37 # will be written 38 # if this file not already exists. 39 # 40 # This output file 41 # :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` 42 # must be processed after by 43 # :func:`lwr_correction_ncdf`. 44 # 45 # Log file is written on :file:`${PROJECT_LOG}/add_19890101.sh.log.{YYYYMMDDTHHMMSSZ}` 27 # .. option:: -good goodend 28 # 29 # good end part of the name 30 # 31 # .. option:: -bad badend 32 # 33 # bad end part of the name 34 # 35 # .. option:: -d <dirin> 36 # 37 # base location of the dataset to be changed 38 # 39 # Modify filenames in the dataset based under dirin parameter 40 # 41 # Log file is written on :file:`${PROJECT_LOG}/correct_terminology.sh.log.{YYYYMMDDTHHMMSSZ}` 46 42 # 47 43 # .. graphviz:: 48 44 # 49 # digraph add_19890101 { 50 # 51 # filein [shape=ellipse,fontname=Courier,label="$PROJECT_OD/erai_lwr_19890102_20091231_oafluxgrid.nc"]; 52 # fileout [shape=ellipse,fontname=Courier,label="$PROJECT_OD/erai_lwr_19890101_20091231_oafluxgrid.nc"]; 53 # 54 # add_19890101 [shape=box, 45 # digraph correct_terminology { 46 # 47 # correct_terminology [shape=box, 55 48 # fontname=Courier, 56 49 # color=blue, 57 # URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/ add_19890101.sh",58 # label="${PROJECT}/src/ add_19890101.sh"];59 # 60 # {filein} -> { add_19890101} -> {fileout}50 # URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/correct_terminology.sh", 51 # label="${PROJECT}/src/correct_terminology.sh"]; 52 # 53 # {filein} -> {correct_terminology} -> {fileout} 61 54 # 62 55 # } … … 65 58 # ======== 66 59 # 67 # To produce $PROJECT_OD/erai_lwr_19890101_20091231_oafluxgrid.nc68 # from $PROJECT_OD/erai_lwr_19890102_20091231_oafluxgrid.nc::69 # 70 # $ add_19890101.sh --debug60 # To modify files under /usr/lodyc/incas/fplod/tropflux_d/to_be_published/ because files are not named 61 # :file:`var_tropflux_1d_${yyyy}_{yyyy}.nc` but :file:`var_tropflux_1d_{yyyy}_{month}{yyyy}.nc`:: 62 # 63 # $ correct_terminology.sh -d /usr/lodyc/incas/fplod/tropflux_d/to_be_published/ -good "1979_2013" -bad "1979_march2013" 71 64 # 72 65 # And look at log file with :: 73 66 # 74 # $ tlogd.sh add_19890101 75 # 76 # and of course on files in ${PROJECT_OD}. 77 # 78 # TIPS 79 # ==== 80 # 81 # To see the 3 first time values in input and files:: 82 # 83 # $ ncks -s "%16.10f\n" -v tt -d time,0,2 ${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc 84 # 14246.0000000005 85 # 14247.0000000005 86 # 14248.0000000005 87 # 88 # $ ncks -s "%16.10f\n" -v tt -d time,0,2 ${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc 89 # 14245.0000000005 90 # 14246.0000000005 91 # 14247.0000000005 92 # 93 # while : 94 # 95 # $ idl 96 # print, julday(01, 01, 1989,12)-julday(01, 01, 1950,0) 97 # 14245.500 98 # print, julday(01, 01, 1989,12)-julday(01, 01, 1950,0) +1 99 # 14246.500 67 # $ tlogd.sh correct_terminology 100 68 # 101 69 # SEE ALSO 102 70 # ======== 103 71 # 72 # :ref:`updatedata` 73 # 104 74 # :ref:`project_profile.sh` 105 #106 # :func:`ncks <nco:ncks>`107 # :func:`ncrcat <nco:ncrcat>`108 # :func:`ncatted <nco:ncatted>`109 # :func:`ncap2 <nco:ncap2>`110 #111 # :ref:`lwr_correction_ncdf.pro`112 75 # 113 76 # TODO … … 116 79 # coding rules 117 80 # 118 # won't it be more conveniant to add this articifial time step in 119 # the IDL creation tool interp_erai_lwr_1989_2009.pro. 120 # It will allow to avoid a shell interruption in the IDL processing chain. 121 # 122 # improve global attributes with ... creation_date and so on 123 # 124 # check if the first time step is really 19890102 in the input file 125 # 126 # change tt to ttt to complete time correction 127 # 128 # remove hard coded end time 129 # 130 # get rid of this long mesage on cratos:: 131 # 132 # ncrcat: WARNING Variable lwr has attribute "missing_value" but not "_FillValue". To 133 # comply with netCDF conventions, NCO ignores values that equal the _FillValue attribu 134 # te when performing arithmetic. Confusingly, values equal to the missing_value should 135 # also be neglected. However, it is tedious and (possibly) computationally expensive 136 # to check each value against multiple missing values during arithmetic on large varia 137 # bles. So NCO thinks that processing variables with a "missing_value" attribute and n 138 # o "_FillValue" attribute may produce undesired arithmetic results (i.e., where value 139 # s that were intended to be neglected were not, in fact, neglected). We suggest you r 140 # ename all "missing_value" attributes to "_FillValue" or include both "missing_value" 141 # and "_FillValue" attributes (with the _same values_) for all variables that have ei 142 # ther attribute. Because it is long, this message is only printed once per operator e 143 # ven though multiple variables may have the same attribute configuration. More inform 144 # ation on missing values is given at: 145 # http://nco.sf.net/nco.html#mss_val 146 # Examples of renaming attributes are at: 147 # http://nco.sf.net/nco.html#xmp_ncrename 148 # 149 # ... on a déjà une idee de la solution : convention CF et meilleure gestion des 150 # valeurs manquantes dans les softs IDL !!! 151 # 81 # overwrite : may be an other option to avoid scratch 82 # 83 # debug not used 84 # 85 # build file name according to time in the file instead of parameter 152 86 # 153 87 # EVOLUTIONS … … 158 92 # $URL$ 159 93 # 160 # - fplod 20110819T091143Z aedon.locean-ipsl.upmc.fr (Darwin) 161 # 162 # * creation from pk email 20110811 "lwr first timestep" 163 # * include time correction and timerange modificaton 94 # - fplod 20130726T112836Z cratos.locean-ipsl.upmc.fr (Linux) 95 # 96 # * creation 164 97 # 165 98 #- … … 191 124 log_date=$(date -u +"%Y%m%dT%H%M%SZ") 192 125 # 193 usage=" Usage : ${command} [--debug] "126 usage=" Usage : ${command} [--debug] -d dirin -good yyyymmdd_yyyymmdd -bad anything" 194 127 # 195 128 hostname=$(hostname) … … 209 142 do 210 143 case ${1} in 144 -good) 145 goodend=${2} 146 shift 147 ;; 148 -bad) 149 badend=${2} 150 shift 151 ;; 152 -d) 153 dirin=${2} 154 shift 155 ;; 211 156 --debug) 212 157 debug=1 … … 224 169 # 225 170 # check parameters 226 # N.A. 227 # 228 tool=ncrcat 229 type ${tool} 1> /dev/null 2>&1 230 status=${?} 231 if [ ${status} -ne 0 ] 232 then 233 echo "${command} : eee : tool ${tool} not found" 234 exit 1 235 fi 236 unset status 237 unset tool 238 # 239 tool=ncks 240 type ${tool} 1> /dev/null 2>&1 241 status=${?} 242 if [ ${status} -ne 0 ] 243 then 244 echo "${command} : eee : tool ${tool} not found" 245 exit 1 246 fi 247 unset status 248 unset tool 249 # 250 tool=ncatted 251 type ${tool} 1> /dev/null 2>&1 252 status=${?} 253 if [ ${status} -ne 0 ] 254 then 255 echo "${command} : eee : tool ${tool} not found" 256 exit 1 257 fi 258 unset status 259 unset tool 171 if [ ! -d ${dirin} ] 172 then 173 echo " eee : ${dirin} not found" 174 exit 1 175 fi 176 # 177 # check for permission on dirin 178 if [ ! -x ${dirin} ] 179 then 180 echo " eee : ${dirin} not reachable" 181 exit 1 182 fi 183 #++ check good validity 260 184 # 261 185 # check for ${PROJECT_LOG} definition 262 186 if [ "${PROJECT_LOG}" = "" ] 263 187 then 264 echo "${command} : eee : \${PROJECT_LOG} not defined"188 echo "${command} : ${LINENO} : eee : \${PROJECT_LOG} not defined" 265 189 exit 1 266 190 fi … … 297 221 echo "" 1>> ${log} 298 222 echo "[Parameters]" 1>> ${log} 299 echo "N.A." 1>> ${log} 223 echo "dirin=${dirin}" 1>> ${log} 224 echo "good=${goodend}" 1>> ${log} 225 echo "bad=${badend}" 1>> ${log} 300 226 echo "" 1>> ${log} 301 227 # 302 filein=${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc 303 if [ ! -f ${filein} ] 304 then 305 echo " eee : ${filein} not found" 1>> ${log} 306 exit 1 307 fi 308 fileout=${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc 309 if [ -f ${fileout} ] 310 then 311 echo "eee : ${fileout} already exists" 1>>${log} 312 exit 1 313 fi 314 # 315 rm -f ${PROJECT_OD}/erai_lwr_step19890101.nc 2> /dev/null 316 rm -f ${PROJECT_OD}/erai_lwr_step19890102.nc 2> /dev/null 317 # 318 # extraction of the first time step 19890102 319 ncks -h -d time,0,0 ${filein} ${PROJECT_OD}/erai_lwr_step19890102.nc >> ${log} 2>&1 320 status=${?} 321 if [ ${status} -ne 0 ] 322 then 323 echo "eee : pb with ncks" >> ${log} 2>&1 324 ncdump -h ${filein} >> ${log} 2>&1 325 exit 1 326 fi 327 unset status 328 # 329 # ++ check if tt[0] is really 19890102 330 # 331 # substract 1 to tt to simulate 19890101 332 ncap2 -h -s "tt=tt-1" \ 333 ${PROJECT_OD}/erai_lwr_step19890102.nc \ 334 ${PROJECT_OD}/erai_lwr_step19890101.nc 335 status=${?} 336 if [ ${status} -ne 0 ] 337 then 338 echo "eee : pb with ncap2" >> ${log} 2>&1 339 ncdump -h ${PROJECT_OD}/erai_lwr_step19890102.nc >> ${log} 2>&1 340 exit 1 341 fi 342 unset status 343 ls -l ${PROJECT_OD}/erai_lwr_step19890102.nc >> ${log} 2>&1 344 ls -l ${PROJECT_OD}/erai_lwr_step19890101.nc >> ${log} 2>&1 345 # 346 # ++ check if tt[0] is really 19890101 347 # 348 rm ${fileout}_bad_timerange 2> /dev/null 349 ncrcat -h \ 350 ${PROJECT_OD}/erai_lwr_step19890101.nc \ 351 ${filein} \ 352 ${fileout}_bad_timerange >> ${log} 2>&1 353 status=${?} 354 if [ ${status} -ne 0 ] 355 then 356 echo "eee : pb with ncrcat" >> ${log} 2>&1 357 ncdump -h ${PROJECT_OD}/erai_lwr_step19890101.nc >> ${log} 2>&1 358 ncdump -h ${filein} >> ${log} 2>&1 359 exit 1 360 fi 361 unset status 362 # 363 ncatted -h -a timerange,global,o,c,"19890101 - 20091231" \ 364 ${fileout}_bad_timerange \ 365 ${fileout} >> ${log} 2>&1 366 status=${?} 367 if [ ${status} -ne 0 ] 368 then 369 echo "eee : pb with ncatted" >> ${log} 2>&1 370 ncdump -h ${fileout}_bad_timerange >> ${log} 2>&1 371 exit 1 372 fi 373 unset status 374 # 375 if [ ${debug} -eq 1 ] 376 then 377 ncdump -v tt ${fileout} >> ${log} 2>&1 378 fi 228 # build list files 229 varlist="lhf lwr netflux q2m shf sst swr t2m tau taux tauy ws" 230 period_list="daily monthly" 231 list_filein="" 232 for var in $varlist 233 do 234 for period in ${period_list} 235 do 236 if [ "${period}" == "daily" ] 237 then 238 suffix=1d 239 else 240 suffix=1m 241 fi 242 filein=${dirin}/${period}/${var}_tropflux_${suffix}_${badend}.nc 243 if [ ! -f ${filein} ] 244 then 245 echo " eee : ${filein} not found" 1>> ${log} 246 exit 1 247 else 248 list_filein=${list_filein}" ${filein}" 249 fi 250 done 251 unset period 252 done 253 unset period_list 254 unset var 255 unset varlist 256 # 257 # rename all files 258 for filein in ${list_filein} 259 do 260 echo "iii : rename ${filein}" >> ${log} 2>&1 261 bfileout=$(basename ${filein} ${badend}.nc)"${goodend}.nc" 262 fileout=$(dirname ${filein})/${bfileout} 263 unset bfileout 264 mv ${filein} ${fileout} >> ${log} 2>&1 265 status=${?} 266 if [ ${status} -ne 0 ] 267 then 268 echo "eee : pb with mv" >> ${log} 2>&1 269 ncdump -h ${filein} >> ${log} 2>&1 270 exit 1 271 fi 272 unset status 273 unset fileout 274 done 275 unset filein 379 276 # 380 277 # cleanning 381 #++rm -f ${PROJECT_OD}/erai_lwr_step19890101.nc 2> /dev/null 382 #++rm -f ${PROJECT_OD}/erai_lwr_step19890102.nc 2> /dev/null 383 #++rm -f ${PROJECT_OD}/${fileout}_bad_timerange 2> /dev/null 384 # 385 unset fileout 386 unset filein 278 #++ 387 279 #++ set 388 280 # end
Note: See TracChangeset
for help on using the changeset viewer.