Skip to content

Commit

Permalink
Update ONC_data_product_url attr in ferry datasets
Browse files Browse the repository at this point in the history
Updated the ONC_data_product_url attribute in the datasets produced by the
get_onc_ferry worker to reflect changes in the data source's domain name and API
query parameter names. Code changes include updating the ONC data API domain
name, adding the 'locationCode' query parameter, and changing the
'deviceCategory' query parameter name to 'deviceCategoryCode'. All of those
changes are for compatibility with the ONC data API v3.
  • Loading branch information
douglatornell committed Feb 26, 2024
1 parent b70601c commit c865c19
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions nowcast/workers/get_onc_ferry.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,28 +445,40 @@ def _create_dataarray(var, array, ferry_platform, location_config):
"ioos category": "location",
"standard name": "longitude",
"long name": "Longitude",
"ONC_data_product_url": f"http://dmas.uvic.ca/DataSearch?deviceCategory={location_config['device category']}",
"ONC_data_product_url": (
f"http://data.oceannetworks.ca/DataSearch?&locationCode={ferry_platform}"
f"&deviceCategoryCode={location_config['device category']}"
),
},
"latitude": {
"name": "latitude",
"ioos category": "location",
"standard name": "latitude",
"long name": "Latitude",
"ONC_data_product_url": f"http://dmas.uvic.ca/DataSearch?deviceCategory={location_config['device category']}",
"ONC_data_product_url": (
f"http://data.oceannetworks.ca/DataSearch?locationCode={ferry_platform}"
f"&deviceCategoryCode={location_config['device category']}"
),
},
"nemo_grid_j": {
"name": "nemo_grid_j",
"ioos category": "location",
"standard name": "nemo_grid_j",
"long name": "NEMO grid j index",
"ONC_data_product_url": f"http://dmas.uvic.ca/DataSearch?deviceCategory={location_config['device category']}",
"ONC_data_product_url": (
f"http://data.oceannetworks.ca/DataSearch?locationCode={ferry_platform}"
f"&deviceCategoryCode={location_config['device category']}"
),
},
"nemo_grid_i": {
"name": "nemo_grid_i",
"ioos category": "location",
"standard name": "nemo_grid_i",
"long name": "NEMO grid i index",
"ONC_data_product_url": f"http://dmas.uvic.ca/DataSearch?deviceCategory={location_config['device category']}",
"ONC_data_product_url": (
f"http://data.oceannetworks.ca/DataSearch?locationCode={ferry_platform}"
f"&deviceCategoryCode={location_config['device category']}"
),
},
"on_crossing_mask": {
"name": "on_crossing_mask",
Expand All @@ -475,7 +487,9 @@ def _create_dataarray(var, array, ferry_platform, location_config):
"long name": "On Crossing",
"flag_values": "0, 1",
"flag_meanings": "in berth, on crossing",
"ONC_data_product_url": f"http://dmas.uvic.ca/DataSearch?location={ferry_platform}",
"ONC_data_product_url": (
f"http://data.oceannetworks.ca/DataSearch?locationCode={ferry_platform}"
),
},
"crossing_number": {
"name": "crossing_number",
Expand All @@ -493,7 +507,9 @@ def _create_dataarray(var, array, ferry_platform, location_config):
"crossing_number==n observation from the previous day, "
"where n is max(crossing_number). "
"The number of crossings per day varies throughout the year.",
"ONC_data_product_url": f"http://dmas.uvic.ca/DataSearch?location={ferry_platform}",
"ONC_data_product_url": (
f"http://data.oceannetworks.ca/DataSearch?locationCode={ferry_platform}"
),
},
"temperature": {
"name": "temperature",
Expand Down Expand Up @@ -814,11 +830,11 @@ def _create_dataarray(var, array, ferry_platform, location_config):
dataset_array.attrs["ONC_stationCode"] = array.attrs["station"]
dataset_array.attrs[
"ONC_data_product_url"
] += f'&location={array.attrs["station"]}'
] += f'&locationCode={array.attrs["station"]}'
except KeyError:
dataset_array.attrs["ONC_data_product_url"] = (
f"http://dmas.uvic.ca/DataSearch?location={ferry_platform}"
f"&deviceCategory={array.device_category}"
f"http://data.oceannetworks.ca/DataSearch?locationCode={ferry_platform}"
f"&deviceCategoryCode={array.device_category}"
)
return dataset_array

Expand Down

0 comments on commit c865c19

Please sign in to comment.