|
1 | 1 | # pyo_oracle |
2 | | -## Python interface for the Bio-ORACLE ERDDAP server |
3 | 2 |
|
4 | | -### Quick start |
| 3 | +**Python client for the [Bio-ORACLE](https://bio-oracle.org/) ERDDAP server.** |
5 | 4 |
|
6 | | -```python |
7 | | -import pyo_oracle |
8 | | - |
9 | | -# List available layers in the Bio-ORACLE server |
10 | | -pyo_oracle.list_layers() |
11 | | - |
12 | | -# Define constraints and download a layer (the full layer is a large file) |
13 | | -constraints = { |
14 | | - "time>=": "2000-01-01T00:00:00Z", |
15 | | - "time<=": "2010-01-01T12:00:00Z", |
16 | | - "time_step": 100, |
17 | | - "latitude>=": 0, |
18 | | - "latitude<=": 10, |
19 | | - "latitude_step": 100, |
20 | | - "longitude>=": 0, |
21 | | - "longitude<=": 10, |
22 | | - "longitude_step": 1 |
23 | | -} |
24 | | -pyo_oracle.download_layers("thetao_baseline_2000_2019_depthsurf", constraints=constraints) |
25 | | - |
26 | | -# See local data |
27 | | -pyo_oracle.list_local_data() |
28 | | -``` |
| 5 | +Discover, inspect, subset, download, and load Bio-ORACLE marine environmental |
| 6 | +layers (temperature, salinity, nutrients, sea ice, and more) from Python. |
| 7 | +`pyo_oracle` is the Python counterpart of the R package |
| 8 | +[`biooracler`](https://github.com/bio-oracle/biooracler) and is built on |
| 9 | +[`erddapy`](https://github.com/ioos/erddapy). |
| 10 | + |
| 11 | +📖 **Documentation:** <https://bio-oracle.github.io/pyo_oracle/> |
29 | 12 |
|
30 | | -### Installation |
| 13 | +## Installation |
31 | 14 |
|
32 | 15 | ```bash |
| 16 | +# With pip |
| 17 | +pip install pyo-oracle |
| 18 | + |
| 19 | +# Load layers as xarray (optional extra) |
| 20 | +pip install "pyo-oracle[xarray]" |
| 21 | + |
33 | 22 | # With conda |
34 | 23 | conda create -n pyo_oracle conda-forge::pyo-oracle |
| 24 | +``` |
35 | 25 |
|
36 | | -# or with pip |
37 | | -pip install pyo-oracle |
| 26 | +## Quick start |
| 27 | + |
| 28 | +```python |
| 29 | +import pyo_oracle as pyo |
| 30 | + |
| 31 | +# 1. List available layers (filter by search term, variable, scenario, depth, ...) |
| 32 | +pyo.list_layers(search="Temperature") |
| 33 | + |
| 34 | +# 2. Inspect a layer: dimension ranges + variables and units |
| 35 | +pyo.info_layer("thetao_baseline_2000_2019_depthsurf") |
| 36 | + |
| 37 | +# 3. Build constraints from friendly bounds (no hand-written dicts) |
| 38 | +constraints = pyo.build_constraints( |
| 39 | + "thetao_baseline_2000_2019_depthsurf", |
| 40 | + time=("2000-01-01T00:00:00Z", "2010-01-01T00:00:00Z"), |
| 41 | + latitude=(0, 10), |
| 42 | + longitude=(0, 10), |
| 43 | +) |
| 44 | + |
| 45 | +# 4a. Load directly into memory (pandas or xarray) |
| 46 | +df = pyo.load_layer( |
| 47 | + "thetao_baseline_2000_2019_depthsurf", |
| 48 | + constraints=constraints, |
| 49 | + variables=["thetao_mean"], |
| 50 | +) |
| 51 | +ds = pyo.load_layer( |
| 52 | + "thetao_baseline_2000_2019_depthsurf", |
| 53 | + constraints=constraints, |
| 54 | + fmt="xarray", |
| 55 | +) |
| 56 | + |
| 57 | +# 4b. Or download to a file (NetCDF by default) |
| 58 | +pyo.download_layers( |
| 59 | + "thetao_baseline_2000_2019_depthsurf", |
| 60 | + constraints=constraints, |
| 61 | + variables=["thetao_mean"], |
| 62 | +) |
| 63 | + |
| 64 | +# 5. See local data |
| 65 | +pyo.list_local_data() |
38 | 66 | ``` |
39 | 67 |
|
40 | | -Please open an issue if you experience any problems. More documentation coming soon! |
| 68 | +## Key functions |
| 69 | + |
| 70 | +| Function | Purpose | |
| 71 | +|----------|---------| |
| 72 | +| `list_layers` | List/filter available layers | |
| 73 | +| `info_layer` | Inspect a layer's dimensions and variables | |
| 74 | +| `build_constraints` | Build griddap constraints from `(min, max)` bounds + strides | |
| 75 | +| `load_layer` | Load a layer into memory (`pandas` or `xarray`) | |
| 76 | +| `download_layers` | Download a layer (NetCDF/CSV), optionally a variable subset | |
| 77 | +| `list_local_data` | List downloaded files | |
| 78 | + |
| 79 | +## Contributing |
| 80 | + |
| 81 | +See [`CLAUDE.md`](CLAUDE.md) for the dev setup, testing, and release flow. |
| 82 | +Please open an issue if you experience any problems. |
0 commit comments