Changeset 352


Ignore:
Timestamp:
21/11/04 14:30:19 (15 years ago)
Author:
badc
Message:

Replaced sys.path lines to point to likely nappy directories. Fixed issue if no time axis defined.
Ag Stephens

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nappy/trunk/bin/nc2na

    r349 r352  
    1414===== 
    1515 
    16     cdms2na.py [<options>] -i <infilename> -o <outfilename>  
     16    cdms2na.py [<options>] -i <infilename> -o <outfilename> 
    1717 
    1818Where 
     
    2727# Imports from python standard library 
    2828import sys, os, time, string, fileinput, re 
    29 sys.path.append("..") 
     29if len(sys.argv)>0: 
     30    sys.path.append(os.path.join("..", "..")) 
     31    sys.path.append("..") 
    3032 
    3133# Import cdat modules 
     
    117119    if hasattr(var, "long_name"): name=var.long_name 
    118120    if hasattr(var, "standard_name"): name=var.standard_name 
    119     if hasattr(var, "units") and not re.match("^\s+$", var.units): name="%s (%s)" % (name, var.units)     
    120     # Do a check to see units are not duplicated 
    121     match=re.match("(.*\(%s\)\s*)\(%s\)(.*)$" % (var.units, var.units), name) 
    122     if match: 
    123         name=match.groups()[0]+match.groups()[1] 
     121    if hasattr(var, "units") and not re.match("^\s+$", var.units):  
     122        name="%s (%s)" % (name, var.units)     
     123        # Do a check to see units are not duplicated 
     124        match=re.match("(.*\(%s\)\s*)\(%s\)(.*)$" % (var.units, var.units), name) 
     125        if match: 
     126            name=match.groups()[0]+match.groups()[1] 
    124127         
    125128    if name[-2:]=="()": name=name[:-2] 
     
    250253            else: 
    251254                self.naDict["FFI"]=1001 
    252         print self.naDict["FFI"] 
     255        #print self.naDict["FFI"] 
    253256        axes=bestVar.getAxisList() 
    254257         
    255258        # Get other variable info 
    256         for var in self.vars[:bestVarIndex]+self.vars[bestVarIndex:]: 
     259        for var in self.vars[:bestVarIndex-1]+self.vars[bestVarIndex:]: 
    257260            if len(var.shape)!=ndims or var.shape!=shape:  
    258261                # Could it be an auxiliary variable  
     
    486489         
    487490        if len(self.extra_comments[2])>0: 
    488             for excom in extra_comments[2]: 
     491            for excom in self.extra_comments[2]: 
    489492                NCOM.append(excom) 
    490493         
Note: See TracChangeset for help on using the changeset viewer.