Changeset 915 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jun 20, 2016, 8:08:32 PM (8 years ago)
Author:
lfita
Message:

Working until `pinterp'

  • A new function `cleaning_varsfile': Function to keep only a list of variables from a file
  • If a variable can be computed directly from the model of via a 'diagnostic' the later one is preferred
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/model_graphics.bash

    r912 r915  
    144144      Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'`
    145145      ferrmsgF ${pyn} ${fname} "python!'varaddattr'!'units'!failed#"${Spyout} ${wrff}
     146    fi
     147  done
     148}
     149
     150function cleaning_varsfile() {
     151# Function to keep only a list of variables from a file
     152#   filen= file to clean
     153#   keepvars= ':' separated list of variables to keep
     154  fname='cleaning_varsfile'
     155
     156  filen=$1
     157  keepvars=$2
     158
     159  fvars=`${pyHOME}/nc_var.py -o ivars -f ${filen} | grep allvars | tr '=' ' ' |      \
     160    awk '{print $3}'`
     161  fvs=`echo ${fvars} | tr ':' ' '`
     162
     163  for fv in ${fvs}; do
     164    if ! $(isInlist ${keepvars} ${fv}); then
     165      pyout=`python ${pyHOME}/nc_var.py -o varrm -v ${fv} -f ${filen}`
     166      pyn=$?
     167      Spyout=`echo ${pyout} | tr '\n' '#' | tr ' ' '!'`
     168      ferrmsg ${pyn} ${fname} "python!'varrm'!'${fv}'!failed#"${Spyout}
    146169    fi
    147170  done
     
    220243
    221244    if test ! -f ${filen} && test ! -f ${odir}/${CFvarn}_${fhead}.nc; then
    222       if test ! ${modvar} = 'None'; then
     245# Since model direct values are retrieved from `variables_valules.dat' which was initially coincived
     246#   as a way to only give variable attributes, range and color bars, if a variable has a diagnostic
     247#   way to be computed, the later one will be preferred
     248
     249      if test ! ${modvar} = 'None' && test ${diagvar} = 'None'; then
    223250        # model variable
    224251        values=${modvar}',0,-1,-1'
     
    251278          idiagv=`expr ${idiagv} + 1`
    252279        done
    253 
    254280        pyout=`python ${pyHOME}/diagnostics.py -f ${cf} -d ${dims} -v ${diagn}'|'${diagc}`
    255281        pyn=$?
     
    276302      fi
    277303    fi
    278 
    279304
    280305    ifile=`expr ${ifile} + 1`
     
    463488    esac
    464489  fi
     490
     491  cleaning_varsfile ${filen} ${CFvarn}':lon:lat:pres:time'
    465492#  exit
    466493# LLUIS
Note: See TracChangeset for help on using the changeset viewer.