nappy/nc_interface/na_to_cdms.py
def _convertNAToCdmsVariable(self, var_number, attributes={}):
        """
        Creates a single cdms variable from the variable number provided in the list.
        """
        (var_name, units, miss, scal) = self.na_file_obj.getVariable(var_number)
        msg = "\nAdding variable: %s" % self.na_file_obj.VNAME[var_number]
        log.debug(msg)
        self.output_message.append(msg)
        array = N.array(self.na_file_obj.V[var_number])
        array = array * scal
        # Set up axes
        if not hasattr(self, 'cdms_axes'):
            self._convertCdmsAxes()

        # Set up variable
        var=cdms.createVariable(array, axes=self.cdms_axes, fill_value=miss, attributes=attributes)

        # Sort units etc
        if units:   var.units=units
	
        # Add the best variable name
        if len(var_name) < max_id_length:
            var.id=safe_nc_id.sub("_", var_name).lower()
        else:
            var.id="naVariable_%s" % (var_number)
        
	     # Check if mapping provided for renaming this variable
        if var_name in self.rename_variables.keys():
            var_name = self.rename_variables[var_name]
	    
        var.long_name = var.name = var.title = var_name

        # Add a NASA Ames variable number (for mapping correctly back to NASA Ames)
        var.nasa_ames_var_number = var_number
        return var

        Creates a single cdms variable from the variable number provided in the list.
        
Creates a single cdms variable from the variable number provided in the list.
Creates a single cdms variable from the variable number provided in the list .
def _convertNAToCdmsVariable(self, var_number, attributes={}):
        (var_name, units, miss, scal) = self.na_file_obj.getVariable(var_number)
        msg = "\nAdding variable: %s" % self.na_file_obj.VNAME[var_number]
        log.debug(msg)
        self.output_message.append(msg)
        array = N.array(self.na_file_obj.V[var_number])
        array = array * scal
        if not hasattr(self, 'cdms_axes'):
            self._convertCdmsAxes()
        var=cdms.createVariable(array, axes=self.cdms_axes, fill_value=miss, attributes=attributes)
        if units:   var.units=units
        if len(var_name) < max_id_length:
            var.id=safe_nc_id.sub("_", var_name).lower()
        else:
            var.id="naVariable_%s" % (var_number)
        if var_name in self.rename_variables.keys():
            var_name = self.rename_variables[var_name]
        var.long_name = var.name = var.title = var_name
        var.nasa_ames_var_number = var_number
        return var
def _convertNAToCdmsVariable ( self , var_number , attributes = { } ) : ( var_name , units , miss , scal ) = self . na_file_obj . getVariable ( var_number ) msg = "\nAdding variable: %s" % self . na_file_obj . VNAME [ var_number ] log . debug ( msg ) self . output_message . append ( msg ) array = N . array ( self . na_file_obj . V [ var_number ] ) array = array * scal if not hasattr ( self , 'cdms_axes' ) : self . _convertCdmsAxes ( ) var = cdms . createVariable ( array , axes = self . cdms_axes , fill_value = miss , attributes = attributes ) if units : var . units = units if len ( var_name ) < max_id_length : var . id = safe_nc_id . sub ( "_" , var_name ) . lower ( ) else : var . id = "naVariable_%s" % ( var_number ) if var_name in self . rename_variables . keys ( ) : var_name = self . rename_variables [ var_name ] var . long_name = var . name = var . title = var_name var . nasa_ames_var_number = var_number return var
Creates a single cdms variable from the variable number provided in the list.
Creates a single cdms variable from the variable number provided in the list .
"""
        Creates a single cdms variable from the variable number provided in the list.
        """ # Set up axes # Set up variable # Sort units etc # Add the best variable name # Check if mapping provided for renaming this variable # Add a NASA Ames variable number (for mapping correctly back to NASA Ames)
self
var_number
attributes