Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the correct usage of scale_factors? #195

Open
msadowski opened this issue Sep 2, 2024 · 0 comments
Open

What's the correct usage of scale_factors? #195

msadowski opened this issue Sep 2, 2024 · 0 comments

Comments

@msadowski
Copy link

  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant