Examples
========

.. toctree::
   :maxdepth: 2

   examples/wave-height.md

Querying
--------

A catlaog can be generated by passing your desired query parameters directly
with the ``kwargs_search`` keyword argument. This object gets passed to
`erddappy <https://github.com/ioos/erddapy>`_ ::

    search = {
        "min_lon": -180,
        "max_lon": -156,
        "min_lat": 50,
        "max_lat": 66,
        "min_time": "2021-04-01",
        "max_time": "2021-04-02",
    }
    cat = intake.open_erddap_catalog(server_url, kwargs_search=search)


The same query can also be specified using the constructor keyword arguments::

    cat = intake.open_erddap_catalog(
        server=server_url,
        bbox=(-180., 50., -156., 66.),
        start_time=datetime(2021, 4, 1),
        end_time=datetime(2021, 4, 2),
    )

The catalog supports querying for datasets that contain a variable with a
particular
`CF Standard Name <https://cfconventions.org/Data/cf-standard-names/current/build/cf-standard-name-table.html>`_
. Clients can specify the standard name queries with either the
``kwargs_search`` keyword argument, or the ``standard_names`` keyword argument::

    cat = intake.open_erddap_catalog(
        server=server_url,
        kwargs_search={
            "standard_name": "air_temperature",
        },
    )

or::

    cat = intake.open_erddap_catalog(
        server=server_url,
        standard_names=["air_temperature"],
    )

Multiple standard name values can be queries which will return all datasets
containing at least one of the queried standard names::


    cat = intake.open_erddap_catalog(
        server=server_url,
        standard_names=["air_temperature", "air_pressure"],
    )

In cases where standard names are not sufficient, clients can query using the
variable name as it appears in ERDDAP::

    cat = intake.open_erddap_catalog(
        server=server_url,
        variable_names=["Pair", "temp"],
    )

Lastly, ERDDAP offers a plaintext search option. Clients can query for datasets
containing a plaintext search term::

    cat = intake.open_erddap_catalog(
        server=server_url,
        search_for=["ioos", "aoos", "NOAA"],
    )


Querying with AND
-----------------

Sometimes, clients may want to find only datasets that match all of the query
terms exactly. This can be achieved with the ``query_type`` keyword argument::


    cat = intake.open_erddap_catalog(
        server=server_url,
        standard_names=["air_temperature", "air_pressure"],
        query_type="intersection",
    )

This will return only datasets that have both ``air_temperature`` and
``air_pressure`` as standard names associated with variables.
