argovis Python API

Python API to

This post is the first part of a three-part series into argovis.

  1. Argovis api introduces my website, and how users can access data using a python API.
  2. Linear time series analysis in R shows how time series models can be used to fit ocean temperatures from Argo data.
  3. Linear time series model fitting in python gives further detail on how non-linear least squares fitting is typically done on time series.

For over a decade, the ARGO program has provided temperature, salinity and pressure data (T/S/P) on a global scale for depths as far as 2000 dbar, with unprecedented spatial and temporal resolution and no seasonal bias. Close to two million profiles have been collected and made publicly available on Argo’s Global Data Assembly Centres (GDACs) on FTP servers. Unfortunately, online tools for selection and visualization of this big data set are limited slow to access.

In response, a webapp attempts to improve data access. Overall, this website offers seamless navigation of the Argo dataset. Argo now has a maintainable, scalable, and portable tool written with representational state transfer (REST) architecture. RESTful design offers us the opportunity to feature cloud computing applications; chiefly, map comparison from existing gridded Argo products, as well as parameter estimation such as basin mean T/S/P.

The following code is an interface to HTTP 'get' requests access the web app's database, similar to a browser; however, there is no HTML or javascript. Essentially, this interface is used to query the same database that builds the website. The idea behind this approach is that we no longer rely on the browser to handle queries.

This script will guide a python user to:

1. Query a specific profile its id, designated by its platform (WMO) number with its cycle number, connected by an underscore. For example '3900737_9'

2. Query a specified platform by number. Example '3900737'.

3.1 Query profiles within a given shape, date range, and pressure range.

3.2 Query profiles position, date, and cycle number within month and year.

4. Plot query results

5. Create time series given for a selection and set of dates.

6. Query database using a gridded scheme

7. Plot gridded data using Cartopy and Basemap Libraries

Firstly, following libraries are called

In [1]:
import requests
import pandas as pd
import numpy as np
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
import plotly.graph_objs as go
import cmocean
import matplotlib.pylab as plt
from scipy.interpolate import griddata
from datetime import datetime
import pdb
import os

# depreciated but still usefull.
from mpl_toolkits.basemap import Basemap

#used for map projections
from netCDF4 import Dataset as netcdf_dataset
from cartopy import config
import as ccrs

%matplotlib inline

#sets plot styles
import seaborn as sns
from matplotlib import rc
from matplotlib import rcParams
import matplotlib.ticker as mtick
rc('text', usetex=False)
rcStyle = {"font.size": 10,
           "axes.titlesize": 20,
           "axes.labelsize": 20,
           'xtick.labelsize': 16,
           'ytick.labelsize': 16}
sns.set_context("paper", rc=rcStyle)
sns.set_style("whitegrid", {'axes.grid' : False})
myColors = ["windows blue", "amber", "dusty rose", "prussian blue", "faded green", "dusty purple", "gold", "dark pink", "green", "red", "brown"]
colorsBW = ["black", "grey"]

curDir = os.getcwd()
docDir = os.path.join(curDir, 'docs', 'argo')