예제 #1
0
    def setUp(self):
        with netCDF4.Dataset(SEARISE_GRID, 'r') as nc:
            self.plotterA = ibplotter.read_nc(nc, 'grid')
            gridA = ibgrid.read_nc(nc, 'grid')
            self.indexingA = ibgrid.Indexing(nc, 'grid.indexing')

        with netCDF4.Dataset(OVERLAP_FILE, 'r') as nc:
            gridI = ibgrid.read_nc(nc, 'gridI')
            exgrid = ibgrid.read_nc(nc, 'exgrid')


        nA = gridA.cells_nfull
        nI = gridI.vertices_nfull
        AvI,weightsA,weightsI = element_l1.compute_AvI(exgrid, nA, gridI)

        # Diagonal scale matrices based on regrid weights
        scaleA = scipy.sparse.dia_matrix( ([1. / weightsA], [0]), shape=(nA,nA))
        scaleI = scipy.sparse.dia_matrix( ([1. / weightsI], [0]), shape=(nI,nI))

        self.AvI = (scaleA * AvI).tocoo()
        self.IvA = (scaleI * AvI.transpose()).tocoo()
예제 #2
0
with netCDF4.Dataset(ICEBIN_IN) as nc:
#    indexingA = ibgrid.Indexing(nc, 'm.gridA.indexing')
#    indexingHP = ibgrid.Indexing(nc, 'm.indexingHP')
    indexingI = ibgrid.Indexing(nc, 'm.{}.gridI.indexing'.format(ice_sheet))
    plotterI = ibplotter.read_nc(nc, 'm.{}.gridI'.format(ice_sheet))
#    plotterA = ibplotter.read_nc(nc, 'm.gridA')

IvE,wIvE = rm.regrid('IvE', scale=True)

wI = wIvE        # Numpy array
nI = len(wI)


# Read the grid
nc = netCDF4.Dataset(ICEBIN_IN, 'r')
pgridI = ibgrid.read_nc(nc, 'm.{}.gridI'.format(ice_sheet))
nc.close()


# Obtain a single point and weight for each basis functions.
# This is a simplification and approximate.  But it should work
# pretty well as long as grid cells are small.  And it will work
# for any kind of grid/mesh.
def inserts():
    n=0
    for cell in pgridI.cells.values():
        if wI[cell.index] > 0:
            centroid = cell.centroid()
            weight = wI[cell.index]
            yield  (cell.index, (centroid[0], centroid[1], centroid[0], centroid[1]), wI[cell.index])
            n += 1
예제 #3
0
import icebin
from icebin import ibgrid
import sys

import giss.basemap

grid_fname = sys.argv[1]
vname = sys.argv[2]

# =============== Step 2: Plot grid outlines

# Set up the page
figure = matplotlib.pyplot.figure(figsize=(11,8.5))
# figure.set_size_inches(11., 8.5)# US Letter
figure.set_size_inches(8.267,11.692)# A4

# -------- First plot: grid1

# Read the grid
nc = netCDF4.Dataset(grid_fname + '.nc', 'r')
grid1 = ibgrid.read_nc(nc, vname)
nc.close()

# Plot it!
ax = figure.add_subplot(111)
basemap = giss.basemap.greenland_laea(ax=ax)
grid1.plot(basemap, linewidth=.1)

# ------------ Render the page
figure.savefig(grid_fname + '.pdf', dpi=100, transparent=False)
예제 #4
0
import icebin
from icebin import ibgrid
import sys

import giss.basemap

grid_fname = sys.argv[1]
vname = sys.argv[2]

# =============== Step 2: Plot grid outlines

# Set up the page
figure = matplotlib.pyplot.figure(figsize=(11,8.5))
# figure.set_size_inches(11., 8.5)# US Letter
figure.set_size_inches(8.267,11.692)# A4

# -------- First plot: grid1

# Read the grid
nc = netCDF4.Dataset(grid_fname + '.nc', 'r')
grid1 = ibgrid.read_nc(nc, vname)
nc.close()

# Plot it!
ax = figure.add_subplot(111)
basemap = giss.basemap.greenland_laea(ax=ax)
grid1.plot(basemap, linewidth=.1)

# ------------ Render the page
figure.savefig(grid_fname + '.pdf', dpi=100, transparent=False)
예제 #5
0
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import netCDF4
from icebin import ibgrid
from matplotlib import pyplot
import giss.basemap

# Loads an plots grids from an IceBin grid file
# See: https://github.com/citibob/icebin

figure = pyplot.figure(figsize=(11., 8.5))

# -------------- Plot ice grid
with netCDF4.Dataset('modele_ll_g2x2_5-ISSM_mesh.nc') as nc:
    grid = ibgrid.read_nc(nc, 'gridI')

ax = figure.add_subplot(121)
basemap = giss.basemap.greenland_laea()
grid.plot(basemap, ax=ax)

# -------------- Plot GCM grid
with netCDF4.Dataset('modele_ll_g2x2_5.nc') as nc:
    grid = ibgrid.read_nc(nc, 'grid')

ax = figure.add_subplot(122)
basemap = giss.basemap.greenland_laea()
grid.plot(basemap, ax=ax)

# ---------------- Get a regridding matrix
예제 #6
0
from icebin import ibgrid, element_l1

ISSM_IN = 'modele_ll_g2x2_5-ISSM_mesh.nc'

with netCDF4.Dataset(ISSM_IN) as nc:
    gridA = ibgrid.read_nc(nc, 'gridA')    # ISMIP6 Grid
    gridI = ibgrid.read_nc(nc, 'gridI')    # ISSM Grid
    exgrid = ibgrid.read_nc(nc, 'exgrid')    # Exchange Grid

AvI,weightsA,weightsI = element_l1.compute_AvI(gridX, gridI)

valueI = ...
valueA = (1. / weightsA) * AvI * valueI
예제 #7
0
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import netCDF4
from icebin import ibgrid
from matplotlib import pyplot
import giss.basemap

# Loads an plots grids from an IceBin grid file
# See: https://github.com/citibob/icebin

figure = pyplot.figure(figsize=(11.,8.5))

# -------------- Plot ice grid
with netCDF4.Dataset('modele_ll_g2x2_5-ISSM_mesh.nc') as nc:
    grid = ibgrid.read_nc(nc, 'gridI')

ax = figure.add_subplot(121)
basemap = giss.basemap.greenland_laea()
grid.plot(basemap, ax=ax)

# -------------- Plot GCM grid
with netCDF4.Dataset('modele_ll_g2x2_5.nc') as nc:
    grid = ibgrid.read_nc(nc, 'grid')

ax = figure.add_subplot(122)
basemap = giss.basemap.greenland_laea()
grid.plot(basemap, ax=ax)

# ---------------- Get a regridding matrix