Skip to content

What's the correct usage of scale_factors? #195

@msadowski

Description

@msadowski
  • Generic Sensor Format for Python version: 2.0
  • Python version: 3.6.9
  • Operating System: Ubuntu

Description

Hi!

I'm wondering if you would have some hints on the correct usage of scale_factor with gfs. I'm trying to develop a pipeline for converting sounding data from a custom system to gsf. In my initial trial, I was trying to add the time series intensity data before moving on with other fields, however no matter what I seem to try I get an error:

gsfpy3_09.GsfException: [-21] GSF Error: Illegal scale factor multiplier specified

What I Did

I tried to define the scale_factors as follows:

    scale_factors = c_gsfScaleFactors()
    scale_factors.numArraySubrecords = 1
    # Initialize the scaleTable with some example values
    for i in range(scale_factors.numArraySubrecords):
        scale_factors.scaleTable[i] = c_gsfScaleInfo(
            #set first bit to 1, and the rest to 0
            compressionFlag=c_ubyte(0x00),    # Example compression flag
            multiplier=c_double(0.0001),   # Example multiplier
            offset=c_double(0.0)        # Example offset
        )

    record.mb_ping.scaleFactors = scale_factors

and fill in the intensity array as follows:

    NumElements = 1
    BRBIntensityArray = c_gsfBRBIntensity * NumElements
    brb_array = BRBIntensityArray()
    brb_array[0].bits_per_sample = 8
    brb_array[0].applied_corrections = 0
    brb_array[0].sensor_imagery = c_gsfSensorImagery()

    time_series = c_gsfTimeSeriesIntensity * 1
    brb_array[0].time_series = time_series()

    """
    class c_gsfTimeSeriesIntensity(Structure):
    _fields_ = [
        ("sample_count", c_ushort),
        ("detect_sample", c_ushort),
        ("start_range_samples", c_ushort),
        ("spare", TIME_SERIES_INTENSITY_SPARE_BYTES),
        ("samples", POINTER(c_uint)),
    ]
    """
    brb_array[0].time_series[0].sample_count = len(json_row['sample_data'])
    brb_array[0].time_series[0].detect_sample = 0 # TODO: Do we need to set this?
    brb_array[0].time_series[0].start_range_samples = 0 # TODO: Do we need to set this?
    brb_array[0].time_series[0].samples = (c_uint * len(json_row['sample_data']))(*json_row['sample_data'])

    record.mb_ping.brb_inten = brb_array

    gsf_file.write(record, RecordType.GSF_RECORD_SWATH_BATHYMETRY_PING)

Howver without much luck. I read the gsf_spec and on figure 4-7 they mention a subrecord identifier, however browsing through the code I couldn't find a way to set this field.

I'd appreciate any hints you might have to move this forward, I'm also happy to provide more context if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions