Beispiel #1
0
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()

# plt.figure()
Beispiel #2
0
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())
Beispiel #3
0
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,:]
Beispiel #4
0
# 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,
#                             maptype,
#                             normalize_opt="fracarea")


scrip.compute_remap_weights(
    "/Users/dchandan/Research/PlioTopo/gencesmbc/prism4_N/cpl_s2/grids/prism4_N_gx1.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,
    maptype,
    normalize_opt="fracarea",
)


# # Testing part
scrip.test_remap_weights(2, a.getmap(case, maptype, g1, g2).fname, "out1.nc")
scrip.test_remap_weights(2, a.getmap(case, maptype, g2, g1).fname, "out2.nc")
Beispiel #5
0
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()