Changeset 24732


Ignore:
Timestamp:
04/23/20 11:29:16 (5 years ago)
Author:
Mathieu Morlighem
Message:

CHG: time should be in years

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/scripts/OutbinRead.py

    r24726 r24732  
    77
    88def OutbinRead(filin, filout='', verbose=0):  #{{{
     9
     10    yts  = 365*24*3600.
    911
    1012    print("reading binary file.")
     
    3133        time = struct.unpack('d', f.read(struct.calcsize('d')))[0]
    3234        step = struct.unpack('i', f.read(struct.calcsize('i')))[0]
     35        if time!=-9999.: time = time/yts
    3336        print("time = {} step = {}".format(time,step))
    3437
     
    4043        M = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    4144        N = 1 #default
    42         print("M = {}".format(M))
    4345
    4446        #Step 2: read the data itself.
     
    7274            s[1] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    7375            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]))
    8085
    8186        else:
Note: See TracChangeset for help on using the changeset viewer.