Changeset 27839


Ignore:
Timestamp:
07/19/23 13:46:00 (20 months ago)
Author:
jdquinn
Message:

CHG: initialization.age was not being marshalled; cleanup

Location:
issm/trunk-jpl
Files:
3 edited

Legend:

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

    r24726 r27839  
    1 #!/usr/bin/env python
     1#!/usr/bin/env python3
    22import numpy as np
    33from os import environ, path
     
    66from argparse import ArgumentParser
    77
    8 def BinRead(filin, filout='', verbose=0):  #{{{
     8def BinRead(infile, outfile='', verbose=0):  #{{{
    99
    10     print("reading binary file.")
    11     f = open(filin, 'rb')
     10    print('reading binary file')
     11    f = open(infile, 'rb')
    1212
    13     if filout:
    14         sys.stdout = open(filout, 'w')
     13    if outfile:
     14        sys.stdout = open(outfile, 'w')
    1515
    1616    while True:
    1717        try:
    18             #Step 1: read size of record name
     18            # Step 1: Read size of record name
    1919            recordnamesize = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    2020        except struct.error as e:
    21             print("probable EOF: {}".format(e))
     21            print('probable EOF: {}'.format(e))
    2222            break
    2323
    24         print("============================================================================ ")
     24        print('============================================================================')
    2525        if verbose > 2:
    26             print("\n recordnamesize = {}".format(recordnamesize))
    27         recordname = struct.unpack('{}s'.format(recordnamesize), f.read(recordnamesize))[0]
    28         print("field: {}".format(recordname))
     26            print('\n recordnamesize = {}'.format(recordnamesize))
     27        recordname = struct.unpack('{}s'.format(recordnamesize), f.read(recordnamesize))[0].decode('ASCII')
     28        print('field: {}'.format(recordname))
    2929
    30         #Step 2: read the data itself.
    31         #first read length of record
     30        # Step 2: Read the data itself
     31        # First read length of record
    3232        #reclen = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    3333        reclen = struct.unpack('q', f.read(struct.calcsize('q')))[0]
    3434        if verbose > 1:
    35             print("reclen = {}".format(reclen))
     35            print('reclen = {}'.format(reclen))
    3636
    37         #read data code:
     37        # Read data code
    3838        code = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    39         print("Format = {} (code {})".format(CodeToFormat(code), code))
     39        print('Format = {} (code {})'.format(CodeToFormat(code), code))
    4040
    4141        if code == FormatToCode('Boolean'):
    4242            bval = struct.unpack('i', f.read(reclen - struct.calcsize('i')))[0]
    43             print("value = {}".format(bval))
     43            print('value = {}'.format(bval))
    4444
    4545        elif code == FormatToCode('Integer'):
    4646            ival = struct.unpack('i', f.read(reclen - struct.calcsize('i')))[0]
    47             print("value = {}".format(ival))
     47            print('value = {}'.format(ival))
    4848
    4949        elif code == FormatToCode('Double'):
    5050            dval = struct.unpack('d', f.read(reclen - struct.calcsize('i')))[0]
    51             print("value = {}".format(dval))
     51            print('value = {}'.format(dval))
    5252
    5353        elif code == FormatToCode('String'):
    5454            strlen = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    5555            if verbose > 1:
    56                 print("strlen = {}".format(strlen))
     56                print('strlen = {}'.format(strlen))
    5757            sval = struct.unpack('{}s'.format(strlen), f.read(strlen))[0]
    58             print("value = '{}'".format(sval))
     58            print('value = {}'.format(sval))
    5959
    6060        elif code == FormatToCode('BooleanMat'):
    61             #read matrix type:
     61            # Read matrix type
    6262            mattype = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    63             print("mattype = {}".format(mattype))
     63            print('mattype = {}'.format(mattype))
    6464
    65             #now read matrix
     65            # Read matrix
    6666            s = [0, 0]
    6767            s[0] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    6868            s[1] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    69             print("size = [{}x{}]".format(s[0], s[1]))
     69            print('size = [{}x{}]'.format(s[0], s[1]))
    7070            data = np.zeros((s[0], s[1]))
    7171            for i in range(s[0]):
    7272                for j in range(s[1]):
    73                     data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0]    #get to the "c" convention, hence the transpose
     73                    data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0]
    7474                    if verbose > 2:
    75                         print("data[{}, {}] = {}".format(i, j, data[i][j]))
     75                        print('data[{}, {}] = {}'.format(i, j, data[i][j]))
    7676
    7777        elif code == FormatToCode('IntMat'):
    78             #read matrix type:
     78            # Read matrix type
    7979            mattype = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    80             print("mattype = {}".format(mattype))
     80            print('mattype = {}'.format(mattype))
    8181
    82             #now read matrix
     82            # Read matrix
    8383            s = [0, 0]
    8484            s[0] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    8585            s[1] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    86             print("size = [{}x{}]".format(s[0], s[1]))
     86            print('size = [{}x{}]'.format(s[0], s[1]))
    8787            data = np.zeros((s[0], s[1]))
    8888            for i in range(s[0]):
    8989                for j in range(s[1]):
    90                     data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0]    #get to the "c" convention, hence the transpose
     90                    data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0]
    9191                    if verbose > 2:
    92                         print("data[{}, {}] = {}".format(i, j, data[i][j]))
     92                        print('data[{}, {}] = {}'.format(i, j, data[i][j]))
    9393
    9494        elif code == FormatToCode('DoubleMat'):
    95             #read matrix type:
     95            # Read matrix type
    9696            mattype = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    97             print("mattype = {}".format(mattype))
     97            print('mattype = {}'.format(mattype))
    9898
    99             #now read matrix
     99            # Read matrix
    100100            s = [0, 0]
    101101            s[0] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    102102            s[1] = struct.unpack('i', f.read(struct.calcsize('i')))[0]
    103             print("size = [{}x{}]".format(s[0], s[1]))
     103            print('size = [{}x{}]'.format(s[0], s[1]))
    104104            data = np.zeros((s[0], s[1]))
    105105            for i in range(s[0]):
    106106                for j in range(s[1]):
    107                     data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0]    #get to the "c" convention, hence the transpose
     107                    data[i][j] = struct.unpack('d', f.read(struct.calcsize('d')))[0]
    108108                    if verbose > 2:
    109                         print("data[{}, {}] = {}".format(i, j, data[i][j]))
     109                        print('data[{}, {}] = {}'.format(i, j, data[i][j]))
    110110
    111111        elif code == FormatToCode('MatArray'):
    112112            f.seek(reclen - 4, 1)
    113             print("skipping {} bytes for code {}.".format(code, reclen - 4))
     113            print('skipping {} bytes for code {}'.format(code, reclen - 4))
    114114        elif code == FormatToCode('StringArray'):
    115115            f.seek(reclen - 4, 1)
    116             print("skipping {} bytes for code {}.".format(code, reclen - 4))
     116            print('skipping {} bytes for code {}'.format(code, reclen - 4))
    117117
    118118        else:
     
    123123
    124124def FormatToCode(format):  # {{{
    125     """
    126     This routine takes the format string, and hardcodes it into an integer, which
    127     is passed along the record, in order to identify the nature of the dataset being
    128     sent.
     125    """This routine takes the format string and converts it into an integer,
     126    which is passed along with the record in order to identify the nature of
     127    the data being sent.
    129128    """
    130129
     
    154153
    155154def CodeToFormat(code):  # {{{
    156     """
    157     This routine takes the format string, and hardcodes it into an integer, which
    158     is passed along the record, in order to identify the nature of the dataset being
    159     sent.
     155    """This routine takes a datatype code and converts it to the corresponding
     156    string in order to identify the nature of the data retrieved.
    160157    """
    161158
     
    186183if __name__ == '__main__':  #{{{
    187184    parser = ArgumentParser(description='BinRead - function to read binary input file.')
    188     parser.add_argument('-f', '--filin', help='name of binary input file', default='')
    189     parser.add_argument('-o', '--filout', help='optional name of text output file', default='')
     185    parser.add_argument('-f', '--infile', help='name of binary input file', default='')
     186    parser.add_argument('-o', '--outfile', help='optional name of text output file', default='')
    190187    parser.add_argument('-v', '--verbose', help='optional level of output', default=0)
    191188    args = parser.parse_args()
    192189
    193     BinRead(args.filin, args.filout, args.verbose)
     190    BinRead(args.infile, args.outfile, args.verbose)
    194191#}}}
  • issm/trunk-jpl/src/m/classes/initialization.m

    r27505 r27839  
    181181                        WriteData(fid,prefix,'object',self,'fieldname','hydraulic_potential','format','DoubleMat','mattype',1);
    182182                        WriteData(fid,prefix,'object',self,'fieldname','sample','format','DoubleMat','mattype',1);
    183                         WriteData(fid,prefix,'object',self,'fieldname','debris','format','DoubleMat','mattype',1,'scale',yts);
     183                        WriteData(fid,prefix,'object',self,'fieldname','debris','format','DoubleMat','mattype',1);
     184                        WriteData(fid,prefix,'object',self,'fieldname','age','format','DoubleMat','mattype',1,'scale',yts);
    184185
    185186                        if md.thermal.isenthalpy,
  • issm/trunk-jpl/test/NightlyRun/test2010.py

    r27747 r27839  
    124124areaice = md.results.TransientSolution.SealevelBarystaticIceArea
    125125areaice[np.isnan(areaice)] = 0
    126 print(np.isnan(areaice))
    127 print(np.sum(areaice))
    128126loadice = md.results.TransientSolution.SealevelBarystaticIceLoad
    129127rad_e = md.solidearth.planetradius
Note: See TracChangeset for help on using the changeset viewer.