diff --git a/README.md b/README.md index 235f348..6a21efa 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,375 @@ Full documentation can be found at https://stormevents.readthedocs.io ## Usage -### `StormEvent` +There are two ways to retrieve observational data via `stormevents`; + +1. retrieve data for any arbitrary time interval / region, or +2. retrieve data surrounding a specific storm. + +### retrieve data for any arbitrary time interval / region + +`stormevents` currently implements retrieval for + +- storm tracks from the National Hurricane Center (NHC), +- high-water mark (HWM) surveys provided by the United States Geological Survey (USGS), and +- data products from the Center for Operational Oceanographic Products and Services (CO-OPS). + +#### storm tracks from the National Hurricane Center (NHC) + +The [National Hurricane Center (NHC)](https://www.nhc.noaa.gov) tracks and tropical cyclones dating back to 1851. + +The `nhc_storms()` function provides a list of NHC storms from their online archive: + +```python +from stormevents.nhc import nhc_storms + +nhc_storms() +``` + +``` + name class ... start_date end_date +nhc_code ... +AL021851 UNNAMED HU ... 1851-07-05 12:00:00 1851-07-05 12:00:00 +AL031851 UNNAMED TS ... 1851-07-10 12:00:00 1851-07-10 12:00:00 +AL041851 UNNAMED HU ... 1851-08-16 00:00:00 1851-08-27 18:00:00 +AL051851 UNNAMED TS ... 1851-09-13 00:00:00 1851-09-16 18:00:00 +AL061851 UNNAMED TS ... 1851-10-16 00:00:00 1851-10-19 18:00:00 + ... ... ... ... ... ... +EP922021 INVEST DB ... 2021-06-05 06:00:00 NaT +AL952021 INVEST DB ... 2021-10-28 12:00:00 NaT +AL962021 INVEST EX ... 2021-11-07 12:00:00 NaT +EP712022 GENESIS001 DB ... 2022-01-20 12:00:00 NaT +EP902022 INVEST LO ... 2022-01-20 12:00:00 NaT + +[2729 rows x 8 columns] +``` + +##### retrieve storm track by NHC code + +```python +from stormevents.nhc import VortexTrack + +track = VortexTrack('AL112017') +track.data +``` + +``` + basin storm_number ... name geometry +0 AL 11 ... INVEST POINT (-26.90000 16.10000) +1 AL 11 ... INVEST POINT (-28.30000 16.20000) +2 AL 11 ... IRMA POINT (-29.70000 16.30000) +3 AL 11 ... IRMA POINT (-30.80000 16.30000) +4 AL 11 ... IRMA POINT (-30.80000 16.30000) +.. ... ... ... ... ... +168 AL 11 ... IRMA POINT (-86.90000 33.80000) +169 AL 11 ... IRMA POINT (-88.10000 34.80000) +170 AL 11 ... IRMA POINT (-88.90000 35.60000) +171 AL 11 ... IRMA POINT (-89.50000 36.20000) +172 AL 11 ... IRMA POINT (-90.10000 36.80000) + +[173 rows x 22 columns] +``` + +##### retrieve storm track by name and year + +If you do not know the storm code, you can input the storm name and year: + +```python +from stormevents.nhc import VortexTrack + +vortex = VortexTrack.from_storm_name('irma', 2017) +``` + +``` +VortexTrack('AL112017', Timestamp('2017-08-30 00:00:00'), Timestamp('2017-09-13 12:00:00'), , , 'BEST', None) +``` + +##### specify storm track file deck + +By default, `VortexTrack` retrieves data from the `BEST` track file deck (`b`). You can specify that you want +the `ADVISORY` (`a`) or `FIXED` (`f`) file decks with the `file_deck` parameter. + +```python +from stormevents.nhc import VortexTrack + +track = VortexTrack('AL112017', file_deck='a') +track.data +``` + +``` + basin storm_number ... name geometry +0 AL 11 ... INVEST POINT (-26.90000 16.10000) +1 AL 11 ... INVEST POINT (-28.30000 16.20000) +2 AL 11 ... IRMA POINT (-29.70000 16.30000) +3 AL 11 ... IRMA POINT (-30.80000 16.30000) +4 AL 11 ... IRMA POINT (-30.80000 16.30000) +.. ... ... ... ... ... +168 AL 11 ... IRMA POINT (-86.90000 33.80000) +169 AL 11 ... IRMA POINT (-88.10000 34.80000) +170 AL 11 ... IRMA POINT (-88.90000 35.60000) +171 AL 11 ... IRMA POINT (-89.50000 36.20000) +172 AL 11 ... IRMA POINT (-90.10000 36.80000) + +[173 rows x 22 columns] +``` + +##### read storm track from file + +If you have an ATCF or `fort.22` file, use the corresponding methods: + +```python +from stormevents.nhc import VortexTrack + +VortexTrack.from_atcf_file('tests/data/input/test_from_atcf/atcf.trk') +``` + +``` +VortexTrack('BT02008', Timestamp('2008-10-16 17:06:00'), Timestamp('2008-10-20 20:06:00'), , , 'BEST', PosixPath('tests/data/input/test_from_atcf/florence2018_atcf.trk')) +``` + +```python +from stormevents.nhc import VortexTrack + +VortexTrack.from_fort22('tests/data/input/test_from_fort22/irma2017_fort.22') +``` + +``` +VortexTrack('AL112017', Timestamp('2017-09-05 00:00:00'), Timestamp('2017-09-19 00:00:00'), , , 'BEST', PosixPath('tests/data/input/test_from_fort22/irma2017_fort.22')) +``` + +##### write storm track to `fort.22` file + +```python +from stormevents.nhc import VortexTrack + +track = VortexTrack.from_storm_name('florence', 2018) +track.write('fort.22') +``` + +#### high-water mark (HWM) surveys provided by the United States Geological Survey (USGS) + +The [United States Geological Survey (USGS)](https://www.usgs.gov) +conducts surveys of flooded areas following flood events to determine the highest level of water elevation, and provides the +results of these surveys via their API. + +##### list flood events that have HWM surveys + +```python +from stormevents.usgs import usgs_highwatermark_events + +usgs_highwatermark_events() +``` + +``` + name year +usgs_id +7 FEMA 2013 exercise 2013 +8 Wilma 2013 +18 Isaac Aug 2012 2012 +19 Rita 2005 +23 Irene 2011 +24 Sandy 2017 +119 Joaquin 2015 +131 Hermine 2016 +133 Isabel September 2003 2003 +135 Matthew October 2016 2016 +180 Harvey Aug 2017 2017 +182 Irma September 2017 2017 +189 Maria September 2017 2017 +196 Nate October 2017 2017 +281 Lane August 2018 2019 +283 Florence Sep 2018 2018 +287 Michael Oct 2018 2018 +291 2019 Hurricane Dorian 2019 +301 2020 Hurricane Isaias 2020 +303 2020 TS Marco - Hurricane Laura 2020 +304 2020 Hurricane Sally 2020 +305 2020 Hurricane Delta 2020 +310 2021 Tropical Cyclone Henri 2021 +312 2021 Tropical Cyclone Ida 2021 +``` + +##### retrieve HWM survey data for any flood event + +```python +from stormevents.usgs import HighWaterMarks + +survey = HighWaterMarks(182) +survey.data +``` + +``` + latitude longitude ... siteZone geometry +hwm_id ... +22636 32.007730 -81.238270 ... NaN POINT (-81.23827 32.00773) +22757 30.510528 -81.460833 ... 0 POINT (-81.46083 30.51053) +22885 30.770560 -81.581390 ... NaN POINT (-81.58139 30.77056) +22965 31.063150 -81.404540 ... NaN POINT (-81.40454 31.06315) +23052 30.845000 -81.560000 ... NaN POINT (-81.56000 30.84500) + ... ... ... ... ... +25147 30.018190 -81.859657 ... NaN POINT (-81.85966 30.01819) +25148 30.097214 -81.891451 ... NaN POINT (-81.89145 30.09721) +25150 30.038222 -81.880928 ... NaN POINT (-81.88093 30.03822) +25158 29.720560 -81.506110 ... NaN POINT (-81.50611 29.72056) +25159 30.097514 -81.794375 ... NaN POINT (-81.79438 30.09751) + +[221 rows x 52 columns] +``` + +```python +from stormevents.usgs import HighWaterMarks + +survey = HighWaterMarks(182) +survey.hwm_quality = 'EXCELLENT', 'GOOD' +survey.data +``` + +``` + latitude longitude ... siteZone geometry +hwm_id ... +22636 32.007730 -81.238270 ... NaN POINT (-81.23827 32.00773) +22885 30.770560 -81.581390 ... NaN POINT (-81.58139 30.77056) +23130 31.034720 -81.640000 ... NaN POINT (-81.64000 31.03472) +23216 32.035150 -81.045040 ... NaN POINT (-81.04504 32.03515) +23236 32.083650 -81.157520 ... NaN POINT (-81.15752 32.08365) + ... ... ... ... ... ... +25146 29.992580 -81.851518 ... NaN POINT (-81.85152 29.99258) +25148 30.097214 -81.891451 ... NaN POINT (-81.89145 30.09721) +25150 30.038222 -81.880928 ... NaN POINT (-81.88093 30.03822) +25158 29.720560 -81.506110 ... NaN POINT (-81.50611 29.72056) +25159 30.097514 -81.794375 ... NaN POINT (-81.79438 30.09751) + +[138 rows x 52 columns] +``` + +#### data products from the Center for Operational Oceanographic Products and Services (CO-OPS) + +The [Center for Operational Oceanographic Products and Services (CO-OPS)](https://tidesandcurrents.noaa.gov) +maintains and operates a large array of tidal buoys and oceanic weather stations that measure water and atmospheric variables +across the coastal United States. CO-OPS provides several [data products](https://tidesandcurrents.noaa.gov/products.html) +including hourly water levels, tidal datums and predictions, and trends in sea level over time. + +A list of CO-OPS stations can be retrieved with the `coops_stations()` function. + +```python +from stormevents.coops import coops_stations + +coops_stations() +``` + +``` + nws_id name state removed geometry +nos_id +1600012 46125 QREB buoy NaT POINT (122.62500 37.75000) +1611400 NWWH1 Nawiliwili HI NaT POINT (-159.37500 21.95312) +1612340 OOUH1 Honolulu HI NaT POINT (-157.87500 21.31250) +1612480 MOKH1 Mokuoloe HI NaT POINT (-157.75000 21.43750) +1615680 KLIH1 Kahului, Kahului Harbor HI NaT POINT (-156.50000 20.89062) + ... ... ... ... ... ... +9759394 MGZP4 Mayaguez PR NaT POINT (-67.18750 18.21875) +9759938 MISP4 Mona Island NaT POINT (-67.93750 18.09375) +9761115 BARA9 Barbuda NaT POINT (-61.81250 17.59375) +9999530 FRCB6 Bermuda, Ferry Reach Channel NaT POINT (-64.68750 32.37500) +9999531 Calcasieu Test Station LA NaT POINT (-93.31250 29.76562) + +[363 rows x 5 columns] +``` + +Additionally, you can use a Shapely `Polygon` or `MultiPolygon` to constrain the stations query to a specific region: + +```python +from shapely.geometry import Polygon +from stormevents.coops import coops_stations_within_region + +region = Polygon(...) + +coops_stations_within_region(region=region) +``` + +``` + nws_id name state removed geometry +nos_id +8651370 DUKN7 Duck NC NaT POINT (-75.75000 36.18750) +8652587 ORIN7 Oregon Inlet Marina NC NaT POINT (-75.56250 35.78125) +8654467 HCGN7 USCG Station Hatteras NC NaT POINT (-75.68750 35.21875) +8656483 BFTN7 Beaufort, Duke Marine Lab NC NaT POINT (-76.68750 34.71875) +8658120 WLON7 Wilmington NC NaT POINT (-77.93750 34.21875) +8658163 JMPN7 Wrightsville Beach NC NaT POINT (-77.81250 34.21875) +8661070 MROS1 Springmaid Pier SC NaT POINT (-78.93750 33.65625) +8662245 NITS1 Oyster Landing (N Inlet Estuary) SC NaT POINT (-79.18750 33.34375) +8665530 CHTS1 Charleston, Cooper River Entrance SC NaT POINT (-79.93750 32.78125) +8670870 FPKG1 Fort Pulaski GA NaT POINT (-80.87500 32.03125) +``` + +##### retrieve CO-OPS data product from within a region and time interval + +To retrieve data, you must provide three things: + +1. the data product of interest; one of + - `water_level` - Preliminary or verified water levels, depending on availability. + - `air_temperature` - Air temperature as measured at the station. + - `water_temperature` - Water temperature as measured at the station. + - `wind` - Wind speed, direction, and gusts as measured at the station. + - `air_pressure` - Barometric pressure as measured at the station. + - `air_gap` - Air Gap (distance between a bridge and the water's surface) at the station. + - `conductivity` - The water's conductivity as measured at the station. + - `visibility` - Visibility from the station's visibility sensor. A measure of atmospheric clarity. + - `humidity` - Relative humidity as measured at the station. + - `salinity` - Salinity and specific gravity data for the station. + - `hourly_height` - Verified hourly height water level data for the station. + - `high_low` - Verified high/low water level data for the station. + - `daily_mean` - Verified daily mean water level data for the station. + - `monthly_mean` - Verified monthly mean water level data for the station. + - `one_minute_water_level` One minute water level data for the station. + - `predictions` - 6 minute predictions water level data for the station.* + - `datums` - datums data for the stations. + - `currents` - Currents data for currents stations. + - `currents_predictions` - Currents predictions data for currents predictions stations. +2. a region within which to retrieve the data product +3. a time interval within which to retrieve the data product + +```python +from datetime import datetime, timedelta + +from shapely.geometry import Polygon +from stormevents.coops import coops_product_within_region + +polygon = Polygon(...) + +coops_product_within_region( + 'water_level', + region=polygon, + start_date=datetime.now() - timedelta(hours=1), +) +``` + +``` + +Dimensions: (nos_id: 10, t: 10) +Coordinates: + * nos_id (nos_id) int64 8651370 8652587 8654467 ... 8662245 8665530 8670870 + * t (t) datetime64[ns] 2022-02-17T11:42:00 ... 2022-02-17T12:36:00 + nws_id (nos_id) , , None, None) +VortexTrack('AL062018', Timestamp('2018-08-30 06:00:00'), Timestamp('2018-09-18 12:00:00'), , , 'BEST', None) ``` ```python from stormevents import StormEvent -florence2018 = StormEvent('florence', 2018) - -florence2018.track(file_deck='b') +storm = StormEvent('florence', 2018) +storm.track(file_deck='b') ``` ``` -VortexTrack('AL062018', Timestamp('2018-08-30 06:00:00'), Timestamp('2018-09-18 12:00:00'), , , 'BEST', None) +VortexTrack('AL062018', Timestamp('2018-08-30 06:00:00'), Timestamp('2018-09-18 12:00:00'), , , 'BEST', None) ``` -#### retrieve high-water mark surveys conducted provided by the United States Geological Survey (USGS) +#### high-water mark (HWM) surveys provided by the United States Geological Survey (USGS) ```python from stormevents import StormEvent -florence2018 = StormEvent('florence', 2018) - -florence2018.high_water_marks +storm = StormEvent('florence', 2018) +storm.high_water_marks ``` ``` - latitude ... siteZone -hwm_id ... -33496 37.298440 ... NaN -33502 35.342089 ... NaN -33503 35.378963 ... NaN -33505 35.216282 ... NaN -33508 35.199859 ... NaN - ... ... ... ... -34191 33.724722 ... NaN -34235 34.936308 ... -34840 34.145930 ... NaN -34871 35.424707 ... NaN -34876 35.301135 ... NaN + latitude longitude ... siteZone geometry +hwm_id ... +33496 37.298440 -80.007750 ... NaN POINT (-80.00775 37.29844) +33502 35.342089 -78.041553 ... NaN POINT (-78.04155 35.34209) +33503 35.378963 -78.010596 ... NaN POINT (-78.01060 35.37896) +33505 35.216282 -78.935229 ... NaN POINT (-78.93523 35.21628) +33508 35.199859 -78.960296 ... NaN POINT (-78.96030 35.19986) + ... ... ... ... ... +34191 33.724722 -79.059722 ... NaN POINT (-79.05972 33.72472) +34235 34.936308 -76.811223 ... POINT (-76.81122 34.93631) +34840 34.145930 -78.868567 ... NaN POINT (-78.86857 34.14593) +34871 35.424707 -77.593860 ... NaN POINT (-77.59386 35.42471) +34876 35.301135 -77.264727 ... NaN POINT (-77.26473 35.30114) -[509 rows x 51 columns] +[509 rows x 52 columns] ``` -##### retrieve water level products from tidal buoys maintained by the National Oceanic and Atmospheric Administration (NOAA) Center for Operational Oceanographic Products and Services (CO-OPS) +#### products from the Center for Operational Oceanographic Products and Services (CO-OPS) ```python from stormevents import StormEvent -florence2018 = StormEvent('florence', 2018) - -florence2018.tidal_data_within_isotach( - wind_speed=34, - start_date='20180913230000', - end_date='20180914', -) +storm = StormEvent('florence', 2018) +storm.coops_product_within_isotach('water_level', wind_speed=34, start_date='2018-09-12 14:03:00', end_date='2018-09-14') ``` ``` -Dimensions: (nos_id: 10, t: 11) + +Dimensions: (nos_id: 7, t: 340) Coordinates: - * t (t) datetime64[ns] 2018-09-13T23:00:00 ... 2018-09-14 - * nos_id (nos_id) int64 8639348 8651370 8652587 ... 8661070 8662245 8665530 - nws_id (nos_id) DataFrame: def get( self, + product: COOPS_Product, start_date: datetime, end_date: datetime = None, - product: COOPS_Product = None, datum: COOPS_TidalDatum = None, units: COOPS_Units = None, time_zone: COOPS_TimeZone = None, @@ -199,28 +199,29 @@ def get( :param interval: time interval of data :return: data for the current station within the specified parameters - >>> COOPS_Station(8632200).get(start_date=datetime(2018, 9, 13), end_date=datetime(2018, 9, 16, 12)) + >>> station = COOPS_Station(8632200) + >>> station.get('water_level', start_date=datetime(2018, 9, 13), end_date=datetime(2018, 9, 16, 12)) - Dimensions: (t: 841) + Dimensions: (nos_id: 1, t: 841) Coordinates: + * nos_id (nos_id) int64 8632200 * t (t) datetime64[ns] 2018-09-13 ... 2018-09-16T12:00:00 - nos_id int64 8632200 - nws_id DataFrame: """ :return: data for the current query parameters - >>> COOPS_Query(1612480, start_date='2022-01-01', end_date='2022-01-03').data + >>> query = COOPS_Query(1612480, 'water_level', start_date='2022-01-01', end_date='2022-01-03') + >>> query.data v s f q t 2022-01-01 00:00:00 1.193 0.002 0,0,0,0 p @@ -484,19 +484,19 @@ def coops_stations(station_type: COOPS_StationType = None) -> GeoDataFrame: :return: data frame of stations >>> coops_stations() - nws_id ... geometry - nos_id ... - 1600012 46125 ... POINT (122.62500 37.75000) - 1611400 NWWH1 ... POINT (-159.37500 21.95312) - 1612340 OOUH1 ... POINT (-157.87500 21.31250) - 1612480 MOKH1 ... POINT (-157.75000 21.43750) - 1615680 KLIH1 ... POINT (-156.50000 20.89062) - ... ... ... ... - 9759394 MGZP4 ... POINT (-67.18750 18.21875) - 9759938 MISP4 ... POINT (-67.93750 18.09375) - 9761115 BARA9 ... POINT (-61.81250 17.59375) - 9999530 FRCB6 ... POINT (-64.68750 32.37500) - 9999531 ... POINT (-93.31250 29.76562) + nws_id name state removed geometry + nos_id + 1600012 46125 QREB buoy NaT POINT (122.62500 37.75000) + 1611400 NWWH1 Nawiliwili HI NaT POINT (-159.37500 21.95312) + 1612340 OOUH1 Honolulu HI NaT POINT (-157.87500 21.31250) + 1612480 MOKH1 Mokuoloe HI NaT POINT (-157.75000 21.43750) + 1615680 KLIH1 Kahului, Kahului Harbor HI NaT POINT (-156.50000 20.89062) + ... ... ... ... ... + 9759394 MGZP4 Mayaguez PR NaT POINT (-67.18750 18.21875) + 9759938 MISP4 Mona Island NaT POINT (-67.93750 18.09375) + 9761115 BARA9 Barbuda NaT POINT (-61.81250 17.59375) + 9999530 FRCB6 Bermuda, Ferry Reach Channel NaT POINT (-64.68750 32.37500) + 9999531 Calcasieu Test Station LA NaT POINT (-93.31250 29.76562) [363 rows x 5 columns] """ @@ -572,20 +572,19 @@ def coops_stations_within_region( >>> from shapely import ops >>> track = VortexTrack('florence2018', file_deck='b') >>> combined_wind_swaths = ops.unary_union(list(track.wind_swaths(34).values())) - >>> stations = coops_stations_within_region(region=combined_wind_swaths) - nws_id ... geometry - nos_id ... - 8651370 DUKN7 ... POINT (-75.75000 36.18750) - 8652587 ORIN7 ... POINT (-75.56250 35.78125) - 8654467 HCGN7 ... POINT (-75.68750 35.21875) - 8656483 BFTN7 ... POINT (-76.68750 34.71875) - 8658120 WLON7 ... POINT (-77.93750 34.21875) - 8658163 JMPN7 ... POINT (-77.81250 34.21875) - 8661070 MROS1 ... POINT (-78.93750 33.65625) - 8662245 NITS1 ... POINT (-79.18750 33.34375) - 8665530 CHTS1 ... POINT (-79.93750 32.78125) - 8670870 FPKG1 ... POINT (-80.87500 32.03125) - [10 rows x 5 columns] + >>> coops_stations_within_region(region=combined_wind_swaths) + nws_id name state removed geometry + nos_id + 8651370 DUKN7 Duck NC NaT POINT (-75.75000 36.18750) + 8652587 ORIN7 Oregon Inlet Marina NC NaT POINT (-75.56250 35.78125) + 8654467 HCGN7 USCG Station Hatteras NC NaT POINT (-75.68750 35.21875) + 8656483 BFTN7 Beaufort, Duke Marine Lab NC NaT POINT (-76.68750 34.71875) + 8658120 WLON7 Wilmington NC NaT POINT (-77.93750 34.21875) + 8658163 JMPN7 Wrightsville Beach NC NaT POINT (-77.81250 34.21875) + 8661070 MROS1 Springmaid Pier SC NaT POINT (-78.93750 33.65625) + 8662245 NITS1 Oyster Landing (N Inlet Estuary) SC NaT POINT (-79.18750 33.34375) + 8665530 CHTS1 Charleston, Cooper River Entrance SC NaT POINT (-79.93750 32.78125) + 8670870 FPKG1 Fort Pulaski GA NaT POINT (-80.87500 32.03125) """ stations = coops_stations(station_type) @@ -600,11 +599,11 @@ def coops_stations_within_bounds( ) -def coops_data_within_region( +def coops_product_within_region( + product: COOPS_Product, region: Union[Polygon, MultiPolygon], start_date: datetime, end_date: datetime = None, - product: COOPS_Product = None, datum: COOPS_TidalDatum = None, units: COOPS_Units = None, time_zone: COOPS_TimeZone = None, @@ -614,10 +613,10 @@ def coops_data_within_region( """ retrieve CO-OPS data from within the specified region of interest + :param product: CO-OPS product; one of ``water_level``, ``air_temperature``, ``water_temperature``, ``wind``, ``air_pressure``, ``air_gap``, ``conductivity``, ``visibility``, ``humidity``, ``salinity``, ``hourly_height``, ``high_low``, ``daily_mean``, ``monthly_mean``, ``one_minute_water_level``, ``predictions``, ``datums``, ``currents``, ``currents_predictions`` :param region: polygon or multipolygon denoting region of interest :param start_date: start date of CO-OPS query :param end_date: start date of CO-OPS query - :param product: CO-OPS product :param datum: tidal datum :param units: one of ``metric`` or ``english`` :param time_zone: station time zone @@ -630,18 +629,19 @@ def coops_data_within_region( >>> from datetime import timedelta >>> track = VortexTrack('florence2018', file_deck='b') >>> combined_wind_swaths = ops.unary_union(list(track.wind_swaths(34).values())) - >>> coops_data_within_region(region=combined_wind_swaths, start_date=datetime.now() - timedelta(hours=1), end_date=datetime.now()) + >>> coops_product_within_region('water_level', region=combined_wind_swaths, start_date=datetime.now() - timedelta(hours=1), end_date=datetime.now()) + Dimensions: (nos_id: 10, t: 10) Coordinates: * nos_id (nos_id) int64 8651370 8652587 8654467 ... 8662245 8665530 8670870 - * t (t) datetime64[ns] 2022-02-15T13:48:00 ... 2022-02-15T14:42:00 + * t (t) datetime64[ns] 2022-02-17T11:42:00 ... 2022-02-17T12:36:00 nws_id (nos_id) >> VortexTrack.from_storm_name('irma', 2017) + VortexTrack('AL112017', Timestamp('2017-08-30 00:00:00'), Timestamp('2017-09-13 12:00:00'), , , 'BEST', None) """ year = int(year) @@ -172,6 +175,9 @@ def from_fort22( :param fort22: file path to ``fort.22`` :param start_date: start date of track :param end_date: end date of track + + >>> VortexTrack.from_fort22('tests/data/input/test_from_fort22/irma2017_fort.22') + VortexTrack('AL112017', Timestamp('2017-09-05 00:00:00'), Timestamp('2017-09-19 00:00:00'), , , 'BEST', PosixPath('tests/data/input/test_from_fort22/irma2017_fort.22')) """ filename = None @@ -196,6 +202,9 @@ def from_atcf_file( :param atcf: file path to ATCF data :param start_date: start date of track :param end_date: end date of track + + >>> VortexTrack.from_atcf_file('tests/data/input/test_from_atcf/atcf.trk') + VortexTrack('BT02008', Timestamp('2008-10-16 17:06:00'), Timestamp('2008-10-20 20:06:00'), , , 'BEST', PosixPath('tests/data/input/test_from_atcf/florence2018_atcf.trk')) """ filename = None @@ -353,7 +362,7 @@ def file_deck(self) -> ATCF_FileDeck: @file_deck.setter def file_deck(self, file_deck: ATCF_FileDeck): if file_deck is None: - file_deck = ATCF_FileDeck.b + file_deck = ATCF_FileDeck.BEST elif not isinstance(file_deck, ATCF_FileDeck): file_deck = typepigeon.convert_value(file_deck, ATCF_FileDeck) self.__file_deck = file_deck @@ -389,7 +398,7 @@ def record_type(self) -> str: :return: ATCF advisory type; one of ``BEST``, ``OFCL``, ``OFCP``, ``HMON``, ``CARQ``, ``HWRF`` """ - if self.file_deck == ATCF_FileDeck.b: + if self.file_deck == ATCF_FileDeck.BEST: self.__record_type = ATCF_RecordType.best.value return self.__record_type @@ -409,15 +418,15 @@ def record_type(self, record_type: ATCF_RecordType): @property def valid_record_types(self) -> List[ATCF_RecordType]: - if self.file_deck == ATCF_FileDeck.a: + if self.file_deck == ATCF_FileDeck.ADVISORY: # see ftp://ftp.nhc.noaa.gov/atcf/docs/nhc_techlist.dat # there are more but they may not have enough columns valid_record_types = [ entry.value for entry in ATCF_RecordType if entry != ATCF_RecordType.best ] - elif self.file_deck == ATCF_FileDeck.b: + elif self.file_deck == ATCF_FileDeck.BEST: valid_record_types = [ATCF_RecordType.best.value] - elif self.file_deck == ATCF_FileDeck.f: + elif self.file_deck == ATCF_FileDeck.FIXED: valid_record_types = [entry.value for entry in ATCF_RecordType] else: raise NotImplementedError(f'file deck {self.file_deck.value} not implemented') @@ -443,21 +452,21 @@ def data(self) -> DataFrame: """ :return: track data for the given parameters as a data frame - >>> track = VortexTrack('michael2018') + >>> track = VortexTrack('AL112017', file_deck='a') >>> track.data - basin storm_number ... name geometry - 0 AL 14 ... INVEST POINT (-86.60000 17.80000) - 1 AL 14 ... FOURTEEN POINT (-86.90000 18.10000) - 2 AL 14 ... FOURTEEN POINT (-86.80000 18.40000) - 3 AL 14 ... FOURTEEN POINT (-86.40000 18.80000) - 4 AL 14 ... MICHAEL POINT (-85.70000 19.10000) - .. ... ... ... ... ... - 80 AL 14 ... MICHAEL POINT (-13.50000 45.90000) - 81 AL 14 ... MICHAEL POINT (-11.40000 44.40000) - 82 AL 14 ... MICHAEL POINT (-11.40000 44.40000) - 83 AL 14 ... MICHAEL POINT (-10.30000 42.80000) - 84 AL 14 ... MICHAEL POINT (-10.00000 41.20000) - [85 rows x 22 columns] + basin storm_number ... name geometry + 0 AL 11 ... INVEST POINT (-26.90000 16.10000) + 1 AL 11 ... INVEST POINT (-28.30000 16.20000) + 2 AL 11 ... IRMA POINT (-29.70000 16.30000) + 3 AL 11 ... IRMA POINT (-30.80000 16.30000) + 4 AL 11 ... IRMA POINT (-30.80000 16.30000) + .. ... ... ... ... ... + 168 AL 11 ... IRMA POINT (-86.90000 33.80000) + 169 AL 11 ... IRMA POINT (-88.10000 34.80000) + 170 AL 11 ... IRMA POINT (-88.90000 35.60000) + 171 AL 11 ... IRMA POINT (-89.50000 36.20000) + 172 AL 11 ... IRMA POINT (-90.10000 36.80000) + [173 rows x 22 columns] """ return self.__unfiltered_data.loc[ diff --git a/stormevents/stormevent.py b/stormevents/stormevent.py index 30d0838..8a480dd 100644 --- a/stormevents/stormevent.py +++ b/stormevents/stormevent.py @@ -43,6 +43,18 @@ def __init__( >>> StormEvent('florence', 2018) StormEvent('FLORENCE', 2018) + + >>> StormEvent('paine', 2016, start_date='2016-09-18', end_date=datetime(2016, 9, 19, 12)) + StormEvent('PAINE', 2016, end_date='2016-09-19 12:00:00') + + >>> StormEvent('florence', 2018, start_date=timedelta(days=2)) + StormEvent('FLORENCE', 2018, start_date='2018-09-01 06:00:00') + + >>> StormEvent('henri', 2021, start_date=timedelta(days=-3), end_date=timedelta(days=-2)) + StormEvent('HENRI', 2021, start_date='2021-08-21 12:00:00', end_date='2021-08-22 12:00:00') + + >>> StormEvent('ida', 2021, end_date=timedelta(days=2)) + StormEvent('IDA', 2021, end_date='2021-08-29 18:00:00') """ storms = nhc_storms(year=year) @@ -256,6 +268,10 @@ def track( :param record_type: ATCF record type :param filename: file path to ``fort.22`` :return: vortex track + + >>> storm = StormEvent('florence', 2018) + >>> storm.track(file_deck='b') + VortexTrack('AL062018', Timestamp('2018-08-30 06:00:00'), Timestamp('2018-09-18 12:00:00'), , , 'BEST', None) """ if start_date is None: @@ -278,6 +294,23 @@ def track( def high_water_marks(self) -> DataFrame: """ :return: USGS high-water marks (HWMs) for this storm event + + >>> storm = StormEvent('florence', 2018) + >>> storm.high_water_marks + latitude longitude ... siteZone geometry + hwm_id ... + 33496 37.298440 -80.007750 ... NaN POINT (-80.00775 37.29844) + 33502 35.342089 -78.041553 ... NaN POINT (-78.04155 35.34209) + 33503 35.378963 -78.010596 ... NaN POINT (-78.01060 35.37896) + 33505 35.216282 -78.935229 ... NaN POINT (-78.93523 35.21628) + 33508 35.199859 -78.960296 ... NaN POINT (-78.96030 35.19986) + ... ... ... ... ... + 34191 33.724722 -79.059722 ... NaN POINT (-79.05972 33.72472) + 34235 34.936308 -76.811223 ... POINT (-76.81122 34.93631) + 34840 34.145930 -78.868567 ... NaN POINT (-78.86857 34.14593) + 34871 35.424707 -77.593860 ... NaN POINT (-77.59386 35.42471) + 34876 35.301135 -77.264727 ... NaN POINT (-77.26473 35.30114) + [509 rows x 52 columns] """ configuration = {'name': self.name, 'year': self.year} @@ -285,13 +318,13 @@ def high_water_marks(self) -> DataFrame: self.__high_water_marks = StormHighWaterMarks(name=self.name, year=self.year).data return self.__high_water_marks - def tidal_data_within_isotach( + def coops_product_within_isotach( self, + product: COOPS_Product, wind_speed: int, station_type: COOPS_StationType = None, start_date: datetime = None, end_date: datetime = None, - product: COOPS_Product = None, datum: COOPS_TidalDatum = None, units: COOPS_Units = None, time_zone: COOPS_TimeZone = None, @@ -301,11 +334,11 @@ def tidal_data_within_isotach( """ retrieve CO-OPS tidal station data from within the specified polygon + :param product: CO-OPS product :param wind_speed: wind speed in knots (one of ``34``, ``50``, or ``64``) - :param station_type: either ``current`` or ``historical`` :param start_date: start date :param end_date: end date - :param product: CO-OPS product + :param station_type: either ``current`` or ``historical`` :param datum: tidal datum :param units: either ``metric`` or ``english`` :param time_zone: time zone @@ -314,18 +347,18 @@ def tidal_data_within_isotach( :return: CO-OPS station data >>> storm = StormEvent('florence', 2018) - >>> storm.tidal_data_within_isotach(wind_speed=34, start_date='2018-09-13', end_date='2018-09-13 06:00:00') + >>> storm.coops_product_within_isotach('water_level', wind_speed=34, start_date='2018-09-12 14:03:00', end_date='2018-09-14') - Dimensions: (t: 121, nos_id: 7) + Dimensions: (nos_id: 7, t: 340) Coordinates: - * t (t) datetime64[ns] 2018-09-13T12:00:00 ... 2018-09-14 * nos_id (nos_id) int64 8651370 8652587 8654467 ... 8658120 8658163 8661070 + * t (t) datetime64[ns] 2018-09-12T14:06:00 ... 2018-09-14 nws_id (nos_id) >> import shapely >>> storm = StormEvent('florence', 2018) >>> region = shapely.geometry.box(self.track().linestring.bounds) - >>> storm.tidal_data_within_region(region, start_date='2018-09-13', end_date='2018-09-13 06:00:00') + >>> storm.coops_product_within_isotach('water_level', wind_speed=34, start_date='2018-09-12 14:03:00', end_date='2018-09-14') - Dimensions: (t: 61, nos_id: 65) + Dimensions: (nos_id: 7, t: 340) Coordinates: - * t (t) datetime64[ns] 2018-09-13 ... 2018-09-13T06:00:00 - * nos_id (nos_id) int64 8652587 8654467 8654467 ... 8652587 8652587 8652587 - nws_id (nos_id) >> hwm = HighWaterMarks(182) - >>> hwm.data - latitude longitude ... siteZone geometry + >>> survey = HighWaterMarks(182) + >>> survey.hwm_quality = 'EXCELLENT', 'GOOD' + >>> survey.data + latitude longitude ... siteZone geometry hwm_id ... - 22636 32.007730 -81.238270 ... NaN POINT Z (-81.23827 32.00773 2.10373) - 22757 30.510528 -81.460833 ... 0 POINT Z (-81.46083 30.51053 1.99461) - 22885 30.770560 -81.581390 ... NaN POINT Z (-81.58139 30.77056 2.42987) - 22965 31.063150 -81.404540 ... NaN POINT Z (-81.40454 31.06315 4.12090) - 23052 30.845000 -81.560000 ... NaN POINT Z (-81.56000 30.84500 1.97328) - ... ... ... ... ... ... - 25147 30.018190 -81.859657 ... NaN POINT Z (-81.85966 30.01819 9.07390) - 25148 30.097214 -81.891451 ... NaN POINT Z (-81.89145 30.09721 7.26338) - 25150 30.038222 -81.880928 ... NaN POINT Z (-81.88093 30.03822 7.62305) - 25158 29.720560 -81.506110 ... NaN POINT Z (-81.50611 29.72056 0.96012) - 25159 30.097514 -81.794375 ... NaN POINT Z (-81.79438 30.09751 2.64262) - [221 rows x 52 columns] - >>> hwm.hwm_quality = 'EXCELLENT', 'GOOD' - >>> hwm.data - latitude longitude ... siteZone geometry - hwm_id ... - 22636 32.007730 -81.238270 ... NaN POINT Z (-81.23827 32.00773 2.10373) - 22885 30.770560 -81.581390 ... NaN POINT Z (-81.58139 30.77056 2.42987) - 23130 31.034720 -81.640000 ... NaN POINT Z (-81.64000 31.03472 2.22199) - 23216 32.035150 -81.045040 ... NaN POINT Z (-81.04504 32.03515 2.42316) - 23236 32.083650 -81.157520 ... NaN POINT Z (-81.15752 32.08365 3.07238) - ... ... ... ... ... ... - 25146 29.992580 -81.851518 ... NaN POINT Z (-81.85152 29.99258 10.69238) - 25148 30.097214 -81.891451 ... NaN POINT Z (-81.89145 30.09721 7.26338) - 25150 30.038222 -81.880928 ... NaN POINT Z (-81.88093 30.03822 7.62305) - 25158 29.720560 -81.506110 ... NaN POINT Z (-81.50611 29.72056 0.96012) - 25159 30.097514 -81.794375 ... NaN POINT Z (-81.79438 30.09751 2.64262) + 22636 32.007730 -81.238270 ... NaN POINT (-81.23827 32.00773) + 22885 30.770560 -81.581390 ... NaN POINT (-81.58139 30.77056) + 23130 31.034720 -81.640000 ... NaN POINT (-81.64000 31.03472) + 23216 32.035150 -81.045040 ... NaN POINT (-81.04504 32.03515) + 23236 32.083650 -81.157520 ... NaN POINT (-81.15752 32.08365) + ... ... ... ... ... + 25146 29.992580 -81.851518 ... NaN POINT (-81.85152 29.99258) + 25148 30.097214 -81.891451 ... NaN POINT (-81.89145 30.09721) + 25150 30.038222 -81.880928 ... NaN POINT (-81.88093 30.03822) + 25158 29.720560 -81.506110 ... NaN POINT (-81.50611 29.72056) + 25159 30.097514 -81.794375 ... NaN POINT (-81.79438 30.09751) [138 rows x 52 columns] """ @@ -272,21 +257,22 @@ def data(self) -> GeoDataFrame: """ :returns: data frame of data for the current parameters - >>> hwm = HighWaterMarks(182) - >>> hwm.data - latitude longitude ... siteZone geometry + >>> survey = HighWaterMarks(182) + >>> survey.data + latitude longitude ... siteZone geometry hwm_id ... - 22636 32.007730 -81.238270 ... NaN POINT Z (-81.23827 32.00773 2.10373) - 22757 30.510528 -81.460833 ... 0 POINT Z (-81.46083 30.51053 1.99461) - 22885 30.770560 -81.581390 ... NaN POINT Z (-81.58139 30.77056 2.42987) - 22965 31.063150 -81.404540 ... NaN POINT Z (-81.40454 31.06315 4.12090) - 23052 30.845000 -81.560000 ... NaN POINT Z (-81.56000 30.84500 1.97328) - ... ... ... ... ... ... - 25147 30.018190 -81.859657 ... NaN POINT Z (-81.85966 30.01819 9.07390) - 25148 30.097214 -81.891451 ... NaN POINT Z (-81.89145 30.09721 7.26338) - 25150 30.038222 -81.880928 ... NaN POINT Z (-81.88093 30.03822 7.62305) - 25158 29.720560 -81.506110 ... NaN POINT Z (-81.50611 29.72056 0.96012) - 25159 30.097514 -81.794375 ... NaN POINT Z (-81.79438 30.09751 2.64262) + 22636 32.007730 -81.238270 ... NaN POINT (-81.23827 32.00773) + 22757 30.510528 -81.460833 ... 0 POINT (-81.46083 30.51053) + 22885 30.770560 -81.581390 ... NaN POINT (-81.58139 30.77056) + 22965 31.063150 -81.404540 ... NaN POINT (-81.40454 31.06315) + 23052 30.845000 -81.560000 ... NaN POINT (-81.56000 30.84500) + ... ... ... ... ... + 25147 30.018190 -81.859657 ... NaN POINT (-81.85966 30.01819) + 25148 30.097214 -81.891451 ... NaN POINT (-81.89145 30.09721) + 25150 30.038222 -81.880928 ... NaN POINT (-81.88093 30.03822) + 25158 29.720560 -81.506110 ... NaN POINT (-81.50611 29.72056) + 25159 30.097514 -81.794375 ... NaN POINT (-81.79438 30.09751) + [221 rows x 52 columns] """ @@ -358,15 +344,15 @@ def data(self) -> GeoDataFrame: data = self.__data return GeoDataFrame( - data, - geometry=geopandas.points_from_xy( - data['longitude'], data['latitude'], data['elev_ft'] * 0.3048 - ), + data, geometry=geopandas.points_from_xy(data['longitude'], data['latitude']), ) def __eq__(self, other: 'HighWaterMarks') -> bool: return self.data.equals(other.data) + def __repr__(self) -> str: + return f'{self.__class__.__name__}({", ".join(repr(value) for value in (self.event_id, self.event_status, self.us_states, self.us_counties, self.hwm_type, self.hwm_quality, self.hwm_environment, self.survey_completed, self.still_water))})' + class StormHighWaterMarks(HighWaterMarks): """ diff --git a/tests/data/input/test_from_atcf/florence2018_atcf.trk b/tests/data/input/test_from_atcf/florence2018_atcf.trk deleted file mode 100644 index a8c003f..0000000 --- a/tests/data/input/test_from_atcf/florence2018_atcf.trk +++ /dev/null @@ -1,100 +0,0 @@ -BT, 0, 2008101617, 06, BEST, 0, 161N, 768W, 022, 1005, TC, 0, , 0, 0, 0, 0, 1005, 250, 80, , , L, , WRT, 012, 004, WRT00001, -BT, 0, 2008101618, 06, BEST, 0, 161N, 768W, 022, 1005, TC, 0, , 0, 0, 0, 0, 1005, 250, 78, , , L, , WRT, 009, 004, WRT00001, -BT, 0, 2008101619, 06, BEST, 0, 162N, 768W, 023, 1005, TC, 0, , 0, 0, 0, 0, 1005, 250, 76, , , L, , WRT, 007, 005, WRT00001, -BT, 0, 2008101620, 06, BEST, 0, 163N, 769W, 024, 1005, TC, 0, , 0, 0, 0, 0, 1005, 250, 75, , , L, , WRT, 004, 005, WRT00001, -BT, 0, 2008101621, 06, BEST, 0, 163N, 769W, 024, 1005, TC, 0, , 0, 0, 0, 0, 1005, 250, 73, , , L, , WRT, 001, 005, WRT00001, -BT, 0, 2008101622, 06, BEST, 0, 164N, 769W, 025, 1004, TC, 0, , 0, 0, 0, 0, 1005, 250, 72, , , L, , WRT, 358, 005, WRT00001, -BT, 0, 2008101623, 06, BEST, 0, 165N, 769W, 026, 1004, TC, 0, , 0, 0, 0, 0, 1005, 250, 70, , , L, , WRT, 355, 006, WRT00001, -BT, 0, 2008101700, 06, BEST, 0, 166N, 768W, 027, 1004, TC, 0, , 0, 0, 0, 0, 1005, 250, 69, , , L, , WRT, 353, 006, WRT00001, -BT, 0, 2008101701, 06, BEST, 0, 167N, 768W, 028, 1004, TC, 0, , 0, 0, 0, 0, 1005, 250, 67, , , L, , WRT, 351, 007, WRT00001, -BT, 0, 2008101702, 06, BEST, 0, 168N, 768W, 029, 1003, TC, 0, , 0, 0, 0, 0, 1005, 250, 66, , , L, , WRT, 348, 007, WRT00001, -BT, 0, 2008101703, 06, BEST, 0, 169N, 768W, 030, 1003, TC, 0, , 0, 0, 0, 0, 1005, 250, 65, , , L, , WRT, 346, 008, WRT00001, -BT, 0, 2008101704, 06, BEST, 0, 170N, 768W, 031, 1003, TC, 0, , 0, 0, 0, 0, 1005, 250, 64, , , L, , WRT, 345, 009, WRT00001, -BT, 0, 2008101705, 06, BEST, 0, 172N, 767W, 032, 1003, TC, 0, , 0, 0, 0, 0, 1005, 250, 62, , , L, , WRT, 343, 009, WRT00001, -BT, 0, 2008101706, 06, BEST, 0, 173N, 767W, 033, 1003, TC, 0, , 0, 0, 0, 0, 1005, 250, 61, , , L, , WRT, 342, 010, WRT00001, -BT, 0, 2008101707, 06, BEST, 0, 175N, 766W, 034, 1002, TC, 0, , 0, 0, 0, 0, 1005, 250, 60, , , L, , WRT, 342, 011, WRT00001, -BT, 0, 2008101708, 06, BEST, 0, 176N, 766W, 035, 1002, TC, 0, , 0, 0, 0, 0, 1005, 250, 59, , , L, , WRT, 341, 011, WRT00001, -BT, 0, 2008101709, 06, BEST, 0, 178N, 765W, 036, 1002, TC, 0, , 0, 0, 0, 0, 1005, 250, 57, , , L, , WRT, 341, 012, WRT00001, -BT, 0, 2008101710, 06, BEST, 0, 180N, 765W, 037, 1001, TC, 0, , 0, 0, 0, 0, 1005, 250, 56, , , L, , WRT, 341, 013, WRT00001, -BT, 0, 2008101711, 06, BEST, 0, 182N, 764W, 039, 1001, TC, 0, , 0, 0, 0, 0, 1005, 250, 55, , , L, , WRT, 341, 014, WRT00001, -BT, 0, 2008101712, 06, BEST, 0, 184N, 763W, 040, 1001, TC, 0, , 0, 0, 0, 0, 1005, 250, 54, , , L, , WRT, 342, 014, WRT00001, -BT, 0, 2008101713, 06, BEST, 0, 186N, 762W, 041, 1000, TC, 0, , 0, 0, 0, 0, 1005, 250, 52, , , L, , WRT, 343, 015, WRT00001, -BT, 0, 2008101714, 06, BEST, 0, 189N, 762W, 042, 1000, TC, 0, , 0, 0, 0, 0, 1005, 250, 51, , , L, , WRT, 343, 015, WRT00001, -BT, 0, 2008101715, 06, BEST, 0, 191N, 761W, 043, 1000, TC, 0, , 0, 0, 0, 0, 1005, 250, 50, , , L, , WRT, 344, 016, WRT00001, -BT, 0, 2008101716, 06, BEST, 0, 194N, 760W, 045, 0999, TC, 0, , 0, 0, 0, 0, 1005, 250, 49, , , L, , WRT, 345, 017, WRT00001, -BT, 0, 2008101717, 06, BEST, 0, 196N, 760W, 046, 0999, TC, 0, , 0, 0, 0, 0, 1005, 250, 48, , , L, , WRT, 346, 017, WRT00001, -BT, 0, 2008101718, 06, BEST, 0, 199N, 759W, 047, 0998, TC, 0, , 0, 0, 0, 0, 1005, 250, 47, , , L, , WRT, 347, 017, WRT00001, -BT, 0, 2008101719, 06, BEST, 0, 202N, 758W, 047, 0998, TC, 0, , 0, 0, 0, 0, 1005, 250, 46, , , L, , WRT, 348, 018, WRT00001, -BT, 0, 2008101720, 06, BEST, 0, 205N, 758W, 048, 0998, TC, 0, , 0, 0, 0, 0, 1005, 250, 46, , , L, , WRT, 348, 018, WRT00001, -BT, 0, 2008101721, 06, BEST, 0, 208N, 757W, 048, 0998, TC, 0, , 0, 0, 0, 0, 1005, 250, 46, , , L, , WRT, 349, 019, WRT00001, -BT, 0, 2008101722, 06, BEST, 0, 211N, 756W, 049, 0998, TC, 0, , 0, 0, 0, 0, 1005, 250, 46, , , L, , WRT, 350, 019, WRT00001, -BT, 0, 2008101723, 06, BEST, 0, 214N, 756W, 050, 0998, TC, 0, , 0, 0, 0, 0, 1005, 250, 45, , , L, , WRT, 350, 019, WRT00001, -BT, 0, 2008101800, 06, BEST, 0, 217N, 755W, 052, 0997, TC, 0, , 0, 0, 0, 0, 1005, 250, 44, , , L, , WRT, 350, 020, WRT00001, -BT, 0, 2008101801, 06, BEST, 0, 220N, 755W, 053, 0997, TC, 0, , 0, 0, 0, 0, 1005, 250, 43, , , L, , WRT, 351, 020, WRT00001, -BT, 0, 2008101802, 06, BEST, 0, 223N, 754W, 055, 0996, TC, 0, , 0, 0, 0, 0, 1005, 250, 42, , , L, , WRT, 351, 021, WRT00001, -BT, 0, 2008101803, 06, BEST, 0, 227N, 754W, 057, 0996, TC, 0, , 0, 0, 0, 0, 1005, 250, 41, , , L, , WRT, 351, 021, WRT00001, -BT, 0, 2008101804, 06, BEST, 0, 230N, 753W, 058, 0995, TC, 0, , 0, 0, 0, 0, 1005, 250, 40, , , L, , WRT, 350, 022, WRT00001, -BT, 0, 2008101805, 06, BEST, 0, 234N, 753W, 060, 0995, TC, 0, , 0, 0, 0, 0, 1005, 250, 39, , , L, , WRT, 350, 023, WRT00001, -BT, 0, 2008101806, 06, BEST, 0, 237N, 752W, 063, 0994, TC, 0, , 0, 0, 0, 0, 1005, 250, 37, , , L, , WRT, 350, 023, WRT00001, -BT, 0, 2008101807, 06, BEST, 0, 241N, 751W, 065, 0993, TC, 0, , 0, 0, 0, 0, 1005, 250, 36, , , L, , WRT, 349, 024, WRT00001, -BT, 0, 2008101808, 06, BEST, 0, 245N, 750W, 067, 0992, TC, 0, , 0, 0, 0, 0, 1005, 250, 35, , , L, , WRT, 349, 024, WRT00001, -BT, 0, 2008101809, 06, BEST, 0, 249N, 750W, 070, 0991, TC, 0, , 0, 0, 0, 0, 1005, 250, 34, , , L, , WRT, 348, 025, WRT00001, -BT, 0, 2008101810, 06, BEST, 0, 253N, 749W, 072, 0990, TC, 0, , 0, 0, 0, 0, 1005, 250, 33, , , L, , WRT, 347, 025, WRT00001, -BT, 0, 2008101811, 06, BEST, 0, 257N, 748W, 075, 0989, TC, 0, , 0, 0, 0, 0, 1005, 250, 31, , , L, , WRT, 347, 025, WRT00001, -BT, 0, 2008101812, 06, BEST, 0, 261N, 747W, 077, 0988, TC, 0, , 0, 0, 0, 0, 1005, 250, 30, , , L, , WRT, 346, 025, WRT00001, -BT, 0, 2008101813, 06, BEST, 0, 265N, 746W, 079, 0987, TC, 0, , 0, 0, 0, 0, 1005, 250, 29, , , L, , WRT, 346, 025, WRT00001, -BT, 0, 2008101814, 06, BEST, 0, 269N, 745W, 082, 0986, TC, 0, , 0, 0, 0, 0, 1005, 250, 29, , , L, , WRT, 346, 025, WRT00001, -BT, 0, 2008101815, 06, BEST, 0, 273N, 744W, 083, 0985, TC, 0, , 0, 0, 0, 0, 1005, 250, 28, , , L, , WRT, 347, 024, WRT00001, -BT, 0, 2008101816, 06, BEST, 0, 277N, 743W, 085, 0984, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 348, 024, WRT00001, -BT, 0, 2008101817, 06, BEST, 0, 281N, 742W, 086, 0984, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 349, 024, WRT00001, -BT, 0, 2008101818, 06, BEST, 0, 285N, 741W, 087, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 350, 024, WRT00001, -BT, 0, 2008101819, 06, BEST, 0, 289N, 741W, 088, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 351, 024, WRT00001, -BT, 0, 2008101820, 06, BEST, 0, 293N, 740W, 089, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 353, 023, WRT00001, -BT, 0, 2008101821, 06, BEST, 0, 297N, 740W, 089, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 354, 024, WRT00001, -BT, 0, 2008101822, 06, BEST, 0, 301N, 739W, 089, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 26, , , L, , WRT, 354, 024, WRT00001, -BT, 0, 2008101823, 06, BEST, 0, 305N, 739W, 089, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 26, , , L, , WRT, 355, 024, WRT00001, -BT, 0, 2008101900, 06, BEST, 0, 308N, 738W, 089, 0982, TC, 0, , 0, 0, 0, 0, 1005, 250, 26, , , L, , WRT, 355, 024, WRT00001, -BT, 0, 2008101901, 06, BEST, 0, 312N, 738W, 089, 0982, TC, 0, , 0, 0, 0, 0, 1005, 250, 26, , , L, , WRT, 356, 024, WRT00001, -BT, 0, 2008101902, 06, BEST, 0, 316N, 738W, 090, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 358, 024, WRT00001, -BT, 0, 2008101903, 06, BEST, 0, 320N, 738W, 090, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 358, 024, WRT00001, -BT, 0, 2008101904, 06, BEST, 0, 324N, 738W, 090, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 359, 024, WRT00001, -BT, 0, 2008101905, 06, BEST, 0, 328N, 737W, 090, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 359, 023, WRT00001, -BT, 0, 2008101906, 06, BEST, 0, 332N, 737W, 090, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 000, 023, WRT00001, -BT, 0, 2008101907, 06, BEST, 0, 336N, 737W, 089, 0983, TC, 0, , 0, 0, 0, 0, 1005, 250, 27, , , L, , WRT, 001, 023, WRT00001, -BT, 0, 2008101908, 06, BEST, 0, 340N, 737W, 089, 0984, TC, 0, , 0, 0, 0, 0, 1005, 250, 28, , , L, , WRT, 003, 023, WRT00001, -BT, 0, 2008101909, 06, BEST, 0, 344N, 738W, 089, 0984, TC, 0, , 0, 0, 0, 0, 1005, 250, 28, , , L, , WRT, 005, 023, WRT00001, -BT, 0, 2008101910, 06, BEST, 0, 348N, 738W, 088, 0984, TC, 0, , 0, 0, 0, 0, 1005, 250, 28, , , L, , WRT, 007, 023, WRT00001, -BT, 0, 2008101911, 06, BEST, 0, 351N, 739W, 088, 0985, TC, 0, , 0, 0, 0, 0, 1005, 250, 29, , , L, , WRT, 010, 023, WRT00001, -BT, 0, 2008101912, 06, BEST, 0, 355N, 739W, 087, 0985, TC, 0, , 0, 0, 0, 0, 1005, 250, 29, , , L, , WRT, 013, 023, WRT00001, -BT, 0, 2008101913, 06, BEST, 0, 359N, 740W, 087, 0986, TC, 0, , 0, 0, 0, 0, 1005, 250, 30, , , L, , WRT, 016, 023, WRT00001, -BT, 0, 2008101914, 06, BEST, 0, 363N, 741W, 086, 0987, TC, 0, , 0, 0, 0, 0, 1005, 250, 30, , , L, , WRT, 018, 024, WRT00001, -BT, 0, 2008101915, 06, BEST, 0, 366N, 742W, 085, 0987, TC, 0, , 0, 0, 0, 0, 1005, 250, 31, , , L, , WRT, 019, 024, WRT00001, -BT, 0, 2008101916, 06, BEST, 0, 370N, 744W, 084, 0988, TC, 0, , 0, 0, 0, 0, 1005, 250, 32, , , L, , WRT, 020, 024, WRT00001, -BT, 0, 2008101917, 06, BEST, 0, 374N, 745W, 083, 0989, TC, 0, , 0, 0, 0, 0, 1005, 250, 33, , , L, , WRT, 020, 025, WRT00001, -BT, 0, 2008101918, 06, BEST, 0, 378N, 747W, 081, 0990, TC, 0, , 0, 0, 0, 0, 1005, 250, 34, , , L, , WRT, 019, 025, WRT00001, -BT, 0, 2008101919, 06, BEST, 0, 382N, 748W, 079, 0990, TC, 0, , 0, 0, 0, 0, 1005, 250, 35, , , L, , WRT, 018, 025, WRT00001, -BT, 0, 2008101920, 06, BEST, 0, 386N, 749W, 077, 0991, TC, 0, , 0, 0, 0, 0, 1005, 250, 36, , , L, , WRT, 017, 026, WRT00001, -BT, 0, 2008101921, 06, BEST, 0, 390N, 751W, 074, 0993, TC, 0, , 0, 0, 0, 0, 1005, 250, 38, , , L, , WRT, 016, 025, WRT00001, -BT, 0, 2008101922, 06, BEST, 0, 394N, 752W, 071, 0994, TC, 0, , 0, 0, 0, 0, 1005, 250, 40, , , L, , WRT, 014, 025, WRT00001, -BT, 0, 2008101923, 06, BEST, 0, 398N, 753W, 068, 0996, TC, 0, , 0, 0, 0, 0, 1005, 250, 43, , , L, , WRT, 013, 025, WRT00001, -BT, 0, 2008102000, 06, BEST, 0, 403N, 754W, 064, 0997, TC, 0, , 0, 0, 0, 0, 1005, 250, 46, , , L, , WRT, 012, 024, WRT00001, -BT, 0, 2008102001, 06, BEST, 0, 407N, 755W, 061, 0998, TC, 0, , 0, 0, 0, 0, 1005, 250, 41, , , L, , WRT, 010, 024, WRT00001, -BT, 0, 2008102002, 06, BEST, 0, 411N, 755W, 058, 0998, TC, 0, , 0, 0, 0, 0, 1005, 250, 36, , , L, , WRT, 010, 023, WRT00001, -BT, 0, 2008102003, 06, BEST, 0, 414N, 756W, 054, 0999, TC, 0, , 0, 0, 0, 0, 1005, 250, 39, , , L, , WRT, 010, 022, WRT00001, -BT, 0, 2008102004, 06, BEST, 0, 418N, 757W, 050, 1001, TC, 0, , 0, 0, 0, 0, 1005, 250, 41, , , L, , WRT, 010, 022, WRT00001, -BT, 0, 2008102005, 06, BEST, 0, 422N, 757W, 047, 1001, TC, 0, , 0, 0, 0, 0, 1005, 250, 44, , , L, , WRT, 010, 021, WRT00001, -BT, 0, 2008102006, 06, BEST, 0, 425N, 758W, 044, 1002, TC, 0, , 0, 0, 0, 0, 1005, 250, 47, , , L, , WRT, 011, 020, WRT00001, -BT, 0, 2008102007, 06, BEST, 0, 429N, 758W, 042, 1003, TC, 0, , 0, 0, 0, 0, 1005, 250, 49, , , L, , WRT, 012, 020, WRT00001, -BT, 0, 2008102008, 06, BEST, 0, 432N, 759W, 040, 1003, TC, 0, , 0, 0, 0, 0, 1005, 250, 52, , , L, , WRT, 015, 019, WRT00001, -BT, 0, 2008102009, 06, BEST, 0, 435N, 760W, 038, 1004, TC, 0, , 0, 0, 0, 0, 1005, 250, 44, , , L, , WRT, 019, 019, WRT00001, -BT, 0, 2008102010, 06, BEST, 0, 438N, 761W, 037, 1004, TC, 0, , 0, 0, 0, 0, 1005, 250, 36, , , L, , WRT, 022, 019, WRT00001, -BT, 0, 2008102011, 06, BEST, 0, 441N, 762W, 036, 1004, TC, 0, , 0, 0, 0, 0, 1005, 250, 37, , , L, , WRT, 026, 018, WRT00001, -BT, 0, 2008102012, 06, BEST, 0, 444N, 764W, 036, 1004, TC, 0, , 0, 0, 0, 0, 1005, 250, 38, , , L, , WRT, 030, 018, WRT00001, -BT, 0, 2008102013, 06, BEST, 0, 447N, 765W, 035, 1005, TC, 0, , 0, 0, 0, 0, 1005, 250, 39, , , L, , WRT, 035, 018, WRT00001, -BT, 0, 2008102014, 06, BEST, 0, 450N, 767W, 035, 1005, TC, 0, , 0, 0, 0, 0, 1005, 250, 40, , , L, , WRT, 039, 018, WRT00001, -BT, 0, 2008102015, 06, BEST, 0, 452N, 769W, 034, 1005, TC, 0, , 0, 0, 0, 0, 1005, 250, 41, , , L, , WRT, 044, 018, WRT00001, -BT, 0, 2008102016, 06, BEST, 0, 455N, 772W, 034, 1005, TC, 0, , 0, 0, 0, 0, 1005, 250, 42, , , L, , WRT, 048, 017, WRT00001, -BT, 0, 2008102017, 06, BEST, 0, 457N, 774W, 034, 1006, TC, 0, , 0, 0, 0, 0, 1005, 250, 43, , , L, , WRT, 052, 017, WRT00001, -BT, 0, 2008102018, 06, BEST, 0, 459N, 777W, 034, 1006, TC, 0, , 0, 0, 0, 0, 1005, 250, 44, , , L, , WRT, 056, 017, WRT00001, -BT, 0, 2008102019, 06, BEST, 0, 461N, 780W, 033, 1006, TC, 0, , 0, 0, 0, 0, 1005, 250, 45, , , L, , WRT, 060, 017, WRT00001, -BT, 0, 2008102020, 06, BEST, 0, 463N, 783W, 033, 1006, TC, 0, , 0, 0, 0, 0, 1005, 250, 46, , , L, , WRT, 060, 017, WRT00001, diff --git a/tests/data/reference/scratch_3.py b/tests/data/reference/scratch_3.py new file mode 100644 index 0000000..e08456c --- /dev/null +++ b/tests/data/reference/scratch_3.py @@ -0,0 +1,18 @@ +import math + + +def num_polynomials(dimensions: int, order: int) -> int: + return ( + int( + math.factorial(dimensions + order) + / (math.factorial(dimensions) * math.factorial(order)) + ) + - 1 + ) + + +if __name__ == '__main__': + print(num_polynomials(4, 3)) + print(10 * num_polynomials(4, 3)) + + print('done') diff --git a/tests/data/reference/test_from_atcf/florence2018_fort.22 b/tests/data/reference/test_from_atcf/fort.22 similarity index 100% rename from tests/data/reference/test_from_atcf/florence2018_fort.22 rename to tests/data/reference/test_from_atcf/fort.22 diff --git a/tests/test_atcf.py b/tests/test_atcf.py index 9ff65a8..5b2f7db 100644 --- a/tests/test_atcf.py +++ b/tests/test_atcf.py @@ -14,9 +14,9 @@ def test_atcf_url(): def test_atcf_storm_ids(): - a_realtime = atcf_files(file_deck=ATCF_FileDeck.a, mode=ATCF_Mode.realtime) + a_realtime = atcf_files(file_deck=ATCF_FileDeck.ADVISORY, mode=ATCF_Mode.realtime) abf_realtime = atcf_files(mode=ATCF_Mode.realtime) - a_2014_2015 = atcf_files(file_deck=ATCF_FileDeck.a, year=range(2014, 2015)) + a_2014_2015 = atcf_files(file_deck=ATCF_FileDeck.ADVISORY, year=range(2014, 2015)) abf_2014_2015 = atcf_files(year=range(2014, 2015)) assert len(a_realtime) == 67 diff --git a/tests/test_coops.py b/tests/test_coops.py index 957093b..c26547a 100644 --- a/tests/test_coops.py +++ b/tests/test_coops.py @@ -4,7 +4,7 @@ from stormevents import VortexTrack from stormevents.coops.tidalstations import ( - coops_data_within_region, + coops_product_within_region, COOPS_Station, coops_stations, coops_stations_within_region, @@ -31,7 +31,7 @@ def test_coops_data_within_region(): track = VortexTrack('florence2018', file_deck='b') combined_wind_swaths = ops.unary_union(list(track.wind_swaths(34).values())) - data = coops_data_within_region( + data = coops_product_within_region( region=combined_wind_swaths, start_date=datetime.now() - timedelta(hours=1), end_date=datetime.now(), diff --git a/tests/test_nhc.py b/tests/test_nhc.py index 086f142..2f59180 100644 --- a/tests/test_nhc.py +++ b/tests/test_nhc.py @@ -124,12 +124,12 @@ def test_from_atcf(): if not output_directory.exists(): output_directory.mkdir(parents=True, exist_ok=True) - vortex = VortexTrack.from_atcf_file(atcf=input_directory / 'florence2018_atcf.trk',) + vortex = VortexTrack.from_atcf_file(atcf=input_directory / 'atcf.trk',) assert vortex.nhc_code == 'BT02008' assert vortex.name == 'WRT00001' - vortex.write(output_directory / 'florence2018_fort.22', overwrite=True) + vortex.write(output_directory / 'fort.22', overwrite=True) check_reference_directory(output_directory, reference_directory) diff --git a/tests/test_stormevent.py b/tests/test_stormevent.py index 82c6fef..d840c91 100644 --- a/tests/test_stormevent.py +++ b/tests/test_stormevent.py @@ -138,11 +138,11 @@ def test_high_water_marks(florence2018): def test_tidal_data_within_isotach(florence2018): - null_data = florence2018.tidal_data_within_isotach( + null_data = florence2018.coops_product_within_isotach( wind_speed=34, end_date=florence2018.start_date + timedelta(minutes=1), ) - tidal_data = florence2018.tidal_data_within_isotach( + tidal_data = florence2018.coops_product_within_isotach( wind_speed=34, start_date=datetime(2018, 9, 13), end_date=datetime(2018, 9, 14), @@ -158,7 +158,7 @@ def test_tidal_data_within_isotach(florence2018): def test_tidal_data_within_region(florence2018): null_track = florence2018.track(end_date=florence2018.start_date + timedelta(hours=12)) - null_data = florence2018.tidal_data_within_region( + null_data = florence2018.coops_product_within_region( region=box(*null_track.linestring.bounds), end_date=null_track.end_date, ) @@ -168,7 +168,7 @@ def test_tidal_data_within_region(florence2018): file_deck='a', record_type='OFCL', ) - tidal_data = florence2018.tidal_data_within_region( + tidal_data = florence2018.coops_product_within_region( region=box(*track.linestring.bounds), start_date=track.start_date, end_date=track.end_date,