Aquarius Data#

Very simple program, just mapping some salinity data from Aqarius (available in the RIDDC ERDDAP server). This code is a good starting point for learning how to work with the ERDDAP data through a Python notebook.

#the following installations and imports are necessary to run the program (once the installations are done they can be commented out): 
!pip install netCDF4
!pip install erddapy
!apt install libproj-dev proj-data proj-bin
!apt-get install libgeos-dev
!pip install cython
!pip install cartopy
!pip install display
from netCDF4 import Dataset as NetCDFFile 
import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs

3 month data

#this cell does mapping for the 3 month Aquarius data
mydata = NetCDFFile('https://pricaimcit.services.brown.edu/erddap/griddap/jplAquariusSSS3MonthV5') #this gets the data from ERDDAP
#the first part of the url is 'https://pricaimcit.services.brown.edu/erddap'. That's just the riddc erddap webpage.
#the second part of the url is '/griddap'. That tells it whether you want gridded or tabular data (for tabular it would be '/tabledap')
#the third part of the url is '/jplAquariusSSS3MonthV5', which gives the Dataset ID
#the following lines define some data variables:
lat = mydata.variables['latitude'][:]
lon = mydata.variables['longitude'][:]
time = mydata.variables['time'][:]
sss = mydata.variables['sss'][:]
#plotting:
plt.figure(1)
plt.pcolor(lon,lat,sss[0,:,:])
<matplotlib.collections.PolyCollection at 0x7fb4f7fcab00>
../../_images/5260ed44de891df01975a5f6ae03422f95d09b69a6969b21a0dcb7fe10628bf4.png

7 Day data

#this cell does mapping for the 7 day Aquarius data
mydata = NetCDFFile('https://pricaimcit.services.brown.edu/erddap/griddap/jplAquariusSSS7DayV5')
lat = mydata.variables['latitude'][:]
lon = mydata.variables['longitude'][:]
time = mydata.variables['time'][:]
sss = mydata.variables['sss'][:]
plt.figure(1)
plt.pcolor(lon,lat,sss[0,:,:])
<matplotlib.collections.PolyCollection at 0x7fb4f6f2c198>
../../_images/7a3da8eacfd63fa6c0b5513e88ed9198ef9e9103b1b3c48a262e3f42696ee461.png

Daily data

#this cell does mapping for the daily Aquarius data
mydata = NetCDFFile('https://pricaimcit.services.brown.edu/erddap/griddap/jplAquariusSSSDailyV5')
lat = mydata.variables['latitude'][:]
lon = mydata.variables['longitude'][:]
time = mydata.variables['time'][:]
sss = mydata.variables['sss'][:]
plt.figure(1)
plt.pcolor(lon,lat,sss[0,:,:])
<matplotlib.collections.PolyCollection at 0x7fb4f5cb6668>
../../_images/e3f8ae0deba552943cb778412b1a8eb4f7d9ed2c0ab715c5fde7d41c375d099c.png

Monthly data

#this cell does mapping for the monthly Aquarius data
mydata = NetCDFFile('https://pricaimcit.services.brown.edu/erddap/griddap/jplAquariusSSSMonthlyV5')
lat = mydata.variables['latitude'][:]
lon = mydata.variables['longitude'][:]
time = mydata.variables['time'][:]
sss = mydata.variables['sss'][:]
plt.figure(1)
Image = plt.pcolor(lon,lat,sss[0,:,:])
../../_images/fead4c64948edff68d1f52aad0fdf4e37aa27ce85c1dfe9a04283d4b837b441d.png