Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream GPM brightness temperature and precip with earthaccess #42

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d7f4623
Add earthaccess to Conda env
zmoon Dec 6, 2024
c87d311
Ignore cached HTTP info thing
zmoon Dec 6, 2024
47bbfe8
Initial MERGIR getter
zmoon Dec 6, 2024
a907fb5
Expose version; doc
zmoon Dec 6, 2024
cfac966
WIP: get IMERG
zmoon Dec 6, 2024
763a277
Specifying group we get data
zmoon Dec 6, 2024
87e99e2
doc
zmoon Dec 6, 2024
053b4bf
Show some query info if no results
zmoon Dec 10, 2024
83031b2
Late and early should work now
zmoon Dec 10, 2024
80fee63
Clean up IMERG ds
zmoon Dec 12, 2024
39eb274
Include ED CMR ShortName and Version in ds attrs
zmoon Dec 12, 2024
fcc7525
Expose mf parallel option
zmoon Dec 12, 2024
ac5723c
Note not full global coverage
zmoon Dec 13, 2024
af19c27
Return ds instead for MERGIR, with improved attrs
zmoon Dec 13, 2024
961e52f
Drop conflicting ds attrs when combining
zmoon Dec 13, 2024
7a727b2
Require passing version as kw
zmoon Dec 13, 2024
73de48a
Tweak docstrings
zmoon Dec 19, 2024
ac70871
Add a bit of example
zmoon Dec 19, 2024
b5fab97
Merge branch 'main' into earthdata
zmoon Dec 19, 2024
267dc55
Please mypy
zmoon Dec 19, 2024
2c3e36b
Increase cell timeout
zmoon Dec 19, 2024
78396ce
tmp disable nb raise
zmoon Dec 19, 2024
aa05d80
Check authenticated
zmoon Dec 20, 2024
9fab735
Revert RTD testing changes
zmoon Dec 20, 2024
2ce6b26
tmp disable nb raise
zmoon Dec 20, 2024
aea56df
Raise on error for other nbs
zmoon Dec 20, 2024
2649ef4
Support early/late IMERG version '06'
zmoon Dec 20, 2024
af428dc
Add test for get-imerg
zmoon Dec 20, 2024
0226327
Show pytest tests and summary in CI
zmoon Dec 20, 2024
15ace4a
Merge branch 'main' into earthdata
zmoon Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: python -c "from tams.data import download_examples; download_examples()"

- name: pytest
run: pytest test_tams.py
run: pytest -v -ra test_tams.py

- name: Run as script
run: python -m tams.core
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.ipynb_checkpoints
.dodsrc
Satellite_data.nc
MPAS_data.nc
MPAS_unstructured_data.nc
Expand Down
2 changes: 2 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Data
tams.data.download_examples
tams.data.load_example_ir
tams.data.tb_from_ir
tams.data.get_mergir
tams.data.get_imerg


Utilities
Expand Down
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"geopandas": ("https://geopandas.org/en/stable/", None),
"dask": ("https://docs.dask.org/en/latest/", None),
"shapely": ("https://shapely.readthedocs.io/en/stable/", None),
"earthaccess": ("https://earthaccess.readthedocs.io/en/stable/", None),
}

napoleon_google_docstring = False
Expand Down Expand Up @@ -77,6 +78,7 @@
"examples/tracking-options.ipynb",
]
nb_execution_raise_on_error = True
nb_execution_timeout = 90

myst_enable_extensions = [
"dollarmath",
Expand Down
142 changes: 142 additions & 0 deletions docs/examples/get.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "0",
"metadata": {},
"source": [
"# Stream input data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1",
"metadata": {},
"outputs": [],
"source": [
"import cartopy.crs as ccrs\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import tams"
]
},
{
"cell_type": "markdown",
"id": "2",
"metadata": {},
"source": [
"## GPM precipitation and brightness temperature\n",
"\n",
"With the help of [earthaccess](https://earthaccess.readthedocs.io/), we can stream these data without downloading the files to disk.\n",
"* {func}`tams.data.get_imerg`\n",
"* {func}`tams.data.get_mergir`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"pr = tams.data.get_imerg(\"2024-06-01 02:30\")[\"pr\"]\n",
"pr"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"tb = tams.data.get_mergir(pr.time.item())[\"tb\"]\n",
"tb"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"fig = plt.figure(figsize=(13, 5))\n",
"ax = fig.add_subplot(projection=ccrs.PlateCarree())\n",
"\n",
"ax.coastlines(color=\"magenta\")\n",
"\n",
"tb.plot(x=\"lon\", cmap=\"gist_gray_r\", robust=True, ax=ax)\n",
"pr.plot(x=\"lon\", norm=mpl.colors.LogNorm(0.01, pr.quantile(0.99)), alpha=0.85, ax=ax)"
]
},
{
"cell_type": "markdown",
"id": "6",
"metadata": {},
"source": [
"The white dots in the brightness temperature field above represent missing data.\n",
"For most CE identification methods, this will influence results.\n",
"Since they are mostly scattered points, not large regions,\n",
"a reasonable way to fill in the missing data is a nearest-neighbor interpolation."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"kws = dict(method=\"nearest\", fill_value=\"extrapolate\", assume_sorted=True)\n",
"tb_ = tb.interpolate_na(\"lat\", **kws).interpolate_na(\"lon\", **kws)\n",
"\n",
"print(f\"{tb.isnull().sum().item() / tb.size:.3%} -> {tb_.isnull().sum().item() / tb_.size:.3%} null\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8",
"metadata": {},
"outputs": [],
"source": [
"box = dict(lon=slice(-115, -80), lat=slice(-53, -20))\n",
"tb_.sel(**box).plot(cmap=\"gist_gray_r\", robust=True)\n",
"plt.gca().set_aspect(\"equal\", \"box\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
},
"mystnb": {
"execution_raise_on_error": false
}
},
"nbformat": 4,
"nbformat_minor": 5
}
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ examples/tams-run.ipynb
examples/tracking-options.ipynb
examples/sample-mpas-ug-data.ipynb
examples/identify.ipynb
examples/get.ipynb
```

```{toctree}
Expand Down
1 change: 1 addition & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
# Extras
- cartopy >=0.21
- dask-core
- earthaccess
- gdown
- joblib
- netcdf4
Expand Down
Loading
Loading