Changeset 21170
- Timestamp:
- 08/25/16 21:53:46 (9 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/archive/arch.py
r21166 r21170 216 216 rows=struct.unpack('>i',fid.read(struct.calcsize('>i')))[0] 217 217 cols=struct.unpack('>i',fid.read(struct.calcsize('>i')))[0] 218 data=numpy.zeros(shape=(rows,cols),dtype=float)218 raw_data=numpy.zeros(shape=(rows,cols),dtype=float) 219 219 for i in xrange(rows): 220 data[i,:]=struct.unpack('>%dd' % cols,fid.read(cols*struct.calcsize('>d'))) 220 raw_data[i,:]=struct.unpack('>%dd' % cols,fid.read(cols*struct.calcsize('>d'))) 221 # The matrix will be unpacked in order and will be filled left -> right by column 222 # We need to reshape and transpose the matrix so it can be read correctly 223 data=raw_data.reshape(raw_data.shape[::-1]).T 221 224 else: 222 225 raise TypeError("Cannot read data type %d" % data_type) -
issm/trunk-jpl/test/Par/79North.py
r19527 r21170 1 1 import os.path 2 2 import inspect 3 import netCDF4 3 from arch import * 4 4 import numpy 5 5 from verbose import verbose … … 11 11 12 12 #Geometry and observation 13 f = netCDF4.Dataset('../Data/79North.nc','r') 14 x = numpy.reshape(f.variables['x'][:],(-1)) 15 y = numpy.reshape(f.variables['y'][:],(-1)) 16 vx = f.variables['vx'][:] 17 vy = f.variables['vy'][:] 18 index = f.variables['index'][:] 19 surface = f.variables['surface'][:] 20 thickness = f.variables['thickness'][:] 21 f.close() 13 x = numpy.array(archread('../Data/79North.arch','x')) 14 y = numpy.array(archread('../Data/79North.arch','y')) 15 vx = numpy.array(archread('../Data/79North.arch','vx')); 16 vy = numpy.array(archread('../Data/79North.arch','vy')); 17 index = numpy.array(archread('../Data/79North.arch','index')); 18 surface = numpy.array(archread('../Data/79North.arch','surface')); 19 thickness = numpy.array(archread('../Data/79North.arch','thickness')); 22 20 23 21 [md.initialization.vx] = InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y) -
issm/trunk-jpl/test/Par/ISMIPE.py
r17769 r21170 1 1 import numpy 2 import netCDF4 2 from arch import * 3 3 from SetIceSheetBC import SetIceSheetBC 4 4 … … 6 6 7 7 print " creating thickness" 8 f = netCDF4.Dataset('../Data/ISMIPE.nc','r') 9 data = f.variables['data'][:] 10 f.close() 8 data = numpy.array(archread('../Data/ISMIPE.arch','data')); 11 9 md.geometry.surface=numpy.zeros((md.mesh.numberofvertices,1)) 12 10 md.geometry.base=numpy.zeros((md.mesh.numberofvertices,1)) -
issm/trunk-jpl/test/Par/Pig.py
r17769 r21170 1 1 import os.path 2 2 import inspect 3 import netCDF4 3 from arch import * 4 4 import numpy 5 5 from verbose import verbose … … 11 11 12 12 #Geometry and observation 13 f = netCDF4.Dataset('../Data/Pig.nc','r') 14 x = numpy.reshape(f.variables['x'][:],(-1)) 15 y = numpy.reshape(f.variables['y'][:],(-1)) 16 vx_obs = f.variables['vx_obs'][:] 17 vy_obs = f.variables['vy_obs'][:] 18 index = f.variables['index'][:] 19 surface = f.variables['surface'][:] 20 thickness = f.variables['thickness'][:] 21 f.close() 13 x = numpy.array(archread('../Data/Pig.arch','x')) 14 y = numpy.array(archread('../Data/Pig.arch','y')) 15 vx_obs = numpy.array(archread('../Data/Pig.arch','vx_obs')) 16 vy_obs = numpy.array(archread('../Data/Pig.arch','vy_obs')) 17 index = numpy.array(archread('../Data/Pig.arch','index')) 18 surface = numpy.array(archread('../Data/Pig.arch','surface')) 19 thickness = numpy.array(archread('../Data/Pig.arch','thickness')) 22 20 23 21 [md.inversion.vx_obs] =InterpFromMeshToMesh2d(index,x,y,vx_obs,md.mesh.x,md.mesh.y) -
issm/trunk-jpl/test/Par/SquareSheetConstrained.py
r20468 r21170 1 1 import os.path 2 import netCDF43 2 import numpy 4 3 import inspect … … 7 6 from paterson import paterson 8 7 from SetIceSheetBC import SetIceSheetBC 8 from arch import * 9 9 10 10 #Start defining model parameters here … … 22 22 23 23 #Initial velocity 24 f = netCDF4.Dataset('../Data/SquareSheetConstrained.nc','r') 25 x = numpy.reshape(f.variables['x'][:],(-1)) 26 y = numpy.reshape(f.variables['y'][:],(-1)) 27 vx = f.variables['vx'][:] 28 vy = f.variables['vy'][:] 29 index = f.variables['index'][:] 30 f.close() 24 x = numpy.array(archread('../Data/SquareSheetConstrained.arch','x')) 25 y = numpy.array(archread('../Data/SquareSheetConstrained.arch','y')) 26 vx = numpy.array(archread('../Data/SquareSheetConstrained.arch','vx')); 27 vy = numpy.array(archread('../Data/SquareSheetConstrained.arch','vy')); 28 index = archread('../Data/SquareSheetConstrained.arch','index').astype(int); 31 29 32 30 [md.initialization.vx]=InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y) -
issm/trunk-jpl/test/Par/SquareSheetShelf.py
r19527 r21170 1 1 import os.path 2 2 import inspect 3 import netCDF4 3 from arch import * 4 4 import numpy 5 5 from verbose import verbose … … 25 25 26 26 #Initial velocity 27 f = netCDF4.Dataset('../Data/SquareSheetShelf.nc','r') 28 x = numpy.reshape(f.variables['x'][:],(-1)) 29 y = numpy.reshape(f.variables['y'][:],(-1)) 30 vx = f.variables['vx'][:] 31 vy = f.variables['vy'][:] 32 index = f.variables['index'][:] 33 f.close() 27 x = numpy.array(archread('../Data/SquareSheetShelf.arch','x')) 28 y = numpy.array(archread('../Data/SquareSheetShelf.arch','y')) 29 vx = numpy.array(archread('../Data/SquareSheetShelf.arch','vx')); 30 vy = numpy.array(archread('../Data/SquareSheetShelf.arch','vy')); 31 index = numpy.array(archread('../Data/SquareSheetShelf.arch','index')); 34 32 35 33 [md.initialization.vx] = InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y) -
issm/trunk-jpl/test/Par/SquareShelf.py
r17769 r21170 1 1 import os.path 2 2 import inspect 3 import netCDF4 3 from arch import * 4 4 import numpy 5 5 from verbose import verbose … … 21 21 22 22 #Initial velocity and pressure 23 iVelF = netCDF4.Dataset('../Data/SquareShelf.nc','r') 24 25 x=numpy.reshape(iVelF.variables['x'][:],(-1)) 26 y=numpy.reshape(iVelF.variables['y'][:],(-1)) 27 vx=iVelF.variables['vx'][:] 28 vy=iVelF.variables['vy'][:] 29 index=iVelF.variables['index'][:].astype(int) 23 x = numpy.array(archread('../Data/SquareShelf.arch','x')) 24 y = numpy.array(archread('../Data/SquareShelf.arch','y')) 25 vx = numpy.array(archread('../Data/SquareShelf.arch','vx')); 26 vy = numpy.array(archread('../Data/SquareShelf.arch','vy')); 27 index = archread('../Data/SquareShelf.arch','index').astype(int); 30 28 31 29 #dbg - begin … … 34 32 # # print v 35 33 #dbg - end 36 37 iVelF.close()38 34 39 35 [md.initialization.vx]=InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y) -
issm/trunk-jpl/test/Par/SquareShelf2.py
r17769 r21170 1 1 import os.path 2 2 import inspect 3 import netCDF4 3 from arch import * 4 4 import numpy 5 5 from verbose import verbose … … 21 21 22 22 #Initial velocity and pressure 23 iVelF = netCDF4.Dataset('../Data/SquareShelf.nc','r') 24 25 x=numpy.reshape(iVelF.variables['x'][:],(-1)) 26 y=numpy.reshape(iVelF.variables['y'][:],(-1)) 27 vx=iVelF.variables['vx'][:] 28 vy=iVelF.variables['vy'][:] 29 index=iVelF.variables['index'][:].astype(int) 30 23 x = numpy.array(archread('../Data/SquareShelf.arch','x')) 24 y = numpy.array(archread('../Data/SquareShelf.arch','y')) 25 vx = numpy.array(archread('../Data/SquareShelf.arch','vx')); 26 vy = numpy.array(archread('../Data/SquareShelf.arch','vy')); 27 index = archread('../Data/SquareShelf.arch','index').astype(int); 31 28 #dbg - begin 32 29 # #print 'vars in SquareShelf.nc:' … … 34 31 # # print v 35 32 #dbg - end 36 37 iVelF.close()38 33 39 34 [md.initialization.vx]=InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y) -
issm/trunk-jpl/test/Par/SquareShelfConstrained.py
r20988 r21170 1 1 import os.path 2 import netCDF4 2 from arch import * 3 3 import numpy 4 4 import inspect … … 22 22 23 23 #Initial velocity 24 f = netCDF4.Dataset('../Data/SquareShelfConstrained.nc','r') 25 #Reshape as Rank-1 arrays 26 x=numpy.reshape(f.variables['x'][:],(-1)) 27 y=numpy.reshape(f.variables['y'][:],(-1)) 28 vx=f.variables['vx'][:] 29 vy=f.variables['vy'][:] 30 index=f.variables['index'][:] 31 f.close() 24 #x = numpy.reshape(numpy.array(archread('../Data/SquareShelfConstrained.arch','x')),(-1)) 25 #y = numpy.reshape(numpy.array(archread('../Data/SquareShelfConstrained.arch','y')),(-1)) 26 x = numpy.array(archread('../Data/SquareShelfConstrained.arch','x')) 27 y = numpy.array(archread('../Data/SquareShelfConstrained.arch','y')) 28 vx = numpy.array(archread('../Data/SquareShelfConstrained.arch','vx')) 29 vy = numpy.array(archread('../Data/SquareShelfConstrained.arch','vy')) 30 index = numpy.array(archread('../Data/SquareShelfConstrained.arch','index').astype(int)) 32 31 33 32 [md.initialization.vx]=InterpFromMeshToMesh2d(index,x,y,vx,md.mesh.x,md.mesh.y) -
issm/trunk-jpl/test/Par/ValleyGlacierShelf.py
r20468 r21170 1 1 import os.path 2 import netCDF4 2 from arch import * 3 3 import numpy 4 4 import inspect
Note:
See TracChangeset
for help on using the changeset viewer.