Changeset 974 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jun 29, 2016, 6:33:14 PM (8 years ago)
Author:
lfita
Message:

Adding `compute_combos' Function to compute the given list of combos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/model_graphics.bash

    r973 r974  
    462462  done
    463463
    464   echo ${fname}" varcompute= "${varcompute}_${itotv}
     464  echo ${fname}" varcompute= "${varcompute}_${itotv}_${combo}
    465465}
    466466
     
    10451045}
    10461046
     1047function compute_combos(){
     1048# Function to compute the given list of combos
     1049#   Iwdir= input folder
     1050#   Owdir= output folder
     1051#   Files= files to use
     1052#   Testfiles= files for testing the wat of compute a given variable
     1053#   Moddims= dimensions of the input files
     1054#   Modvdims= variable dimensions of the input files
     1055#   VarCombo= ':' separated list of combos to compute
     1056#   Filescratch= do we need to start files from the scratch?
     1057  fname='compute_combos'
     1058
     1059  set -x
     1060
     1061  Iwdir=$1
     1062  Owdir=$2
     1063  Files=$3
     1064  Testfiles=$4
     1065  Moddims=$5
     1066  Modvdims=$6
     1067  VarCombo=$7
     1068  Filescratch=$8
     1069
     1070  varcos=`echo ${VarCombo} | tr ':' ' '`
     1071  for vco in ${varcos}; do
     1072    echo "        "${vco}
     1073    CFvarn=`echo ${vco} | tr ';' ' ' | awk '{print $1}'`
     1074    cvar=`variable_compute ${Iwdir} ${CFvarn} ${Testfiles} | grep varcomp |          \
     1075      awk '{print $2}'`
     1076    CFv=`echo ${cvar} | tr '|' ' ' | awk '{print $1}'`
     1077    vark=`echo ${cvar} | tr '|' ' ' | awk '{print $2}'`
     1078    fileh=`echo ${cvar} | tr '|' ' ' | awk '{print $3}'`
     1079    modv=`echo ${cvar} | tr '|' ' ' | awk '{print $4}'`
     1080    diagv=`echo ${cvar} | tr '|' ' ' | awk '{print $5}'`
     1081
     1082#        if $(index_string ${vark} 'pinterp') -ne -1; then
     1083#          fhead=${fileh}'p'
     1084#        else
     1085#          fhead=${fileh}
     1086#        fi
     1087    combs=`echo ${vco} | tr ';' ' ' | awk '{print $2}' | tr '@' ' '`
     1088    ifile=${CFv}_${fhead}
     1089    for comb in ${combs}; do
     1090      combcvar=${CFv}'|'${comb}'|'${fhead}'|'${modv}'|'${diagv}
     1091      compute_statistics ${Iwdir} ${ifile}.nc ${Owdir} ${combcvar} ${Moddims}    \
     1092        ${Modvdims} ${Filescratch} ${ifile}.nc
     1093      ifile=${ifile}_${comb}
     1094
     1095      # Adding 'surnames' to the variable's name
     1096      if test ${comb} = 'turb'; then
     1097        CFv=${CFv}'turb'
     1098      fi
     1099      if $(isInlist ${varmeanname} ${comb}); then
     1100        CFv=${CFv}'mean'
     1101      fi
     1102
     1103      isc=`expr ${isc} + 1`
     1104    # End of combo
     1105    done
     1106  # End of combo variables
     1107  done
     1108
     1109  return
     1110}
     1111
    10471112function draw_plot(){
    10481113# Function to carry out the drawing of the plots
     
    15391604      cd ${rootsh}
    15401605
    1541       varcompute=`compvars_listconstruct ${varkinds} $(echo ${testfiles} | tr '@' ':')\
     1606      varcompt=`compvars_listconstruct ${varkinds} $(echo ${testfiles} | tr '@' ':') \
    15421607       | grep varcompute | awk '{print $3}'`
     1608
     1609      varcompute=`echo ${varcompt} | tr '_' ' ' | awk '{print $1}'`
     1610      itotv=`echo ${varcompt} | tr '_' ' ' | awk '{print $2}'`
     1611      combo=`echo ${varcompt} | tr '_' ' ' | awk '{print $3}'`
    15431612
    15441613      # Outwritting the varcompute to avoid next time (if it is not filescratch!)
    15451614      cat << EOF > ${owdir}/varcompute.inf
    15461615files: ${files}
    1547 varcompute: $(echo ${varcompute} | tr '_' ' ' | awk '{print $1}')
    1548 itotv: $(echo ${varcompute} | tr '_' ' ' | awk '{print $2}')
     1616varcompute: ${varcompute}
     1617itotv: $itotv}
    15491618testfs: ${testfiles}
     1619combo: ${combo}
    15501620EOF
    15511621    else
     
    15561626      itotv=`cat ${owdir}/varcompute.inf | grep itotv | awk '{print $2}'`
    15571627      testfiles=`cat ${owdir}/varcompute.inf | grep testfs | awk '{print $2}'`
     1628      combo=`cat ${owdir}/varcompute.inf | grep combo | awk '{print $2}'`
    15581629# End of avoiding to repeat all the experiment search
    15591630    fi
     
    15641635    echo "      Computing all variables ..."
    15651636
    1566     compute_vars ${iwdir} ${owdir} ${files} ${moddims} ${modvdims} ${varcompute} ${filescratch}
    1567 
    1568     exit
     1637    compute_vars ${iwdir} ${owdir} ${files} ${moddims} ${modvdims} ${varcompute}     \
     1638      ${filescratch}
     1639
    15691640    # Computing combos
    15701641    if ${combo}; then
    15711642      echo "      Computing combos: "${varcombo}
    1572       varcos=`echo ${varcombo} | tr ':' ' '`
    1573       for vco in ${varcos}; do
    1574         echo "        "${vco}
    1575         CFvarn=`echo ${vco} | tr ';' ' ' | awk '{print $1}'`
    1576         cvar=`variable_compute ${iwdir} ${CFvarn} ${testfiles} | grep varcomp |      \
    1577           awk '{print $2}'`
    1578         CFv=`echo ${cvar} | tr '|' ' ' | awk '{print $1}'`
    1579         vark=`echo ${cvar} | tr '|' ' ' | awk '{print $2}'`
    1580         fileh=`echo ${cvar} | tr '|' ' ' | awk '{print $3}'`
    1581         modv=`echo ${cvar} | tr '|' ' ' | awk '{print $4}'`
    1582         diagv=`echo ${cvar} | tr '|' ' ' | awk '{print $5}'`
    1583 
    1584 #        if $(index_string ${vark} 'pinterp') -ne -1; then
    1585 #          fhead=${fileh}'p'
    1586 #        else
    1587 #          fhead=${fileh}
    1588 #        fi
    1589         combs=`echo ${vco} | tr ';' ' ' | awk '{print $2}' | tr '@' ' '`
    1590         ifile=${CFv}_${fhead}
    1591         for comb in ${combs}; do
    1592           combcvar=${CFv}'|'${comb}'|'${fhead}'|'${modv}'|'${diagv}
    1593           compute_statistics ${iwdir} ${ifile}.nc ${owdir} ${combcvar} ${moddims}    \
    1594             ${modvdims} ${filescratch} ${ifile}.nc
    1595           ifile=${ifile}_${comb}
    1596 
    1597           # Adding 'surnames' to the variable's name
    1598           if test ${comb} = 'turb'; then
    1599             CFv=${CFv}'turb'
    1600           fi
    1601           if $(isInlist ${varmeanname} ${comb}); then
    1602             CFv=${CFv}'mean'
    1603           fi
    1604 
    1605           isc=`expr ${isc} + 1`
    1606         # End of combo
    1607         done
    1608       # End of combo variables
    1609       done
     1643      compute_combos ${iwdir} ${owdir} ${files} ${testfiles} ${moddims} ${modvdims}  \
     1644        ${varcombo} ${filescratch}
    16101645    fi
     1646
     1647    exit
    16111648
    16121649    echo "  "${main}": "${ic}" variables has been computed"
Note: See TracChangeset for help on using the changeset viewer.