def addattr(self, attrname, attrvalue): if self.ncvariable is None: if self.attributes is None: self.attributes = [] self.attributes.append(Attribute(attrname, attrvalue)) else: if isinstance(attrvalue, np.NDArray): attrvalue = NCUtil.convertArray(attrvalue._array) self.ncvariable.addAttribute(NCAttribute(attrname, attrvalue))
def addgroupattr(self, attrname, attrvalue, group=None, float=False): ''' Add a global attribute. :param attrname: (*string*) Attribute name. :param attrvalue: (*object*) Attribute value. :param group: None means global attribute. :param float: (*boolean*) Transfer data as float or not. ''' if float: if isinstance(attrvalue, (list, tuple)): for i in range(len(attrvalue)): attrvalue[i] = Float(attrvalue[i]) else: attrvalue = Float(attrvalue) if isinstance(attrvalue, np.NDArray): attrvalue = attrvalue._array return self.ncfile.addGroupAttribute(group, NCAttribute(attrname, attrvalue))
def addattr(self, attrname, attrvalue): if isinstance(attrvalue, np.NDArray): attrvalue = NCUtil.convertArray(attrvalue._array) self.ncvariable.addAttribute(NCAttribute(attrname, attrvalue))
def addattr(self, attrname, attrvalue): self.ncvariable.addAttribute(NCAttribute(attrname, attrvalue))