### Initialize ERDDAP Client Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Basic setup for connecting to an ERDDAP server. ```python from erddapy import ERDDAP e = ERDDAP( server="https://erddap.ioos.us/erddap", protocol="tabledap", response="csv", ) ``` -------------------------------- ### Install erddapy with Pip Source: https://ioos.github.io/erddapy/_sources/00-quick_intro-output.ipynb.txt Install the erddapy package using pip. ```shell pip install erddapy ``` -------------------------------- ### Install erddapy Source: https://ioos.github.io/erddapy/00-quick_intro-output.html Installation commands for erddapy using conda or pip. ```bash conda install --channel conda-forge erddapy ``` ```bash pip install erddapy ``` -------------------------------- ### GET /info Source: https://ioos.github.io/erddapy/erddapy.html Builds the info URL for the ERDDAP server endpoint. ```APIDOC ## GET /info ### Description Build the info URL for the server endpoint. If dataset_id is empty, the full dataset listing will be returned. ### Method GET ### Parameters #### Query Parameters - **dataset_id** (str) - Optional - A dataset unique id. - **response** (str) - Optional - The response format (default is HTML). ### Response #### Success Response (200) - **url** (str) - The info URL for the response chosen. ``` -------------------------------- ### Initialize ERDDAP Client Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Instantiate the ERDDAP client to connect to a specific ERDDAP server. No setup or imports are required beyond this. ```python from erddapy import ERDDAP e = ERDDAP(server='https://erddap.sensors.ioos.us/erddap/') ``` -------------------------------- ### Get Dataset Info Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Fetch detailed information about a dataset, including its title, summary, and keywords. ```python e.get_dataset_info(datasetid='ac9f_d7c1_177c') ``` -------------------------------- ### Install erddapy with Conda Source: https://ioos.github.io/erddapy/_sources/00-quick_intro-output.ipynb.txt Install the erddapy package using conda from the conda-forge channel. ```shell conda install --channel conda-forge erddapy ``` -------------------------------- ### Get Available Variables for a Dataset Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt List all available variables for a given dataset. This helps in understanding the data content before downloading. ```python e.get_var_by_attr(e.search(platform_name='BGC Argo')[0], 'standard_name', 'sea_water_temperature') ``` -------------------------------- ### Visualize data with cartopy Source: https://ioos.github.io/erddapy/01b-tabledap-output.html Setup a map projection using cartopy and matplotlib for plotting geospatial data. ```python import cartopy.crs as ccrs import matplotlib.pyplot as plt from cartopy.mpl.ticker import LatitudeFormatter, LongitudeFormatter def make_map(): fig, ax = plt.subplots( figsize=(9, 9), subplot_kw={"projection": ccrs.PlateCarree()}, ) ax.coastlines(resolution="10m") lon_formatter = LongitudeFormatter(zero_direction_label=True) lat_formatter = LatitudeFormatter() ax.xaxis.set_major_formatter(lon_formatter) ``` -------------------------------- ### Get Available Constraints Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Fetch the constraints that can be applied to a dataset, such as time ranges, geographical boundaries, and other filtering options. ```python from erddapy import ERDDAP e = ERDDAP(server='https://data.ioos.us/erddap/') constraints = e.get_constraints(datasetid='erdSS19990301t090000d000000') print(constraints) ``` -------------------------------- ### Handle Large Datasets with `erddapy` Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt When dealing with large datasets, it's recommended to use the `erddapy` library to efficiently download data. This example shows how to download data in chunks or specific formats. ```python from erddapy import ERDDAP import pandas as pd e = ERDDAP(server='https://erddap.sensors.ioos.us/erddap') df = e.to_pandas( datasetid='erdPMdata', response='csv', query_type='search', search_for='temperature', min_time='2019-01-01T00:00:00Z', max_time='2019-12-31T23:59:59Z', north=40, south=30, east=-70, west=-80 ) ``` -------------------------------- ### GET /search/advanced.{response} Source: https://ioos.github.io/erddapy/_modules/erddapy/core/url.html Builds a search URL to query datasets on an ERDDAP server based on metadata, protocol, and spatial/temporal constraints. ```APIDOC ## GET /search/advanced.{response} ### Description Constructs a URL to perform an advanced search across datasets on an ERDDAP server. ### Method GET ### Endpoint {server}/search/advanced.{response} ### Parameters #### Query Parameters - **server** (string) - Required - The base URL of the ERDDAP server. - **response** (string) - Optional - The response format (e.g., html, csv, json). Default is 'html'. - **protocol** (string) - Optional - The data protocol, either 'tabledap' or 'griddap'. - **itemsPerPage** (integer) - Optional - Number of items per page. Default is 1,000,000. - **page** (integer) - Optional - The page number to display. Default is 1. - **searchFor** (string) - Optional - Google-like search query for metadata. - **minLon/maxLon** (float) - Optional - Longitude range constraints. - **minLat/maxLat** (float) - Optional - Latitude range constraints. - **minTime/maxTime** (string/float) - Optional - Time range constraints. Can be ISO strings or seconds since 1970. ### Response #### Success Response (200) - **url** (string) - The generated search URL. ``` -------------------------------- ### GET /search Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Search for datasets on an ERDDAP server using specific keywords or constraints. ```APIDOC ## GET /search ### Description Searches the ERDDAP server for datasets matching the provided query parameters. ### Method GET ### Endpoint /search ### Parameters #### Query Parameters - **query** (string) - Required - The search term to look for in dataset metadata. - **items_per_page** (integer) - Optional - Number of results to return per page. ### Request Example GET /search?query=temperature&items_per_page=10 ### Response #### Success Response (200) - **results** (array) - List of matching dataset objects. #### Response Example { "results": [ {"dataset_id": "dataset_01", "title": "Sea Surface Temperature"} ] } ``` -------------------------------- ### Get ERDDAP Server Info Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve general information about the ERDDAP server, including its version and capabilities. ```python e.get_server_info() ``` -------------------------------- ### Get Dataset Info Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Obtain detailed information about a specific dataset, including its metadata, variables, and constraints. ```python from erddapy import ERDDAP e = ERDDAP(server='https://data.ioos.us/erddap/') dataset_info = e.info(datasetid='erdSS19990301t090000d000000') print(dataset_info) ``` -------------------------------- ### GET /info Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve metadata information for a specific dataset ID. ```APIDOC ## GET /info ### Description Fetches detailed metadata for a specific dataset, including variables, attributes, and coordinate ranges. ### Method GET ### Endpoint /info ### Parameters #### Query Parameters - **dataset_id** (string) - Required - The unique identifier of the dataset. ### Request Example GET /info?dataset_id=dataset_01 ### Response #### Success Response (200) - **variables** (array) - List of variables contained in the dataset. - **attributes** (object) - Global attributes of the dataset. #### Response Example { "dataset_id": "dataset_01", "variables": ["time", "latitude", "longitude", "temperature"] } ``` -------------------------------- ### GET /get_download_url Source: https://ioos.github.io/erddapy/erddapy.html Builds the download URL for the server endpoint based on provided constraints and parameters. ```APIDOC ## GET /get_download_url ### Description Builds the download URL for the server endpoint. ### Parameters - **dataset_id** (str) - Optional - A dataset unique id. - **protocol** (str) - Optional - tabledap or griddap. - **variables** (list/tuple) - Optional - A list of the variables to download. - **dim_names** (list/tuple) - Optional - A list of the dimensions (griddap only). - **response** (str) - Optional - Default is HTML. - **constraints** (dict) - Optional - Download constraints. - **distinct** (bool) - Optional - If true, only unique values will be downloaded. ### Response - **url** (str) - The constructed download URL. ``` -------------------------------- ### GET /search Source: https://ioos.github.io/erddapy/erddapy.html Builds the search URL for the ERDDAP server endpoint to query datasets. ```APIDOC ## GET /search ### Description Build the search URL for the server endpoint provided using Google-like metadata search. ### Method GET ### Parameters #### Query Parameters - **response** (str) - Optional - The response format (default is HTML). - **search_for** (str) - Optional - Search terms for dataset metadata. - **protocol** (str) - Optional - The protocol (tabledap or griddap). - **items_per_page** (int) - Optional - Number of items per page (default 1,000,000). - **page** (int) - Optional - Which page to display (default 1). - **kwargs** (dict) - Optional - Extra search constraints based on metadata or coordinates. ### Response #### Success Response (200) - **url** (str) - The search URL. ``` -------------------------------- ### Get ERDDAP Server Info Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve general information about the ERDDAP server, such as its title, summary, and contact details. ```python from erddapy import ERDDAP e = ERDDAP(server='https://data.ioos.us/erddap/') info = e.info() print(info) ``` -------------------------------- ### GET /get_categorize_url Source: https://ioos.github.io/erddapy/erddapy.html Builds the categorize URL for the server endpoint based on attributes. ```APIDOC ## GET /get_categorize_url ### Description Builds the categorize URL for the server endpoint. ### Parameters - **categorize_by** (str) - Required - A valid attribute (e.g., ioos_category or standard_name). - **value** (str) - Optional - An attribute value. - **response** (str) - Optional - Default is HTML. ### Response - **url** (str) - The categorized URL for the response chosen. ``` -------------------------------- ### Get Available Variables Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve a list of available variables for a given dataset ID. This helps in understanding what data can be extracted. ```python e.get_available_variables('erdPMdata') ``` -------------------------------- ### Get Dataset Information Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieves metadata and information about a specific dataset from an ERDDAP server. ```APIDOC ## Get Dataset Information ### Description Retrieves detailed information about a specific ERDDAP dataset, including metadata, variables, and constraints. ### Method GET ### Endpoint /erddap/{dataset_id}/index.json ### Parameters #### Path Parameters - **dataset_id** (string) - Required - The unique identifier of the dataset. ### Response #### Success Response (200) - **table** (object) - Contains information about the dataset's structure and metadata. - **rows** (array) - Metadata rows describing variables and attributes. - **columns** (array) - Column names for the metadata. ### Response Example ```json { "table": { "rows": [ ["id", "dataset1"], ["title", "Example Dataset 1"], ["variables", "{\"temperature\": {\"units\": \"Celsius\"}}"] ], "columns": ["key", "value"] } } ``` ``` -------------------------------- ### Get Available Variables Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve a list of available variables for a given dataset ID. This helps in selecting the correct variables for data download. ```python e.get_variables(datasetid='ac9f_d7c1_177c') ``` -------------------------------- ### Define Relative Constraints Source: https://ioos.github.io/erddapy/_modules/erddapy/core/url.html Example dictionary for applying relative time, latitude, and depth constraints to an ERDDAP request. ```python constraints = { 'time>': 'now-7days', 'latitude<': 'min(longitude)+180', 'depth>': 'max(depth)-23', } ``` -------------------------------- ### Search Across Multiple Servers Source: https://ioos.github.io/erddapy/03-advanced_search-output.html Searches for datasets across multiple ERDDAP servers simultaneously using the `search_servers` function. This example queries for 'glider' data. ```python from erddapy.multiple_server_search import search_servers df = search_servers( query="glider", servers_list=None, parallel=True, protocol="tabledap", ) ``` -------------------------------- ### Get Dataset Information Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve metadata and variable information for a specific dataset using `get_dataset_metadata`. This is useful for understanding the data structure before downloading. ```python from erddapy import ERDDAP e = ERDDAP(server='https://erddapy.com/erddap/') df = e.get_dataset_metadata(datasetid='erdAP_all') print(df) ``` -------------------------------- ### Get Dataset Metadata Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Fetch metadata for a dataset, including its variables and their properties. This is essential for understanding data structure. ```python e.get_dataset_metadata(datasetid='ac9f_d7c1_177c') ``` -------------------------------- ### Get Dataset Table Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve a table of metadata for a specific dataset. This is useful for understanding the variables and structure of a dataset before downloading. ```python e.get_datasetIDs(search_for='sea surface temperature', limit=1) ``` -------------------------------- ### Get Constraints for a Dataset Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Fetch the constraints for a dataset, such as the available time range or spatial extent. This is crucial for defining valid data requests. ```python e.get_constraints('erdPMdata') ``` -------------------------------- ### Get Data as Pandas DataFrame Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve data for a specific dataset directly as a Pandas DataFrame. This is convenient for in-memory data analysis. ```python e.to_pandas(e.search(platform_name='BGC Argo')[0]) ``` -------------------------------- ### Filter Search with Extra Words Source: https://ioos.github.io/erddapy/03-advanced_search-output.html Filters search results by specifying a keyword. This example retrieves 'Dataset ID's for 'etopo5'. ```python search_for = "etopo5" url = e.get_search_url(search_for=search_for, response="csv") pd.read_csv(url)["Dataset ID"] ``` -------------------------------- ### Get Dataset Information Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve metadata and information about a specific ERDDAP dataset. This is useful for understanding the available variables and their properties. ```python from erddapy import ERDDAP e = ERDDAP(server='https://erddap.sensors.ioos.us/erddap/') info = e.info('ac97_1118_1440') print(info) ``` -------------------------------- ### Get Dataset Table Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve a table of dataset information, including variable names and data types. This is useful for understanding the structure of a dataset before downloading. ```python from erddapy import ERDDAP e = ERDDAP(server='https://data.ioos.us/erddap/') df = e.get_datasetstable(search_max_results=1, title='SST') print(df) ``` -------------------------------- ### Initialize ERDDAP instance and search datasets Source: https://ioos.github.io/erddapy/_modules/erddapy/erddapy.html Demonstrates creating an ERDDAP instance with a server URL and searching for datasets using pandas. ```python >>> e = ERDDAP(server="https://gliders.ioos.us/erddap") >>> import pandas as pd >>> url = e.get_search_url(search_for="ru29", response="csv") >>> pd.read_csv(url)["Dataset ID"] 0 ru29-20150623T1046 1 ru29-20161105T0131 Name: Dataset ID, dtype: object ``` -------------------------------- ### Use ERDDAP server shortcuts Source: https://ioos.github.io/erddapy/_modules/erddapy/erddapy.html Shows how to use built-in server acronyms and retrieve a list of available server shortcuts. ```python >>> e = ERDDAP(server="SECOORA") >>> e.server 'https://erddap.secoora.org/erddap' ``` ```python >>> from erddapy import servers >>> {k: v.url for k, v in servers.items()} {'MDA': 'https://bluehub.jrc.ec.europa.eu/erddap/', 'MII': 'https://erddap.marine.ie/erddap/', 'CSCGOM': 'https://cwcgom.aoml.noaa.gov/erddap/', 'CSWC': 'https://coastwatch.pfeg.noaa.gov/erddap/', 'CeNCOOS': 'https://erddap.axiomalaska.com/erddap/', 'NERACOOS': 'https://www.neracoos.org/erddap/', 'NGDAC': 'https://gliders.ioos.us/erddap/', 'PacIOOS': 'https://pae-paha.pacioos.hawaii.edu/erddap/', 'SECOORA': 'https://erddap.secoora.org/erddap/', 'NCEI': 'https://ecowatch.ncddc.noaa.gov/erddap/', 'OSMC': 'https://osmc.noaa.gov/erddap/', 'UAF': 'https://upwell.pfeg.noaa.gov/erddap/', 'ONC': 'https://dap.onc.uvic.ca/erddap/', 'BMLSC': 'http://bmlsc.ucdavis.edu:8080/erddap/', 'RTECH': 'https://meteo.rtech.fr/erddap/', 'IFREMER': 'https://www.ifremer.fr/erddap/', 'UBC': 'https://salishsea.eos.ubc.ca/erddap/'} ``` -------------------------------- ### GET /variables Source: https://ioos.github.io/erddapy/erddapy.html Retrieves variables from a dataset based on provided attributes. ```APIDOC ## GET /variables ### Description Return a variable based on its attributes by creating an info csv return for the dataset_id. ### Method GET ### Parameters #### Query Parameters - **dataset_id** (str) - Optional - The dataset unique id. - **kwargs** (dict) - Optional - Attribute filters (e.g., axis, standard_name). ### Response #### Success Response (200) - **variables** (list[str]) - A list of variable names matching the attributes. ``` -------------------------------- ### Get Dataset Table Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve a table of datasets matching specific criteria. This provides metadata about the datasets, such as their ID, title, and summary. ```python e.get_dataset_table(min_lat=40, max_lat=50, min_lon=-130, max_lon=-120, platform_name='BGC Argo') ``` -------------------------------- ### Create and Plot Regions from GeoPandas Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt This snippet shows how to create a regionmask from a GeoPandas object and then plot it. Ensure GeoPandas is installed and the 'SA' object is defined. ```python import regionmask region = regionmask.from_geopandas(SA, name=name) region.plot(); ``` -------------------------------- ### Initialize ERDDAP Client Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Instantiate the ERDDAP client by providing the base URL of the ERDDAP server. This is the first step before making any requests. ```python from erddapy import ERDDAP e = ERDDAP(server='https://erddap.sensors.ioos.us/erddap') ``` -------------------------------- ### Filter Search with Exclusion Source: https://ioos.github.io/erddapy/03-advanced_search-output.html Filters search results by excluding specific terms. This example searches for 'etopo5' but excludes results containing 'lon360'. ```python search_for = "etopo5 -lon360" url = e.get_search_url(search_for=search_for, response="csv") pd.read_csv(url)["Dataset ID"] ``` -------------------------------- ### Initialize erddapy Client Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Instantiate the ERDDAP client to connect to a specific ERDDAP server. This is the first step before making any data requests. ```python from erddapy import ERDDAP e = ERDDAP(server='https://data.ioos.us/erddap/') ``` -------------------------------- ### Get Dataset Metadata Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieves detailed metadata for a specific dataset. ```APIDOC ## Get Dataset Metadata ### Description Fetches detailed metadata for a given dataset ID from the ERDDAP server. ### Method `erddapy.ERDDAP.get_dataset_metadata()` ### Parameters #### Path Parameters None #### Query Parameters - **datasetid** (string) - Required - The unique identifier of the dataset. #### Request Body None ### Request Example ```python from erddapy import ERDDAP erddap_server = ERDDAP(server_url='https://erddap.example.com/erddap/') metadata = erddap_server.get_dataset_metadata(datasetid='dataset1_id') ``` ### Response #### Success Response (200) - **metadata** (dict) - A dictionary containing detailed metadata for the dataset. #### Response Example ```json { "variables": { "time": {"units": "days since 1970-01-01T00:00:00Z"}, "temperature": {"units": "degrees C"} }, "title": "Example Dataset 1", "id": "dataset1_id" } ``` ``` -------------------------------- ### Initialize ERDDAP Client Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Create an instance of the ERDDAP class by specifying the server URL and the dataset ID. ```python from erddapy import ERDDAP e = ERDDAP( server="https://erddap.ioos.us/erddap", protocol="tabledap", response="csv", ) e.dataset_id = "noaa_nos_co_ops_8775870" ``` -------------------------------- ### Initialize ERDDAP Connection Source: https://ioos.github.io/erddapy/03-advanced_search-output.html Establishes a connection to an ERDDAP server using a specified protocol. This is the first step before performing any search operations. ```python from erddapy import ERDDAP e = ERDDAP( server="https://pae-paha.pacioos.hawaii.edu/erddap", protocol="griddap", ) ``` -------------------------------- ### Perform Quoted Phrase Search Source: https://ioos.github.io/erddapy/03-advanced_search-output.html Performs an exact phrase search using quotes to narrow down results. This example counts the number of datasets matching the exact phrase 'ocean bathymetry'. ```python search_for = '"ocean bathymetry"' url = e.get_search_url(search_for=search_for, response="csv") len(pd.read_csv(url)["Dataset ID"]) ``` -------------------------------- ### Initialize ERDDAP connection Source: https://ioos.github.io/erddapy/02-extras-output.html Instantiate the ERDDAP class with the server URL. This is the first step to interact with an ERDDAP server. ```python from erddapy import ERDDAP e = ERDDAP(server="https://gliders.ioos.us/erddap") ``` -------------------------------- ### Get Dataset Info URL Source: https://ioos.github.io/erddapy/01b-tabledap-output.html Generate a URL to retrieve metadata for a specific dataset ID. The 'response' parameter can be set to 'html' for a human-readable page or 'csv' for programmatic access. ```python glider = gliders[-1] info_url = e.get_info_url(dataset_id=glider, response="html") print(info_url) ``` -------------------------------- ### GET /get_var_by_attr Source: https://ioos.github.io/erddapy/_modules/erddapy/erddapy.html Retrieves a list of variables from a dataset that match specified attribute criteria. ```APIDOC ## GET /get_var_by_attr ### Description Returns a list of variable names that match the provided attribute key-value pairs or filter functions. ### Parameters #### Query Parameters - **dataset_id** (str) - Optional - The ID of the dataset to query. - **kwargs** (dict) - Optional - Attribute names and values (or callables) to filter variables by. ### Response #### Success Response (200) - **variables** (list[str]) - A list of variable names matching the criteria. ``` -------------------------------- ### ERDDAP Server Shortcuts Source: https://ioos.github.io/erddapy/_modules/erddapy/erddapy.html Lists available server acronyms and their corresponding URLs. ```APIDOC ## ERDDAP Server Shortcuts ### Description Provides a dictionary of predefined ERDDAP server acronyms and their URLs for easy initialization. ### Usage ```python from erddapy import servers # Accessing the dictionary print(servers) # Example: Getting the URL for SECOORA secoora_url = servers['SECOORA'].url print(secoora_url) ``` ### Available Servers (Example Output) ```json { "MDA": {"url": "https://bluehub.jrc.ec.europa.eu/erddap/"}, "MII": {"url": "https://erddap.marine.ie/erddap/"}, "CSCGOM": {"url": "https://cwcgom.aoml.noaa.gov/erddap/"}, "CSWC": {"url": "https://coastwatch.pfeg.noaa.gov/erddap/"}, "CeNCOOS": {"url": "https://erddap.axiomalaska.com/erddap/"}, "NERACOOS": {"url": "https://www.neracoos.org/erddap/"}, "NGDAC": {"url": "https://gliders.ioos.us/erddap/"}, "PacIOOS": {"url": "https://pae-paha.pacioos.hawaii.edu/erddap/"}, "SECOORA": {"url": "https://erddap.secoora.org/erddap/"}, "NCEI": {"url": "https://ecowatch.ncddc.noaa.gov/erddap/"}, "OSMC": {"url": "https://osmc.noaa.gov/erddap/"}, "UAF": {"url": "https://upwell.pfeg.noaa.gov/erddap/"}, "ONC": {"url": "https://dap.onc.uvic.ca/erddap/"}, "BMLSC": {"url": "http://bmlsc.ucdavis.edu:8080/erddap/"}, "RTECH": {"url": "https://meteo.rtech.fr/erddap/"}, "IFREMER": {"url": "https://www.ifremer.fr/erddap/"}, "UBC": {"url": "https://salishsea.eos.ubc.ca/erddap/"} } ``` ``` -------------------------------- ### Initialize ERDDAP Object Source: https://ioos.github.io/erddapy/01b-tabledap-output.html Instantiate the ERDDAP object with a server URL. This is the first step to interact with an ERDDAP server. ```python from erddapy import ERDDAP server = "https://gliders.ioos.us/erddap" e = ERDDAP(server=server) [method for method in dir(e) if not method.startswith("_")] ``` -------------------------------- ### GET /tabledap Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieves data from a tabledap dataset based on specified constraints and variables. ```APIDOC ## GET /tabledap ### Description Retrieves data from a tabledap dataset. Users can specify the dataset ID, variables, and constraints to filter the returned data. ### Method GET ### Endpoint /tabledap/{datasetID}.{format} ### Parameters #### Path Parameters - **datasetID** (string) - Required - The unique identifier for the dataset. - **format** (string) - Required - The desired output format (e.g., csv, json, html). #### Query Parameters - **query** (string) - Optional - Constraints to filter the data (e.g., time>=2023-01-01). ### Response #### Success Response (200) - **data** (array) - The requested dataset records. ``` -------------------------------- ### Download Data Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Fetch the data into a pandas DataFrame. ```python df = e.to_pandas() print(df.head()) ``` -------------------------------- ### Initialize ERDDAP Client for Griddap Source: https://ioos.github.io/erddapy/01a-griddap-output.html Instantiate the ERDDAP client specifying the server URL and setting the protocol to 'griddap'. The dataset_id should be set to the desired griddap dataset. ```python from erddapy import ERDDAP e = ERDDAP( server="https://pae-paha.pacioos.hawaii.edu/erddap", protocol="griddap", ) e.dataset_id = "etopo5_lon180" ``` -------------------------------- ### Instantiate ERDDAP Connection Source: https://ioos.github.io/erddapy/00-quick_intro-output.html Initialize the ERDDAP object with a server URL, protocol, and response format. ```python from erddapy import ERDDAP server = "https://erddap.sensors.ioos.us/erddap" e = ERDDAP( server=server, protocol="tabledap", response="csv", ) ``` -------------------------------- ### Get ERDDAP Categorize URL Source: https://ioos.github.io/erddapy/_modules/erddapy/erddapy.html Generates a URL to categorize datasets based on a specified attribute and value. ```APIDOC ## GET /erddap/categorize ### Description Build the categorize URL for the `server` endpoint. This method allows users to categorize datasets based on ERDDAP attributes like `ioos_category` or `standard_name`. ### Method GET ### Endpoint /erddap/categorize ### Parameters #### Query Parameters - **categorize_by** (str) - Required - A valid ERDDAP attribute to categorize by (e.g., `ioos_category`, `standard_name`). - **value** (str) - Optional - A specific value of the `categorize_by` attribute to filter by. - **response** (str) - Optional - The desired response format (e.g., HTML, JSON). Defaults to HTML. ### Request Example ```json { "categorize_by": "ioos_category", "value": "Ocean Temperature", "response": "JSON" } ``` ### Response #### Success Response (200) - **url** (str) - The constructed URL for the categorization query. ``` -------------------------------- ### Download and explore data with to_pandas Source: https://ioos.github.io/erddapy/_sources/00-quick_intro-output.ipynb.txt Download data for a specific dataset ID, variables, and constraints, then load it into a pandas DataFrame for exploration. This method retrieves data in CSV format with units. ```python e.to_pandas( datasetid="all", variables=[ "latitude (degrees_north)", "longitude (degrees_east)", "sea_water_temperature (degree_Celsius)", "air_temperature (degree_Celsius)", ], constraints={ "time>=": "2005-11-14T23:00:40Z", "time<=": "2005-11-15T07:00:40Z", }, limit=1000, chunksize=1000, ) ``` -------------------------------- ### List Available ERDDAP Server Shortcuts Source: https://ioos.github.io/erddapy/erddapy.html Retrieve a dictionary of available ERDDAP server acronyms and their corresponding URLs. This is helpful for discovering and using shorthand server names. ```python from erddapy import servers {k: v.url for k, v in servers.items()} ``` -------------------------------- ### Download Data as a Pandas DataFrame Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Download data directly into a Pandas DataFrame using `to_pandas`. This is convenient for immediate data analysis. ```python from erddapy import ERDDAP e = ERDDAP(server='https://erddapy.com/erddap/') df = e.to_pandas(datasetid='erdAP_all', variables=['time', 'latitude', 'longitude', 'temperature'], limit=1000, orderbys='time') print(df.head()) ``` -------------------------------- ### Download Data as Pandas DataFrame Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Fetch the data from the server and load it directly into a pandas DataFrame. ```python import pandas as pd df = e.to_pandas( index_col="time (UTC)", parse_dates=True, ).dropna() ``` -------------------------------- ### Download Dataset as Pandas DataFrame Source: https://ioos.github.io/erddapy/00-quick_intro-output.html Configure dataset ID, variables, and constraints to download data into a pandas DataFrame. ```python e.dataset_id = "org_cormp_cap2" e.variables = [ "time", "latitude", "longitude", "sea_water_temperature", "air_temperature", ] e.constraints = { "time>=": "2000-01-01", } df = e.to_pandas( index_col="time (UTC)", parse_dates=True, ).dropna() df.head() ``` -------------------------------- ### Get ERDDAP Info URL Source: https://ioos.github.io/erddapy/_modules/erddapy/erddapy.html Constructs a URL to retrieve information about a specific dataset or a list of all datasets from an ERDDAP server. ```APIDOC ## GET /erddap/info ### Description Build the info URL for the `server` endpoint. This method can be used to get metadata for a specific dataset or a listing of all available datasets if `dataset_id` is not provided. ### Method GET ### Endpoint /erddap/info ### Parameters #### Query Parameters - **dataset_id** (str) - Optional - The unique identifier of the dataset. If omitted, a listing of all datasets will be returned. - **response** (str) - Optional - The desired response format (e.g., HTML, JSON, XML). Defaults to HTML. ### Request Example ```json { "dataset_id": "erdPMdata", "response": "JSON" } ``` ### Response #### Success Response (200) - **url** (str) - The constructed URL for retrieving dataset information. ``` -------------------------------- ### Build Download URL with Constraints Source: https://ioos.github.io/erddapy/erddapy.html Generate a URL to download specific data variables from a dataset, applying constraints on dimensions like latitude, longitude, and time. Supports both absolute and relative time constraints. ```python constraints = { 'latitude<=': 41.0, 'latitude>=': 38.0, 'longitude<=': -69.0, 'longitude>=': -72.0, 'time<=': '2017-02-10T00:00:00+00:00', 'time>=': '2016-07-10T00:00:00+00:00', } e.get_download_url(dataset_id='dataset-id', constraints=constraints, variables=['temperature', 'salinity'], response='netcdf') ``` ```python constraints = { 'time>': 'now-7days', 'latitude<': 'min(longitude)+180', 'depth>': 'max(depth)-23', } e.get_download_url(dataset_id='dataset-id', constraints=constraints, variables=['temperature', 'salinity'], response='netcdf') ``` -------------------------------- ### Handle Different ERDDAP Servers Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt The `ERDDAP` class can be initialized with different server URLs to access data from various ERDDAP instances. ```python from erddapy import ERDDAP # Example with a different ERDDAP server e = ERDDAP(server='https://data.nodc.noaa.gov/erddap/') df = e.search(keyword='sst') print(df.head()) ``` -------------------------------- ### Fetch OPeNDAP URL and summary Source: https://ioos.github.io/erddapy/02-extras-output.html Retrieve the OPeNDAP URL for a dataset and print its summary. Ensure the protocol is set to 'tabledap' and dataset_id is specified. ```python from netCDF4 import Dataset e.constraints = None e.protocol = "tabledap" e.dataset_id = "whoi_406-20160902T1700" opendap_url = e.get_download_url( response="opendap", ) print(opendap_url) with Dataset(opendap_url) as nc: print(nc.summary) ``` -------------------------------- ### POST /download_file Source: https://ioos.github.io/erddapy/_modules/erddapy/erddapy.html Downloads a dataset to a local file in a specified format. ```APIDOC ## POST /download_file ### Description Downloads the dataset associated with the current instance to a local file using the specified file format. ### Parameters #### Request Body - **file_type** (str) - Required - The format of the file to download (e.g., 'csv', 'nc'). ### Response #### Success Response (200) - **file_name** (str) - The path to the downloaded file. ``` -------------------------------- ### ERDDAP Class Initialization Source: https://ioos.github.io/erddapy/erddapy.html Initializes an ERDDAP instance for a specific server endpoint. ```APIDOC ## ERDDAP Initialization ### Description Creates an ERDDAP instance for a specific server endpoint. ### Parameters - **server** (str) - Required - An ERDDAP server URL or acronym. - **protocol** (str) - Optional - tabledap or griddap. - **response** (str) - Optional - Default is HTML. ### Request Example ```python e = ERDDAP(server="https://gliders.ioos.us/erddap") ``` ``` -------------------------------- ### URL Opener Wrapper Source: https://ioos.github.io/erddapy/_modules/erddapy/core/url.html A thin wrapper around httpx.get content. It includes a workaround for opendap.co-ops.nos.noaa.gov to ensure date variables are in the correct order. Optionally quotes the URL. ```python def urlopen( url: str, *, quote: bool = True, requests_kwargs: dict | None = None, ) -> BinaryIO: """Thin wrapper around httpx get content. See httpx.get docs for the `params` and `kwargs` options. """ # This is a horrible hack to work around opendap.co-ops.nos.noaa.gov. # The co-ops serve require variable in a specific order to work. date_string = ("BEGIN_DATE", "END_DATE") if "opendap.co-ops.nos.noaa.gov" in url: dates, base = [], [] for part in url.split("&"): if part.startswith(date_string): dates.append(part) else: base.append(part) url = "&".join(base + dates) if requests_kwargs is None: requests_kwargs = {} if quote: url = quote_url(url) data = _urlopen(url, **requests_kwargs) data.seek(0) return data ``` -------------------------------- ### Define ERDDAP constraints Source: https://ioos.github.io/erddapy/_modules/erddapy/erddapy.html Examples of dictionary-based constraints for filtering data, including absolute values and relative time or coordinate expressions. ```python constraints = { 'latitude<=': 41.0, 'latitude>=': 38.0, 'longitude<=': -69.0, 'longitude>=': -72.0, 'time<=': '2017-02-10T00:00:00+00:00', 'time>=': '2016-07-10T00:00:00+00:00', } ``` ```python constraints = { 'time>': 'now-7days', 'latitude<': 'min(longitude)+180', 'depth>': 'max(depth)-23', } ``` -------------------------------- ### Initialize ERDDAP Client with OPeNDAP Protocol Source: https://ioos.github.io/erddapy/01a-griddap-output.html Initializes an ERDDAP client to access data using the OPeNDAP protocol, suitable for large datasets or post-request subsetting. Specify the server URL, protocol, and response format. ```python e = ERDDAP( server="https://pae-paha.pacioos.hawaii.edu/erddap", protocol="griddap", response="opendap", ) e.dataset_id = "etopo5_lon180" ``` -------------------------------- ### Instantiate ERDDAP Client for Griddap Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Initializes an ERDDAP client specifically for accessing gridded data using the 'griddap' protocol. Ensure the server URL and dataset ID are correct for your target dataset. ```python from erddapy import ERDDAP e = ERDDAP( server="https://pae-paha.pacioos.hawaii.edu/erddap", protocol="griddap", ) e.dataset_id = "etopo5_lon180" ``` -------------------------------- ### Download Data with Specific Variables Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Select only the variables you need from a dataset to reduce download size and processing time. Check dataset documentation for available variable names. ```python from erddapy import ERDDAP e = ERDDAP(server='https://erddap.sensors.ioos.us/erddap/') df = e.download( datasetid='ac97_1118_1440', response='csv', variables=['time', 'temperature', 'salinity'] ) print(df.head()) ``` -------------------------------- ### Search Datasets Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Demonstrates how to search for datasets available through ERDDAP using keywords. ```APIDOC ## Search Datasets ### Description This endpoint allows you to search for ERDDAP datasets based on a query string. ### Method GET ### Endpoint /erddap/find/index.json ### Query Parameters - **page_number** (integer) - Optional - The page number of the search results. - **items_per_page** (integer) - Optional - The number of items to return per page. - **query** (string) - Required - The search query string. ### Request Example ``` GET /erddap/find/index.json?query=temperature ``` ### Response #### Success Response (200) - **datasets** (array) - A list of datasets matching the query. - **title** (string) - The title of the dataset. - **id** (string) - The unique identifier of the dataset. - **url** (string) - The URL to access the dataset. #### Response Example ```json { "datasets": [ { "title": "Sea Surface Temperature (SST) Data", "id": "sst_data", "url": "/erddap/info/sst_data/index.html" } ] } ``` ``` -------------------------------- ### Download Data as CSV Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Download data from a dataset in CSV format. Specify the desired variables and constraints for the download. ```python e.download(datasetid='ac9f_d7c1_177c', response='csv', variables=['time', 'latitude', 'longitude', 'sea_surface_temperature'], griddap_limit=1000000, gridID='grid', time={'gt': '2020-01-01T00:00:00Z'}, lat={'gt': 40, 'lt': 50}, lon={'gt': -130, 'lt': -120}) ``` -------------------------------- ### Open URL with httpx Source: https://ioos.github.io/erddapy/_modules/erddapy/core/url.html Opens a URL using httpx.get, following redirects and setting a default timeout of 60 seconds. Raises httpx.HTTPError for non-2xx status codes, including the response content in the error message. ```python def _urlopen(url: str, auth: tuple | None = None, **kwargs: dict) -> BinaryIO: if "timeout" not in kwargs: kwargs["timeout"] = 60 response = httpx.get( url, follow_redirects=True, auth=auth, **kwargs, ) try: response.raise_for_status() except httpx.HTTPError as err: msg = str(response.content.decode()) raise httpx.HTTPError(msg) from err return io.BytesIO(response.content) ``` -------------------------------- ### Get Dataset Table Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Retrieve the metadata table for a specific dataset ID. This table contains information about the dataset's variables, constraints, and other properties. ```python e.get_dataset_table('erdPMdata') ``` -------------------------------- ### ERDDAP Class Initialization Source: https://ioos.github.io/erddapy/_modules/erddapy/erddapy.html Initializes an ERDDAP instance for a specific server endpoint and protocol. ```APIDOC ## ERDDAP Class ### Description Creates an ERDDAP instance for a specific server endpoint. ### Parameters #### Path Parameters * **server** (str) - Required - An ERDDAP server URL or acronym for builtin servers. * **protocol** (Optional[str]) - Optional - 'tabledap' or 'griddap'. * **response** (str) - Optional - Default is 'html'. ### Attributes * **server**: The ERDDAP server URL. * **protocol**: ERDDAP's protocol (tabledap/griddap). * **response**: Default is HTML. * **dataset_id**: A dataset unique id. * **variables**: A list of variables to download. * **constraints**: Download constraints, default None (opendap-like url). * **params and requests_kwargs**: `httpx.get` options. ### Request Example ```python from erddapy import ERDDAP # Specifying the server URL e = ERDDAP(server="https://gliders.ioos.us/erddap") # Using a server acronym e_secoora = ERDDAP(server="SECOORA") ``` ### Response Example ```json { "instance": "ERDDAP URL builder instance" } ``` ``` -------------------------------- ### Construct ERDDAP Download URL Source: https://ioos.github.io/erddapy/_modules/erddapy/core/url.html Function logic for building a download URL based on protocol, dataset ID, variables, and constraints. ```python if not dataset_id: msg = f"Please specify a valid `dataset_id`, got {dataset_id}" raise ValueError(msg) if not protocol: msg = f"Please specify a valid `protocol`, got {protocol}" raise ValueError(msg) if ( protocol == "griddap" and constraints is not None and variables is not None and dim_names is not None ): download_url = [ server, "/", protocol, "/", dataset_id, ".", response, "?", ] for var in variables: sub_url = [var] sub_url.extend( f"[({constraints[dim + '>=']}):" f"{constraints[dim + '_step']}:" f"({constraints[dim + '<=']})]" for dim in dim_names ) sub_url.append(",") download_url.append("".join(sub_url)) return "".join(download_url)[:-1] # This is an unconstrained OPeNDAP response b/c # the integer based constrained version is just not worth supporting ;-p if response == "opendap": return f"{server}/{protocol}/{dataset_id}" url = f"{server}/{protocol}/{dataset_id}.{response}?" if variables: url += ",".join(variables) if constraints: _constraints = copy.copy(constraints) for k, v in _constraints.items(): if _check_substrings(v): continue # The valid operators are =, != (not equals), # =~ (a regular expression test), <, <=, >, and >= valid_time_constraints = ( "time=", "time!=", "time=~", "time<", "time<=", "time>", "time>=", ) if k.startswith(valid_time_constraints): _constraints.update({k: parse_dates(v)}) _constraints = _quote_string_constraints(_constraints) _constraints_url = _format_constraints_url(_constraints) url += _constraints_url return _distinct(url, distinct=distinct) ``` -------------------------------- ### Download Data as Excel Source: https://ioos.github.io/erddapy/_sources/01a-griddap-output.ipynb.txt Download data in Excel format. This is convenient for users who prefer to analyze data using spreadsheet software. ```python from erddapy import ERDDAP e = ERDDAP(server='https://data.ioos.us/erddap/') e.download( datasetid='erdSS19990301t090000d000000', search_max_results=1, response='xls', latitude=(30, 40), longitude=(-130, -120), time=(1999, 1, 1, 2000, 1, 1) ) ```