Changeset 674 in lmdz_wrf for trunk


Ignore:
Timestamp:
Jan 18, 2016, 4:37:28 PM (9 years ago)
Author:
lfita
Message:

Adding 'variables' in `DataSetSection_multidims'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var.py

    r666 r674  
    133133    ncvar.DataSetSection(opts.values, opts.ncfile)
    134134elif oper == 'DataSetSection_multidims':
    135     ncvar.DataSetSection_multidims(opts.values, opts.ncfile)
     135    ncvar.DataSetSection_multidims(opts.values, opts.ncfile, opts.varname)
    136136elif oper == 'DataSetSection_multivars':
    137137    ncvar.DataSetSection_multivars(opts.values, opts.ncfile, opts.varname)
  • trunk/tools/nc_var_tools.py

    r672 r674  
    87668766    return
    87678767
    8768 def DataSetSection_multidims(values, filen):
     8768def DataSetSection_multidims(values, filen, varn):
    87698769    """ Function to get a section (values along multiple dimensions) of a given data-set
    87708770      values= [dimn1],[beg1],[end1],[int1]@[...[[dimnM],[begM],[endM],[intM]]]
     
    87748774          NOTE: dimensions without values are taken allover their size
    87758775      filen= netCDF with the data-set
    8776       DataSetSection_multidims('Time,-1,-1,1@bottom_top,6,6,1','wrfout_d01_1979-12-01_00:00:00')
     8776      varn= ',' list of variables, 'all' for all variables in data-set
     8777      DataSetSection_multidims('Time,-1,-1,1@bottom_top,6,6,1','wrfout_d01_1979-12-01_00:00:00','all')
    87778778    """
    87788779    fname = 'DataSetSection_multidims'
     
    88358836
    88368837            if begvs[dimid] != endvs[dimid]:
    8837                 dimsize = (endvs[dimid]-begvs[dimid]+1)/intvs[dimid]
    8838                 dimslices[dims] = [begvs[dimid],endvs[dimid]+1,intvs[dimid]]
     8838                if endvs[dimid] != -1:
     8839                    dimsize = (endvs[dimid]-begvs[dimid]+1)/intvs[dimid]
     8840                    dimslices[dims] = [begvs[dimid],endvs[dimid]+1,intvs[dimid]]
     8841                else:
     8842                    print 'here!'
     8843                    dimsize = len(objdim)
     8844                    dimslices[dims] = [begvs[dimid],len(objdim),1]
    88398845            else:
    88408846                dimsize = 1
     
    88568862##
    88578863    print '  ' + fname + ': adding variables...'
    8858     for varns in nciobj.variables:
    8859 #        print '    ' + fname + ': adding variable "' + varns + '"...'
     8864    if varn == 'all':
     8865        getvarns = nciobj.variables
     8866    else:
     8867        getvarns = varn.split(',')
     8868
     8869    for varns in getvarns:
     8870        print '    ' + fname + ': adding variable "' + varns + '"...'
    88608871        varobj = nciobj.variables[varns]
    88618872
Note: See TracChangeset for help on using the changeset viewer.