Ignore:
Timestamp:
06/07/17 10:50:54 (8 years ago)
Author:
Eric.Larour
Message:

CHG: merged branch back to trunk-jpl 21754.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/branches/trunk-larour-NatGeoScience2016/src/m/archive/arch.py

    r21170 r21759  
    1 import numpy
     1import numpy as np
    22import math
    33import struct
     
    150150def write_vector(fid,data): # {{{
    151151        """
    152         Procedure to write a numpy array to an arch file
     152        Procedure to write a np.array to an arch file
    153153        """
    154154        # Make sure our vector is the correct shape.
    155155        # Reshape it into a row vector if it is not correct.
    156156        if isinstance(data,(bool,int,long,float)):
    157                 data=numpy.array([data])
     157                data=np.array([data])
    158158        elif isinstance(data,(list,tuple)):
    159                 data=numpy.array(data).reshape(-1,1)
    160        
    161         if numpy.ndim(data) == 1:
    162                 if numpy.size(data):
    163                         data=data.reshape(numpy.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),)
    164164                else:
    165165                        data=data.reshape(0,0)
     
    216216                        rows=struct.unpack('>i',fid.read(struct.calcsize('>i')))[0]
    217217                        cols=struct.unpack('>i',fid.read(struct.calcsize('>i')))[0]
    218                         raw_data=numpy.zeros(shape=(rows,cols),dtype=float)
     218                        raw_data=np.zeros(shape=(rows,cols),dtype=float)
    219219                        for i in xrange(rows):
    220220                                raw_data[i,:]=struct.unpack('>%dd' % cols,fid.read(cols*struct.calcsize('>d')))
     
    259259        elif format.shape[0] == 1 and format.shape[1] == 1:
    260260                code=2
    261         elif isinstance(format,(list,tuple,numpy.ndarray)):
     261        elif isinstance(format,(list,tuple,np.ndarray)):
    262262                code=3
    263263        else:
Note: See TracChangeset for help on using the changeset viewer.