Skip to content

Commit

Permalink
Merge pull request #298 from ocefpaf/docs
Browse files Browse the repository at this point in the history
Use more stable servers
  • Loading branch information
ocefpaf authored Mar 31, 2023
2 parents f7bb350 + 832ac3e commit 9779b3f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 64 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The main advantages of ERDDAP are:
and reformats the data into the format that you requested.


See https://coastwatch.pfeg.noaa.gov/erddap/index.html for more information.
See https://standards.sensors.ioos.us/erddap/index.html for more information.


.. toctree::
Expand Down
69 changes: 19 additions & 50 deletions notebooks/00-quick_intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"\n",
"\n",
"First we need to instantiate the ERDDAP URL constructor for a server.\n",
"In this example we will use\n",
"[https://erddap.ifremer.fr/erddap](https://erddap.ifremer.fr/erddap/index.html)."
"In these examples we will use\n",
"[https://standards.sensors.ioos.us/erddap/index.html](https://standards.sensors.ioos.us/erddap/index.html) and [https://erddap.ioos.us/erddap/index.html](https://erddap.ioos.us/erddap/index.html)."
]
},
{
Expand All @@ -33,8 +33,9 @@
"from erddapy import ERDDAP\n",
"\n",
"\n",
"server = \"https://standards.sensors.ioos.us/erddap\"\n",
"e = ERDDAP(\n",
" server=\"ifremer\",\n",
" server=server,\n",
" protocol=\"tabledap\",\n",
" response=\"csv\",\n",
")"
Expand All @@ -55,15 +56,14 @@
"metadata": {},
"outputs": [],
"source": [
"e.dataset_id = \"OceanGlidersGDACTrajectories\"\n",
"e.dataset_id = \"org_cormp_cap2\"\n",
"\n",
"e.variables = [\n",
" \"time\",\n",
" \"latitude\",\n",
" \"longitude\",\n",
" \"PRES\",\n",
" \"PSAL\",\n",
" \"TEMP\",\n",
" \"sea_water_temperature\",\n",
" \"air_temperature\"\n",
"]\n",
"\n",
"e.constraints = {\n",
Expand Down Expand Up @@ -94,11 +94,21 @@
"metadata": {},
"outputs": [],
"source": [
"server = \"https://erddap.ioos.us/erddap\"\n",
"e = ERDDAP(\n",
" server=server,\n",
" protocol=\"tabledap\",\n",
" response=\"csv\",\n",
")\n",
"\n",
"e.dataset_id = \"processed_asset_inventory\"\n",
"\n",
"# Get the box of the first 10 degrees bbox.\n",
"constraints = {\n",
" \"time>=\": \"now-14days\",\n",
" \"time<=\": \"now-7days\",\n",
" \"longitude<=\": \"min(longitude)+10\",\n",
" \"longitude>=\": \"min(longitude)\",\n",
" \"latitude<=\": \"min(latitude)+10\",\n",
" \"latitude>=\": \"min(latitude)\",\n",
"}\n",
"\n",
"\n",
Expand All @@ -110,35 +120,6 @@
"print(url)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The same request as above but with non-relative constraints. Note that these\n",
"values will change if we run this at a later time.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"constraints = {\n",
" \"time>=\": \"2023-02-06T19:12:32Z\",\n",
" \"time<=\": \"2023-02-13T19:12:32Z\",\n",
" \"longitude>=\": -149.60,\n",
" \"longitude<=\": -139.60,\n",
"}\n",
"\n",
"url = e.get_download_url(\n",
" response=\"html\",\n",
" constraints=constraints,\n",
")\n",
"\n",
"print(url)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -157,26 +138,14 @@
"e.variables = [\n",
" \"datasetID\",\n",
" \"institution\",\n",
" \"minTime\",\n",
" \"maxTime\",\n",
" \"minLatitude\",\n",
" \"maxLatitude\",\n",
" \"minLongitude\",\n",
" \"maxLongitude\",\n",
"]\n",
"\n",
"\n",
"e.constraints = {\n",
" \"minTime>=\": \"1997-01-01T00:00:00Z\",\n",
"}\n",
"\n",
"\n",
"url = e.get_download_url(response=\"html\")\n",
"print(url)\n",
"\n",
"df = e.to_pandas(\n",
" index_col=\"datasetID\",\n",
" parse_dates=True,\n",
").dropna()\n",
"\n",
"\n",
Expand Down
25 changes: 13 additions & 12 deletions notebooks/01b-tabledap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"from erddapy import ERDDAP\n",
"\n",
"\n",
"e = ERDDAP(server=\"https://gliders.ioos.us/erddap\")\n",
"server = \"https://gliders.ioos.us/erddap\"\n",
"e = ERDDAP(server=server)\n",
"\n",
"[method for method in dir(e) if not method.startswith(\"_\")]"
]
Expand Down Expand Up @@ -64,9 +65,9 @@
"metadata": {},
"source": [
"There are many responses available, see the docs for\n",
"[griddap](https://coastwatch.pfeg.noaa.gov/erddap/griddap/documentation.html)\n",
"[griddap](https://erddap.ioos.us/erddap/griddap/documentation.html)\n",
"and\n",
"[tabledap](https://coastwatch.pfeg.noaa.gov/erddap/tabledap/documentation.html)\n",
"[tabledap](https://erddap.ioos.us/erddap/tabledap/documentation.html)\n",
"respectively. The most useful ones for Pythonistas are the .csv and .nc that can\n",
"be read with pandas and netCDF4-python respectively.\n",
"\n",
Expand Down Expand Up @@ -374,9 +375,9 @@
"source": [
"Let's create a map of some WHOI gliders tracks.\n",
"\n",
"(We are downloading a lot of data! Note that we will use\n",
"We are downloading a lot of data! Note that we will use\n",
"[joblib](https://joblib.readthedocs.io/en/latest/) to parallelize the for loop\n",
"and get the data faster.)\n"
"and get the data faster and we will limit to the first 5 gliders."
]
},
{
Expand All @@ -388,21 +389,21 @@
"iopub.status.busy": "2021-08-09T20:11:41.202272Z",
"iopub.status.idle": "2021-08-09T20:12:31.692271Z",
"shell.execute_reply": "2021-08-09T20:12:31.693604Z"
}
},
"scrolled": false
},
"outputs": [],
"source": [
"from joblib import Parallel, delayed\n",
"import multiprocessing\n",
"from erddapy.core import get_download_url, to_pandas\n",
"\n",
"\n",
"def request_whoi(dataset_id):\n",
" e.constraints = None\n",
" e.protocol = \"tabledap\"\n",
" e.variables = [\"longitude\", \"latitude\", \"temperature\", \"salinity\"]\n",
" e.dataset_id = dataset_id\n",
" variables = [\"longitude\", \"latitude\", \"temperature\", \"salinity\"]\n",
" url = get_download_url(server, dataset_id, protocol=\"tabledap\", variables=variables, response=\"csv\")\n",
" # Drop units in the first line and NaNs.\n",
" df = e.to_pandas(response=\"csv\", skiprows=(1,)).dropna()\n",
" df = to_pandas(url, pandas_kwargs={\"skiprows\": (1,)}).dropna()\n",
" return (dataset_id, df)\n",
"\n",
"\n",
Expand All @@ -418,7 +419,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally let's see some figures!\n"
"Finally let's see some figures!"
]
},
{
Expand Down

0 comments on commit 9779b3f

Please sign in to comment.