- Timestamp:
- 06/07/17 10:50:54 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/branches/trunk-larour-NatGeoScience2016/src/m/archive/arch.py
r21170 r21759 1 import numpy 1 import numpy as np 2 2 import math 3 3 import struct … … 150 150 def write_vector(fid,data): # {{{ 151 151 """ 152 Procedure to write a n umpyarray to an arch file152 Procedure to write a np.array to an arch file 153 153 """ 154 154 # Make sure our vector is the correct shape. 155 155 # Reshape it into a row vector if it is not correct. 156 156 if isinstance(data,(bool,int,long,float)): 157 data=n umpy.array([data])157 data=np.array([data]) 158 158 elif isinstance(data,(list,tuple)): 159 data=n umpy.array(data).reshape(-1,1)160 161 if n umpy.ndim(data) == 1:162 if n umpy.size(data):163 data=data.reshape(n umpy.size(data),1)159 data=np.array(data).reshape(-1,) 160 161 if np.ndim(data) == 1: 162 if np.size(data): 163 data=data.reshape(np.size(data),) 164 164 else: 165 165 data=data.reshape(0,0) … … 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 raw_data=n umpy.zeros(shape=(rows,cols),dtype=float)218 raw_data=np.zeros(shape=(rows,cols),dtype=float) 219 219 for i in xrange(rows): 220 220 raw_data[i,:]=struct.unpack('>%dd' % cols,fid.read(cols*struct.calcsize('>d'))) … … 259 259 elif format.shape[0] == 1 and format.shape[1] == 1: 260 260 code=2 261 elif isinstance(format,(list,tuple,n umpy.ndarray)):261 elif isinstance(format,(list,tuple,np.ndarray)): 262 262 code=3 263 263 else:
Note:
See TracChangeset
for help on using the changeset viewer.