Skip to content

Commit

Permalink
remove CO-OPS module (moved to searvey) (#41)
Browse files Browse the repository at this point in the history
* remove CO-OPS module (moved to `searvey`)

* fix tests

* add pre-commit hook

* change code linting to `black`

* update reference files

* retrieve `searvey` from PyPI

* constrain `searvey` requirement to be below future API changes

* fix tests

* update reference files
  • Loading branch information
zacharyburnett authored Jul 13, 2022
1 parent ef994b9 commit ce424f0
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 1,783 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: test

on:
push:
branches:
- 'main'
paths:
- '**.py'
- '.github/workflows/test*.yml'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: quick test

on:
push:
branches:
- 'main'
paths:
- '**.py'
- '.github/workflows/test*.yml'
Expand Down
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
python: "python3"
fail_fast: true
ci:
skip: ["poetry-lock", "prospector", "mypy"]
skip: [ "poetry-lock", "prospector", "mypy" ]

repos:
- repo: "https://github.com/pre-commit/pre-commit-hooks"
Expand All @@ -22,7 +22,9 @@ repos:
- id: "check-yaml"
- id: "debug-statements"
- id: "end-of-file-fixer"
exclude: .+\.ipynb
exclude: .+\.ipynb|tests/data/.+
- id: "trailing-whitespace"
exclude: .+\.ipynb|tests/data/.+

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
Expand Down
145 changes: 1 addition & 144 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![codecov](https://codecov.io/gh/oceanmodeling/StormEvents/branch/main/graph/badge.svg?token=BQWB1QKJ3Q)](https://codecov.io/gh/oceanmodeling/StormEvents)
[![version](https://img.shields.io/pypi/v/StormEvents)](https://pypi.org/project/StormEvents)
[![license](https://img.shields.io/github/license/oceanmodeling/StormEvents)](https://opensource.org/licenses/gpl-license)
[![style](https://github.com/psf/black)](https://img.shields.io/badge/code%20style-black-000000.svg)
[![style](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black)

`stormevents` provides Python interfaces for observational data surrounding named storm events.

Expand Down Expand Up @@ -246,149 +246,6 @@ hwm_id ...
[277 rows x 53 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 status removed geometry
nos_id
1600012 46125 QREB buoy active <NA> POINT (122.62500 37.75000)
1619910 SNDP5 Sand Island, Midway Islands active <NA> POINT (-177.37500 28.21875)
1630000 APRP7 Apra Harbor, Guam active <NA> POINT (144.62500 13.44531)
1631428 PGBP7 Pago Bay, Guam active <NA> POINT (144.75000 13.42969)
1770000 NSTP6 Pago Pago, American Samoa active <NA> POINT (-170.75000 -14.27344)
... ... ... ... ... ... ...
8423898 FTPN3 Fort Point NH discontinued 2020-04-13 00:00:00,2014-08-05 00:00:00,2012-0... POINT (-70.68750 43.06250)
8726667 MCYF1 Mckay Bay Entrance FL discontinued 2020-05-20 00:00:00,2019-03-08 00:00:00,2017-0... POINT (-82.43750 27.90625)
8772447 FCGT2 Freeport TX discontinued 2020-05-24 18:45:00,2018-10-10 21:50:00,2018-1... POINT (-95.31250 28.93750)
9087079 GBWW3 Green Bay WI discontinued 2020-10-28 13:00:00,2007-08-06 23:59:00,2007-0... POINT (-88.00000 44.53125)
8770570 SBPT2 Sabine Pass North TX discontinued 2021-01-18 00:00:00,2020-09-30 15:45:00,2020-0... POINT (-93.87500 29.73438)
[435 rows x 6 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 for a specific station

```python
from datetime import datetime
from stormevents.coops import COOPS_Station

station = COOPS_Station(8632200)
station.product('water_level', start_date=datetime(2018, 9, 13), end_date=datetime(2018, 9, 16, 12))
```

```
<xarray.Dataset>
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
nws_id (nos_id) <U5 'KPTV2'
x (nos_id) float64 -76.0
y (nos_id) float64 37.16
Data variables:
v (nos_id, t) float32 1.67 1.694 1.73 1.751 ... 1.597 1.607 1.605
s (nos_id, t) float32 0.026 0.027 0.034 0.03 ... 0.018 0.019 0.021
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' ... 'v' 'v' 'v' 'v' 'v'
```

##### 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),
)
```

```
<xarray.Dataset>
Dimensions: (nos_id: 10, t: 11)
Coordinates:
* nos_id (nos_id) int64 8651370 8652587 8654467 ... 8662245 8665530 8670870
* t (t) datetime64[ns] 2022-03-08T14:48:00 ... 2022-03-08T15:48:00
nws_id (nos_id) <U5 'DUKN7' 'ORIN7' 'HCGN7' ... 'NITS1' 'CHTS1' 'FPKG1'
x (nos_id) float64 -75.75 -75.56 -75.69 ... -79.19 -79.94 -80.88
y (nos_id) float64 36.19 35.78 35.22 34.72 ... 33.34 32.78 32.03
Data variables:
v (nos_id, t) float32 6.256 6.304 6.361 6.375 ... 2.633 2.659 2.686
s (nos_id, t) float32 0.107 0.097 0.127 0.122 ... 0.005 0.004 0.004
f (nos_id, t) object '1,0,0,0' '1,0,0,0' ... '1,0,0,0' '1,0,0,0'
q (nos_id, t) object 'p' 'p' 'p' 'p' 'p' 'p' ... 'p' 'p' 'p' 'p' 'p'
```

### retrieve data surrounding a specific storm

The `StormEvent` class provides an interface to retrieve data within the time interval and spatial bounds of a specific storm
Expand Down
57 changes: 0 additions & 57 deletions docs/source/coops.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
installation
nhc
usgs
coops
stormevent
389 changes: 0 additions & 389 deletions examples/example_2.ipynb

This file was deleted.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ build-backend = 'poetry.core.masonry.api'
enable = true

[tool.poetry.dependencies]
python = '^3.6'
python = '^3.9'
beautifulsoup4 = '*'
geopandas = '*'
netcdf4 = '*'
Expand All @@ -28,6 +28,7 @@ python-dateutil = '*'
pandas = '*'
pyproj = '>=2.6'
requests = '*'
searvey = '^0.2.0'
shapely = '>=1.8'
typepigeon = '>=1.0.5'
xarray = '*'
Expand All @@ -44,6 +45,7 @@ sphinx-rtd-theme = { version = '*', optional = true }
toml = { version = '*', optional = true }

[tool.poetry.extras]
linting = ["mypy", "prospector"]
testing = ['pytest', 'pytest-cov', 'pytest-socket', 'pytest-xdist']
development = ['isort', 'black']
documentation = ['dunamai', 'm2r2', 'sphinx', 'sphinx-rtd-theme', 'toml']
12 changes: 0 additions & 12 deletions stormevents/coops/__init__.py

This file was deleted.

Loading

0 comments on commit ce424f0

Please sign in to comment.