Skip to content

Commit

Permalink
Update get_onc_ctd worker to use ONC API v3
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
douglatornell committed Feb 7, 2024
1 parent 509c2ab commit ea4820d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions config/nowcast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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'

Expand Down
12 changes: 6 additions & 6 deletions nowcast/workers/get_onc_ctd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ea4820d

Please sign in to comment.