demo/detectFronts.R

rm(list = ls()); gc(reset = TRUE)
# Detect fronts --------------------------------------------------------------------------

# Load example data
data(sst)
exampleSSTData <- list(x = sst$longitude,
                       y = sst$latitude,
                       z = sst$sst[,,1])

# Apply detectFronts function
out <- detectFronts(x = exampleSSTData)
str(out)

# Make plots -----------------------------------------------------------------------------

# Define axis values
xAxis <- seq(min(out$x), max(out$x), 5)
yAxis <- seq(min(out$y), max(out$y), 2)

# Set plot parameters
par(xaxs = "i", yaxs = "i", mar = rep(0, 4), oma = c(2, 3, 1, 3), mfrow = c(1, 2))

# Plot original map
image(exampleSSTData, axes = FALSE, col = colPalette); box()
mtext(text = "Original", side = 3, line = -2, adj = 0.99, cex = 1.2, font = 2)
mtext(text = "SST, Aqua MODIS, Monthly Composite\nMarch, 2010\n[85\u00b0 W - 70\u00b0 W] [20\u00b0 S - 0\u00b0 S]",
      side = 3, line = -8, adj = 0.99)
axis(side = 1, at = xAxis, labels = paste(abs(xAxis), "\u00b0W"))
axis(side = 2, at = yAxis, labels = paste(abs(yAxis), "\u00b0S"), las = 2)

# Plot gradient map
out$z <- log10(out$z)
image(out, axes = FALSE, col = colPalette); box()
mtext(text = "Gradient", side = 3, line = -2, adj = 0.99, cex = 1.2, font = 2)
axis(side = 1, at = xAxis, labels = paste(abs(xAxis), "\u00b0W"))

Try the grec package in your browser

Any scripts or data that you put into this service are public.

grec documentation built on Sept. 21, 2018, 6:16 p.m.