From bf9e36ec153358371b9f5a00a2a1c9aa246b7c33 Mon Sep 17 00:00:00 2001 From: Fariborz Daneshvar <132295102+FariborzDaneshvar-NOAA@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:02:07 -0800 Subject: [PATCH] change datum default to MSL for coops_product_within_region (#90) * change datum default to MSL for `coops_product_within_region` * Update test references for USGS storms (due to API response update) --------- Co-authored-by: Soroosh.Mani The coverage test kept being cancelled, so I ignored it and merged! --- .github/workflows/test.yml | 2 +- stormevents/nhc/storms.py | 8 +++++--- stormevents/stormevent.py | 4 +++- tests/data/reference/test_usgs_flood_events/events.csv | 4 ++-- tests/data/reference/test_usgs_flood_storms/storms.csv | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aff539a..be81fd4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,7 +69,7 @@ jobs: path: ${{ env.pythonLocation }} key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }} - run: pip install ".[test]" pytest-cov pytest-xdist - - run: pytest -n auto --cov . --cov-report xml:coverage.xml + - run: pytest --cov . --cov-report xml:coverage.xml - run: coverage report -m - uses: codecov/codecov-action@main with: diff --git a/stormevents/nhc/storms.py b/stormevents/nhc/storms.py index 29e8896..91e1baf 100644 --- a/stormevents/nhc/storms.py +++ b/stormevents/nhc/storms.py @@ -66,9 +66,11 @@ def nhc_storms(year: int = None) -> pandas.DataFrame: header=0, names=columns, parse_dates=["start_date", "end_date"], - date_parser=lambda x: pandas.to_datetime(x.strip(), format="%Y%m%d%H") - if x.strip() != "9999999999" - else numpy.nan, + date_parser=lambda x: ( + pandas.to_datetime(x.strip(), format="%Y%m%d%H") + if x.strip() != "9999999999" + else numpy.nan + ), ) storms = storms.astype( diff --git a/stormevents/stormevent.py b/stormevents/stormevent.py index 28e561e..0395180 100644 --- a/stormevents/stormevent.py +++ b/stormevents/stormevent.py @@ -443,7 +443,7 @@ def coops_product_within_region( :param start_date: start date :param end_date: end date :param status: either ``current`` or ``historical`` - :param datum: tidal datum + :param datum: tidal datum, one of ``STND``, ``MSL``, ``MHHW``, ``MHW``, ``MTL``, ``MLW``, ``MLLW``, ``NAVD`` :param units: either ``metric`` or ``english`` :param time_zone: time zone :param interval: time interval @@ -467,6 +467,8 @@ def coops_product_within_region( f (nos_id, t) object '0,0,0,0' '0,0,0,0' ... '0,0,0,0' '0,0,0,0' q (nos_id, t) object 'v' 'v' 'v' 'v' 'v' 'v' ... 'p' 'p' 'p' 'p' 'p' """ + if datum is None: + datum = "MSL" # change the default from STND to MSL if not isinstance(region, BaseGeometry): region = shapely_shape(region) diff --git a/tests/data/reference/test_usgs_flood_events/events.csv b/tests/data/reference/test_usgs_flood_events/events.csv index f469311..8ba1c1d 100644 --- a/tests/data/reference/test_usgs_flood_events/events.csv +++ b/tests/data/reference/test_usgs_flood_events/events.csv @@ -1,7 +1,7 @@ usgs_id,name,year,description,event_type,event_status,coordinator,instruments,last_updated,last_updated_by,start_date,end_date 7,FEMA 2013 exercise,2013,Ardent/Sentry 2013 FEMA Exercise,HURRICANE,COMPLETED,36,[],,,2013-05-15 04:00:00,2013-05-23 04:00:00 -8,2005 Wilma,2005,"Category 3 in west FL. -Hurricane Wilma was the most intense tropical cyclone ever recorded in the Atlantic basin. Part of the record breaking 2005 Atlantic hurricane season.",HURRICANE,COMPLETED,515,[],2022-09-08 20:02:25.510152,1.0,2005-10-20 04:00:00,2005-10-31 05:00:00 +8,2005 Wilma,2005,"Category 3 in west FL. +Hurricane Wilma was the most intense tropical cyclone ever recorded in the Atlantic basin. Part of the record breaking 2005 Atlantic hurricane season.",HURRICANE,COMPLETED,515,[],2023-12-19 20:47:51.435776,1.0,2005-10-20 04:00:00,2005-10-31 05:00:00 18,2012 Isaac,2012,historical hurricane data loaded by the data archive team,HURRICANE,COMPLETED,36,[],2022-09-09 14:57:23.815290,2062.0,2012-08-27 04:00:00,2012-09-02 04:00:00 19,2005 Rita,2005,historical hurricane data loaded by the data archive team,HURRICANE,COMPLETED,515,[],2022-09-08 20:10:38.533682,1.0,2005-09-23 04:00:00,2005-09-25 04:00:00 23,2011 Irene,2011,historical hurricane data loaded by the data archive team,HURRICANE,COMPLETED,36,[],2022-09-09 15:04:03.637296,2062.0,2011-08-26 04:00:00,2011-08-29 04:00:00 diff --git a/tests/data/reference/test_usgs_flood_storms/storms.csv b/tests/data/reference/test_usgs_flood_storms/storms.csv index 13ea59f..45944ad 100644 --- a/tests/data/reference/test_usgs_flood_storms/storms.csv +++ b/tests/data/reference/test_usgs_flood_storms/storms.csv @@ -1,6 +1,6 @@ nhc_code,usgs_id,usgs_name,year,nhc_name,description,event_type,event_status,coordinator,instruments,last_updated,last_updated_by,start_date,end_date -AL252005,8,2005 Wilma,2005,WILMA,"Category 3 in west FL. -Hurricane Wilma was the most intense tropical cyclone ever recorded in the Atlantic basin. Part of the record breaking 2005 Atlantic hurricane season.",HURRICANE,COMPLETED,515,[],2022-09-08 20:02:25.510152,1.0,2005-10-20 04:00:00,2005-10-31 05:00:00 +AL252005,8,2005 Wilma,2005,WILMA,"Category 3 in west FL. +Hurricane Wilma was the most intense tropical cyclone ever recorded in the Atlantic basin. Part of the record breaking 2005 Atlantic hurricane season.",HURRICANE,COMPLETED,515,[],2023-12-19 20:47:51.435776,1.0,2005-10-20 04:00:00,2005-10-31 05:00:00 AL092012,18,2012 Isaac,2012,ISAAC,historical hurricane data loaded by the data archive team,HURRICANE,COMPLETED,36,[],2022-09-09 14:57:23.815290,2062.0,2012-08-27 04:00:00,2012-09-02 04:00:00 AL182005,19,2005 Rita,2005,RITA,historical hurricane data loaded by the data archive team,HURRICANE,COMPLETED,515,[],2022-09-08 20:10:38.533682,1.0,2005-09-23 04:00:00,2005-09-25 04:00:00 AL092011,23,2011 Irene,2011,IRENE,historical hurricane data loaded by the data archive team,HURRICANE,COMPLETED,36,[],2022-09-09 15:04:03.637296,2062.0,2011-08-26 04:00:00,2011-08-29 04:00:00