コード例 #1
0
ファイル: cmp_lindex.py プロジェクト: citibeth/icebin
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
# 
# 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
import giss

nc = netCDF4.Dataset('hp2hc.nc')
hp2hc = giss.read_coo_matrix(nc, 'hp2hc')
nc.close()

#print hp2hc.__dict__

nc = netCDF4.Dataset('fhc-00.nc')
jm = len(nc.dimensions['jm'])
im = len(nc.dimensions['im'])
nhp = len(nc.dimensions['nhp'])
rows_i = nc.variables['rows_i'][:]
rows_j = nc.variables['rows_j'][:]
rows_k = nc.variables['rows_k'][:]
cols_i = nc.variables['cols_i'][:]
cols_j = nc.variables['cols_j'][:]
cols_k = nc.variables['cols_k'][:]
vals = nc.variables['vals'][:]
コード例 #2
0
ファイル: cmp_i2hc.py プロジェクト: seifer08ms/icebin
fhc_nc = 'fhc-00.nc'


# Read a height-points field so we can play with it
nc = netCDF4.Dataset('JUL1950.ijhchc1k225.nc')
vv = nc.variables['impm_lndice']
val1hp = np.zeros(vv.shape)
val1hp[:] = vv[:]
val1hp[np.abs(val1hp)>1e10] = 0
nc.close()

#val1hp[:] = 1.

# Read the matrices
nc = netCDF4.Dataset('i2hc.nc')
i2hc = giss.read_coo_matrix(nc, 'i2hc')
hp2i = giss.read_coo_matrix(nc, 'hp2i')
nc.close()

# This replicates the picture from December AGU
val2 = glint2.coo_multiply(hp2i, val1hp, fill=np.nan)

# --------------------------------
# Now try to get val1hc
val1hc = glint2.coo_multiply(i2hc, val2, fill=np.nan)
val1hc_r = val1hc.reshape(val1hp.shape)

ncout = netCDF4.Dataset('val1hc-py.nc', 'w')
ncout.createDimension('nhp', val1hp.shape[0])
ncout.createDimension('jm', val1hp.shape[1])
ncout.createDimension('im', val1hp.shape[2])
コード例 #3
0
ファイル: cmp_lindex.py プロジェクト: nkianggiss/icebin
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# 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
import giss

nc = netCDF4.Dataset('hp2hc.nc')
hp2hc = giss.read_coo_matrix(nc, 'hp2hc')
nc.close()

#print hp2hc.__dict__

nc = netCDF4.Dataset('fhc-00.nc')
jm = len(nc.dimensions['jm'])
im = len(nc.dimensions['im'])
nhp = len(nc.dimensions['nhp'])
rows_i = nc.variables['rows_i'][:]
rows_j = nc.variables['rows_j'][:]
rows_k = nc.variables['rows_k'][:]
cols_i = nc.variables['cols_i'][:]
cols_j = nc.variables['cols_j'][:]
cols_k = nc.variables['cols_k'][:]
vals = nc.variables['vals'][:]
コード例 #4
0
fhc_nc = 'fhc-00.nc'

# Read a height-points field so we can play with it
nc = netCDF4.Dataset('JUL1950.ijhchc1k225.nc')
vv = nc.variables['impm_lndice']
val1hp = np.zeros(vv.shape)
val1hp[:] = vv[:]
val1hp[np.abs(val1hp) > 1e10] = 0
nc.close()

#val1hp[:] = 1.

# Read the matrices
nc = netCDF4.Dataset('i2hc.nc')
i2hc = giss.read_coo_matrix(nc, 'i2hc')
hp2i = giss.read_coo_matrix(nc, 'hp2i')
nc.close()

# This replicates the picture from December AGU
val2 = glint2.coo_multiply(hp2i, val1hp, fill=np.nan)

# --------------------------------
# Now try to get val1hc
val1hc = glint2.coo_multiply(i2hc, val2, fill=np.nan)
val1hc_r = val1hc.reshape(val1hp.shape)

ncout = netCDF4.Dataset('val1hc-py.nc', 'w')
ncout.createDimension('nhp', val1hp.shape[0])
ncout.createDimension('jm', val1hp.shape[1])
ncout.createDimension('im', val1hp.shape[2])