Ignore:
Timestamp:
10/06/08 16:23:57 (12 years ago)
Author:
domlowe
Message:

added code to assist in preservation of CF (and other) attributes. Not completely working atm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/csmllibs/netCDFWriter.py

    r3953 r4017  
    2222             
    2323        # Now create the axis    
     24        if not hasattr(self,'axes'): 
     25            self.axes=[] 
     26        else: 
     27            for item in self.axes: 
     28                if item.id == axisName: 
     29                    return None # it's already there, don't do anything 
     30            
    2431        dataarray=MV.array(data) 
    2532        ax=cdms.createAxis(dataarray) 
    2633        ax.id = axisName 
    27         if not hasattr(self,'axes'): 
    28             self.axes=[] 
    2934        if isLon is not None: 
    3035            ax.designateLongitude() 
     
    3944            setattr(ax, key,kwargs[key]) 
    4045        self.axes.append(ax) 
    41          
    4246     
    4347    def getAxis(self, axID): 
     
    6569            setattr(dataarray, key,kwargs[key]) 
    6670        axisCount=0 
    67        
    6871        #depending on whether time is modelled in the underlying data as a dimension or not the shapes may not match 
    6972        if len(dataarray.shape) < len(axesList):   
     
    8184                        axisCount = axisCount +1       
    8285        #missing_value deprecated but in common use; 
    83         setattr(dataarray, 'missing_value' ,fillvalue) 
    84         setattr(dataarray, '_FillValue' ,fillvalue) #_FillValue does not work in CDMS!! 
     86        if fillvalue: 
     87            setattr(dataarray, 'missing_value' ,fillvalue) 
     88            setattr(dataarray, '_FillValue' ,fillvalue) #_FillValue does not work in CDMS!! 
    8589        if stdname: 
    8690            setattr(dataarray, 'standard_name' ,stdname) 
Note: See TracChangeset for help on using the changeset viewer.