Git Product home page Git Product logo

python-sllib's People

Contributors

kmpm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-sllib's Issues

Encoded latitude and longitude being read as unsigned int

Hello,

I have been using this great library to view sl2 data. I was noticing an issue with the output coordinates. The corrected latitude was coming out at 90 degrees, whereas the latitude output from SonarViewer was coming out correctly (~ -31.94). I tested modifying the F1/F3_FRAME type for 'lat_enc' from an unsigned int to a signed int ('i'), and this fixed the issue.

I presume that the issue is that testing has only been done using data acquired in the northern hemisphere. Let me know if you would like some test data showing the issue.

Kind regards,

Steve

sl3 data extraction

I would like to play around with the received signals that are plotted in the echogram, but i am struggling with extracting these from an sl3 file. I tried following your jupyter example for sl2 files, but i have gotten stuck. Any tips?

sl3 behaves strange

There is either something wrong in the sl3 definition or in the test file.
They don't match up.

I would like to have some more sl3 files to test on.

read echograms

@stephenj79 wrote this in issue #3 but it deserves it's own

I think I have figured out the sounding data packet. I am assuming that it is a 1D profile of the received 'ping' energy, though I am only using a simple single source/receiver HDS5 sonar. I was under the impression that the vertical axis of each data sounding would be in time from ping to receiving, however it appears to be a sample interval in depth, that is a ratio of the 'lower_limit' parameter. Very strange, coming from a seismic background!

Below is a function to read the frame 'metadata' (for lack of better word) and the packet, and output them as a list of dicts and a numpy array, respectively. You can probably tell that this is a modification of the function given in the examples of this library. Probably not the best way to output the data (might be better to treat each packet as an array attached to the corresponding frame? Probably something for you guys to decide if you want to use this code), but gives an idea of how the data packet can be read:

def read_echogram(input_file):
    import sllib
    with open(input_file, "rb") as f:
        reader = sllib.Reader(f)
        header = reader.header
        print(header)
        data = []
        for frame in reader:
            data.append(frame.to_dict())
            # the code to unpack the data packet
            temp = struct.unpack("i" * (frame.packetsize // 4), frame.packet)
            temp = np.array(temp)
            try:
                echogram = np.vstack((echogram, temp))
            except NameError:
                echogram = temp
    echogram = echogram.T.astype("float32")
    return data, echogram

Here's a function to read an sl2 file (using above function) and then plot the data packet numpy array as a matplotlib imshow, and overlay the automated water bottom pick. Comparing the output to this to what is shown in the software Sonar Viewer for the same file shows they are the same, which is what I was aiming for. But if you see any discrepancies, please let me know!

def test_overlay_wb_echo(filename):
    import matplotlib.pyplot as plt
    # Load sounding data and echogram.
    data, echo = read_echogram(filename)
    ## Calculate sampling rate, using assumption that y-axis is in depth (ft)
    ## - not actually used in this function but given here as an illustration. 
    # time1 = np.array([i["time1"] for i in data])
    # dz = time1[1:] - time1[:-1]
    ## Calculate the water depth in y-axis samples
    wb = np.array([i["water_depth"] for i in data])
    lower_limit = np.array([i["lower_limit"] for i in data])
    wb_s =  wb * echo.shape[0] / lower_limit
    fig, axes = plt.subplots()
    axes.imshow(echo)
    axes.plot([i["frame_index"] for i in data],
                 wb_s, linewidth=2, color="red")
    fig.show()

I hope that helps. The code isn't the best, as I've been rushing to get it working for a job, so please excuse anything that looks bad. For example the "try / except" in the read function is pretty shoddy, but it meant I got the code working, fast.

Looking forward to some feedback.

Kind regards,
Steve

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.