Skip to content

omps

OMPS Reader

OMPSReader

Bases: GriddedReader

Reader for OMPS (Ozone Mapping and Profiler Suite) data. Supports Level 2 (Nadir Mapper) and Level 3 daily products.

Source code in monetio/readers/omps.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@register_reader("omps")
class OMPSReader(GriddedReader):
    """
    Reader for OMPS (Ozone Mapping and Profiler Suite) data.
    Supports Level 2 (Nadir Mapper) and Level 3 daily products.
    """

    def open_dataset(
        self,
        files: str | list[str],
        product: str = "nmto3_l2",
        use_virtualizarr: bool = False,
        virtualizarr_file: str | None = None,
        virtualizarr_backend: str = "kerchunk",
        icechunk_repo: str | None = None,
        use_dask: bool = False,
        **kwargs,
    ) -> xr.Dataset:
        """
        Reads OMPS data.

        Parameters
        ----------
        files : Union[str, List[str]]
            File path(s) or URL(s).
        product : str, optional
            OMPS product: 'nmto3_l2' (default) or 'nmto3_l3'.
        use_virtualizarr : bool, optional
            Whether to use VirtualiZarr, by default False.
        virtualizarr_file : str or None, optional
            Path to the VirtualiZarr file, by default None.
        virtualizarr_backend : str, optional
            VirtualiZarr backend, by default "kerchunk".
        icechunk_repo : str or None, optional
            Path to the Icechunk repository, by default None.
        use_dask : bool, optional
            Whether to use Dask for lazy loading, by default False.
        **kwargs : dict
            Additional arguments passed to XarrayDriver.open.

        Returns
        -------
        xr.Dataset
            The OMPS dataset.
        """
        if "preprocess" not in kwargs:
            from functools import partial

            kwargs["preprocess"] = partial(omps_preprocess, product=product)

        if "engine" not in kwargs:
            kwargs["engine"] = "h5netcdf"

        # L2 data often has different cross-track dimensions if not carefully selected,
        # but standard products should be consistent.
        ds = super().open_dataset(
            files,
            use_virtualizarr=use_virtualizarr,
            virtualizarr_file=virtualizarr_file,
            virtualizarr_backend=virtualizarr_backend,
            icechunk_repo=icechunk_repo,
            use_dask=use_dask,
            **kwargs,
        )

        # Update history
        ds = update_history(ds, f"Read OMPS {product} data.")

        return ds

open_dataset(files, product='nmto3_l2', use_virtualizarr=False, virtualizarr_file=None, virtualizarr_backend='kerchunk', icechunk_repo=None, use_dask=False, **kwargs)

Reads OMPS data.

Parameters:

Name Type Description Default
files Union[str, List[str]]

File path(s) or URL(s).

required
product str

OMPS product: 'nmto3_l2' (default) or 'nmto3_l3'.

'nmto3_l2'
use_virtualizarr bool

Whether to use VirtualiZarr, by default False.

False
virtualizarr_file str or None

Path to the VirtualiZarr file, by default None.

None
virtualizarr_backend str

VirtualiZarr backend, by default "kerchunk".

'kerchunk'
icechunk_repo str or None

Path to the Icechunk repository, by default None.

None
use_dask bool

Whether to use Dask for lazy loading, by default False.

False
**kwargs dict

Additional arguments passed to XarrayDriver.open.

{}

Returns:

Type Description
Dataset

The OMPS dataset.

Source code in monetio/readers/omps.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
def open_dataset(
    self,
    files: str | list[str],
    product: str = "nmto3_l2",
    use_virtualizarr: bool = False,
    virtualizarr_file: str | None = None,
    virtualizarr_backend: str = "kerchunk",
    icechunk_repo: str | None = None,
    use_dask: bool = False,
    **kwargs,
) -> xr.Dataset:
    """
    Reads OMPS data.

    Parameters
    ----------
    files : Union[str, List[str]]
        File path(s) or URL(s).
    product : str, optional
        OMPS product: 'nmto3_l2' (default) or 'nmto3_l3'.
    use_virtualizarr : bool, optional
        Whether to use VirtualiZarr, by default False.
    virtualizarr_file : str or None, optional
        Path to the VirtualiZarr file, by default None.
    virtualizarr_backend : str, optional
        VirtualiZarr backend, by default "kerchunk".
    icechunk_repo : str or None, optional
        Path to the Icechunk repository, by default None.
    use_dask : bool, optional
        Whether to use Dask for lazy loading, by default False.
    **kwargs : dict
        Additional arguments passed to XarrayDriver.open.

    Returns
    -------
    xr.Dataset
        The OMPS dataset.
    """
    if "preprocess" not in kwargs:
        from functools import partial

        kwargs["preprocess"] = partial(omps_preprocess, product=product)

    if "engine" not in kwargs:
        kwargs["engine"] = "h5netcdf"

    # L2 data often has different cross-track dimensions if not carefully selected,
    # but standard products should be consistent.
    ds = super().open_dataset(
        files,
        use_virtualizarr=use_virtualizarr,
        virtualizarr_file=virtualizarr_file,
        virtualizarr_backend=virtualizarr_backend,
        icechunk_repo=icechunk_repo,
        use_dask=use_dask,
        **kwargs,
    )

    # Update history
    ds = update_history(ds, f"Read OMPS {product} data.")

    return ds

omps_preprocess(ds, product='nmto3_l2')

Preprocess OMPS dataset lazily.

Parameters:

Name Type Description Default
ds Dataset

Input dataset.

required
product str

Product type, by default "nmto3_l2".

'nmto3_l2'

Returns:

Type Description
Dataset

Processed dataset.

Examples:

>>> import xarray as xr
>>> from monetio.readers.omps import omps_preprocess
>>> ds = xr.Dataset({"ColumnAmountO3": (("scanline", "ground_pixel"), [[250, 260]])})
>>> ds = omps_preprocess(ds, product="nmto3_l2")
Source code in monetio/readers/omps.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
def omps_preprocess(ds: xr.Dataset, product: str = "nmto3_l2") -> xr.Dataset:
    """
    Preprocess OMPS dataset lazily.

    Parameters
    ----------
    ds : xr.Dataset
        Input dataset.
    product : str, optional
        Product type, by default "nmto3_l2".

    Returns
    -------
    xr.Dataset
        Processed dataset.

    Examples
    --------
    >>> import xarray as xr
    >>> from monetio.readers.omps import omps_preprocess
    >>> ds = xr.Dataset({"ColumnAmountO3": (("scanline", "ground_pixel"), [[250, 260]])})
    >>> ds = omps_preprocess(ds, product="nmto3_l2")
    """
    if product == "nmto3_l2":
        ds = _preprocess_nmto3_l2(ds)
    elif product == "nmto3_l3":
        ds = _preprocess_nmto3_l3(ds)

    # Standardize coordinates
    ds = standardize_satellite_coords(ds)

    # Scientific Hygiene
    ds = _scientific_hygiene(ds)

    return ds