Skip to content

Note

Click here to download the full example code

Acoustic Objects#

Here we showcase the different objects that are defined within soundevent.

The data module#

All you need to do is import the data module from soundevent.

from soundevent import data

Geometries#

Here we showcase the different geometries that are defined within soundevent.

Warning

All the geometry coordinates should be provided in seconds and Hz.

TimeStamp#

A TimeStamp is defined by a point in time relative to the start of the recording.

time_stamp = data.TimeStamp(
    coordinates=0.1,
)
print(time_stamp.model_dump_json(indent=2))

Out:

{
  "type": "TimeStamp",
  "coordinates": 0.1
}

TimeInterval#

A TimeInterval consists of two points in time to mark the start and end of an interval.

time_interval = data.TimeInterval(
    coordinates=[0.1, 0.2],
)
print(time_interval.model_dump_json(indent=2))

Out:

{
  "type": "TimeInterval",
  "coordinates": [
    0.1,
    0.2
  ]
}

Point#

A Point is a point in time and frequency.

point = data.Point(
    coordinates=[0.1, 2000],
)
print(point.model_dump_json(indent=2))

Out:

{
  "type": "Point",
  "coordinates": [
    0.1,
    2000.0
  ]
}

BoundingBox#

box = data.BoundingBox(
    coordinates=[0.1, 2000, 0.2, 3000],
)
print(box.model_dump_json(indent=2))

Out:

{
  "type": "BoundingBox",
  "coordinates": [
    0.1,
    2000.0,
    0.2,
    3000.0
  ]
}

A LineString is a sequence of points that are connected by a line.

line = data.LineString(
    coordinates=[[0.1, 2000], [0.2, 4000]],
)
print(line.model_dump_json(indent=2))

Out:

{
  "type": "LineString",
  "coordinates": [
    [
      0.1,
      2000.0
    ],
    [
      0.2,
      4000.0
    ]
  ]
}

A Polygon

polygon = data.Polygon(
    coordinates=[
        [
            [0.1, 2000],
            [0.2, 3000],
            [0.3, 2000],
            [0.2, 1000],
            [0.1, 2000],
        ],
        [
            [0.15, 2000],
            [0.25, 2000],
            [0.2, 1500],
            [0.15, 2000],
        ],
    ],
)
print(polygon.model_dump_json(indent=2))

Out:

{
  "type": "Polygon",
  "coordinates": [
    [
      [
        0.1,
        2000.0
      ],
      [
        0.2,
        3000.0
      ],
      [
        0.3,
        2000.0
      ],
      [
        0.2,
        1000.0
      ],
      [
        0.1,
        2000.0
      ]
    ],
    [
      [
        0.15,
        2000.0
      ],
      [
        0.25,
        2000.0
      ],
      [
        0.2,
        1500.0
      ],
      [
        0.15,
        2000.0
      ]
    ]
  ]
}

Total running time of the script: ( 0 minutes 0.757 seconds) Estimated memory usage: 25 MB

Download Python source code: 0_objects.py

Download Jupyter notebook: 0_objects.ipynb

Gallery generated by mkdocs-gallery