def example(): # file properties ncfname = "/arctic1/nick/cases/cfsr/output.2006-08-07_12.00.00.nc" # ncfname = '/home/nickszap/research/mpas/output.2010-10-23_00:00:00.nc' #input file vtkfname = "plotTest.vtk" # output file data = output_data.open_netcdf_data(ncfname) # open the output vtk file and write header. ------------------- fvtk = output_data.write_vtk_header_polydata(vtkfname, ncfname) # write nodes and cells nNodes = output_data.write_vtk_xyzNodes(fvtk, data) nCells = output_data.write_vtk_polygons(fvtk, data) nLevels = len(data.dimensions["nVertLevels"]) # write some cell data -------------------- fvtk.write("\nCELL_DATA " + str(nCells) + "\n") output_data.write_vtk_staticGeoFields(fvtk, data, nCells) # time dependent stuff goes in different files time = 0 output_data.write_vtk_pressureHeights(fvtk, data, nCells, time, nLevels, 50000) # 500mb = 50,000Pa # write some node data # close the .nc and vtk files data.close() fvtk.close()
def derivedSfcs(ncfname, vtkfname): #write some derived surfaces to file data = output_data.open_netcdf_data(ncfname) #header info fvtk = output_data.write_vtk_header_polydata(vtkfname, ncfname) nNodes = output_data.write_vtk_xyzNodes(fvtk, data) nCells = output_data.write_vtk_polygons(fvtk, data) nLevels = len(data.dimensions['nVertLevels']) #cell data fvtk.write('\nCELL_DATA '+str(nCells)+'\n') #geo for reference output_data.write_vtk_staticGeoFields(f,data,nCells) time = 0 #500 mb output_data.write_vtk_pressureHeights(fvtk, data, nCells, time, vLevels, 50000.) #theta on dynamic tropopause pv = np.empty((nCells,nLevels), dtype=float) for hcell in range(nCells): for l in range(nLevels): pv[hcell,l] = vars.calc_ertelPV(data, 'theta', time, hcell, l, nLevels) # pvuVal = 2. thetaVal = np.empty(nCells) for hcell in range(nCells): (l,dl) = output_data.calcIndexOfValue(pvuVal,pv[hcell,:], nLevels) thetaVal[hcell] = output_data.calcValueOfIndex(l,dl,data.variables['theta'][time,hcell,:]) output_data.write_levelData_float('theta_pv', fvtk, thetaVal, nCells) #slp slp = np.empty(nCells) for hcell in range(nCells): slp[hcell] = vars.calc_slp(data, hcell, nLevels, time) output_data.write_levelData_float('slp', fvtk, slp, nCells) #close da files fvtk.close() data.close()