Changeset 2203 in lmdz_wrf


Ignore:
Timestamp:
Oct 19, 2018, 6:35:46 PM (6 years ago)
Author:
lfita
Message:

Adding:

  • `get_right_CFtimeunits': Function to get the right CFtime units from any given format
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic.py

    r2092 r2203  
    2626# create_LateX_figs: Function to create a LaTeX from a folder with multiple plots from different values
    2727# datetimeStr_conversion: Function to transform a string date to an another date object
     28# get_right_CFtimeunits: Function to get the right CFtime units from any given format
    2829# grid_combinations: Function to provide all the possible grid points combination for a given pair of values
    2930#   x,y= pair of grid points
     
    5455# List of available operations
    5556operations=['ASCIIfile_stats', 'coincident_CFtimes', 'count_cond',                   \
    56   'create_LateX_figs', 'datetimeStr_conversion',                                     \
     57  'create_LateX_figs', 'datetimeStr_conversion', 'get_right_CFtimeunits',            \
    5758  'grid_combinations', 'inf_operSlist',                                              \
    5859  'interpolate_locs', 'latex_fig_array', 'list_operations', 'PolyArea',              \
     
    9192## e.g. # generic.py -o inf_operSlist -S '-98.21:1.2:3.45:100.1:34321.1,threshold,:,3.'
    9293## e.g. # generic.py -o create_LateX_figs -S '/home/lluis/estudios/FPS_ALPS/additional/IOP/analysis/figs,WindRose_obs_@SkewT-logP_obs_ta-tda@SkewT-logP_obs_evol@WindRose_obs-sim_step@SkewT-logP_obs-sim_step@SkewT-logP_obs-sim_evol,10868@16080@16144@16546,png'
     94## e.g. # generic.py -o get_right_CFtimeunits -S 'minutes!since!1-1-1'
    9395
    9496operationnames = "'" + gen.numVector_String(operations, "', '") + "'"
     
    115117            print opern + '_______ ______ _____ ____ ___ __ _'
    116118            print getattr(object, opern).__doc__
     119
     120elif oper == 'ASCIIfile_stats':
     121    Nvals = 3
     122    vals = opts.values.split(cS)
     123    if vals[0] == 'h':
     124        print gen.ASCIIfile_stats.__doc__
     125        quit(-1)
     126    else:
     127        if len(vals) != Nvals:
     128            print errormsg
     129            print '  ' + main + ": operation '" + oper + "' requires", Nvals, 'and', \
     130              len(vals), ' has passed!!'
     131            print gen.ASCIIfile_stats.__doc__
     132            quit(-1)
     133        vals0 = vals[0]
     134        vals1 = vals[1]
     135        vals2 = vals[2]
     136       
     137        print gen.ASCIIfile_stats(vals0, vals1, vals2)
    117138
    118139elif oper == 'coincident_CFtimes':
     
    198219#'days_period'
    199220
     221elif oper == 'get_right_CFtimeunits':
     222    Nvals = 1
     223    vals = opts.values.split(cS)
     224    if vals[0] == 'h':
     225        print gen.get_right_CFtimeunits.__doc__
     226        quit(-1)
     227    else:
     228        if len(vals) != Nvals:
     229            print errormsg
     230            print '  ' + main + ": operation '" + oper + "' requires", Nvals, 'and', \
     231              len(vals), ' has passed!!'
     232            print gen.get_right_CFtimeunits.__doc__
     233            quit(-1)
     234        print gen.get_right_CFtimeunits(vals[0].replace('!', ' '))
     235
    200236elif oper == 'grid_combinations':
    201237    Nvals = 2
     
    471507        print gen.WRFsetup(vals0, vals1, vals2)
    472508
    473 elif oper == 'ASCIIfile_stats':
    474     Nvals = 3
    475     vals = opts.values.split(cS)
    476     if vals[0] == 'h':
    477         print gen.ASCIIfile_stats.__doc__
    478         quit(-1)
    479     else:
    480         if len(vals) != Nvals:
    481             print errormsg
    482             print '  ' + main + ": operation '" + oper + "' requires", Nvals, 'and', \
    483               len(vals), ' has passed!!'
    484             print gen.ASCIIfile_stats.__doc__
    485             quit(-1)
    486         vals0 = vals[0]
    487         vals1 = vals[1]
    488         vals2 = vals[2]
    489        
    490         print gen.ASCIIfile_stats(vals0, vals1, vals2)
    491 
Note: See TracChangeset for help on using the changeset viewer.