Ignore:
Timestamp:
07/24/21 17:33:34 (4 years ago)
Author:
jdquinn
Message:

CHG: Completed MATLAB -> Python updates for SE; archive updates now that GMSH can be used on macOS and Linux; various minor bug fixes; formatting; cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/solve/loadresultfromdisk.py

    r25817 r26358  
    44
    55def loadresultfromdisk(filename, step, name, *args):  # {{{
    6     """
    7     LOADRESULTFROMDISK - load specific result of solution sequence from disk
     6    """LOADRESULTFROMDISK - load specific result of solution sequence from disk
    87    file "filename"
    98
    10         Usage:
    11             variable = loadresultsfromdisk(filename, step, name)
     9    Usage:
     10        variable = loadresultsfromdisk(filename, step, name)
    1211
    13         TODO:
    14         - Test this module against output of src/m/solve/loadresultsfromdisk.m
     12    TODO:
     13    - Test this module against output of src/m/solve/loadresultsfromdisk.m
    1514    """
    16     print('Got hwrwefew')
    17     exit()
     15
    1816    # Open file
    1917    try:
     
    5957                for i in range(M):
    6058                    field[i, :] = struct.unpack('{}i'.format(N), fid.read(N * struct.calcsize('i')))
     59            elif datatype == 5:
     60                # TODO:
     61                # - Check that the following results in the same output as
     62                # MATLAB
     63                #
     64                N = struct.unpack('i', fid.read(struct.calcsize('i')))[0]
     65                fieldr = np.zeros(shape=(M, N), dtype=float)
     66                fieldi = np.zeros(shape=(M, N), dtype=float)
     67                for i in range(M):
     68                    fieldr[i, :] = struct.unpack('{}d'.format(N), fid.read(N * struct.calcsize('d')))
     69                    fieldi[i, :] = struct.unpack('{}d'.format(N), fid.read(N * struct.calcsize('d')))
     70                field = np.vectorize(complex)(fieldr, fieldi)
     71                print(field)
    6172            else:
    6273                raise TypeError("cannot read data of type {}".format(datatype))
Note: See TracChangeset for help on using the changeset viewer.