def createNetcdf(self,src,dstpath): ncp = NetcdfCopier() geo = self.__checkUnits(src) # if the file is geolocalized if geo: self.__checkRange(src) self.__checkLatLonAttr(src) if self.dimblacklist or self.varblacklist or self.__rollnames or self.__rollgrid: dst = ncOpen(dstpath, mode='w') ncp.copy(src,dst,dbl=self.dimblacklist,vbl=self.varblacklist) if self.__rollnames: self.__rollbackNames(src) if self.__rollgrid: self.__rollbackGrid(src) return dst else: return src else: return None
if dimensions: try: self.getDimInfo() except: print "couldn't scan for dimensions" pass if variables: try: self.getVarInfo() except: print "couldn't scan for variables" raise if glob: try: self.getGlobInfo() except: print "couldn't scan for global attributes" if __name__ == '__main__': src = ncOpen("../results/test1.nc") an = Analyzer(src, "../results/test1.nc") an.ncScan(False,True,False) an.asJson(show = True)
There we have it: Number of total elements of the grid along x axis: n_x = (x_max - x_min +1)*Dile_x_size Number of internal edges: i_e_x = n_x - 1 Number of elements of along the x axis: n_x - i_e_x = (x_max - x_min + 1)*dile_x_size - (x_max - x_min + 1) - 1 = (x_max - x_min + 1)*dile_x_size - x_max + x_min ''' xsize = (max_dile.x - min_dile.x + 1)*min_dile.XSIZE - max_dile.x + min_dile.x #max_dile would be good as well ysize = (max_dile.y - min_dile.y + 1)*min_dile.YSIZE - max_dile.y + min_dile.y xfirst = bb_min["lon_min"] yfirst = bb_min["lat_min"] xinc = increment yinc = increment gf = GridFile("lonlat", xsize, ysize, xfirst, xinc, yfirst, yinc) return gf.createGrid(dstpath) if __name__ == '__main__': nco = NetcdfOpener() src = ncOpen("../files/std_files/ETOPO1_Ice_g_gmt4.nc", mode='r') r = GridMaker(src) r.gridInit("../files/grid_files/ETOPO1_Ice_g_gmt4.grid")
paths = [] for file in lpw.getDirectoryContent(mydir): if lpw.checkExtention(myext, file): paths.append(file) for i in range(50,len(paths)): timer.start() md5 = getMD5(paths[i]) timer.stop() print i, ") md5 for ",pathLeaf(paths[i],ext=True), " computed in: ", timer.formatted() src = ncOpen(paths[i], mode='r') bb = ncg.getBoundingBox(src['lat'],src['lon']) z = ncg.getZoomLevel(src['lat'],src['lon']) ncs = NetcdfSlicer(src) timer.reset() timer.start() ndiles = ncs.createDiles("/sdiles/ubuntu/diles/"+md5+"/"+pathLeaf(paths[i],ext=False),bb,int(z)) timer.stop() print ndiles, " created. task completed in: ", timer.formatted() src.close()