예제 #1
0
    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
예제 #2
0
파일: pync4.py 프로젝트: jsh1012/okean
  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
예제 #3
0
    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)
예제 #4
0
파일: pync4.py 프로젝트: jsh1012/okean
  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)