oncdw.section

Classes

Section

Module Contents

class oncdw.section.Section(client: oncdw._client.ONCDW)

Display a section with links.

Parameters:
  • links (dict) – A dictionary of links to be displayed at the top of the page. The keys are the link titles, and the values are the URLs.

  • header (str) – Header string above the links

Examples

>>> client = ONCDW()
>>> links = {
...     "Oceans 3.0": "https://data.oceannetworks.ca",
...     "Marine Traffic": "https://www.marinetraffic.com",
... }
>>> client.section.links(links, "Useful Links")
state_of_ocean_images(location_code: str)

Display the State of Ocean images for a given location code.

Also return the information needed to display labels in the sidebar.

Parameters:

location_code (str) – The location code to construct the image URLs.

Returns:

labels – A list of tuples containing the label titles and their corresponding URLs.

Return type:

list of tuples

Examples

>>> client = ONCDW()
>>> client.section.state_of_ocean_images("BACAX")
time_series(sensor: list | dict, date_from: str = '-P7D', date_to: str | None = None)

Display time series plots for a given sensor or two sensors, with labels above the plot.

Parameters:
  • sensor (list) – A list representing a sensor or a pair of sensors. The format can be either: 1. dict: a single sensor, {“sensor_id”: sensor_id, “sensor_name”: sensor_name} 2. list: a pair of sensors, [{},{}]. The format of each dict is the same as a single sensor

  • date_from (str) – date_from parameter for the web service

  • date_to (str or None, optional) – date_to parameter for the web service

Examples

>>> client = ONCDW()
>>> sensor = {
...    "sensor_id": 7684,
...    "sensor_name": "True Heading",
... }
>>> client.section.time_series(sensor)
>>> sensor1 = {
...     "sensor_id": 4182,
...     "sensor_name": "Seafloor Pressure"
... }
>>> sensor2 = {
...     "sensor_id": 7712,
...     "sensor_name": "Uncompensated Seafloor Pressure"
... }
>>> sensor = [sensor1, sensor2]
>>> client.section.time_series(sensor)
data_preview(device: dict)

Display data preview plots for multiple data preview options.

Assume data preview plots are placed in two columns, and the options are a list of a dict in device[“data_preview_options”].

Parameters:

device (dict) –

a dict containing search tree node id, device category id and data preview options, which is a list of data preview option. The dict of data preview option should have the following keys:

  • data_product_format_id

  • plot_number, optional, default 1

  • sensor_code_id, optional

Examples

>>> client = ONCDW()
>>> device = {
...     "search_tree_node_id": 450,
...     "device_category_id": 72,
...     "data_preview_options": [
...         {
...             "data_product_format_id": 3,
...             "plot_number": 1
...         },
...         {
...             "data_product_format_id": 3,
...             "plot_number": 2
...         },
...     ]
... }
>>> client.section.data_preview(device)
location_expander(location: dict)

Display a location label and information retrieved from /api/location web service.

This method has a global variable _prev_location_code to record the previous location, so that it only displays distinct locations.

Parameters:

location (dict) – A dict that contains a location code

Examples

>>> client = ONCDW()
>>> device = {
...     "location_code": "BACAX",
...     "location_name": "Barkley Canyon Axis",
... }
>>> client.section.location_expander(device)
location_sidebar(location: dict)

Display a location label in the side bar.

This method has a global variable _prev_location_code_sidebar to record the previous location, so that it only displays distinct locations.

Parameters:

location (dict) – A dict that contains a location code

Examples

>>> client = ONCDW()
>>> device = {
...     "location_code": "BACAX"
... }
>>> client.section.location_sidebar(device)
sensor_sidebar(sensor: list | dict)

Display a sensor or two sensors label in the sidebar, with the correct href link.

Parameters:

sensor (list) – A list representing a sensor or a pair of sensors. The format can be either: 1. dict: a single sensor, {“sensor_id”: sensor_id, “sensor_name”: sensor_name} 2. list: a pair of sensors, [{},{}]. The format of each dict is the same as a single sensor

Examples

>>> client = ONCDW()
>>> sensor = {
...    "sensor_id": 7684,
...    "sensor_name": "True Heading",
... }
>>> client.section.sensor_sidebar(sensor)
>>> sensor1 = {
...     "sensor_id": 4182,
...     "sensor_name": "Seafloor Pressure"
... }
>>> sensor2 = {
...     "sensor_id": 7712,
...     "sensor_name": "Uncompensated Seafloor Pressure"
... }
>>> sensor = [sensor1, sensor2]
>>> client.section.sensor_sidebar(sensor)
map(location_code: str, center_lat: float | None = None, center_lon: float | None = None, zoom: int | None = None)

Display a map with a location code.

It uses /api/location web service to query the lat and lon for the location.

Parameters:
  • location_code (str) – The location code for the location

  • center_lat (float or None, optional) – The center latitude for the initial view state of the map widget. If not give, it will use the default one

  • center_lon (float or None, optional) – The center longitude for the initial view state of the map widget. If not give, it will use the default one

  • zoom (int or None, optional) – The zoom for the initial view state of the map widget. If not give, it will use the default one

Examples

>>> client = ONCDW()
>>> client.section.map("BACAX")