How to use the construct.SLInt32 function in construct

To help you get started, we’ve selected a few construct examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PIC-IRIS / PH5 / ph5 / core / sac_h.py View on Github external
construct.SLInt32("nzhour"),  # GMT hour.
                           construct.SLInt32("nzmin"),  # GMT minute.
                           construct.SLInt32("nzsec"),  # GMT second.
                           construct.SLInt32("nzmsec"),  # GMT millisecond.
                           # Header version number. Current value is the
                           # integer 6.
                           construct.SLInt32("nvhdr"),
                           # Older version data (NVHDR < 6) are automatically
                           # updated
                           construct.SLInt32("norid"),  # Origin ID (CSS 3.0)
                           construct.SLInt32("nevid"),  # Event ID (CSS 3.0)
                           # Number of points per data component. [required]
                           construct.SLInt32("npts"),
                           construct.SLInt32("nsnpts"),     #
                           construct.SLInt32("nwfid"),  # Waveform ID (CSS 3.0)
                           construct.SLInt32("nxsize"),     #
                           construct.SLInt32("nysize"),     #
                           construct.SLInt32("unused15"),   #
                           # Type of file [required]:
                           construct.SLInt32("iftype"),
                           #    * ITIME {Time series file}
                           #    * IRLIM {Spectral file---real and imaginary}
                           #    * IAMPH {Spectral file---amplitude and phase}
                           #    * IXY {General x versus y data}
                           #    * IXYZ {General XYZ (3-D) file}
                           # Type of dependent variable:
                           construct.SLInt32("idep"),
                           #    * IUNKN (Unknown)
                           #    * IDISP (Displacement in nm)
                           #    * IVEL (Velocity in nm/sec)
                           #    * IVOLTS (Velocity in volts)
                           #    * IACC (Acceleration in nm/sec/sec)
github fredreichbier / genie / genie / slp / __init__.py View on Github external
"""

import struct

import construct as cons

class FrameAdapter(cons.Adapter):
    def _decode(self, obj, context):
        return Frame(context['_']['slp_file'], obj)

FRAME = cons.Struct('frames',
    cons.ULInt32('cmd_table_offset'),
    cons.ULInt32('outline_table_offset'),
    cons.ULInt32('palette_offset'),
    cons.ULInt32('properties'),
    cons.SLInt32('width'),
    cons.SLInt32('height'),
    cons.SLInt32('hotspot_x'),
    cons.SLInt32('hotspot_y'),
)

HEADER = cons.Struct('header',
    cons.String('version', 4),
    cons.ULInt32('num_frames'),
    cons.String('comment', 24),
    cons.Array(lambda ctx: ctx['num_frames'], FrameAdapter(FRAME)),
)

class ImageAdapter(object):
    """
        A generic image writer. Could be used with PIL, cairo, ...
    """
github PIC-IRIS / PH5 / ph5 / core / sac_h.py View on Github external
# * IEX (Other explosion)
                           # * INU (Nuclear explosion)
                           # * INC (Nuclear cavity collapse)
                           # * IO\_ (Other source of known origin)
                           # * IR (Regional event of unknown origin)
                           # * IT (Teleseismic event of unknown origin)
                           # * IU (Undetermined or conflicting information)
                           # Quality of data [not currently used]:
                           construct.SLInt32("iqual"),
                           #    * IGOOD (Good data)
                           #    * IGLCH (Glitches)
                           #    * IDROP (Dropouts)
                           #    * ILOWSN (Low signal to noise ratio)
                           #    * IOTHER (Other)
                           # Synthetic data flag [not currently used]:
                           construct.SLInt32("isynth"),
                           #    * IRLDTA (Real data)
                           #    * ?????
                           #    (Flags for various synthetic seismogram
                           #      codes)
                           construct.SLInt32("imagtyp"),    #
                           construct.SLInt32("imagsrc"),    #
                           construct.SLInt32("unused19"),   #
                           construct.SLInt32("unused20"),   #
                           construct.SLInt32("unused21"),   #
                           construct.SLInt32("unused22"),   #
                           construct.SLInt32("unused23"),   #
                           construct.SLInt32("unused24"),   #
                           construct.SLInt32("unused25"),   #
                           construct.SLInt32("unused26"),   #
                           # TRUE if data is evenly spaced. [required]
                           construct.SLInt32("leven"),
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
construct.SLInt32("sourceSurfaceElevation"),
                             construct.SLInt32("sourceDepth"),  # Source depth
                             # Elevation at receiver group
                             construct.SLInt32("datumElevRec"),
                             # Source elevation
                             construct.SLInt32("datumElevSource"),
                             # Water depth at source
                             construct.SLInt32("sourceWaterDepth"),
                             # Water depth at group
                             construct.SLInt32("recWaterDepth"),
                             # Elevation and depth scalar
                             construct.SLInt16("elevationScale"),
                             # Coordinate scalar
                             construct.SLInt16("coordScale"),
                             # X coordinate of source
                             construct.SLInt32("sourceLongOrX"),
                             # Y coordinate of source
                             construct.SLInt32("sourceLatOrY"),
                             # X coordinate of receiver group
                             construct.SLInt32("recLongOrX"),
                             # Y coordinate of receiver group
                             construct.SLInt32("recLatOrY"),
                             # Coordinate system
                             construct.SLInt16("coordUnits"),
                             # Weathering velocity
                             construct.SLInt16("weatheringVelocity"),
                             # Sub-weathering velocity
                             construct.SLInt16("subWeatheringVelocity"),
                             # Uphole time at source in ms
                             construct.SLInt16("sourceUpholeTime"),
                             # Uphole time at group in ms
                             construct.SLInt16("recUpholeTime"),
github PIC-IRIS / PH5 / ph5 / core / sac_h.py View on Github external
#    * IRLDTA (Real data)
                           #    * ?????
                           #    (Flags for various synthetic seismogram
                           #      codes)
                           construct.SLInt32("imagtyp"),    #
                           construct.SLInt32("imagsrc"),    #
                           construct.SLInt32("unused19"),   #
                           construct.SLInt32("unused20"),   #
                           construct.SLInt32("unused21"),   #
                           construct.SLInt32("unused22"),   #
                           construct.SLInt32("unused23"),   #
                           construct.SLInt32("unused24"),   #
                           construct.SLInt32("unused25"),   #
                           construct.SLInt32("unused26"),   #
                           # TRUE if data is evenly spaced. [required]
                           construct.SLInt32("leven"),
                           # TRUE if station components have a positive
                           # polarity
                           construct.SLInt32("lpspol"),
                           # (left-hand rule).
                           # TRUE if it is okay to overwrite this file on disk.
                           construct.SLInt32("lovrok"),
                           # TRUE if DIST AZ BAZ and GCARC are to be calculated
                           # from
                           construct.SLInt32("lcalda"),
                           # st event coordinates.
                           construct.SLInt32("unused27"))
    return BIN
# SAC Little Endian binary header, string part
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
def seg_header_le():
    TRACE = construct.Struct("TRACE",
                             # X coordinate of ensemble
                             construct.SLInt32("Xcoor"),
                             # Y coordinate of ensemble
                             construct.SLInt32("Ycoor"),
                             # Same as lino in reel header
                             construct.SLInt32("Inn"),
                             construct.SLInt32("Cnn"),  # Same as cdp
                             construct.SLInt32("Spn"),  # Shot point number
                             # Scaler to apply to Spn
                             construct.SLInt16("Scal"),
                             # Trace value measurement units
                             construct.SLInt16("Tvmu"),
                             # Transduction constant mantissa
                             construct.SLInt32("Tucmant"),
                             # Transduction constant exponent
                             construct.SLInt16("Tucexp"),
                             construct.SLInt16("Tdu"),  # Transduction units
                             # Device/Trace identifier
                             construct.SLInt16("Dti"),
                             construct.SLInt16("Tscaler"),  # Time scalar
                             # Source Type/Orientation
                             construct.SLInt16("Sto"),
                             # Source Energy direction
                             construct.String("Sed", 6),
                             # Source measurement mantissa
                             construct.SLInt32("Smsmant"),
                             # Source measurement exponent
                             construct.SLInt16("Smsexp"),
                             # Source measurement Units
                             construct.SLInt16("Smu"),
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
def seg_header_le():
    TRACE = construct.Struct("TRACE",
                             # X coordinate of ensemble
                             construct.SLInt32("Xcoor"),
                             # Y coordinate of ensemble
                             construct.SLInt32("Ycoor"),
                             # Same as lino in reel header
                             construct.SLInt32("Inn"),
                             construct.SLInt32("Cnn"),  # Same as cdp
                             construct.SLInt32("Spn"),  # Shot point number
                             # Scaler to apply to Spn
                             construct.SLInt16("Scal"),
                             # Trace value measurement units
                             construct.SLInt16("Tvmu"),
                             # Transduction constant mantissa
                             construct.SLInt32("Tucmant"),
                             # Transduction constant exponent
                             construct.SLInt16("Tucexp"),
                             construct.SLInt16("Tdu"),  # Transduction units
                             # Device/Trace identifier
                             construct.SLInt16("Dti"),
                             construct.SLInt16("Tscaler"),  # Time scalar
                             # Source Type/Orientation
                             construct.SLInt16("Sto"),
                             # Source Energy direction
                             construct.String("Sed", 6),
github PIC-IRIS / PH5 / ph5 / core / sac_h.py View on Github external
# Number of points per data component. [required]
                           construct.SLInt32("npts"),
                           construct.SLInt32("nsnpts"),     #
                           construct.SLInt32("nwfid"),  # Waveform ID (CSS 3.0)
                           construct.SLInt32("nxsize"),     #
                           construct.SLInt32("nysize"),     #
                           construct.SLInt32("unused15"),   #
                           # Type of file [required]:
                           construct.SLInt32("iftype"),
                           #    * ITIME {Time series file}
                           #    * IRLIM {Spectral file---real and imaginary}
                           #    * IAMPH {Spectral file---amplitude and phase}
                           #    * IXY {General x versus y data}
                           #    * IXYZ {General XYZ (3-D) file}
                           # Type of dependent variable:
                           construct.SLInt32("idep"),
                           #    * IUNKN (Unknown)
                           #    * IDISP (Displacement in nm)
                           #    * IVEL (Velocity in nm/sec)
                           #    * IVOLTS (Velocity in volts)
                           #    * IACC (Acceleration in nm/sec/sec)
                           # Reference time equivalence:
                           construct.SLInt32("iztype"),
                           #    * IUNKN (5): Unknown
                           #    * IB (9): Begin time
                           #    * IDAY (10): Midnight of refernece GMT day
                           #    * IO (11): Event origin time
                           #    * IA (12): First arrival time
                           #    * ITn (13-22): User defined time pick n,n=0,9
                           construct.SLInt32("unused16"),   #
                           # Type of recording instrument. [currently not used]
                           construct.SLInt32("iinst"),
github PIC-IRIS / PH5 / ph5 / core / sac_h.py View on Github external
#    * IDROP (Dropouts)
                           #    * ILOWSN (Low signal to noise ratio)
                           #    * IOTHER (Other)
                           # Synthetic data flag [not currently used]:
                           construct.SLInt32("isynth"),
                           #    * IRLDTA (Real data)
                           #    * ?????
                           #    (Flags for various synthetic seismogram
                           #      codes)
                           construct.SLInt32("imagtyp"),    #
                           construct.SLInt32("imagsrc"),    #
                           construct.SLInt32("unused19"),   #
                           construct.SLInt32("unused20"),   #
                           construct.SLInt32("unused21"),   #
                           construct.SLInt32("unused22"),   #
                           construct.SLInt32("unused23"),   #
                           construct.SLInt32("unused24"),   #
                           construct.SLInt32("unused25"),   #
                           construct.SLInt32("unused26"),   #
                           # TRUE if data is evenly spaced. [required]
                           construct.SLInt32("leven"),
                           # TRUE if station components have a positive
                           # polarity
                           construct.SLInt32("lpspol"),
                           # (left-hand rule).
                           # TRUE if it is okay to overwrite this file on disk.
                           construct.SLInt32("lovrok"),
                           # TRUE if DIST AZ BAZ and GCARC are to be calculated
                           # from
                           construct.SLInt32("lcalda"),
                           # st event coordinates.
                           construct.SLInt32("unused27"))
github PIC-IRIS / PH5 / ph5 / core / sac_h.py View on Github external
def bin_header_le_int():
    BIN = construct.Struct("BIN",
                           # GMT year corresponding to reference (zero) time in
                           # file.
                           construct.SLInt32("nzyear"),
                           construct.SLInt32("nzjday"),  # GMT julian day.
                           construct.SLInt32("nzhour"),  # GMT hour.
                           construct.SLInt32("nzmin"),  # GMT minute.
                           construct.SLInt32("nzsec"),  # GMT second.
                           construct.SLInt32("nzmsec"),  # GMT millisecond.
                           # Header version number. Current value is the
                           # integer 6.
                           construct.SLInt32("nvhdr"),
                           # Older version data (NVHDR < 6) are automatically
                           # updated
                           construct.SLInt32("norid"),  # Origin ID (CSS 3.0)
                           construct.SLInt32("nevid"),  # Event ID (CSS 3.0)
                           # Number of points per data component. [required]
                           construct.SLInt32("npts"),
                           construct.SLInt32("nsnpts"),     #
                           construct.SLInt32("nwfid"),  # Waveform ID (CSS 3.0)
                           construct.SLInt32("nxsize"),     #
                           construct.SLInt32("nysize"),     #
                           construct.SLInt32("unused15"),   #