Utility functions

theta, rho = cart2pol(x, y; deg=false)

Transform Cartesian to polar coordinates. Angles are returned in radians by default. Use deg=true to return the angles in degrees. Input can be scalar, vectors or matrices.

az, elev, rho = cart2sph(x, y, z; deg=false)

Transform Cartesian coordinates to spherical. Angles are returned in radians by default. Use deg=true to return the angles in degrees. Input can be scalar, vectors or matrices.

date2doy(date) -> Integer

Compute the Day-Of-Year (DOY) from date that can be a string or a Date/DateTime type. If ommited, returns today's DOY

delrows!(A::Matrix, rows::VecOrMat)

Delete the rows of Matrix A listed in the vector rows

D = df2ds(df)

Extract numeric data from a DataFrame type and return it into a GMTdataset. Works only with 'simple' DataFrames.

doy2date(doy[, year]) -> Date

Compute the date from the Day-Of-Year doy. If year is ommited we take it to mean the current year. Both doy and year can be strings or integers.

u, ind = gunique(x::AbstractVector; sorted=false)

Return an array containing only the unique elements of x and the indices ind such that u = x[ind]. If sorted is true the output is sorted (default is not)

isnodata(array::AbstractArray, val=0)

Return a boolean array with the same size a array with 1's (true) where $array[i] == val$. Test with an image have shown that this function was 5x faster than $ind = (I.image .== 0)$

M = magic(n::Int) => Matrix{Int}

M = magic(n) returns an n-by-n matrix constructed from the integers 1 through n^2 with equal row and column sums. The order n must be a scalar greater than or equal to 3 in order to create a valid magic square.

D = ODE2ds(sol; interp=0)

Extract data from a DifferentialEquations solution type and return it into a GMTdataset.

• interp: == 0 means we return the original points (no interpolation). == 2 => do data interpolation to the double of original number of points. == 3 => three times, == n => n times.

plotyy(arg1, arg2; kwargs...)

Example:

plotyy([1 1; 2 2], [1.5 1.5; 3 3], R="0.8/3/0/5", title="Ai", ylabel=:Bla, xlabel=:Ble, seclabel=:Bli, show=1)
x, y = pol2cart(theta, rho; deg=false)

Transform polar to Cartesian coordinates. Angles are in radians by default. Use deg=true if angles are in degrees. Input can be scalar, vectors or matrices.

regiongeog(GI)::Tuple

Returns a tuple with (lonmin, lonmax, latmin, latmax) of the projected GI object limits converted to geographic coordinates. Returns an empty tuple if GI has no registered referencing system. GI can either a GMTgrid, a GMTimage or a file name (String) of one those types.

x, y, z = sph2cart(az, elev, rho; deg=false)

Transform spherical coordinates to Cartesian. Angles are in radians by default. Use deg=true if angles are in degrees. Input can be scalar, vectors or matrices.

tern2cart(abcz::Matrix{<:Real}, reverse::Bool=false)

Converts ternary to cartesian units.

abcz is either a Mx3 (a,b,c) or Mx4 (a,b,c,z) matrix

ind = uniqueind(x)

Return the index ind such that x[ind] gets the unique values of x. No sorting is done

angles, ind = vecangles(lonlat0::VecOrMat{Real}, lonlat1::Matrix{Real}; proj::String="",
s_srs::String="", epsg::Integer=0, sorted=true)

Computes the angles between lines taken from the central point lonlat0 and those passed in the Mx2 matrix lonlat1.

Args:

• lonlat1: - coordinates of point 1 in the given projection (or a matrix with several points).

• lonlat2: - coordinates of point 2 in the given projection (or a matrix with same size as lonlat1).

• proj or s_srs: - the given projection whose ellipsoid we move along. Can be a proj4 string or an WKT.

• epsg: - Alternative way of specifying the projection [Default is WGS84].

• sorted: - By default we sort the lines azimuth so that the angles refer to contiguous line. If sorted is set to false we compute the angles in the order of points as given in lonlat2.

Returns

• angles - A Float64 vector with the angles between center and points determined by the arguments plus the angle betwen the lines from center to first and from center to last point.

• ind - A vector of Int with the order obtained by sorting the lines azimuths (when sorted=true). Apply it to lonlat2[ind,:] to get the point distribution order in the same way as angles. Neddless, ofc, if sorted=false.

yeardecimal(date)

Convert a Date or DateTime or a string representation of them to decimal years.

Example

yeardecimal(now())