physoce-datasets 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/.gitignore +1 -0
- physoce_datasets-0.3.0/LICENSE +21 -0
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/PKG-INFO +21 -28
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/README.md +17 -27
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/pyproject.toml +2 -0
- physoce_datasets-0.3.0/src/physoce_datasets/cli.py +286 -0
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/src/physoce_datasets/download/__init__.py +2 -1
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/src/physoce_datasets/download/_base.py +15 -8
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/src/physoce_datasets/download/eke.py +75 -88
- physoce_datasets-0.3.0/src/physoce_datasets/download/ooi.py +735 -0
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/src/physoce_datasets/download/sst.py +5 -3
- physoce_datasets-0.3.0/src/physoce_datasets/download/wind_stress.py +362 -0
- physoce_datasets-0.3.0/src/physoce_datasets/util.py +407 -0
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/uv.lock +20 -0
- physoce_datasets-0.2.0/src/physoce_datasets/cli.py +0 -163
- physoce_datasets-0.2.0/src/physoce_datasets/download/wind_stress.py +0 -930
- physoce_datasets-0.2.0/src/physoce_datasets/util.py +0 -90
- physoce_datasets-0.2.0/test.ipynb +0 -793
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/.github/workflows/build-publish.yaml +0 -0
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/.pre-commit-config.yaml +0 -0
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/.python-version +0 -0
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/src/physoce_datasets/__init__.py +0 -0
- {physoce_datasets-0.2.0 → physoce_datasets-0.3.0}/src/physoce_datasets/logging.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrew Scherer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: physoce-datasets
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A Python package and CLI for downloading various physical oceanographic datasets.
|
|
5
|
+
License-File: LICENSE
|
|
5
6
|
Requires-Python: >=3.12
|
|
7
|
+
Requires-Dist: beautifulsoup4>=4.14.3
|
|
6
8
|
Requires-Dist: cdsapi>=0.7.7
|
|
7
9
|
Requires-Dist: cfgrib>=0.9.15.1
|
|
8
10
|
Requires-Dist: click>=8.2.1
|
|
@@ -10,6 +12,7 @@ Requires-Dist: copernicusmarine>=2.3.0
|
|
|
10
12
|
Requires-Dist: earthaccess>=0.18.0
|
|
11
13
|
Requires-Dist: ecmwf-datastores-client>=0.5.1
|
|
12
14
|
Requires-Dist: gcsfs>=2026.3.0
|
|
15
|
+
Requires-Dist: gsw>=3.6.21
|
|
13
16
|
Requires-Dist: h5py>=3.16.0
|
|
14
17
|
Requires-Dist: harmony-py>=1.3.4
|
|
15
18
|
Requires-Dist: ipykernel>=7.2.0
|
|
@@ -24,7 +27,19 @@ Description-Content-Type: text/markdown
|
|
|
24
27
|
|
|
25
28
|
A Python package and command line interface aimed at standardizing the access of various oceanographic datasets and calculating derived parameters according to modern best practices.
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
> [!WARNING]
|
|
31
|
+
> Due to issues with the [NASA Harmony API](https://forum.earthdata.nasa.gov/viewtopic.php?t=7954&sid=bdeec61e589c16e9d8642040d2fb01ff), the SST dataset is currently unavailable with an unknown fix timeline. Running any of the `sst` commands will fail with a `NotImplementedError` until this is fixed.
|
|
32
|
+
|
|
33
|
+
## Why physoce-datasets?
|
|
34
|
+
|
|
35
|
+
This package provides an *opinionated* interface which aims to simplify and align access to datasets across providing institutions (NASA, ECMWF, etc.); as such, it is aimed primarily at those looking for streamlined data access. If you are an expert user who wants a lot of control over the details of the download and analysis process, this may not be for you. However, if you want:
|
|
36
|
+
|
|
37
|
+
- a unified command line and Python interface across datasets
|
|
38
|
+
- expert-informed derived variables such as wind stress and eddy kinetic energy
|
|
39
|
+
- long time series at a single or a few locations
|
|
40
|
+
- the simplest downloading and opening process possible
|
|
41
|
+
|
|
42
|
+
then this package is designed for you!
|
|
28
43
|
|
|
29
44
|
## Install
|
|
30
45
|
|
|
@@ -88,7 +103,7 @@ python physoce-datasets --help
|
|
|
88
103
|
Available commands:
|
|
89
104
|
|
|
90
105
|
- `eke`: Download altimetry-derived geostrophic velocities and compute eddy kinetic energy from Copernicus Marine Services.
|
|
91
|
-
- `wind-stress`: Download ERA5 wind velocities and compute wind stress using the [COARE 3.5 algorithm](https://github.com/pyCOARE/coare).
|
|
106
|
+
- `wind-stress`: Download ERA5 wind velocities and compute wind stress using the [COARE 3.5 algorithm](https://github.com/pyCOARE/coare).
|
|
92
107
|
- `sst`: Download NASA Multi-scale Ultra-high Resolution (MUR) sea surface temperature.
|
|
93
108
|
|
|
94
109
|
Show command help:
|
|
@@ -101,11 +116,11 @@ uv run physoce-datasets eke --help
|
|
|
101
116
|
|
|
102
117
|
All commands share the same base options:
|
|
103
118
|
|
|
119
|
+
- `--location`: Location for the dataset in the format 'lon,lat' (e.g., '-132.0,36.55'). **Required for all commands!**
|
|
104
120
|
- `--save-dir`: Directory where the dataset file is written. If not set, defaults to `.data/`, relative to the current working directory.
|
|
105
121
|
- `--save-file`: File name to save the dataset. If not set, a default file name based on the data to be downloaded will be used.
|
|
106
122
|
- `--start-date`: Start date in `YYYY-MM-DD` format. If not set, uses `2000-01-01`, or the earliest available date, whichever is later.
|
|
107
123
|
- `--end-date`: End date in `YYYY-MM-DD` format. If not set, uses the current date or the latest available date, whicher is earlier.
|
|
108
|
-
- `--area`: Area string with the format `lon_min,lon_max,lat_min,lat_max` (note commas and no spaces). If not set, defaults to global extent.
|
|
109
124
|
|
|
110
125
|
### Examples
|
|
111
126
|
|
|
@@ -132,9 +147,9 @@ from physoce_datasets import EKEDownloader
|
|
|
132
147
|
|
|
133
148
|
# initialize the downloader
|
|
134
149
|
eke_downloader = EKEDownloader(
|
|
150
|
+
location="-130,45",
|
|
135
151
|
start_date="2020-01-01",
|
|
136
|
-
end_date="2020-
|
|
137
|
-
area="-140,-120,30,50",
|
|
152
|
+
end_date="2020-12-31",
|
|
138
153
|
save_dir="data",
|
|
139
154
|
save_file="eke.nc",
|
|
140
155
|
)
|
|
@@ -157,28 +172,6 @@ import logging
|
|
|
157
172
|
logging.getLogger("physoce_datasets").setLevel(logging.WARNING)
|
|
158
173
|
```
|
|
159
174
|
|
|
160
|
-
Note that progress bars for downloads will still appear when they are available.
|
|
161
|
-
|
|
162
|
-
## Efficiency
|
|
163
|
-
|
|
164
|
-
This package aims to be as efficient as possible when downloading datasets, with the overall goal of sending the least amount of data over the network as possible.
|
|
165
|
-
|
|
166
|
-
One of the biggest opportunities for this optimization is in the updating of existing datasets. When requesting a download and either specifying a file name that already exists or using the default file name, each download script will determine what data you already have downloaded and only make requests for the *additional* data necessary to fulfill your request. This is currently only implemented temporally - if you want to expand a spatial subset, you will have to recreate a full request. If at any point you'd like to force a complete re-download and overwrite any existing data, simply delete or move the existing data files in the download folder and re-run the script.
|
|
167
|
-
|
|
168
|
-
In addition, as much processing as possible is put onto the data storage backends. For example, the NASA MUR SST dataset is re-chunked on the NASA servers and then only the requested subset is actually downloaded. The same is true for the Copernicus Marine EKE dataset. In other cases, this is not possible, such as the ECMWF wind stress data, since calculating wind stress requires the original hourly data. In order to not massively increase local storage, however, the wind stress calculation is done one month at a time, resampling to daily after it is completed for each dataset and removing the original data.
|
|
169
|
-
|
|
170
|
-
## Notes for ERA5 Downloads
|
|
171
|
-
|
|
172
|
-
ERA5 data is accesed through the [Copernicus Climate Data Store (CDS)](https://cds.climate.copernicus.eu). Accessing data through this interface comes with several constraints on request size and numbers which have to be managed when downloading data from the CDS.
|
|
173
|
-
|
|
174
|
-
Notably, each user must submit "jobs" which are then processed one-by-one by the CDS backend. Each job has a maximum size based on the number of variables and areas. We require the original hourly data for calculating the wind stress (due to the non-linearity of the wind stress algorithm), which CDS recommends requesting no more than one month per job.
|
|
175
|
-
|
|
176
|
-
In addition to per-request limits, I found that CDS will pre-cancel any job if more than ~100 are submitted per account at any given time. Therefore, this package manually delays the submission of jobs past the 100 job cap to prevent arbitrary cancellations. This submission process can take some time for large subsets.
|
|
177
|
-
|
|
178
|
-
Since the submission and completion of jobs can take quite some time on the CDS backend, I wrote this package such that the user can exit the wind-stress program at any time and resume from where they left off. This is done by creating a "state file" (often `submitted_requests.json`) that is saved in the download directory. DO NOT DELETE THIS FILE!
|
|
179
|
-
|
|
180
|
-
One should keep these limits in mind as they are requesting wind stress data. I wrote this package to manage as much of this as possible in the code, but if you run into issues it might be due to the CDS backend (i.e., not an issue in this code). If you run into issues, take a look at your [existing CDS requests](https://cds.climate.copernicus.eu/requests?tab=all) and see if there are reasons given for any cancellations.
|
|
181
|
-
|
|
182
175
|
## Contributions
|
|
183
176
|
|
|
184
177
|
Do you have a publicly available dataset that you've got a great download script for? Do you have specialist knowledge required for calculating derived data products? Please consider [opening an issue](https://github.com/andrew-s28/physoce-datasets/issues) or [submitting a pull request](https://github.com/andrew-s28/physoce-datasets/pulls)! We welcome any and all contributions to this project.
|
|
@@ -2,7 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
A Python package and command line interface aimed at standardizing the access of various oceanographic datasets and calculating derived parameters according to modern best practices.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> Due to issues with the [NASA Harmony API](https://forum.earthdata.nasa.gov/viewtopic.php?t=7954&sid=bdeec61e589c16e9d8642040d2fb01ff), the SST dataset is currently unavailable with an unknown fix timeline. Running any of the `sst` commands will fail with a `NotImplementedError` until this is fixed.
|
|
7
|
+
|
|
8
|
+
## Why physoce-datasets?
|
|
9
|
+
|
|
10
|
+
This package provides an *opinionated* interface which aims to simplify and align access to datasets across providing institutions (NASA, ECMWF, etc.); as such, it is aimed primarily at those looking for streamlined data access. If you are an expert user who wants a lot of control over the details of the download and analysis process, this may not be for you. However, if you want:
|
|
11
|
+
|
|
12
|
+
- a unified command line and Python interface across datasets
|
|
13
|
+
- expert-informed derived variables such as wind stress and eddy kinetic energy
|
|
14
|
+
- long time series at a single or a few locations
|
|
15
|
+
- the simplest downloading and opening process possible
|
|
16
|
+
|
|
17
|
+
then this package is designed for you!
|
|
6
18
|
|
|
7
19
|
## Install
|
|
8
20
|
|
|
@@ -66,7 +78,7 @@ python physoce-datasets --help
|
|
|
66
78
|
Available commands:
|
|
67
79
|
|
|
68
80
|
- `eke`: Download altimetry-derived geostrophic velocities and compute eddy kinetic energy from Copernicus Marine Services.
|
|
69
|
-
- `wind-stress`: Download ERA5 wind velocities and compute wind stress using the [COARE 3.5 algorithm](https://github.com/pyCOARE/coare).
|
|
81
|
+
- `wind-stress`: Download ERA5 wind velocities and compute wind stress using the [COARE 3.5 algorithm](https://github.com/pyCOARE/coare).
|
|
70
82
|
- `sst`: Download NASA Multi-scale Ultra-high Resolution (MUR) sea surface temperature.
|
|
71
83
|
|
|
72
84
|
Show command help:
|
|
@@ -79,11 +91,11 @@ uv run physoce-datasets eke --help
|
|
|
79
91
|
|
|
80
92
|
All commands share the same base options:
|
|
81
93
|
|
|
94
|
+
- `--location`: Location for the dataset in the format 'lon,lat' (e.g., '-132.0,36.55'). **Required for all commands!**
|
|
82
95
|
- `--save-dir`: Directory where the dataset file is written. If not set, defaults to `.data/`, relative to the current working directory.
|
|
83
96
|
- `--save-file`: File name to save the dataset. If not set, a default file name based on the data to be downloaded will be used.
|
|
84
97
|
- `--start-date`: Start date in `YYYY-MM-DD` format. If not set, uses `2000-01-01`, or the earliest available date, whichever is later.
|
|
85
98
|
- `--end-date`: End date in `YYYY-MM-DD` format. If not set, uses the current date or the latest available date, whicher is earlier.
|
|
86
|
-
- `--area`: Area string with the format `lon_min,lon_max,lat_min,lat_max` (note commas and no spaces). If not set, defaults to global extent.
|
|
87
99
|
|
|
88
100
|
### Examples
|
|
89
101
|
|
|
@@ -110,9 +122,9 @@ from physoce_datasets import EKEDownloader
|
|
|
110
122
|
|
|
111
123
|
# initialize the downloader
|
|
112
124
|
eke_downloader = EKEDownloader(
|
|
125
|
+
location="-130,45",
|
|
113
126
|
start_date="2020-01-01",
|
|
114
|
-
end_date="2020-
|
|
115
|
-
area="-140,-120,30,50",
|
|
127
|
+
end_date="2020-12-31",
|
|
116
128
|
save_dir="data",
|
|
117
129
|
save_file="eke.nc",
|
|
118
130
|
)
|
|
@@ -135,28 +147,6 @@ import logging
|
|
|
135
147
|
logging.getLogger("physoce_datasets").setLevel(logging.WARNING)
|
|
136
148
|
```
|
|
137
149
|
|
|
138
|
-
Note that progress bars for downloads will still appear when they are available.
|
|
139
|
-
|
|
140
|
-
## Efficiency
|
|
141
|
-
|
|
142
|
-
This package aims to be as efficient as possible when downloading datasets, with the overall goal of sending the least amount of data over the network as possible.
|
|
143
|
-
|
|
144
|
-
One of the biggest opportunities for this optimization is in the updating of existing datasets. When requesting a download and either specifying a file name that already exists or using the default file name, each download script will determine what data you already have downloaded and only make requests for the *additional* data necessary to fulfill your request. This is currently only implemented temporally - if you want to expand a spatial subset, you will have to recreate a full request. If at any point you'd like to force a complete re-download and overwrite any existing data, simply delete or move the existing data files in the download folder and re-run the script.
|
|
145
|
-
|
|
146
|
-
In addition, as much processing as possible is put onto the data storage backends. For example, the NASA MUR SST dataset is re-chunked on the NASA servers and then only the requested subset is actually downloaded. The same is true for the Copernicus Marine EKE dataset. In other cases, this is not possible, such as the ECMWF wind stress data, since calculating wind stress requires the original hourly data. In order to not massively increase local storage, however, the wind stress calculation is done one month at a time, resampling to daily after it is completed for each dataset and removing the original data.
|
|
147
|
-
|
|
148
|
-
## Notes for ERA5 Downloads
|
|
149
|
-
|
|
150
|
-
ERA5 data is accesed through the [Copernicus Climate Data Store (CDS)](https://cds.climate.copernicus.eu). Accessing data through this interface comes with several constraints on request size and numbers which have to be managed when downloading data from the CDS.
|
|
151
|
-
|
|
152
|
-
Notably, each user must submit "jobs" which are then processed one-by-one by the CDS backend. Each job has a maximum size based on the number of variables and areas. We require the original hourly data for calculating the wind stress (due to the non-linearity of the wind stress algorithm), which CDS recommends requesting no more than one month per job.
|
|
153
|
-
|
|
154
|
-
In addition to per-request limits, I found that CDS will pre-cancel any job if more than ~100 are submitted per account at any given time. Therefore, this package manually delays the submission of jobs past the 100 job cap to prevent arbitrary cancellations. This submission process can take some time for large subsets.
|
|
155
|
-
|
|
156
|
-
Since the submission and completion of jobs can take quite some time on the CDS backend, I wrote this package such that the user can exit the wind-stress program at any time and resume from where they left off. This is done by creating a "state file" (often `submitted_requests.json`) that is saved in the download directory. DO NOT DELETE THIS FILE!
|
|
157
|
-
|
|
158
|
-
One should keep these limits in mind as they are requesting wind stress data. I wrote this package to manage as much of this as possible in the code, but if you run into issues it might be due to the CDS backend (i.e., not an issue in this code). If you run into issues, take a look at your [existing CDS requests](https://cds.climate.copernicus.eu/requests?tab=all) and see if there are reasons given for any cancellations.
|
|
159
|
-
|
|
160
150
|
## Contributions
|
|
161
151
|
|
|
162
152
|
Do you have a publicly available dataset that you've got a great download script for? Do you have specialist knowledge required for calculating derived data products? Please consider [opening an issue](https://github.com/andrew-s28/physoce-datasets/issues) or [submitting a pull request](https://github.com/andrew-s28/physoce-datasets/pulls)! We welcome any and all contributions to this project.
|
|
@@ -5,6 +5,7 @@ description = "A Python package and CLI for downloading various physical oceanog
|
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
7
7
|
dependencies = [
|
|
8
|
+
"beautifulsoup4>=4.14.3",
|
|
8
9
|
"cdsapi>=0.7.7",
|
|
9
10
|
"cfgrib>=0.9.15.1",
|
|
10
11
|
"click>=8.2.1",
|
|
@@ -12,6 +13,7 @@ dependencies = [
|
|
|
12
13
|
"earthaccess>=0.18.0",
|
|
13
14
|
"ecmwf-datastores-client>=0.5.1",
|
|
14
15
|
"gcsfs>=2026.3.0",
|
|
16
|
+
"gsw>=3.6.21",
|
|
15
17
|
"h5py>=3.16.0",
|
|
16
18
|
"harmony-py>=1.3.4",
|
|
17
19
|
"ipykernel>=7.2.0",
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"""CLI commands for physoce_datasets."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from .download import EAMooringDownloader, EAProfilerDownloader, EKEDownloader, WindStressDownloader
|
|
8
|
+
|
|
9
|
+
save_dir_option = click.option(
|
|
10
|
+
"--save-dir",
|
|
11
|
+
type=str,
|
|
12
|
+
default=None,
|
|
13
|
+
help=(
|
|
14
|
+
"Directory to save the downloaded dataset. If not specified, defaults "
|
|
15
|
+
"to a 'data' directory in the current working directory."
|
|
16
|
+
),
|
|
17
|
+
)
|
|
18
|
+
save_file_option = click.option(
|
|
19
|
+
"--save-file",
|
|
20
|
+
type=str,
|
|
21
|
+
default=None,
|
|
22
|
+
help=(
|
|
23
|
+
"Filename to save the dataset. If not specified, defaults to a filename "
|
|
24
|
+
"based on the dataset name and date range (e.g., 'eke_2000-01-01_to_2020-12-31.nc')."
|
|
25
|
+
),
|
|
26
|
+
)
|
|
27
|
+
start_datetime_option = click.option(
|
|
28
|
+
"--start-date",
|
|
29
|
+
type=str,
|
|
30
|
+
default=None,
|
|
31
|
+
help=(
|
|
32
|
+
"Start datetime for the dataset. Format should be YYYY-MM-DD. If not "
|
|
33
|
+
"specified, defaults to the earliest available datetime for the dataset."
|
|
34
|
+
),
|
|
35
|
+
)
|
|
36
|
+
end_datetime_option = click.option(
|
|
37
|
+
"--end-date",
|
|
38
|
+
type=str,
|
|
39
|
+
default=None,
|
|
40
|
+
help=(
|
|
41
|
+
"End datetime for the dataset. Format should be YYYY-MM-DD. If not "
|
|
42
|
+
"specified, defaults to the latest available datetime for the dataset."
|
|
43
|
+
),
|
|
44
|
+
)
|
|
45
|
+
update_option = click.option(
|
|
46
|
+
"--update-file",
|
|
47
|
+
type=str,
|
|
48
|
+
default=None,
|
|
49
|
+
help=(
|
|
50
|
+
"Whether to update an existing dataset with new data. If specified, should be "
|
|
51
|
+
"the path to an existing netCDF file found in the directory specified by --save-dir (default './data')."
|
|
52
|
+
),
|
|
53
|
+
)
|
|
54
|
+
location_option = click.option(
|
|
55
|
+
"--location",
|
|
56
|
+
type=str,
|
|
57
|
+
required=True,
|
|
58
|
+
help=(
|
|
59
|
+
"Location for the dataset, either in the format 'lon,lat' (e.g., '132.0,36.55') for global datasets or as a site name (see sub-command documentation for available sites) for moored datasets. Required."
|
|
60
|
+
),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@click.group(invoke_without_command=True)
|
|
65
|
+
@click.pass_context
|
|
66
|
+
def cli(ctx: click.Context) -> None:
|
|
67
|
+
"""Command-line interface for downloading datasets."""
|
|
68
|
+
if ctx.invoked_subcommand is None:
|
|
69
|
+
click.echo("No subcommand specified. Use --help for more information.")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@cli.command(
|
|
73
|
+
"eke",
|
|
74
|
+
help="Download geostrophic velocities and compute eddy kinetic energy from Copernicus Marine Services.",
|
|
75
|
+
)
|
|
76
|
+
@location_option
|
|
77
|
+
@save_dir_option
|
|
78
|
+
@save_file_option
|
|
79
|
+
@start_datetime_option
|
|
80
|
+
@end_datetime_option
|
|
81
|
+
def _eke(
|
|
82
|
+
location: str,
|
|
83
|
+
save_dir: str | None,
|
|
84
|
+
save_file: str | None,
|
|
85
|
+
start_date: str | None,
|
|
86
|
+
end_date: str | None,
|
|
87
|
+
) -> None:
|
|
88
|
+
"""Download geostrophic velocities and compute eddy kinetic energy from Copernicus Marine Services.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
location (str): Location for the dataset in the format 'lon,lat' (e.g., '132.0,36.55').
|
|
92
|
+
save_dir (str | None): Directory to save the downloaded dataset. If not specified,
|
|
93
|
+
defaults to a "data" directory in the current working directory.
|
|
94
|
+
start_date (str | None): Start date for the dataset. Format should be YYYY-MM-DD.
|
|
95
|
+
If not specified, defaults to the earliest available date for the dataset.
|
|
96
|
+
end_date (str | None): End date for the dataset. Format should be YYYY-MM-DD.
|
|
97
|
+
If not specified, defaults to the latest available date for the dataset.
|
|
98
|
+
save_file (str | None): Filename to save the dataset. If not specified, defaults to a filename
|
|
99
|
+
based on the dataset name and date range (e.g., "eke_2000-01-01_to_2020-12-31.nc").
|
|
100
|
+
|
|
101
|
+
"""
|
|
102
|
+
downloader = EKEDownloader(
|
|
103
|
+
location=location,
|
|
104
|
+
save_dir=save_dir,
|
|
105
|
+
start_date=start_date,
|
|
106
|
+
end_date=end_date,
|
|
107
|
+
save_file=save_file,
|
|
108
|
+
)
|
|
109
|
+
downloader.download()
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@cli.command("sst", help="Download NASA MUR SST datasets.")
|
|
113
|
+
@location_option
|
|
114
|
+
@save_dir_option
|
|
115
|
+
@save_file_option
|
|
116
|
+
@start_datetime_option
|
|
117
|
+
@end_datetime_option
|
|
118
|
+
def _sst(
|
|
119
|
+
location: str,
|
|
120
|
+
save_dir: str | None,
|
|
121
|
+
save_file: str | None,
|
|
122
|
+
start_date: str | None,
|
|
123
|
+
end_date: str | None,
|
|
124
|
+
) -> None:
|
|
125
|
+
"""Download NASA MUR SST datasets.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
location (str): Location for the dataset in the format 'lon,lat' (e.g., '132.0,36.55').
|
|
129
|
+
save_dir (str | None): Directory to save the downloaded dataset. If not specified,
|
|
130
|
+
defaults to a "data" directory in the current working directory.
|
|
131
|
+
start_date (str | None): Start date for the dataset. Format should be YYYY-MM-DD.
|
|
132
|
+
If not specified, defaults to the earliest available date for the dataset.
|
|
133
|
+
end_date (str | None): End date for the dataset. Format should be YYYY-MM-DD.
|
|
134
|
+
If not specified, defaults to the latest available date for the dataset.
|
|
135
|
+
save_file (str | None): Filename to save the dataset. If not specified, defaults to a filename
|
|
136
|
+
based on the dataset name and date range (e.g., "eke_2000-01-01_to_2020-12-31.nc").
|
|
137
|
+
|
|
138
|
+
"""
|
|
139
|
+
msg = "The 'sst' command is not implemented yet due to issues with the NASA Harmony API."
|
|
140
|
+
raise NotImplementedError(msg)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@cli.command("wind-stress", help="Download wind velocity and compute wind stress from ERA5.")
|
|
144
|
+
@location_option
|
|
145
|
+
@save_dir_option
|
|
146
|
+
@save_file_option
|
|
147
|
+
@start_datetime_option
|
|
148
|
+
@end_datetime_option
|
|
149
|
+
def _wind_stress(
|
|
150
|
+
location: str,
|
|
151
|
+
save_dir: str | None,
|
|
152
|
+
save_file: str | None,
|
|
153
|
+
start_date: str | None,
|
|
154
|
+
end_date: str | None,
|
|
155
|
+
) -> None:
|
|
156
|
+
"""Download wind velocity and compute wind stress from ERA5.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
location (str): Location for the dataset in the format 'lon,lat' (e.g., '132.0,36.55').
|
|
160
|
+
save_dir (str | None): Directory to save the downloaded dataset. If not specified,
|
|
161
|
+
defaults to a "data" directory in the current working directory.
|
|
162
|
+
start_date (str | None): Start date for the dataset. Format should be YYYY-MM-DD.
|
|
163
|
+
If not specified, defaults to the earliest available date for the dataset.
|
|
164
|
+
end_date (str | None): End date for the dataset. Format should be YYYY-MM-DD.
|
|
165
|
+
If not specified, defaults to the latest available date for the dataset.
|
|
166
|
+
save_file (str | None): Filename to save the dataset. If not specified, defaults to a filename
|
|
167
|
+
based on the dataset name and date range (e.g., "eke_2000-01-01_to_2020-12-31.nc").
|
|
168
|
+
|
|
169
|
+
"""
|
|
170
|
+
downloader = WindStressDownloader(
|
|
171
|
+
location=location,
|
|
172
|
+
save_dir=save_dir,
|
|
173
|
+
save_file=save_file,
|
|
174
|
+
start_date=start_date,
|
|
175
|
+
end_date=end_date,
|
|
176
|
+
)
|
|
177
|
+
downloader.download()
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@cli.command(
|
|
181
|
+
"ooi-ea-mooring",
|
|
182
|
+
help="""
|
|
183
|
+
Download moored OOI Endurance Array temperature, salinity, and density datasets.
|
|
184
|
+
|
|
185
|
+
Available sites for the --location argument include (case insensitive):\n
|
|
186
|
+
\t- 'CE01ISSM' (Oregon Inshore)\n
|
|
187
|
+
\t- 'CE02SHSM' (Oregon Shelf)\n
|
|
188
|
+
\t- 'CE04OSSM' (Oregon Offshore)\n
|
|
189
|
+
\t- 'CE06ISSM' (Washington Inshore)\n
|
|
190
|
+
\t- 'CE07SHSM' (Washington Shelf)\n
|
|
191
|
+
\t- 'CE09OSSM' (Washington Offshore)\n
|
|
192
|
+
|
|
193
|
+
Please see the OOI Endurance Array documentation for more information on these sites: https://oceanobservatories.org/array/coastal-endurance/.
|
|
194
|
+
""",
|
|
195
|
+
)
|
|
196
|
+
@location_option
|
|
197
|
+
@save_dir_option
|
|
198
|
+
@save_file_option
|
|
199
|
+
@start_datetime_option
|
|
200
|
+
@end_datetime_option
|
|
201
|
+
def _ooi_ea_mooring(
|
|
202
|
+
location: str,
|
|
203
|
+
save_dir: str | None,
|
|
204
|
+
save_file: str | None,
|
|
205
|
+
start_date: str | None,
|
|
206
|
+
end_date: str | None,
|
|
207
|
+
) -> None:
|
|
208
|
+
"""Download moored OOI Endurance Array temperature, salinity, and density datasets.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
location (str): Location for the dataset, either in the format 'lon,lat' (e.g., '132.0,36.55') for global datasets or as a site name (see sub-command documentation for available sites) for moored datasets.
|
|
212
|
+
save_dir (str | None): Directory to save the downloaded dataset. If not specified,
|
|
213
|
+
defaults to a "data" directory in the current working directory.
|
|
214
|
+
start_date (str | None): Start date for the dataset. Format should be YYYY-MM-DD.
|
|
215
|
+
If not specified, defaults to the earliest available date for the dataset.
|
|
216
|
+
end_date (str | None): End date for the dataset. Format should be YYYY-MM-DD.
|
|
217
|
+
If not specified, defaults to the latest available date for the dataset.
|
|
218
|
+
save_file (str | None): Filename to save the dataset. If not specified, defaults to a filename
|
|
219
|
+
based on the dataset name and date range (e.g., "ooi_ea_mooring_2000-01-01_to_2020-12-31.nc").
|
|
220
|
+
|
|
221
|
+
"""
|
|
222
|
+
downloader = EAMooringDownloader(
|
|
223
|
+
location=location,
|
|
224
|
+
save_dir=save_dir,
|
|
225
|
+
save_file=save_file,
|
|
226
|
+
start_date=start_date,
|
|
227
|
+
end_date=end_date,
|
|
228
|
+
)
|
|
229
|
+
downloader.download()
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
@cli.command(
|
|
233
|
+
"ooi-ea-profiler",
|
|
234
|
+
help="""
|
|
235
|
+
Download moored OOI Endurance Array temperature, salinity, and density datasets and calculate mixed layer depth and stratification.
|
|
236
|
+
|
|
237
|
+
Available sites for the --location argument include (case insensitive):\n
|
|
238
|
+
\t- 'CE01ISSP' (Oregon Inshore)\n
|
|
239
|
+
\t- 'CE02SHSP' (Oregon Shelf)\n
|
|
240
|
+
\t- 'CE04OSPS' (Oregon Offshore Shallow)\n
|
|
241
|
+
\t- 'CE04OSPD' (Oregon Offshore Deep)\n
|
|
242
|
+
\t- 'CE06ISSP' (Washington Inshore)\n
|
|
243
|
+
\t- 'CE07SHSP' (Washington Shelf)\n
|
|
244
|
+
\t- 'CE09OSPM' (Washington Offshore)\n
|
|
245
|
+
|
|
246
|
+
Please see the OOI Endurance Array documentation for more information on these sites: https://oceanobservatories.org/array/coastal-endurance/.
|
|
247
|
+
""",
|
|
248
|
+
)
|
|
249
|
+
@location_option
|
|
250
|
+
@save_dir_option
|
|
251
|
+
@save_file_option
|
|
252
|
+
@start_datetime_option
|
|
253
|
+
@end_datetime_option
|
|
254
|
+
def _ooi_ea_profiler(
|
|
255
|
+
location: str,
|
|
256
|
+
save_dir: str | None,
|
|
257
|
+
save_file: str | None,
|
|
258
|
+
start_date: str | None,
|
|
259
|
+
end_date: str | None,
|
|
260
|
+
) -> None:
|
|
261
|
+
"""Download moored OOI Endurance Array temperature, salinity, and density datasets and calculate mixed layer depth and stratification.
|
|
262
|
+
|
|
263
|
+
Args:
|
|
264
|
+
location (str): Location for the dataset, either in the format 'lon,lat' (e.g., '132.0,36.55') for global datasets or as a site name (see sub-command documentation for available sites) for moored datasets.
|
|
265
|
+
save_dir (str | None): Directory to save the downloaded dataset. If not specified,
|
|
266
|
+
defaults to a "data" directory in the current working directory.
|
|
267
|
+
start_date (str | None): Start date for the dataset. Format should be YYYY-MM-DD.
|
|
268
|
+
If not specified, defaults to the earliest available date for the dataset.
|
|
269
|
+
end_date (str | None): End date for the dataset. Format should be YYYY-MM-DD.
|
|
270
|
+
If not specified, defaults to the latest available date for the dataset.
|
|
271
|
+
save_file (str | None): Filename to save the dataset. If not specified, defaults to a filename
|
|
272
|
+
based on the dataset name and date range (e.g., "ooi_ea_profiler_2000-01-01_to_2020-12-31.nc").
|
|
273
|
+
|
|
274
|
+
"""
|
|
275
|
+
downloader = EAProfilerDownloader(
|
|
276
|
+
location=location,
|
|
277
|
+
save_dir=save_dir,
|
|
278
|
+
save_file=save_file,
|
|
279
|
+
start_date=start_date,
|
|
280
|
+
end_date=end_date,
|
|
281
|
+
)
|
|
282
|
+
downloader.download()
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
if __name__ == "__main__":
|
|
286
|
+
cli()
|
|
@@ -5,7 +5,8 @@ appropriate metadata.
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
from .eke import EKEDownloader
|
|
8
|
+
from .ooi import EAMooringDownloader, EAProfilerDownloader
|
|
8
9
|
from .sst import SSTDownloader
|
|
9
10
|
from .wind_stress import WindStressDownloader
|
|
10
11
|
|
|
11
|
-
__all__ = ["EKEDownloader", "SSTDownloader", "WindStressDownloader"]
|
|
12
|
+
__all__ = ["EAMooringDownloader", "EAProfilerDownloader", "EKEDownloader", "SSTDownloader", "WindStressDownloader"]
|
|
@@ -5,7 +5,7 @@ from pathlib import Path
|
|
|
5
5
|
|
|
6
6
|
import xarray as xr
|
|
7
7
|
|
|
8
|
-
from physoce_datasets.util import
|
|
8
|
+
from physoce_datasets.util import parse_location_or_site
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class _Downloader(ABC):
|
|
@@ -13,20 +13,24 @@ class _Downloader(ABC):
|
|
|
13
13
|
|
|
14
14
|
def __init__(
|
|
15
15
|
self,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
location: str,
|
|
17
|
+
location_type: str,
|
|
18
|
+
save_file_prefix: str,
|
|
19
19
|
save_dir: str | None = None,
|
|
20
20
|
save_file: str | None = None,
|
|
21
|
+
start_date: str | None = None,
|
|
22
|
+
end_date: str | None = None,
|
|
21
23
|
) -> None:
|
|
22
24
|
"""Initialize the downloader.
|
|
23
25
|
|
|
24
26
|
Args:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
location (str): Location for the dataset in the format 'lon,lat' (e.g., '132.0,36.55'). Required.
|
|
28
|
+
location_type (str): The type of the location, either 'lonlat' or 'site'. Used to determine how to parse the location string.
|
|
29
|
+
save_file_prefix (str): A prefix to add to the saved file name.
|
|
28
30
|
save_dir (str | None): The directory to save the downloaded dataset. If None, defaults to a "data" directory in the current working directory.
|
|
29
31
|
save_file (str | None): The file name to save the downloaded dataset. If None, defaults to a name based on the dataset and date range.
|
|
32
|
+
start_date (str | None): The start date for the dataset in "YYYY-MM-DD" format. If None, defaults to "2000-01-01".
|
|
33
|
+
end_date (str | None): The end date for the dataset in "YYYY-MM-DD" format. If None, defaults to the current date.
|
|
30
34
|
|
|
31
35
|
"""
|
|
32
36
|
# handle default parameters
|
|
@@ -37,9 +41,12 @@ class _Downloader(ABC):
|
|
|
37
41
|
|
|
38
42
|
self.start_date = start_date
|
|
39
43
|
self.end_date = end_date
|
|
40
|
-
self.
|
|
44
|
+
self.location = parse_location_or_site(location, location_type)
|
|
41
45
|
self.save_dir = self._create_data_dir(save_dir)
|
|
46
|
+
if save_file is None:
|
|
47
|
+
save_file = f"{save_file_prefix}_{self.start_date}_{self.end_date}_{self.location.file_name}.nc"
|
|
42
48
|
self.save_file = save_file
|
|
49
|
+
self.save_file_path = self._create_save_file(self.save_dir, self.save_file)
|
|
43
50
|
self.downloaded = False
|
|
44
51
|
|
|
45
52
|
@staticmethod
|