Skip to content

modis_ornl

MODIS ORNL Reader

MODISORNLReader

Bases: GriddedReader

Reader for MODIS data from ORNL web service.

Source code in monetio/readers/modis_ornl.py
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
83
84
85
86
87
88
89
90
91
92
93
94
95
@register_reader("modis_ornl")
class MODISORNLReader(GriddedReader):
    """
    Reader for MODIS data from ORNL web service.
    """

    def open_dataset(
        self,
        date: pd.Timestamp | str = None,
        product: str = "MOD12A2H",
        band: str = "Lai_500m",
        quality_control: Any | None = None,
        latitude: float = 0,
        longitude: float = 0,
        kmAboveBelow: int = 100,
        kmLeftRight: int = 100,
        files: str | list[str] = None,
        **kwargs,
    ) -> xr.Dataset:
        """
        Reads MODIS data from ORNL.

        Parameters
        ----------
        date : pd.Timestamp or str
            Date to retrieve.
        product : str, optional
            MODIS product.
        band : str, optional
            Product band.
        quality_control : optional
            Quality control filter.
        latitude : float, optional
            Center latitude.
        longitude : float, optional
            Center longitude.
        kmAboveBelow : int, optional
            Kilometers above/below center.
        kmLeftRight : int, optional
            Kilometers left/right center.
        **kwargs : dict
            Additional arguments.

        Returns
        -------
        xr.Dataset
            The MODIS ORNL dataset.

        Examples
        --------
        >>> reader = MODISORNLReader()
        >>> ds = reader.open_dataset(date='2020-01-01', product='MOD15A2H', band='Lai_500m')
        """
        if not HAS_SUDS:
            raise ImportError(
                "Please install a suds client (pip install suds-jurko or suds-community)"
            )

        date = pd.to_datetime(date)
        ds = _get_single_retrieval(
            date,
            product=product,
            band=band,
            quality_control=quality_control,
            lat=latitude,
            lon=longitude,
            kmAboveBelow=kmAboveBelow,
            kmLeftRight=kmLeftRight,
        )

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

        return ds

open_dataset(date=None, product='MOD12A2H', band='Lai_500m', quality_control=None, latitude=0, longitude=0, kmAboveBelow=100, kmLeftRight=100, files=None, **kwargs)

Reads MODIS data from ORNL.

Parameters:

Name Type Description Default
date Timestamp or str

Date to retrieve.

None
product str

MODIS product.

'MOD12A2H'
band str

Product band.

'Lai_500m'
quality_control optional

Quality control filter.

None
latitude float

Center latitude.

0
longitude float

Center longitude.

0
kmAboveBelow int

Kilometers above/below center.

100
kmLeftRight int

Kilometers left/right center.

100
**kwargs dict

Additional arguments.

{}

Returns:

Type Description
Dataset

The MODIS ORNL dataset.

Examples:

>>> reader = MODISORNLReader()
>>> ds = reader.open_dataset(date='2020-01-01', product='MOD15A2H', band='Lai_500m')
Source code in monetio/readers/modis_ornl.py
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
83
84
85
86
87
88
89
90
91
92
93
94
95
def open_dataset(
    self,
    date: pd.Timestamp | str = None,
    product: str = "MOD12A2H",
    band: str = "Lai_500m",
    quality_control: Any | None = None,
    latitude: float = 0,
    longitude: float = 0,
    kmAboveBelow: int = 100,
    kmLeftRight: int = 100,
    files: str | list[str] = None,
    **kwargs,
) -> xr.Dataset:
    """
    Reads MODIS data from ORNL.

    Parameters
    ----------
    date : pd.Timestamp or str
        Date to retrieve.
    product : str, optional
        MODIS product.
    band : str, optional
        Product band.
    quality_control : optional
        Quality control filter.
    latitude : float, optional
        Center latitude.
    longitude : float, optional
        Center longitude.
    kmAboveBelow : int, optional
        Kilometers above/below center.
    kmLeftRight : int, optional
        Kilometers left/right center.
    **kwargs : dict
        Additional arguments.

    Returns
    -------
    xr.Dataset
        The MODIS ORNL dataset.

    Examples
    --------
    >>> reader = MODISORNLReader()
    >>> ds = reader.open_dataset(date='2020-01-01', product='MOD15A2H', band='Lai_500m')
    """
    if not HAS_SUDS:
        raise ImportError(
            "Please install a suds client (pip install suds-jurko or suds-community)"
        )

    date = pd.to_datetime(date)
    ds = _get_single_retrieval(
        date,
        product=product,
        band=band,
        quality_control=quality_control,
        lat=latitude,
        lon=longitude,
        kmAboveBelow=kmAboveBelow,
        kmLeftRight=kmLeftRight,
    )

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

    return ds