From ea4820dece879c030ca9e2d7ce5a91de6edd9d74 Mon Sep 17 00:00:00 2001 From: Doug Latornell Date: Wed, 7 Feb 2024 15:53:51 -0800 Subject: [PATCH] Update get_onc_ctd worker to use ONC API v3 Modified the get_onc_ctd worker to use ONC API v3 'getByLocation' method. The new method uses a location code instead of a station name. Also, these changes include adding a 'dateTo' parameter to limit the data to a specific time range for the day. Additionally, small changes to variable and parameter names were made to match the new method requirements. --- config/nowcast.yaml | 6 +++--- nowcast/workers/get_onc_ctd.py | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/nowcast.yaml b/config/nowcast.yaml index d3436fcc..e6b7ffad 100644 --- a/config/nowcast.yaml +++ b/config/nowcast.yaml @@ -245,7 +245,7 @@ temperature salinity: observations: - # Dataset that maps high resolution lon/lat grid on to NEMO j/i indices + # Dataset that maps high-resolution lon/lat grid on to NEMO j/i indices lon/lat to NEMO ji map: /SalishSeaCast/grid/grid_from_lat_lon_mask999.nc # ONC Strait of Georgia nodes real-time CTD data ctd data: @@ -259,7 +259,7 @@ observations: dest dir: /results/observations/ONC/CTD/ # Template for ONC CTD T&S data file path # **Must be quoted to project {} characters** - filepath template: '{station}/{station}_CTD_15m_{yyyymmdd}.nc' + filepath template: "{station}/{station}_CTD_15m_{yyyymmdd}.nc" # ONC Strait of Georgia ferry platforms real-time data ferry data: @@ -274,7 +274,7 @@ observations: csv dir: /opp/observations/AISDATA/ # Destination directory for VFPA HADCP data netCDF files dest dir: /opp/observations/AISDATA/netcdf/ - # Template for VFPA HADCP data file path + # Template for the VFPA HADCP data file path # **Must be quoted to project {} characters** filepath template: 'VFPA_2ND_NARROWS_HADCP_2s_{yyyymm}.nc' diff --git a/nowcast/workers/get_onc_ctd.py b/nowcast/workers/get_onc_ctd.py index 290185b6..fe5e141b 100644 --- a/nowcast/workers/get_onc_ctd.py +++ b/nowcast/workers/get_onc_ctd.py @@ -79,15 +79,15 @@ def failure(parsed_args): def get_onc_ctd(parsed_args, config, *args): ymd = parsed_args.data_date.format("YYYY-MM-DD") logger.info(f"requesting ONC {parsed_args.onc_station} CTD T&S data for {ymd}") - TOKEN = os.environ["ONC_USER_TOKEN"] onc_data = data_tools.get_onc_data( "scalardata", - "getByStation", - TOKEN, - station=parsed_args.onc_station, - deviceCategory="CTD", - sensors="salinity,temperature", + "getByLocation", + os.environ["ONC_USER_TOKEN"], + locationCode=parsed_args.onc_station, + deviceCategoryCode="CTD", + sensorCategoryCodes="salinity,temperature", dateFrom=data_tools.onc_datetime(f"{ymd} 00:00", "utc"), + dateTo=data_tools.onc_datetime(f"{ymd} 23:59", "utc"), ) try: ctd_data = data_tools.onc_json_to_dataset(onc_data)