Changeset 24732
- Timestamp:
- 04/23/20 11:29:16 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/scripts/OutbinRead.py
r24726 r24732 7 7 8 8 def OutbinRead(filin, filout='', verbose=0): #{{{ 9 10 yts = 365*24*3600. 9 11 10 12 print("reading binary file.") … … 31 33 time = struct.unpack('d', f.read(struct.calcsize('d')))[0] 32 34 step = struct.unpack('i', f.read(struct.calcsize('i')))[0] 35 if time!=-9999.: time = time/yts 33 36 print("time = {} step = {}".format(time,step)) 34 37 … … 40 43 M = struct.unpack('i', f.read(struct.calcsize('i')))[0] 41 44 N = 1 #default 42 print("M = {}".format(M))43 45 44 46 #Step 2: read the data itself. … … 72 74 s[1] = struct.unpack('i', f.read(struct.calcsize('i')))[0] 73 75 print("size = [{}x{}]".format(s[0], s[1])) 74 data = np.zeros((s[0], s[1])) 75 for i in range(s[0]): 76 for j in range(s[1]): 77 data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0] #get to the "c" convention, hence the transpose 78 if verbose > 2: 79 print("data[{}, {}] = {}".format(i, j, data[i][j])) 76 if True: 77 f.read(struct.calcsize('d')*s[0]*s[1]) 78 else: 79 data = np.zeros((s[0], s[1])) 80 for i in range(s[0]): 81 for j in range(s[1]): 82 data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0] #get to the "c" convention, hence the transpose 83 if verbose > 2: 84 print("data[{}, {}] = {}".format(i, j, data[i][j])) 80 85 81 86 else:
Note:
See TracChangeset
for help on using the changeset viewer.