Translate a filter into API parameters¶
In this exercise you will turn a CQL2 JSON filter into an AERONET query string without downloading observations.
Install pygeofilter-aeronet and jupyterlab, then open this notebook in JupyterLab. An internet connection is required because importing the package initializes DuckDB spatial support and reads the hosted station catalogue.
Run the cells below in order.
Build and translate the filter¶
The filter below selects daily Level 1.0 AOD observations for Cart_Site during February 2023. Run the next cell to inspect the translated query string.
What to look for¶
The output should contain site=Cart_Site, AOD10=1, if_no_html=1, and AVG=20, followed by the start and end date parameters. The result describes a request; it does not confirm that observations exist for that period.
After inspecting the output, change daily-average to all-points and rerun the code cell. AVG=20 becomes AVG=10.
Continue with Your first AERONET query to download and read observations, or consult the filter reference.
from pygeofilter_aeronet.evaluator import to_aeronet_api
cql2_filter = {
"op": "and",
"args": [
{"op": "eq", "args": [{"property": "site"}, "Cart_Site"]},
{"op": "eq", "args": [{"property": "data_type"}, "AOD10"]},
{"op": "eq", "args": [{"property": "format"}, "csv"]},
{"op": "eq", "args": [{"property": "data_format"}, "daily-average"]},
{
"op": "t_after",
"args": [
{"property": "time"},
{"timestamp": "2023-02-01T00:00:00Z"},
],
},
{
"op": "t_before",
"args": [
{"property": "time"},
{"timestamp": "2023-02-28T23:59:59Z"},
],
},
],
}
query, _ = to_aeronet_api(cql2_filter)
query
'site=Cart_Site&AOD10=1&if_no_html=1&AVG=20&year=2023&month=2&day=1&hour=0&year2=2023&month2=2&day2=28&hour2=23'