def savegrid(self, x, y, fname, format='surfer', **kwargs): gdata = GridArray(self.array, x.array, y.array, -9999.0) if format == 'surfer': gdata.saveAsSurferASCIIFile(fname) elif format == 'bil': gdata.saveAsBILFile(fname) elif format == 'esri_ascii': gdata.saveAsESRIASCIIFile(fname) elif format == 'micaps4': desc = kwargs.pop('description', 'var') date = kwargs.pop('date', datetime.datetime.now()) date = miutil.jdate(date) hours = kwargs.pop('hours', 0) level = kwargs.pop('level', 0) smooth = kwargs.pop('smooth', 1) boldvalue = kwargs.pop('boldvalue', 0) proj = kwargs.pop('proj', None) if proj is None: gdata.saveAsMICAPS4File(fname, desc, date, hours, level, smooth, boldvalue) else: if proj.isLonLat(): gdata.saveAsMICAPS4File(fname, desc, date, hours, level, smooth, boldvalue) else: gdata.saveAsMICAPS4File(fname, desc, date, hours, level, smooth, boldvalue, proj)
def asgridarray(self): xdata = self.dims[1].getDimValue() ydata = self.dims[0].getDimValue() gdata = GridArray(self.array, xdata, ydata, self.fill_value, self.proj) return gdata