oceans.RPSstuff

oceans.RPSstuff.angled(h)[source]
ANGLED: Returns the phase angles in degrees of a matrix with complex

elements.

Usage:

deg = angled(h) h = complex matrix deg = angle in math convention (degrees counterclockwise from “east”)

oceans.RPSstuff.coast2bln(coast, bln_file)[source]

Converts a matlab coast (two column array w/ nan for line breaks) into a Surfer blanking file.

Where coast is a two column vector and bln_file is the output file name.

Needs fixcoast.

oceans.RPSstuff.fixcoast(coast)[source]

FIXCOAST Makes sure coastlines meet Signell’s conventions.

Fixes coastline is in the format we want. Assumes that lon/lat are in the first two columns of the matrix coast, and that coastline segments are separated by rows of NaNs (or -99999s). This routine ensures that only 1 row of NaNs separates each segment, and makes sure that the first and last rows contain NaNs.

oceans.RPSstuff.gmax(x, **kw)[source]

Just like max, except that it skips over bad points.

oceans.RPSstuff.gmean(x, **kw)[source]

Just like mean, except that it skips over bad points.

oceans.RPSstuff.gmedian(x, **kw)[source]

Just like median, except that it skips over bad points.

oceans.RPSstuff.gmin(x, **kw)[source]

Just like min, except that it skips over bad points.

oceans.RPSstuff.gregorian(jd, noon=False)[source]

Converts decimal Julian days to Gregorian dates using the astronomical conversion, but with time zero starting at midnight instead of noon. In this convention, Julian day 2440000 begins at 0000 hours, May 23, 1968. The Julian day does not have to be an integer, and with Matlab’s double precision, the accuracy of decimal days is about 0.1 milliseconds.

INPUT: jd = decimal Julian days

OUTPUT: gtime = six column Gregorian time matrix, where each row is: [yyyy mo da hr mi sec]. yyyy = year (e.g., 1979) mo = month (1-12) da = day (1-31) hr = hour (0-23) mi = minute (0-59) sec = decimal seconds example: [1990 12 12 0 0 0] is midnight on Dec 12, 1990.

Examples

>>> gregorian(2440000)
array([[1968.,    5.,   23.,    0.,    0.,    0.]])

AUTHOR: Rich Signell (rsignell@usgs.gov)

oceans.RPSstuff.gstd(x, **kw)[source]

Just like std, except that it skips over bad points.

oceans.RPSstuff.gsum(x, **kw)[source]

Just like sum, except that it skips over bad points.

oceans.RPSstuff.h2hms(hours)[source]

Converts hours to hours, minutes, and seconds.

Examples

>>> h2hms(12.51)
(np.float64(12.0), np.float64(30.0), np.float64(36.0))
oceans.RPSstuff.hms2h(h, m=None, s=None)[source]

Converts hours, minutes, and seconds to hours.

Examples

>>> hms2h(12.0, 30.0, 36.0)
12.51
>>> # Or,
>>> hms2h(123036)
np.float64(12.51)
oceans.RPSstuff.ij2ind(a, i, j)[source]
oceans.RPSstuff.ind2ij(a, ind)[source]

ind2ij returns i, j indices of array.

oceans.RPSstuff.jdmat2jdrps(jdmat)[source]

Convert Matlab’s Serial Day to Signell’s Julian days matlab’s serial date = 1 at 0000 UTC, 1-Jan-0000.

Examples

>>> jdmat2jdrps(718941)
array([2440000.])
oceans.RPSstuff.jdrps2jdmat(jd)[source]

Convert Signell’s Julian days to Matlab’s Serial day matlab’s serial date = 1 at 0000 UTC, 1-Jan-0000.

Examples

>>> jdrps2jdmat(2440000)
array([718941.])
oceans.RPSstuff.julian(y, m=0, d=0, h=0, mi=0, s=0, noon=False)[source]

Converts Gregorian calendar dates to Julian dates

USAGE: [j]=julian(y,m,d,h)

DESCRIPTION: Converts Gregorian dates to decimal Julian days using the

astronomical conversion, but with time zero starting at midnight instead of noon. In this convention, Julian day 2440000 begins at 0000 hours, May 23, 1968. The decimal Julian day, with double precision, yields an accuracy of decimal days of about 0.1 milliseconds.

If you want Julian days to start and end at noon set noon to True.

INPUT: y : year (e.g., 1979) component m : month (1-12) component d : day (1-31) component of Gregorian date hour : hours (0-23) min : minutes (0-59) sec : decimal seconds or h : decimal hours (assumed 0 if absent)

OUTPUT: j : decimal Julian day number

last revised 1/3/96 by Rich Signell (rsignell@usgs.gov)

Examples

>>> julian(1968, 5, 23, 0)
array([2440000.])
oceans.RPSstuff.lagcor(a, b, n)[source]

Finds lagged correlations between two series. a and b are two column vectors n is range of lags cor is correlation as fn of lag.

oceans.RPSstuff.ms2hms(millisecs)[source]

Converts milliseconds to integer hour, minute, seconds.

Examples

>>> ms2hms(1e3 * 60)
(np.float64(0.0), np.float64(1.0), np.float64(0.0))
oceans.RPSstuff.near(x, x0, n=1)[source]

Given an 1D array x and a scalar x0, returns the n indices of the element of x closest to x0.

oceans.RPSstuff.rms(u)[source]

Compute root mean square for each column of matrix u.

oceans.RPSstuff.s2hms(secs)[source]

Converts seconds to integer hour,minute,seconds Usage: hour, min, sec = s2hms(secs)

Examples

>>> s2hms(3600 + 60 + 1)
(np.float64(1.0), np.float64(1.0), np.int64(1))
oceans.RPSstuff.shift(a, b, n)[source]

a and b are vectors n is number of points of a to cut off anew and bnew will be the same length.

oceans.RPSstuff.short_calc(amin, amax)[source]
oceans.RPSstuff.ss2(jd)[source]

Return Gregorian start and stop dates of Julian day variable Usage: start, stop = ss2(jd)

oceans.RPSstuff.swantime(a)[source]

Converts SWAN default time format to datetime object.

oceans.RPSstuff.z0toCn(z0, H)[source]

Convert roughness height z0 to Chezy “C” and Manning’s “n” which is a function of the water depth

Inputs:

z0 = roughness height (meters) H = water depth (meters) (can be vector)

Outputs:

C = Chezy “C” (non-dimensional) n = Manning’s “n” (non-dimensional)

Examples

>>> # finds vectors C and n corresponding to a z0=0.003
>>> # and a range of water depths from 2--200 meters.
>>> C, n = z0toCn(0.003, np.arange(2, 200))
oceans.RPSstuff.z0tocd(z0, zr)[source]

Calculates CD at a given ZR corresponding to Z0.