Skip to content

Commit

Permalink
Add new open functions with datatree
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Jan 14, 2025
1 parent 6241033 commit 81378eb
Show file tree
Hide file tree
Showing 15 changed files with 693 additions and 367 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ A GPM granule can be opened in python using:
```python
import gpm

ds = gpm.open_granule(<path_to_granule>)
ds = gpm.open_granule_dataset(<path_to_granule>)
# or
dt = gpm.open_granule_datatree(<path_to_granule>)

```

Expand Down
12 changes: 9 additions & 3 deletions docs/source/03_quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,17 @@ Open the data
Within the GPM-API, the name *granule* is used to refer to a single file,
while the name *dataset* is used to refer to a collection of granules.

GPM-API enables to open single or multiple granules into an ``xarray.Dataset``, an object designed for working with labeled multi-dimensional arrays.
GPM-API enables to open single or multiple granules into ``xarray.Dataset`` or ``xarray.DataTree`` objects,
which are designed for working with labeled multi-dimensional arrays.

The ``gpm.open_granule(filepath)`` opens a single file into xarray by providing the path of the file of interest.
The ``gpm.open_granule_dataset(filepath)`` opens a single file into a ``xarray.Dataset`` object
by providing the path of the file (granule) of interest. This function open a single sensor ``scan_mode``.

The ``gpm.open_dataset`` function enables to open a collection of granules over a period of interest.
The ``gpm.open_granule_datatree(filepath)`` opens a single file into a ``xarray.DataTree`` object
by providing the path of the file (granule) of interest. This function open all sensors ``scan_modes``.

The ``gpm.open_dataset`` and ``gpm.open_datatree`` functions enables to open a collection of granules
over a period of interest.

The following example shows how to download and open a dataset over a specific time period:

Expand Down
6 changes: 3 additions & 3 deletions gpm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
define_configs,
read_configs,
)
from gpm.dataset.dataset import open_dataset # noqa
from gpm.dataset.datatree import open_datatree # noqa
from gpm.dataset.granule import open_granule # noqa
from gpm.dataset.dataset import open_dataset, open_datatree # noqa
from gpm.dataset.datatree import open_raw_datatree # noqa
from gpm.dataset.granule import open_granule, open_granule_dataset, open_granule_datatree # noqa
from gpm.io.download import download_archive as download # noqa
from gpm.io.download import ( # noqa
download_daily_data,
Expand Down
6 changes: 6 additions & 0 deletions gpm/dataset/conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def finalize_dataset(ds, product, decode_cf, scan_mode, start_time=None, end_tim

from gpm import config

##------------------------------------------------------------------------.
# Retrieve closer
closer = ds._close

##------------------------------------------------------------------------.
# Clean out HDF5 attributes
# - CodeMissingValue --> _FillValue
Expand Down Expand Up @@ -235,4 +239,6 @@ def finalize_dataset(ds, product, decode_cf, scan_mode, start_time=None, end_tim
pass

###-----------------------------------------------------------------------.
# Reassign closer
ds.set_close(closer)
return ds
Loading

0 comments on commit 81378eb

Please sign in to comment.