def add_att(self, attname, attvalue, atttype=False): ''' Creates file or variable attribute atttype can be a netcdf type name, numpy type name, dtype or numeric typecode ''' if self._interface == 'pycdf': if atttype: Type = nctypes.type_2pycdf(atttype) else: Type = nctypes.type_var2pycdf(attvalue) a = self._nc.attr(attname) a.put(Type, attvalue) elif self._interface in ('scientific', 'netcdf4'): setattr(self._nc, attname, attvalue) newatt = Pyncatt(self._nc, attname, attvalue, atttype=atttype, ncversion=self.ncversion, interface=self._interface) # update self.atts and self.attnames: self.atts[attname] = newatt # update ncdump_info: if not isinstance(self, Pyncvar): if not self._ncdump_info is False: self._ncdump_info['attributes'][attname] = {} return newatt
def add_att(self,attname,attvalue,atttype=False): ''' Creates file or variable attribute atttype can be a netcdf type name, numpy type name, dtype or numeric typecode ''' if self._interface=='pycdf': if atttype: Type=nctypes.type_2pycdf(atttype) else: Type=nctypes.type_var2pycdf(attvalue) a=self._nc.attr(attname) a.put(Type,attvalue) elif self._interface in ('scientific','netcdf4'): setattr(self._nc,attname,attvalue) newatt=Pyncatt(self._nc,attname,attvalue, atttype=atttype,ncversion=self.ncversion, interface=self._interface) # update self.atts and self.attnames: self.atts[attname]=newatt # update ncdump_info: if not isinstance(self,Pyncvar): if not self._ncdump_info is False: self._ncdump_info['attributes'][attname]={} return newatt
def update(self, value, atttype=False): self.value = value self.atttype = atttype self.set_types() if self._interface == 'pycdf': if self.atttype: Type = nctypes.type_2pycdf(self.atttype) else: Type = nctypes.type_var2pycdf(self.value) a = self._nc.attr(self.name) a.put(Type, self.value) elif self._interface in ('scientific', 'netcdf4'): setattr(self._nc, self.name, value)
def update(self,value,atttype=False): self.value=value self.atttype=atttype self.set_types() if self._interface=='pycdf': if self.atttype: Type=nctypes.type_2pycdf(self.atttype) else: Type=nctypes.type_var2pycdf(self.value) a=self._nc.attr(self.name) a.put(Type,self.value) elif self._interface in ('scientific','netcdf4'): setattr(self._nc,self.name,value)