Changeset 33 for trunk


Ignore:
Timestamp:
02/03/11 10:39:51 (13 years ago)
Author:
pinsard
Message:

revisiting compute_erai_daily_region_2d.sh : allow cdo instead of ncflint (to be cont.)

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/compute_erai_daily_region_2d.sh

    r32 r33  
    1616# :: 
    1717# 
    18 #  $ compute_erai_daily_region_2d.sh 
     18#  $ compute_erai_daily_region_2d.sh [--debug] [--diff_cmd arg] 
    1919# 
    2020# DESCRIPTION 
    2121# =========== 
     22# 
     23# .. option:: --diff_cmd <arg> 
     24# 
     25#    by default :samp:`ncflint` command is used to compute difference between NetCDF files 
     26# 
     27#    if :samp:`cdo` is specified here, this command will be used instead. 
     28# 
     29# .. option:: --debug 
     30# 
     31#    if this option is set, :samp:`ncdump -v time` will be added to log file 
     32# 
    2233# 
    2334# Put in ${TROPFLUX_ID} ERA-Intermin reference files 
     
    3142#           rankdir="LR", 
    3243#           ] 
    33 #           filein_str [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/FC_SF/yyyy/mm/str.yyyymmdd*"]; 
    34 #           filein_msl [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/msl.yyyymm.ashei.GLOBAL_075.nc"]; 
    35 #           filein_sstk [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/sstk.yyyymm.ashei.GLOBAL_075.nc"]; 
    36 #           filein_t2 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/t2.yyyymm.ashei.GLOBAL_075.nc"]; 
    37 #           filein_d2 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/d2.yyyymm.ashei.GLOBAL_075.nc"]; 
    38 #           filein_u10 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/u10.yyyymm.ashei.GLOBAL_075.nc"]; 
    39 #           filein_v10 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/v10.yyyymm.ashei.GLOBAL_075.nc"]; 
     44#           filein_str [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/FC_SF/yyyy/mm/str.yyyymmdd.fshei.GLOBAL_075.nc"]; 
     45#           filein_msl [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/msl.yyyymm.ashei.GLOBAL_075.nc"]; 
     46#           filein_sstk [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/sstk.yyyymm.ashei.GLOBAL_075.nc"]; 
     47#           filein_t2 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/t2.yyyymm.ashei.GLOBAL_075.nc"]; 
     48#           filein_d2 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/d2.yyyymm.ashei.GLOBAL_075.nc"]; 
     49#           filein_u10 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/u10.yyyymm.ashei.GLOBAL_075.nc"]; 
     50#           filein_v10 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/v10.yyyymm.ashei.GLOBAL_075.nc"]; 
    4051# 
    4152#           fileout_str [shape=ellipse,fontname=Courier,label="${TROPFLUX_ID}/erai_TROP_1d_yyyy0101_yyyy1231_str_gridOrig.nc"]; 
     
    101112# ==== 
    102113# 
     114# add cdo reference 
     115# 
     116# minimize use of generic characters (*) to avoid ambiguity 
     117# 
    103118# parametrisation of year min and year max 
    104119# 
    105 # explication on ncflint arguments 
    106 # 
    107120# split get and process files 
    108121# 
    109122# coding rules 
    110123# 
    111 # correction of min and max of latitude field (still -90,+90 !) 
     124# correction of min and max values of latitude attributes (still -90,+90 !) in output files 
    112125# 
    113126# are cmonthmin and cmonthmax the real info to put in output file name ? may be not because if input files do not exist 
    114127# 
     128# same idea for day min and max - some time hard coded with 01 or 31 (avoid yyyy0231 !!) 
    115129# 
    116130# solve this kind of warning:: 
     
    118132#  ncrcat: WARNING Intra-file non-monotonicity. Record coordinate "time" does not monotonically decrease between (input file /homedata/pinsard/log//compute_erai_daily_region_2d.20110126T154235Z.temp//temp_int_str_199012.nc record indices: 29, 30) (output file /homedata/pinsard/tropflux_d//erai_TROP_1d_19900101_19901231_str_gridOrig.nc record indices 363, 364) record coordinate values -0.000278, -0.000278 
    119133# 
     134 
     135#  this seems to be solved by using cdo instead of ncflint. to be confirmed ! 
     136# 
     137# 
     138# no files *19890101* in /bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/FC_SF/1989/01/ : 
     139# is it normal ? 
     140# 
     141# check units of str :: 
     142# 
     143#     str:long_name = "Surface thermal radiation" ; 
     144#     str:units = "W/m^2 s"  
     145#  
     146# still true after ncflint/cdo arithmetic ? 
     147# 
     148# Modify global attributes : Still CF ? no more "five time values per day " in Forecast attributes 
     149# 
     150# enrich info in log file 
    120151# 
    121152# EVOLUTIONS 
    122153# ========== 
     154# 
     155# $URL$ 
     156# 
     157# - pinsard 2011-02-02T16:11:07Z loholt1.ipsl.polytechnique.fr (Linux) 
     158# 
     159#   * add parameter --debug 
     160#   * add parameter --diff_cmd to choose between ncflint and cdo 
     161#   * usage of :samp:`cdo sub` and :samp: cdo divc,86400.` if parameter --diff_cmd is set to cdo 
     162#     thanks to https://code.zmaw.de/embedded/cdo/1.4.7/cdo.html#x1-2280002.7.4 
     163#   * add natural language explanation on ncflit usage provided by Matthieu 
     164# 
     165# - fplod 20110127T142038Z 
     166# 
     167#   * correction of path of input files in header 
    123168# 
    124169# - fplod 20110126T132641Z 
     
    174219log_date=$(date -u +"%Y%m%dT%H%M%SZ") 
    175220# 
    176 usage=" Usage : ${command}" 
     221usage=" Usage : ${command} --debug --diff_cmd [ncflint|cdo]" 
    177222# 
    178223hostname=$(hostname) 
    179224# default 
    180 # N.A. because no parameters 
     225diff_cmd=ncflint 
     226debug=0 
     227# 
     228minargcount=0 
     229if [ ${#} -lt ${minargcount} ] 
     230then 
     231   echo "${command} : eee : not enought arguments" 
     232   echo "${usage}" 
     233   exit 1 
     234fi 
     235# 
     236set +u 
     237while [ ! -z "${1}" ] 
     238do 
     239   case ${1} in 
     240      --debug) 
     241         debug=1 
     242      ;; 
     243      --diff_cmd) 
     244         diff_cmd=${2} 
     245         shift 
     246      ;; 
     247      *) 
     248        # anything else 
     249        echo "${command} : eee : unknown option ${1}" 
     250        echo "${command} : eee : ${usage}" 
     251        exit 1 
     252      ;; 
     253   esac 
     254   # next flag 
     255   shift 
     256done 
    181257# 
    182258set -u 
    183 # 
     259# test if diff_cmd valid 
     260case ${diff_cmd} in 
     261   ncflint) 
     262      # test if ncflint available 
     263      tool=ncflint 
     264      type ${tool} 1> /dev/null 2>&1 
     265      status=${?} 
     266      if [ ${status} -ne 0 ] 
     267      then 
     268         echo "${command} : eee : ${tool} not found" 
     269         exit 1 
     270      fi 
     271      unset status 
     272   ;; 
     273   cdo) 
     274      # test if cdo available 
     275      tool=cdo 
     276      type ${tool} 1> /dev/null 2>&1 
     277      status=${?} 
     278      if [ ${status} -ne 0 ] 
     279      then 
     280         echo "${command} : eee : ${tool} not found" 
     281         exit 1 
     282      fi 
     283      unset status 
     284   ;; 
     285   *) 
     286      echo "${command} : eee : diff_cmd ${diff_cmd} argument invalid" 
     287      exit 1 
     288esac 
     289 
    184290# check for ${TROPFLUX_LOG} definition 
    185291if [ "${TROPFLUX_LOG}" = "" ] 
     
    219325echo "runtime=${log_date}" 1>> ${log} 
    220326unset log_date 
     327# 
    221328echo "" 1>> ${log} 
     329echo "[Parameters]" 1>> ${log} 
     330echo "diff_cmd=${diff_cmd}" 1>> ${log} 
     331echo "" 1>> ${log} 
     332# 
    222333# 
    223334minlat=-36. 
     
    262373         do 
    263374            cday=$(printf "%2.2d" ${day}) 
    264             if [ -f ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}* ] 
     375            if [ -f ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}.fshei.GLOBAL_075.nc ] 
    265376            then 
    266                ncpdq -U ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}* ${dirtemp}/${var}.${yyyy}${cmonth}${cday}.temp.GLOBAL_075.nc 
     377               if [ ${debug} -eq 1 ] 
     378               then 
     379                  ncdump -v time ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}.fshei.GLOBAL_075.nc >> ${log} 2>&1 
     380               fi 
     381               ncpdq -U ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}.fshei.GLOBAL_075.nc ${dirtemp}/${var}.${yyyy}${cmonth}${cday}.temp.GLOBAL_075.nc 
     382               if [ ${debug} -eq 1 ] 
     383               then 
     384                  ncdump -v time ${dirtemp}/${var}.${yyyy}${cmonth}${cday}.temp.GLOBAL_075.nc >> ${log} 2>&1 
     385               fi 
    267386            else 
    268387               echo "${command} : iii : no files ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}*" >> ${log} 
     
    273392         if [ "${exist_temp_files}" != "" ] 
    274393         then 
    275             ncrcat -O ${dirtemp}/${var}.${yyyy}${cmonth}*temp* ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc 
    276             rm ${dirtemp}/${var}.${yyyy}${cmonth}*temp* 2> /dev/null 
     394            # concatenation of daily files 
     395            ncrcat -O ${dirtemp}/${var}.${yyyy}${cmonth}??.temp.GLOBAL_075.nc ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc 
     396            if [ ${debug} -eq 1 ] 
     397            then 
     398               ncdump -v time ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc >> ${log} 2>&1 
     399            fi 
     400            rm ${dirtemp}/${var}.${yyyy}${cmonth}??.temp.GLOBAL_075.nc 2> /dev/null 
    277401            ncks -d lat,${minlat},${maxlat} -d lon,${minlon},${maxlon} -d time,0,,5 ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc ${dirtemp}/temp_time0.nc 
     402            if [ ${debug} -eq 1 ] 
     403            then 
     404               ncdump -v time ${dirtemp}/temp_time0.nc >> ${log} 2>&1 
     405            fi 
    278406            ncks -d lat,${minlat},${maxlat} -d lon,${minlon},${maxlon} -d time,4,,5 ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc ${dirtemp}/temp_time4.nc 
    279             ncflint -w 1.1574074,-1.1574074 ${dirtemp}/temp_time0.nc ${dirtemp}/temp_time4.nc ${dirtemp}/temp_time.nc 
    280             ncflint -w 0.00001,0.0 ${dirtemp}/temp_time.nc ${dirtemp}/temp_time.nc ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc 
     407            if [ ${debug} -eq 1 ] 
     408            then 
     409               ncdump -v time ${dirtemp}/temp_time4.nc >> ${log} 2>&1 
     410            fi 
     411            case "${diff_cmd}" in 
     412               ncflint) 
     413                  # différence entre les forcast a 36 et a 12h (pour avoir des flux par jour) et la constante suivant le -w permet de se ramener a des unites connues 
     414                  ncflint -w 1.1574074,-1.1574074 ${dirtemp}/temp_time0.nc ${dirtemp}/temp_time4.nc ${dirtemp}/temp_time.nc 
     415                  if [ ${debug} -eq 1 ] 
     416                  then 
     417                      ncdump -v time ${dirtemp}/temp_time.nc >> ${log} 2>&1 
     418                  fi 
     419                  # La deuxieme permet uniquement de passer en seconde. 1.1574074*.00001=1/86400. (jour a seconde) 
     420                  ncflint -w 0.00001,0.0 ${dirtemp}/temp_time.nc ${dirtemp}/temp_time.nc ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc 
     421                  if [ ${debug} -eq 1 ] 
     422                  then 
     423                     ncdump -v time ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc >> ${log} 2>&1 
     424                  fi 
     425               ;; 
     426               cdo) 
     427                  cdo sub ${dirtemp}/temp_time0.nc ${dirtemp}/temp_time4.nc ${dirtemp}/temp_time.nc >> ${log} 2>&1 
     428                  if [ ${debug} -eq 1 ] 
     429                  then 
     430                     ncdump -v time ${dirtemp}/temp_time.nc >> ${log} 2>&1 
     431                  fi 
     432                  cdo divc,86400. ${dirtemp}/temp_time.nc ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc >> ${log} 2>&1 
     433                  if [ ${debug} -eq 1 ] 
     434                  then 
     435                     ncdump -v time ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc >> ${log} 2>&1 
     436                  fi 
     437               ;; 
     438            esac 
    281439            rm ${dirtemp}/temp_time* 2> /dev/null 
    282440            rm ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc 2> /dev/null 
     
    287445         month=$(( ${month} + 1 )) 
    288446      done 
    289       ncrcat -O ${dirtemp}/temp_int_${var}_${yyyy}* ${TROPFLUX_ID}/erai_${reg}_1d_${yyyy}${cmonthmin}01_${yyyy}${cmonthmax}31_${var}_gridOrig.nc 
     447      # concatenation of monthly files 
     448      if [ ${debug} -eq 1 ] 
     449      then 
     450         ncdump -v time ${dirtemp}/temp_int_${var}_${yyyy}??.nc 1>> ${log} 2>&1 
     451      fi 
     452      ncrcat -O ${dirtemp}/temp_int_${var}_${yyyy}??.nc ${TROPFLUX_ID}/erai_${reg}_1d_${yyyy}${cmonthmin}01_${yyyy}${cmonthmax}31_${var}_gridOrig.nc 1>> ${log} 2>&1 
    290453      rm ${dirtemp}/temp_int_${var}_${yyyy}* 2> /dev/null 
    291454      yyyy=$(( ${yyyy} + 1 )) 
     
    307470      do 
    308471         cmonth=$(printf "%2.2d" ${month}) 
    309          if [ -f ${dirin}/AN_SF/${yyyy}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ]  
     472         if [ -f ${dirin}/AN_SF/${yyyy}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ] 
    310473         then 
    311474            ncpdq -U ${dirin}/AN_SF/${yyyy}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ${dirtemp}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc 
     
    322485          fi 
    323486      done 
    324       ncrcat -O ${dirtemp}/temp_int_${yyyy}* ${TROPFLUX_ID}/erai_${reg}_1d_${yyyy}${cmonthmin}01_${yyyy}${cmonthmax}31_${var}_gridOrig.nc 
     487      # concatenation of monthly files 
     488      if [ ${debug} -eq 1 ] 
     489      then 
     490         ncdump -v time ${dirtemp}/temp_int_${yyyy}??.nc >> ${log} 2>&1 
     491      fi 
     492      ncrcat -O ${dirtemp}/temp_int_${yyyy}??.nc ${TROPFLUX_ID}/erai_${reg}_1d_${yyyy}${cmonthmin}01_${yyyy}${cmonthmax}31_${var}_gridOrig.nc >> ${log} 2>&1 
    325493      rm ${dirtemp}/temp_int_${yyyy}* 2> /dev/null 
    326494      yyyy=$(( ${yyyy} + 1 )) 
    327495   done 
    328496done 
    329 # 
     497# debug to check if clean is done 
     498if [ ${debug} -eq 1 ] 
     499then 
     500   ls ${dirtemp}/  >> ${log} 2>&1 
     501fi 
    330502# end 
    331503exit 0 
  • trunk/src/get_oaflux.sh

    r16 r33  
    7777# 
    7878# :ref:`tropflux_profile.sh` 
     79# 
     80# :ref:`oaflux_mask_30N30S.pro` 
    7981# 
    8082# EVOLUTIONS 
  • trunk/src/interp_erai_t2m_1989_2009.pro

    r27 r33  
    318318 
    319319 
    320 ncfields = 't2m[longitude,latitude,time]=t2mout:t2m_attr; ' $ 
    321                       + 'longitude[]=lon:lon_attr; ' $ 
    322                       + 'latitude[]=lat:lat_attr; ' $ 
    323                       + 'time[*time]=timein:time_attr ' $ 
    324                       + ' @ globattr' 
    325  
     320help, t2mout 
     321help, timein 
     322;ncfields = 't2m[longitude,latitude,*time]=t2mout:t2m_attr; ' $ 
     323;                      + 'longitude[]=lon:lon_attr; ' $ 
     324;                      + 'latitude[]=lat:lat_attr; ' $ 
     325;                     + 'time[]=timein:time_attr ' $ 
     326;                      + ' @globattr' 
     327 
     328; ok ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr' 
     329; ok ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timein:time_attr' 
     330; ok ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[*]=timein:time_attr' 
     331; ok ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[*]=timein:time_attr@globattr' 
     332; pas ok ncfields = 't2m[longitude,latitude,*time]=t2mout:t2m_attr;longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[*]=timein:time_attr@globattr' 
     333; pas ok  ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[*]=timein:time_attr;t2m[longitude,latitude,*time]=t2mout:t2m_attr@globattr' 
     334 
     335; the simpliest one 
     336nlat=73 
     337nlon=96 
     338latitudetp=findgen(nlat) 
     339longitudetp=findgen(nlon) 
     340timetp=findgen(2) 
     341pressure3d=findgen(nlon,nlat,2) 
     342patts = {units:'pascal',missing_value:1e10} 
     343globatts={source:'my program',version:2} 
     344NCFIELDS = 'pressure3d[longitudetp,latitudetp,*timetp]=pressure3d:patts;longitudetp[];latitudetp[];timetp[]@globatts' 
     345ncfile='my4.nc' 
    326346@ncdf_quickwrite 
    327347 
     348timepb=findgen(2) 
     349t2m=findgen(350,60,2) 
     350help, lat 
     351help, lon 
     352help, t2m  
     353help, time 
     354help, timein 
     355help, timepb 
     356ncfile='!' + fullfilename_out 
     357; pas ok ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timein:time_attr;t2m[longitude,latitude,*time]' 
     358; pas ok ncfields = 't2m[longitude,latitude,*time];longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timein:time_attr' 
     359; ok avec timepb=findgen(2) ncfields = 't2m[longitude,latitude,*time];longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timepb:time_attr' 
     360; ok 
     361;timepb=findgen(2) 
     362;timepb[0]=280512. 
     363;timepb[1]=280536. 
     364;ncfields = 't2m[longitude,latitude,*time];longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timepb:time_attr' 
     365 
     366timepb=findgen(7670) 
     367ncfields = 't2m[longitude,latitude,*time];longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timepb:time_attr' 
     368@ncdf_quickwrite 
     369 
    328370 
    329371end 
  • trunk/src/test/read.jnl

    r31 r33  
    3030! ======== 
    3131! 
    32 ! matlab/octave similar program 
    33 ! 
    34 ! :ref:`read.m` 
     32! matlab/octave similar program : :ref:`read.m` 
    3533!  
     34! IDL+SAXO similar program : :ref:`read.pro` 
    3635! 
    3736! TODO 
Note: See TracChangeset for help on using the changeset viewer.