Changeset 4109


Ignore:
Timestamp:
11/06/18 17:14:39 (3 years ago)
Author:
cugnet
Message:

Available datasets list on ciclad extended.
Scripts slightly modified to accomodate more ways of cutting a time serie into several time slices.

Location:
TOOLS/CMIP6_FORCING/OZONE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/CMIP6_FORCING/OZONE/clims_CMIP6.bash

    r3870 r4109  
    44#=== Indices of chosen datasets among available collection (see DATANAMES after) 
    55DOPROCESS=('n' 'y')          #--- PROCESSED DATA TYPES (SSTandSeaIce, ozone) 
    6 IXPROCESS=("0" "5 6 7")      #--- PROCESSED DATASETS INDICES 
     6IXPROCESS=("0" "1 2 3 4")    #--- PROCESSED DATASETS INDICES 
    77recomp='n'                   #--- RECOMPUTE FILES THAT ARE ALREADY PRESENT (y/n) 
    88 
     
    3131esac 
    3232if [ "$DATAIN" = "" ]; then echo "Raw data folder for $machine has to be specified."; exit; fi 
    33 # DATAOU=/data/dcugnet$DATAOU  # No write acces to $DATAOU => temporary storage space. 
     33 DATAOU=/data/dcugnet$DATAOU  # No write acces to $DATAOU => temporary storage space. 
    3434 
    3535#--- DATA TO TREAT (INTERANNUAL AND CLIMATOLOGIES): "SSTsAndSeaIce" "ozone": 
     
    4242           input4MIPs/CMIP6/CMIP/PCMDI/PCMDI-AMIP-1-1-4/ocean/mon/\${var}/gn/v20180427/$f" \ 
    4343          "input4MIPs/CMIP6/CMIP/UReading/UReading-CCMI-1-0/atmos/mon/\${var}/gn/v20160711/$f   \ 
     44           input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-ssp126-1-0/atmos/mon/\${var}/gn/v20181101/$f \ 
     45           input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-ssp245-1-0/atmos/mon/\${var}/gn/v20181101/$f \ 
     46           input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-ssp370-1-0/atmos/mon/\${var}/gn/v20181101/$f \ 
     47           input4MIPs/CMIP6/ScenarioMIP/UReading/UReading-CCMI-ssp585-1-0/atmos/mon/\${var}/gn/v20181101/$f \ 
    4448           input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-stratO3-1-0/atmos/mon/\${var}/gn/v20170814/$f \ 
    4549           input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-nat-1-0/atmos/mon/\${var}/gn/v20180503/$f     \ 
     
    4852           input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-sol-1-1/atmos/mon/\${var}/gn/v20180525/$f     \ 
    4953           input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-nat-1-1/atmos/mon/\${var}/gn/v20180525/$f     \ 
    50            input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-volc-1-1/atmos/mon/\${var}/gn/v20180525/$f") 
     54           input4MIPs/CMIP6/DAMIP/CCCma/CCMI-hist-volc-1-1/atmos/mon/\${var}/gn/v20180525/$f    \ 
     55           input4MIPs/CMIP6/DAMIP/CCCma/CCMI-ssp245-nat-1-0/atmos/mon/\${var}/gn/v20180820/$f") 
    5156CLIMS_IN=("/ / / / /" \ 
    52           "input4MIPs/CMIP6/CMIP/UReading/UReading-CCMI-1-0/atmos/monC/\${var}/gn/v20160830/$f  /  /  /  /") 
     57          "input4MIPs/CMIP6/CMIP/UReading/UReading-CCMI-1-0/atmos/monC/\${var}/gn/v20160830/$f  /  /  /  / /") 
    5358VARNAM_IN=('tosbcs siconcbcs' 'vmro3') 
    5459DIRSTRUCT='datasets/exercise/project/origin/dataset/domain/frequency/var/grid/version/' 
     
    7984  date=(${DATADATES[$i]}); fin=($fin); if [ ${DOPROCESS[$i]} != 'y' ]; then continue; fi 
    8085  echo ">> Chosen $dt:" 
    81   for ka in ${IXPROCESS[$i]}; do echo "  * ${fin[$ka]%/*} (${date[$ka]%-*})"; done 
     86  for ka in ${IXPROCESS[$i]}; do d=${date[$ka]}; dy=${d%%-*}; d=${d#*-} 
     87    echo "  * ${fin[$ka]%/*} (${dy}-${d%%-*})" 
     88  done 
    8289done 
    8390 
     
    8794  if [ ${DOPROCESS[$i]} != 'y' ]; then continue; fi 
    8895     dt=${DATATYPES[$i]}                                   #=== SSTAndSeaIce, ozone... 
    89     fin=(${FILES_IN[$i]}); vin=(${VARNAM_IN[$i]})          #=== INPUT FILE/VAR NAMES (each version) 
     96    fin=(${FILES_IN[$i]}); vin=(${VARNAM_IN[$i]})          #===  INPUT FILE/VAR NAMES (each version) 
    9097     fou=${FILES_OU[$i]} ; vou=(${VARNAM_OU[$i]})          #=== OUTPUT FILE/VAR NAMES (single pair) 
    9198  date=(${DATADATES[$i]})                                  #=== ${Yb}-${Ye}-${dY} 
     
    96103  #================================================================================ 
    97104    parse_dir ${fin[$is]} $DIRSTRUCT $ex                   #--- Parse input directory 
    98     dso=$dataset                                           #--- For naming purpose 
    99     case $dt in                                            #--- NAMING EXCEPTIONS 
    100       ozone) dso=${dso#*hist-}; dso=hist-${dso%%-*} 
    101                     if [ "$dataset" = "UReading-CCMI-1-0" ]; then dso="historical"; fi ;; 
    102       SSTAndSeaIce) if [ "$dataset" =  "PCMDI-AMIP-1-1-0" ]; then dso='AMIP'; fi ;; 
    103     esac 
     105    dso=$(remove_version $dataset); dso=${dso#*-}          #--- For naming purpose 
     106    if [ $dso = "CCMI" ]; then dso="historical"; fi        #--- NAMING EXCEPTION: UReading-CCMI-1-0 
    104107    #============================================================================== 
    105108    for iv in $(eval echo {0..$((${#vin[@]}-1))}); do      #--- Loop on variables 
    106109    #============================================================================== 
    107       da=${date[$is]}; Yb=${da%%-*}; Ye=${da#*-}; dY=${Ye##*-}; Ye=${Ye%-*} 
     110      da=${date[$is]}; Yi=${da%%-*}; Yf=${da#*-}; dYt=${Yf#*-}; Yf=${Yf%%-*} 
    108111      v_in=${vin[$iv]}; v_ou=${vou[$iv]}                   #--- Variables names 
    109112      f_in=$(var=$v_in; Yb=\${Yb}; Ye=\${Ye}; datatype=$dt; eval echo $DATAIN/${fin[$is]}) 
    110       axis=$(get_grid $(Yb=$Yb; Ye=????; eval echo $f_in) $v_in) 
     113      axis=$(get_grid $(Yb=$Yi; Ye=????; eval echo $f_in) $v_in) 
    111114      res=${axis#*=}; axis=${axis%=*} 
    112115      Zonal='n'; if [ $axis = 'XYZT' ]; then Zonal='y'; fi #--- Zonal mean ?  For 3D files 
     
    115118        res3D=${res%x*}; res2D=${res3D#*x}_zonal; f_ou=${f_ou%/*}/\${res}/${f_ou##*/} 
    116119      fi 
    117       echo ">> BUILDING 12 MONTHS ${v_in} FILES FOR THE $Yb-$Ye PERIOD USING $dataset DATASET ($version)..." 
     120      echo ">> BUILDING 12 MONTHS ${v_in} FILES FOR THE $Yi-$Yf PERIOD USING $dataset DATASET ($version)..." 
     121      Ye=$((Yi-1)) 
    118122      #============================================================================ 
    119       for Y in $(eval echo {$Yb..$Ye}); do                 #--- Loop on years 
     123      for Y in $(eval echo {$Yi..$Yf}); do                 #--- Loop on years 
    120124      #============================================================================ 
    121125        fO=$(Y=$Y; res=${res3D}; eval echo ${f_ou})        #--- Original resolution 
     126        if [ $Y -eq $((Ye+1)) ]; then Yb=$Y; dY=${dYt%%-*}; Ye=$((Yb+dY-1)); dYt=${dYt#*-}; fi 
    122127        if [[ ! -f $fO || $recomp = 'y' ]]; then 
    123128          extract $v_in,$v_ou $f_in,$fO $Yb,$Ye,$dY $Y 0   #--- Field extraction 
     
    128133          if [[ ! -f $fZ || $recomp = 'y' ]]; then zonal_mean $fO $fZ; fi 
    129134        fi 
    130         progress_bar $((Y-Yb+1)) $((Ye-Yb+1)) 50           #--- Check progress 
     135        progress_bar $((Y-Yi+1)) $((Yf-Yi+1)) 50           #--- Check progress 
    131136      #============================================================================ 
    132137      done 
     
    135140      #============================================================================ 
    136141        Yb=${per%%-*}; Ye=${per##*-}; Yc=${Yb}_${Ye}_clim; c='n'; cli0=${cli[$is]} 
     142 
     143        #=== Skip periods outside available years interval 
     144        if [[ $Yb -lt ${da%%-*} || ${Yb} -gt ${da#*-} || $Yb -lt ${da%%-*} || ${Yb} -gt ${da#*-} ]]; then 
     145          continue 
     146        fi 
    137147 
    138148        #=== Is there a single file climatology available ? 
  • TOOLS/CMIP6_FORCING/OZONE/tools.bash

    r3870 r4109  
    7676    Yb=$Ymin; Ye=$Ymax 
    7777  else 
    78     Yb=$((dY*(Y/dY))); Ye=$((Yb+dY-1)); Ye=$(($Ye>$Ymax?$Ymax:$Ye)) 
     78    Yb=$((Ymin+dY*((Y-Ymin)/dY))); Ye=$((Yb+dY-1)) 
     79    Ye=$(($Ye>$Ymax?$Ymax:$Ye)) 
    7980  fi 
    8081  nbm=$((12*(Ye-Yb+1)-1))                           #--- MONTHS NUMBER OF CURRENT FILE 
    8182  it=$((12*(Y-Yb)))                                 #--- JANUARY INDEX IN CURRENT FILE 
    8283  fin=`var=$v_in; Yb=$Yb; Ye=$Ye; eval echo $f_in`  #--- CURRENT FILE NAME 
    83   fou=`var=$v_ou; Y=$Y; eval echo $f_ou`            #--- OUTPUT FILE NAME 
     84  fou=`var=$v_ou; Y=$Y; eval echo $f_ou`            #--- OUTPUT  FILE NAME 
    8485  ib=$(($it<=nmrg?0:$((it-nmrg))))                  #--- INDEX OF FIRST USED MONTH 
    8586  ie=$(($((it+11+mrg))>=$nbm?$nbm:$((it+11+nmrg)))) #--- INDEX OF LAST USED MONTHF 
     
    246247#================================================================================== 
    247248function get_date { 
    248 # Assumes the following filename structure: *_${Yb}*-${Ye}*.* (Yb/e: 4 digits) 
    249 # $1: varname 
    250 # $2: datatype 
    251 # $3: dirin 
    252 # $4: dirin structure patch 
    253 # $5...$N: files_in 
     249# Call get_date1 one time each input file. 
     250# $1: varname    $2: datatype    $3: dirin    $4: <dir_in> patch    $5...$N: <files_in> 
    254251# [$N+1...]: <dset>:<var>=<val> to overwrite value of variables evaluated from parsing. 
    255252  local v_in dtyp d_in dstr f_in Yb Ye St a f first date dates files_in="" 
     
    264261function get_date_1 { 
    265262# Assumes the following filename structure: *_${Yb}*-${Ye}*.* (Yb/e: 4 digits) 
    266 # $1: varname 
    267 # $2: datatype 
    268 # $3: base directory for files 
    269 # $4: dirin structure patch 
    270 # $5: file_in 
     263# Returns ${FirstYear}-${LastYear}-${IntervalsLengths} 
     264# $1: varname    $2: datatype    $3: dirin    $4: <dir_in> patch    $5: <file_in> 
    271265# [$6...]: <dset>:<var>=<val> to overwrite value of variables evaluated from parsing. 
    272266  local v_in dtyp d_in d_str f_in Yb Ye St a f first 
     
    274268  parse_dir $f_in $dstr $*; Yb=1000000; Ye=0; first='t' 
    275269  for f in $(var=$v_in; Yb=????; Ye=????; datatype=$dtyp; eval ls $d_in/$f_in); do 
    276     a=${f##*_}; if [ ${a::4} -le $Yb ]; then Yb=${a::4}; fi 
    277     a=${a##*-}; if [ ${a::4} -ge $Ye ]; then Ye=${a::4}; fi 
    278     if [ $first = 't' ]; then St=$((Ye-Yb+1)); first='f'; fi 
     270    a=${f##*_}; ymn=${a::4}; if [ $ymn -le $Yb ]; then Yb=$ymn; fi 
     271    a=${a##*-}; ymx=${a::4}; if [ $ymx -ge $Ye ]; then Ye=$ymx; fi 
     272    if [ $first != 't' ]; then St=${St}-; fi; first='f'; St=${St}$((ymx-ymn+1)) 
    279273  done 
    280274  echo $Yb-$Ye-$St 
     
    311305} 
    312306#================================================================================== 
     307function is_int { 
     308 # $1: string to be checked 
     309  set +vx 
     310  if [[ $1 =~ ^[0-9]+$ ]]; then return 0; else return 1; fi 
     311  set -vx 
     312} 
     313#================================================================================== 
     314function remove_version { 
     315 # $1: variable name 
     316  local out=$1 
     317  while `is_int ${out##*-}`; do out=${out%-*}; done; echo $out; return 1 
     318} 
    313319 
Note: See TracChangeset for help on using the changeset viewer.