from __future__ import print_function import sys, os import PySCRIP as scrip from PySCRIP.config import PySCRIPConfig from netCDF4 import Dataset import numpy as np from matplotlib import pylab as plt a = PySCRIPConfig() # Mapping part ncfile = Dataset("testdata/cesmpifv1mts_cam_mapping_testdata.nc", "r") src_array = ncfile.variables["TS"][:, :] print(src_array.shape) dest = scrip.remap( src_array, "/Users/dchandan/Research/CESM/bc/cesmpifv1mts/cpl_s2/wrkdir/map_fv1-gx1_a_cesmpifv1_130513.nc", fformat="ncar-csm") print(dest.shape) print(src_array.min(), src_array.max()) print(dest.min(), dest.max()) plt.figure() plt.imshow(np.flipud(src_array[0, :])) plt.colorbar() plt.figure() plt.imshow(np.flipud(dest)) plt.colorbar()
import sys, os import PySCRIP as scrip from PySCRIP.config import PySCRIPConfig from netCDF4 import Dataset import numpy as np from matplotlib import pylab as plt a = PySCRIPConfig() # for maptype in a.maptype: # print maptype # for map_ in getattr(a.maptype, maptype): # print a.mapfile(map_["from"], map_["to"], maptype=maptype) # # print map_ case = "PlioMIP_Eoi400_N" maptype = "conservative" g1 = "gx1" g2 = "ll1" # print(a.getmap(case, maptype, g1, g2).fname) # scrip.compute_remap_weights("/Users/dchandan/Research/PlioTopo/gencesmbc/prism4_N/cpl_s2/grids/fv0.9x1.25_070727.nc", # "/Users/dchandan/Development/PySCRIP/grids/ll1deg_grid.nc", # a.getmap(case, maptype, g1, g2).fname, # a.getmap(case, maptype, g2, g1).fname, # a.getmap(case, maptype, g1, g2).name, # a.getmap(case, maptype, g2, g1).name, # 2,
import PySCRIP as scrip from PySCRIP.config import PySCRIPConfig from netCDF4 import Dataset import numpy as np from matplotlib import pylab as plt a = PySCRIPConfig() # Mapping part ncfile = Dataset("testdata/cesmpifv1mts_pop_mapping_testdata.nc", "r") src_array = ncfile.variables["SSH"][:,:] print(src_array.shape) dest = scrip.remap(src_array, a.mapFile("cesmpifv1mts", "conservative", "gx1", "fv1")) print(dest.shape) print(src_array.min(), src_array.max()) print(dest.min(), dest.max()) plt.figure() plt.imshow(np.flipud(src_array[0,:])) plt.colorbar() # from IPython import embed # print type(dest) # embed() # plt.imshow(dest.mask) # plt.show() # print np.where(dest > src_array.max())
import PySCRIP as scrip from PySCRIP.config import PySCRIPConfig from netCDF4 import Dataset import numpy as np from matplotlib import pylab as plt a = PySCRIPConfig() # Mapping part ncfile = Dataset("testdata/cesmpifv1mts_pop_mapping_testdata.nc", "r") src_array = ncfile.variables["SSH"][:, :] print(src_array.shape) dest = scrip.remap(src_array, a.mapFile("cesmpifv1mts", "conservative", "gx1", "fv1")) print(dest.shape) print(src_array.min(), src_array.max()) print(dest.min(), dest.max()) plt.figure() plt.imshow(np.flipud(src_array[0, :])) plt.colorbar() # from IPython import embed # print type(dest) # embed() # plt.imshow(dest.mask) # plt.show() # print np.where(dest > src_array.max()) # print dest[-1,:]