How to use the construct.BitField 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 / segd_h.py View on Github external
construct.BitField(
                                  "record_length", 12, swapped=swap),
                              construct.BitField(
                                  "scan_types_per_record", 8, swapped=swap),
                              # 0xFF look in general header block 2
                              construct.BitField(
                                  "chan_sets_per_scan", 8, swapped=swap),
                              construct.BitField(
                                  "number_skew_blocks", 8, swapped=swap),
                              # 0xFF look in general header block 2
                              construct.BitField(
                                  "number_extended_header_blocks",
                                  8,
                                  swapped=swap),
                              # 0xFF look in general header block 2
                              construct.BitField(
                                  "number_external_header_blocks",
                                  8,
                                  swapped=swap))

    return BIN
github PIC-IRIS / PH5 / ph5 / core / segy_h.py View on Github external
construct.UBInt16("hstas"),
                            # Sweep taper length ms at end
                            construct.UBInt16("hstae"),
                            construct.UBInt16("htatyp"),  # Taper type
                            # Correlated data traces
                            construct.UBInt16("hcorr"),
                            # Binary gain recovered
                            construct.UBInt16("bgrcv"),
                            # Amplitude recovery method
                            construct.UBInt16("rcvm"),
                            construct.UBInt16("mfeet"),  # Measurement system
                            # Impulse signal polarity
                            construct.UBInt16("polyt"),
                            # Vibratory polarity code
                            construct.UBInt16("vpol"),
                            construct.BitField("unass1", 240),  # Unassigned
                            # *** SEG-Y Revision number   ***
                            construct.UBInt16("rev"),
                            construct.UBInt16("trlen"),  # *** Trace length ***
                            # *** Number of extended text headers ***
                            construct.UBInt16("extxt"),
                            construct.BitField("unass2", 94))  # Unassigned
    return REEL
github PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
# 20 is Fairfield
                              construct.BitField(
                                  "manufactures_code", 8, swapped=swap),
                              construct.BitField(
                                  "manufactures_sn", 16, swapped=swap),
                              # Traces written in superblocks. 0=No, 1=Yes
                              construct.BitField(
                                  "super_blocks", 8, swapped=swap),
                              construct.BitField("user01", 16, swapped=swap),
                              # Sample interval in 1/16 msec
                              construct.BitField(
                                  "base_scan_interval", 8, swapped=swap),
                              construct.BitField(
                                  "polarity_code", 4, swapped=swap),
                              construct.BitField("user02", 12, swapped=swap),
                              construct.BitField(
                                  "record_type", 4, swapped=swap),
                              # From time zero, 0.5 X 1.024 seconds, if 0xFFF
                              # look in general header block 2
                              construct.BitField(
                                  "record_length", 12, swapped=swap),
                              construct.BitField(
                                  "scan_types_per_record", 8, swapped=swap),
                              # 0xFF look in general header block 2
                              construct.BitField(
                                  "chan_sets_per_scan", 8, swapped=swap),
                              construct.BitField(
                                  "number_skew_blocks", 8, swapped=swap),
                              # 0xFF look in general header block 2
                              construct.BitField(
                                  "number_extended_header_blocks",
                                  8,
github PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
"chan_type_code", 4, swapped=swap),
                              construct.BitField("user01", 4, swapped=swap),
                              construct.BitField(
                                  "number_sub-scans", 4, swapped=swap),
                              # 3 is fixed gain
                              construct.BitField(
                                  "gain_control_type", 4, swapped=swap),
                              construct.BitField(
                                  "alias_filter_freq", 16, swapped=swap),
                              construct.BitField(
                                  "alias_filter_slope_db", 16, swapped=swap),
                              construct.BitField(
                                  "low_cut_filter_freq", 16, swapped=swap),
                              construct.BitField(
                                  "low_cut_filter_slope_db", 16, swapped=swap),
                              construct.BitField(
                                  "notch_filter_freq", 16, swapped=swap),
                              construct.BitField(
                                  "second_notch_filter_freq",
                                  16,
                                  swapped=swap),
                              construct.BitField(
                                  "third_notch_filter_freq",
                                  16,
                                  swapped=swap),
                              construct.BitField(
                                  "extended_chan_set_number",
                                  16,
                                  swapped=swap),
                              construct.BitField(
                                  "extended_header_flag", 4, swapped=swap),
                              # Always 10 for Fairfield
github PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
def general_header_block_3():
    swap = False
    if sys.byteorder == 'big':
        swap = False

    BIN = construct.BitStruct("BIN",
                              construct.BitField(
                                  "extended_file_number", 24, swapped=swap),
                              construct.BitField(
                                  "source_line_number_int", 24, swapped=swap),
                              construct.BitField(
                                  "source_line_number_frac", 16, swapped=swap),
                              construct.BitField(
                                  "source_point_number_int", 24, swapped=swap),
                              construct.BitField(
                                  "source_point_number_frac",
                                  16,
                                  swapped=swap),
                              construct.BitField(
                                  "source_point_index", 8, swapped=swap),
                              construct.BitField(
                                  "phase_control", 8, swapped=swap),
                              construct.BitField(
                                  "vibrator_type", 8, swapped=swap),
                              construct.BitField(
github PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
swapped=swap),
                              construct.BitField(
                                  "first_shot_point_doy", 12, swapped=swap),
                              construct.BitField(
                                  "first_shot_point_time_utc",
                                  24,
                                  swapped=swap),
                              # 20 is Fairfield
                              construct.BitField(
                                  "manufactures_code", 8, swapped=swap),
                              construct.BitField(
                                  "manufactures_sn", 16, swapped=swap),
                              # Traces written in superblocks. 0=No, 1=Yes
                              construct.BitField(
                                  "super_blocks", 8, swapped=swap),
                              construct.BitField("user01", 16, swapped=swap),
                              # Sample interval in 1/16 msec
                              construct.BitField(
                                  "base_scan_interval", 8, swapped=swap),
                              construct.BitField(
                                  "polarity_code", 4, swapped=swap),
                              construct.BitField("user02", 12, swapped=swap),
                              construct.BitField(
                                  "record_type", 4, swapped=swap),
                              # From time zero, 0.5 X 1.024 seconds, if 0xFFF
                              # look in general header block 2
                              construct.BitField(
                                  "record_length", 12, swapped=swap),
                              construct.BitField(
                                  "scan_types_per_record", 8, swapped=swap),
                              # 0xFF look in general header block 2
                              construct.BitField(
github PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
def channel_set_descriptor():
    swap = True
    if sys.byteorder == 'big':
        swap = False

    BIN = construct.BitStruct("BIN",
                              construct.BitField(
                                  "scan_type_number", 8, swapped=swap),
                              construct.BitField(
                                  "chan_set_number", 8, swapped=swap),
                              # Times 2 is milliseconds
                              construct.BitField(
                                  "chan_set_start_time", 16, swapped=swap),
                              # Times 2 is milliseconds
                              construct.BitField(
                                  "chan_set_end_time", 16, swapped=swap),
                              construct.BitField(
                                  "optional_mp_factor_extension_byte",
                                  8,
                                  swapped=swap),
                              construct.BitField(
                                  "mp_factor_scaler_multiplier",
                                  8,
                                  swapped=swap),
                              construct.BitField(
                                  "number_of_chans_in_chan_set",
                                  16,
                                  swapped=swap),
github PIC-IRIS / PH5 / ph5 / core / rt_130_h.py View on Github external
def data_packet():
    DT = construct.BitStruct("DT",
                             construct.BitField("PacketHeader", 128),
                             construct.BitField("EventNumber", 16),
                             construct.BitField("DataStream", 8),
                             construct.BitField("Channel", 8),
                             construct.BitField("Samples", 16),
                             # construct.BitField ("Flags", 8),
                             construct.Flag("Calibration"),
                             construct.Flag("Overscaled"),
                             construct.Flag("StackedData"),
                             construct.BitField("Unused", 2),
                             construct.Flag("Second_EH_ET"),
                             construct.Flag("LastDataPacket"),
                             construct.Flag("FirstDataPacket"),
                             construct.BitField("DataFormat", 8),
                             construct.BitField("Data", 8000))
    return DT
github PIC-IRIS / PH5 / ph5 / core / rt_130_h.py View on Github external
def filter_description():
    FD = construct.Struct("FD",
                          construct.BitStruct("BIN",
                                              construct.BitField(
                                                  "PacketHeader", 128),
                                              construct.String("FilterInfo",
                                                               992)),
                          construct.String("ImplementTime", 16))
    return FD
github PIC-IRIS / PH5 / ph5 / core / segd_h.py View on Github external
BIN = construct.BitStruct("BIN",
                              construct.BitField(
                                  "extended_file_number", 24, swapped=swap),
                              construct.BitField(
                                  "source_line_number_int", 24, swapped=swap),
                              construct.BitField(
                                  "source_line_number_frac", 16, swapped=swap),
                              construct.BitField(
                                  "source_point_number_int", 24, swapped=swap),
                              construct.BitField(
                                  "source_point_number_frac",
                                  16,
                                  swapped=swap),
                              construct.BitField(
                                  "source_point_index", 8, swapped=swap),
                              construct.BitField(
                                  "phase_control", 8, swapped=swap),
                              construct.BitField(
                                  "vibrator_type", 8, swapped=swap),
                              construct.BitField(
                                  "phase_angle", 16, swapped=swap),
                              construct.BitField(
                                  "general_header_block_number",
                                  8,
                                  swapped=swap),
                              construct.BitField(
                                  "source_set_number", 8, swapped=swap),
                              construct.BitField("user01", 96, swapped=swap))

    return BIN