oncdw.section
Classes
Module Contents
- class oncdw.section.Section(client: oncdw._client.ONCDW)
- links(links: dict, header: str = 'Links')
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(sensors: list[dict | list[dict]], date_from: str = '-P7D', date_to: str | None = None, shade: bool = False)
Display time series plots for one-sensor or two-sensor entries.
- Parameters:
sensors (list[dict | list[dict]]) – A list where each item is either a single sensor dict or a two-sensor list of sensor dicts. Each sensor dict must contain at least
sensor_idandsensor_name.date_from (str) – date_from parameter for the web service.
date_to (str or None, optional) – date_to parameter for the web service.
shade (bool, default False) – Whether to show the shaded min-max band around each line or pair.
Examples
>>> client = ONCDW() >>> sensors = [{"sensor_id": 7684, "sensor_name": "True Heading"}] >>> client.section.time_series(sensors) >>> sensor1 = {"sensor_id": 4182, "sensor_name": "Seafloor Pressure"} >>> sensor2 = {"sensor_id": 7712, "sensor_name": "Uncompensated Seafloor Pressure"} >>> client.section.time_series([sensor1, [sensor1, sensor2]]) >>> client.section.time_series(sensors)
- 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(sensors: list[dict | list[dict]])
Display sensor sidebar badges for one-sensor and two-sensor entries.
- Parameters:
sensors (list[dict | list[dict]]) – A list where each item is either a single sensor dict or a two-sensor list of sensor dicts. Each sensor dict must contain at least
sensor_idandsensor_name.
Examples
>>> client = ONCDW() >>> sensors = [{"sensor_id": 7684, "sensor_name": "True Heading"}] >>> client.section.sensor_sidebar(sensors) >>> sensor1 = {"sensor_id": 4182, "sensor_name": "Seafloor Pressure"} >>> sensor2 = {"sensor_id": 7712, "sensor_name": "Uncompensated Seafloor Pressure"} >>> client.section.sensor_sidebar([sensor1, [sensor1, sensor2]])
- 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")