Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first prototype of advanced search #215

Merged
merged 4 commits into from
Oct 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
renamed and added new search functions
  • Loading branch information
ocefpaf committed Oct 5, 2021
commit 5b9af70b6c66185bc9a0a02c6bce49e5c328e02c
108 changes: 105 additions & 3 deletions notebooks/03-searchfor.ipynb → notebooks/03-advanced_search.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"metadata": {},
"source": [
"Too many datasets because wind, speed, and wind speed are matched. Now let's use\n",
"the quoted search to reduce the number of results to only wind speed.\n"
"the quoted search to reduce the number of results to only wind speed. \n"
]
},
{
Expand All @@ -126,6 +126,108 @@
"\n",
"len(pd.read_csv(url)[\"Dataset ID\"])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Slitgly less but still quite a lot!\n",
"\n",
"Another common saerch operation would be to search multiple servers instead of only one. In erddapy we can achieve that with `search_servers`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from erddapy.multiple_server_search import search_servers\n",
"\n",
"\n",
"df = search_servers(\n",
" query=\"glider\",\n",
" servers_list=None,\n",
" parallel=True,\n",
" protocol=\"tabledap\",\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(f\"There are {len(df)} entries in this search!\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"These are the servers that have glider data according to our query."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"set(df[\"Server url\"])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"One way to reduce is to search a subset of the servers with the `servers_list` argument. We can also use it to search servers that are not part of the awesome ERDDAP list (https://github.com/IrishMarineInstitute/awesome-erddap).\n",
"\n",
"\n",
"One can also perform an advanced search with ERDDAP constraints `advanced_search_servers`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from erddapy.multiple_server_search import advanced_search_servers\n",
"\n",
"\n",
"min_time = \"2017-07-01T00:00:00Z\"\n",
"max_time = \"2017-09-01T00:00:00Z\"\n",
"min_lon, max_lon = -127, -123.75\n",
"min_lat, max_lat = 43, 48\n",
"standard_name = \"sea_water_practical_salinity\"\n",
"\n",
"\n",
"kw = {\n",
" \"standard_name\": standard_name,\n",
" \"min_lon\": min_lon,\n",
" \"max_lon\": max_lon,\n",
" \"min_lat\": min_lat,\n",
" \"max_lat\": max_lat,\n",
" \"min_time\": min_time,\n",
" \"max_time\": max_time,\n",
" \"cdm_data_type\": \"timeseries\", # let's exclude AUV's tracks\n",
"}\n",
"\n",
"\n",
"servers = {\n",
" \"ooi\": \"https://erddap.dataexplorer.oceanobservatories.org/erddap/\",\n",
" \"ioos\": \"https://erddap.sensors.ioos.us/erddap/\",\n",
"}\n",
" \n",
"\n",
"df = advanced_search_servers(servers_list=servers.values(), **kw)\n",
"\n",
"df.head()"
]
}
],
"metadata": {
Expand All @@ -141,7 +243,7 @@
},
"gist_id": "3f0f25b13ade0c64c84607bd92903d1b",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -155,7 +257,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down