Changeset 202 for trunk/src


Ignore:
Timestamp:
07/26/13 20:19:25 (11 years ago)
Author:
pinsard
Message:

end of 20130725 update data

Location:
trunk/src
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/change_creation_date.sh

    r201 r202  
    3333#    base location of the dataset to be changed 
    3434# 
    35 # Modify creation_date global attribute if the dataset based under dirin parameter 
     35# Modify creation_date global attribute in the dataset based under dirin parameter 
    3636# 
    3737# Log file is written on :file:`${PROJECT_LOG}/change_creation_date.sh.log.{YYYYMMDDTHHMMSSZ}` 
     
    8383# debug not used 
    8484# 
    85 # terminology march2013 non normative 
     85# terminology 1979_2013 hard coded 
    8686# 
    8787# EVOLUTIONS 
     
    246246            suffix=1m 
    247247         fi 
    248          filein=${dirin}/${period}/${var}_tropflux_${suffix}_1979_march2013.nc 
     248         filein=${dirin}/${period}/${var}_tropflux_${suffix}_1979_2013.nc 
    249249         if [ ! -f ${filein} ] 
    250250         then 
  • trunk/src/change_time_range.sh

    r201 r202  
    3737#    base location of the dataset to be changed 
    3838# 
    39 # Modify time_range global attribute if the dataset based under dirin parameter 
     39# Modify time_range global attribute in the dataset based under dirin parameter 
    4040# 
    4141# Log file is written on :file:`${PROJECT_LOG}/change_time_range.sh.log.{YYYYMMDDTHHMMSSZ}` 
     
    8787# debug not used 
    8888# 
    89 # terminology march2013 non normative 
     89# terminology 1979_2013 hardcoded 
    9090# 
    9191# build time period according to time in the file instead of parameter 
     
    257257            suffix=1m 
    258258         fi 
    259          filein=${dirin}/${period}/${var}_tropflux_${suffix}_1979_march2013.nc 
     259         filein=${dirin}/${period}/${var}_tropflux_${suffix}_1979_2013.nc 
    260260         if [ ! -f ${filein} ] 
    261261         then 
  • trunk/src/correct_terminology.sh

    r199 r202  
    33#+ 
    44# 
    5 # .. program:: add_19890101.sh 
    6 # 
    7 # .. _add_19890101.sh: 
    8 # 
    9 # ================== 
    10 # add_19890101.sh  
    11 # ================== 
     5# .. program:: correct_terminology.sh 
     6# 
     7# .. _correct_terminology.sh: 
     8# 
     9# ======================= 
     10# correct_terminology.sh 
     11# ======================= 
    1212# 
    1313# SYNOPSIS 
     
    1616# :: 
    1717# 
    18 #  $ add_19890101.sh [--debug] 
     18#  $ correct_terminology.sh [--debug] -good goodend -bad badend -d directory 
    1919# 
    2020# DESCRIPTION 
     
    2525#    If this option is set, :samp:`ncdump -v tt` will be added to log file 
    2626# 
    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}` 
    4642# 
    4743#     .. graphviz:: 
    4844# 
    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, 
    5548#           fontname=Courier, 
    5649#           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} 
    6154# 
    6255#       } 
     
    6558# ======== 
    6659# 
    67 # To produce $PROJECT_OD/erai_lwr_19890101_20091231_oafluxgrid.nc  
    68 # from $PROJECT_OD/erai_lwr_19890102_20091231_oafluxgrid.nc :: 
    69 # 
    70 #  $ add_19890101.sh --debug 
     60# 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" 
    7164# 
    7265# And look at log file with :: 
    7366# 
    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 
    10068# 
    10169# SEE ALSO 
    10270# ======== 
    10371# 
     72# :ref:`updatedata` 
     73# 
    10474# :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` 
    11275# 
    11376# TODO 
     
    11679# coding rules 
    11780# 
    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 
    15286# 
    15387# EVOLUTIONS 
     
    15892# $URL$ 
    15993# 
    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 
    16497# 
    16598#- 
     
    191124log_date=$(date -u +"%Y%m%dT%H%M%SZ") 
    192125# 
    193 usage=" Usage : ${command} [--debug]" 
     126usage=" Usage : ${command} [--debug] -d dirin -good yyyymmdd_yyyymmdd -bad anything" 
    194127# 
    195128hostname=$(hostname) 
     
    209142do 
    210143   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      ;; 
    211156      --debug) 
    212157         debug=1 
     
    224169# 
    225170# 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 
     171if [ ! -d ${dirin} ] 
     172then 
     173   echo " eee : ${dirin} not found" 
     174   exit 1 
     175fi 
     176# 
     177# check for permission on dirin 
     178if [ ! -x ${dirin} ] 
     179then 
     180   echo " eee : ${dirin} not reachable" 
     181   exit 1 
     182fi 
     183#++ check good validity 
    260184# 
    261185# check for ${PROJECT_LOG} definition 
    262186if [ "${PROJECT_LOG}" = "" ] 
    263187then 
    264    echo "${command} : eee : \${PROJECT_LOG} not defined" 
     188   echo "${command} : ${LINENO} : eee : \${PROJECT_LOG} not defined" 
    265189   exit 1 
    266190fi 
     
    297221echo "" 1>> ${log} 
    298222echo "[Parameters]" 1>> ${log} 
    299 echo "N.A." 1>> ${log} 
     223echo "dirin=${dirin}" 1>> ${log} 
     224echo "good=${goodend}" 1>> ${log} 
     225echo "bad=${badend}" 1>> ${log} 
    300226echo "" 1>> ${log} 
    301227# 
    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 
     229varlist="lhf lwr netflux q2m shf sst swr t2m tau taux tauy ws" 
     230period_list="daily monthly" 
     231list_filein="" 
     232for var in $varlist 
     233do 
     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 
     252done 
     253unset period_list 
     254unset var 
     255unset varlist 
     256# 
     257# rename all files 
     258for filein in ${list_filein} 
     259do 
     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 
     274done 
     275unset filein 
    379276# 
    380277# 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#++ 
    387279#++ set 
    388280# end 
Note: See TracChangeset for help on using the changeset viewer.