Handy python utilities
import airy
Functions for linear wave theory, including celerity, energy density, and group velocity
import djn
Useful little tidbits:
uv2sd()
convert east, north components to speed, directionsd2uv()
convert speed, direction, to east, north componentsboxoff()
a Matlab-likebox off
function for matplotlibtwinboxoff()
a Matlab-likebox off
function for matplotlib with twin y axesthinspines()
make thinner matplotlib plot spines (default linewidth 0.5)find_nearest()
find nearest value to the requested value in a numpy arraymiddles()
given a vector of bin edges of length n, make a vector of the middle values with length n-1.show()
likeplt.show()
but for plotly. Makes it easy to turn a matplotlib plot into a plotly plot.set_fontsize()
set fontsize of all elements of a figure, likedjn.set_fontsize(plt.gcf(), 14)
getcols()
return default color order for matplotlib plotsnextcolor()
return the next color in the default matplotlib color ordersplabel()
plot a subplot letter label like "(a)" in figuressiegel()
compute robust regression using repeated medians, following Siegel (1982). From Vlad Niculae.princax()
compute principal axis, rotation axis, and principal ellipse for velocity data. From Rich Signell.rot_earth()
rotate vectors u, v by given number of degrees using earthwise coordinates (0=N, 90=E)tidalfilt()
low-pass filter data using a 5th order Butterworth filter. Useful for tidally filtering data.get_nan_block_idxs()
return start and stop indexes of (by default) nan blocks`xcorr()
cross-correlate datahaversine()
calculate the great circle distance in kilometers between two points on the earth (specified in decimal degrees)argmaxn()
return largest N values from arraymath2geo()
,geo2math()
convert from math notation to geographic coordinates (degrees) and vice-versascalebar()
add scalebar to cartopy figure
import matlabtools
Functions to interact with .mat
files created by MATLAB. Some functions based on code originally written by J.Paul Rinehimer.
loadmat()
load.mat
filesavemat()
save.mat
filematlab2datetime()
convert MATLAB serial time to Python datetime, optionally with timezonedatetime2matlab()
convert Python datetime to MATLAB serial time
import mesowest
mesowest_to_xarray()
convert a dictionary of data returned by the MesoPy package to an xarray Dataset
import noaa
get_coops_data()
Read data (water level, air pressure, wind, etc) from NOAA COOPS/Tides and Currents sites via the API as a dictget_long_coops_data()
Read data longer than one month and return as an xarray Dataset
import nwis
nwis_json()
Obtain USGS NWIS data (like water level, discharge, meteorological data, etc) via JSON and return it as a Pandas DataFrame or xarray Datasaet
import wavenumber
A couple of functions to compute wavenumber from linear wave theory