Title: | Visualisation and Analysis of Ocean Data Derived from Satellites |
---|---|
Description: | With 'satin' functions, visualisation, data extraction and further analysis like producing climatologies from several images, and anomalies of satellite derived ocean data can be easily done. Reading functions can import a user defined geographical extent of data stored in netCDF files. Currently supported ocean data sources include NASA's Oceancolor web page <https://oceancolor.gsfc.nasa.gov/>, sensors VIIRS-SNPP; MODIS-Terra; MODIS-Aqua; and SeaWiFS. Available variables from this source includes chlorophyll concentration, sea surface temperature (SST), and several others. Data sources specific for SST that can be imported too includes Pathfinder AVHRR <https://www.ncei.noaa.gov/products/avhrr-pathfinder-sst> and GHRSST <https://www.ghrsst.org/>. In addition, ocean productivity data produced by Oregon State University <http://sites.science.oregonstate.edu/ocean.productivity/> can also be handled previous conversion from HDF4 to HDF5 format. Many other ocean variables can be processed by importing netCDF data files from two European Union's Copernicus Marine Service databases <https://marine.copernicus.eu/>, namely Global Ocean Physical Reanalysis and Global Ocean Biogeochemistry Hindcast. |
Authors: | Héctor Villalobos and Eduardo González-Rodríguez <[email protected]> |
Maintainer: | Héctor Villalobos <[email protected]> |
License: | GPL-3 |
Version: | 1.1.0 |
Built: | 2024-11-02 04:27:15 UTC |
Source: | https://github.com/hvillalo/satin |
This function returns ocean data anomalies of a satin object. Anomalies are calculated subtracting a conforming average satin object.
anomaly(X, Y)
anomaly(X, Y)
X |
a satin object obtained with |
Y |
also a satin object returned by |
The anomalies of a satin object represent, for every pixel, the values above and below a reference average. A typical example can be monthly sea surface temperature anomalies for various years. These are calculated subtracting the corresponding average month for the whole period (see example below).
In principle, anomalies can be calculated for other ocean variables and time periods, but is up to the user to determine if that makes sense. For example, let say that Z
is a satin object with daily chlorophyll-a concentration data for several years. In order to calculate quarterly anomalies, we will need first to obtain X <- satinMean(Z, "%Y-%qtr")
and Y <- satinMean(Z, "%qtr")
.
An object of class "satin"
(see satin-class
for details) where the third dimension in the data array accomodates the calculated anomalies. An extra element (labels
) is included in the slot attribs
to identify the time period of the anomalies.
Héctor Villalobos and Eduardo González-Rodríguez
satinMean
for calculating ocean data averages needed, and climatology
for climatologies.
if(interactive()){ # Calculate monthly sea surface temperature from weekly data. # sst contains 240 weekly images for five years. # This will produce the 12 average months for the five years sst.m <- satinMean(sst, by="%m") # and here we have 60 monthly periods, 12 for each one of the five years sst.ym <- satinMean(sst, by="%Y-%m") # monthly sea surface temperature anomalies anom <- anomaly(X = sst.ym, Y = sst.m) # the dimensions of the data slots in sst.ym and anom are the same. dim(sst.ym@data); dim(anom@data) # plots of the first 24 months lab <- paste(month.name, rep(2014:2018, each=12)) for (m in 1:24){ plot(anom, period = m, zlim=c(-10, 10), col.sep = 0.2, main = lab[m], scheme = c("blue", "cyan", "white", "yellow", "red")) } }
if(interactive()){ # Calculate monthly sea surface temperature from weekly data. # sst contains 240 weekly images for five years. # This will produce the 12 average months for the five years sst.m <- satinMean(sst, by="%m") # and here we have 60 monthly periods, 12 for each one of the five years sst.ym <- satinMean(sst, by="%Y-%m") # monthly sea surface temperature anomalies anom <- anomaly(X = sst.ym, Y = sst.m) # the dimensions of the data slots in sst.ym and anom are the same. dim(sst.ym@data); dim(anom@data) # plots of the first 24 months lab <- paste(month.name, rep(2014:2018, each=12)) for (m in 1:24){ plot(anom, period = m, zlim=c(-10, 10), col.sep = 0.2, main = lab[m], scheme = c("blue", "cyan", "white", "yellow", "red")) } }
This function calculates the percent coverage, mean, standard deviation, minimum and maximum for every pixel in a set of images stored in a single satin data object.
climatology(X, depth = NULL)
climatology(X, depth = NULL)
X |
a satin object as returned by |
depth |
an integer referring to a given depth level. Only meaningful for Copernicus data that includes variables at different depths. |
For Copernicus data files containing more than one variable, the read.cmems
function returns a named list, with elements corresponding to each variable. In order to use these objects with climatology
the appropriate indexing should be applied (see examples below).
An object of class "satin"
(see satin-class
for details) where the third dimension in the data array accomodates coverage, mean, standard deviation, minimum and maximum. Also, an extra element (label
) is included in the slot attribs
to summarize the start and end times used for the climatology.
Héctor Villalobos and Eduardo González-Rodríguez
if(interactive()){ csst <- climatology(sst) # sst is a satin object with 12 monthly images # of sea surface temperature # -- plots -- # coverage plot(csst, period = 1) # mean plot(csst, period = 2) # standard deviation plot(csst, period = 3) # minimum plot(csst, period = 4) # maximum plot(csst, period = 5) } # For Copernicus data data(dcmems) # load sample data names(dcmems) # available variables # mean potential temperature (thetao) at 0.49 m # using labels stored in slot period cthetao1 <- climatology(dcmems$thetao, depth = 1) plot(cthetao1, period = 2, main = cthetao1@period$label[2]) # standard deviation of thetao at 318 m cthetao2 <- climatology(dcmems$thetao, depth = 5) plot(cthetao2, period = 3, main = cthetao1@period$label[3])
if(interactive()){ csst <- climatology(sst) # sst is a satin object with 12 monthly images # of sea surface temperature # -- plots -- # coverage plot(csst, period = 1) # mean plot(csst, period = 2) # standard deviation plot(csst, period = 3) # minimum plot(csst, period = 4) # maximum plot(csst, period = 5) } # For Copernicus data data(dcmems) # load sample data names(dcmems) # available variables # mean potential temperature (thetao) at 0.49 m # using labels stored in slot period cthetao1 <- climatology(dcmems$thetao, depth = 1) plot(cthetao1, period = 2, main = cthetao1@period$label[2]) # standard deviation of thetao at 318 m cthetao2 <- climatology(dcmems$thetao, depth = 5) plot(cthetao2, period = 3, main = cthetao1@period$label[3])
Select and cut a polygon shaped area of interest from a satin object.
crop(X, polygon = NULL, return.poly = FALSE)
crop(X, polygon = NULL, return.poly = FALSE)
X |
a satin object as returned by |
polygon |
a polygon defining the area of interest (aoi) to be cutted. |
return.poly |
if TRUE, |
If provided, the polygon defining the aoi must have two columns with x and y coordinates. The function verifies that the last point is exactly the same as the first one. When not specified, the user can draw a polygon by clicking on a previously displayed image. Note that for drawing the polygon in this manner, the plot of the satin object has to be created using colbar = FALSE
. The result is a satin object where the pixels outside the aoi are set to NA. In order to cut Copernicus data returned from read.cmems
, the appropriate indexing should be previously done.
A cutted satin object.
When return.poly = TRUE
, a list with two components:
aoi |
cutted satin object. |
polygon |
polygon coordinates defining the aoi. |
Héctor Villalobos
# load and display sample data data(dsst) plot(dsst) # define polygon, cut the image and display the aoi polyg <- data.frame(x = c(-110, -105, -113, -116, -110), y = c(23, 23, 32, 32, 23)) dsst.clip <- crop(dsst, polygon = polyg) plot(dsst.clip) if(interactive()){ # the same, but polygon is defined by clicking on the image plot(dsst, colbar = FALSE) dsst.clip2 <- crop(dsst, return.poly = TRUE) # *** draw the aoi polygon *** dsst.clip2$polygon # show polygon coordinates plot(dsst.clip2$aoi) # plot the selected aoi }
# load and display sample data data(dsst) plot(dsst) # define polygon, cut the image and display the aoi polyg <- data.frame(x = c(-110, -105, -113, -116, -110), y = c(23, 23, 32, 32, 23)) dsst.clip <- crop(dsst, polygon = polyg) plot(dsst.clip) if(interactive()){ # the same, but polygon is defined by clicking on the image plot(dsst, colbar = FALSE) dsst.clip2 <- crop(dsst, return.poly = TRUE) # *** draw the aoi polygon *** dsst.clip2$polygon # show polygon coordinates plot(dsst.clip2$aoi) # plot the selected aoi }
Chlorophyll-a concentration (8-day average; 4 km resolution) from March 30 to April 7 2013 off northwest Mexico.
data("dchl")
data("dchl")
Formal class 'satin' [package "satin"] with 6 slots
..@ lon | : num [1:360] -119 -119 -119 -119 -119 ... |
..@ lat | : num [1:360] 20 20.1 20.1 20.1 20.2 ... |
..@ data | : num [1:360, 1:360, 1] 0.0631 0.0696 0.0724 0.0723 0.0705 ... |
..@ attribs: List of 6 | |
.. ..$ title | : chr "HMODISA Level-3 Standard Mapped Image" |
.. ..$ longname | : chr "Chlorophyll Concentration, OCI Algorithm" |
.. ..$ name | : chr "chlor_a" |
.. ..$ units | : chr "mg m^-3" |
.. ..$ temporal_range | : chr "8-day" |
.. ..$ spatial_resolution | : chr "4.64 km" |
..@ period: List of 2 | |
.. ..$ tmStart | : POSIXct[1:1], format: "2013-03-30 00:25:01" |
.. ..$ tmEnd | : POSIXct[1:1], format: "2013-04-07 02:59:59" |
..@ depth | : num(0) |
Source data file (A20130892013096.L3m_8D_CHL_chlor_a_4km.nc) was downloaded from the link below, then imported with the read.nasaoc
function. The selected area covers from 20 to 35 degrees of latitude North and from 119 to 104 degrees of longitude West.
https://oceancolor.gsfc.nasa.gov/cgi/l3
https://oceancolor.gsfc.nasa.gov/docs/technical/
data(dchl) dchl str(dchl) plot(dchl) # plot with logarithmic scale plot(dchl, log = TRUE)
data(dchl) dchl str(dchl) plot(dchl) # plot with logarithmic scale plot(dchl, log = TRUE)
This sample data contains monthly values (November and December 2010) of sea water potential temperature (thetao, degrees C) and sea surface height (zos, m) off northwest Mexico, 1/12 degree horizontal resolution (aprox. 9.26 km).
data("dcmems")
data("dcmems")
List of 2
$ thetao:Formal class 'satin' [package "satin"] with 6 slots
.. ..@ lon | : num [1:181] -119 -119 -119 -119 -119 ... |
.. ..@ lat | : num [1:169] 20 20.1 20.2 20.2 20.3 ... |
.. ..@ data | : num [1:169, 1:181, 1:2, 1:5] 23.5 23.5 23.5 23.4 23.4 ... |
.. ..@ attribs:List of 6 | |
.. .. ..$ title | : chr "thetao" |
.. .. ..$ longname | : chr "Temperature" |
.. .. ..$ name | : chr "thetao" |
.. .. ..$ units | : chr "degrees_C" |
.. .. ..$ temporal_range | : chr "monthly" |
.. .. ..$ spatial_resolution | : chr "9.2 km" |
.. ..@ period :List of 2 | |
.. .. ..$ tmStart | : POSIXct[1:2], format: "2010-11-16 00:00:00" ... |
.. .. ..$ tmEnd | : POSIXct[1:2], format: "2010-11-16 00:00:00" ... |
.. ..@ depth | : num [1:5] 0.494 9.573 29.445 92.326 318.127 |
$ zos :Formal class 'satin' [package "satin"] with 6 slots
.. ..@ lon | : num [1:181] -119 -119 -119 -119 -119 ... |
.. ..@ lat | : num [1:169] 20 20.1 20.2 20.2 20.3 ... |
.. ..@ data | : num [1:169, 1:181, 1:2, 1] 0.336 0.34 0.343 0.345 0.347 ... |
.. ..@ attribs:List of 6 | |
.. .. ..$ title | : chr "zos" |
.. .. ..$ longname | : chr "Sea surface height" |
.. .. ..$ name | : chr "zos" |
.. .. ..$ units | : chr "m" |
.. .. ..$ temporal_range | : chr "monthly" |
.. .. ..$ spatial_resolution | : chr "9.2 km" |
.. ..@ period :List of 2 | |
.. .. ..$ tmStart | : POSIXct[1:2], format: "2010-11-16 00:00:00" ... |
.. .. ..$ tmEnd | : POSIXct[1:2], format: "2010-11-16 00:00:00" ... |
.. ..@ depth | : num 0.494 |
Source data corresponds to Global Ocean Physical Reanalysis database (GLOBAL_REANALYSIS_PHY_001_030), and was downloaded from the link below, then imported with the read.cmems
function. The selected area covers from 20 to 35 degrees of latitude North and from 119 to 104 degrees of longitude West. Potential temperature includes five depth levels (0.494, 9.573, 29.445, 92.326, 318.127).
Fernandez, E. and Lellouche, J. M. 2018 Product Manual for the Global Ocean Physical Reanalysis product, issue 1.1. EU Copernicus Marine Service.
data(dcmems) dcmems plot(dcmems$thetao) # potential temperature at 318 m plot(dcmems$thetao, depth = 5) # sea surface height plot(dcmems$zos)
data(dcmems) dcmems plot(dcmems$thetao) # potential temperature at 318 m plot(dcmems$thetao, depth = 5) # sea surface height plot(dcmems$zos)
Map of northwest Mexico obtained from GSHHG database (v2.3.7).
data("dmap")
data("dmap")
This intermediate resolution map was imported from the Global Self-consistent, Hierarchical, High-resolution Geography Database by means of Rgshhs
function from maptools package.
https://www.soest.hawaii.edu/pwessel/gshhg/gshhg-bin-2.3.7.zip
Wessel, P. and Smith, W. H. F. 1996 A Global Self-consistent, Hierarchical, High-resolution Shoreline Database, Journal of Geophysical Research, 101, 8741–8743.
Rgshhs
library(sp) data(dmap) plot(dmap, xlim=c(-120, -105) , ylim=c(20, 35), xaxs="i", yaxs="i", axes=TRUE, col="beige", lty=1, border="grey70"); box()
library(sp) data(dmap) plot(dmap, xlim=c(-120, -105) , ylim=c(20, 35), xaxs="i", yaxs="i", axes=TRUE, col="beige", lty=1, border="grey70"); box()
Ocean Net Primary Production (8-day average; 9.26 km resolution) from March 30 to April 6 2013 off northwest Mexico.
data("dnpp")
data("dnpp")
Formal class 'satin' [package "satin"] with 6 slots
..@ lon | : num [1:180] -119 -119 -119 -119 -119 ... |
..@ lat | : num [1:180] 20.1 20.1 20.2 20.3 20.4 ... |
..@ data | : num [1:180, 1:180, 1] 285 292 270 279 262 ... |
..@ attribs:List of 6 | |
.. ..$ title | : chr "Ocean Productivity" |
.. ..$ longname | : chr "Ocean Net Primary Production" |
.. ..$ name | : chr "npp" |
.. ..$ units | : chr "mgC m-2 day-1" |
.. ..$ temporal_range | : chr "8 day" |
.. ..$ spatial_resolution | : chr "9.26 km" |
..@ period :List of 2 | |
.. ..$ tmStart | : POSIXct[1:1], format: "2013-03-30" |
.. ..$ tmEnd | : POSIXct[1:1], format: "2013-04-06 23:59:59" |
..@ depth | : num(0) |
Source data file (vgpm.2013089.hdf.gz) was downloaded from the link below, decompressed with gunzip
function from R.utils package, then converted to hdf v5 with h4toh5 Conversion Software (https://support.hdfgroup.org/products/hdf5_tools/h4toh5/download.html) before being imported with the read.osunpp
function. The selected area covers from 20 to 35 degrees of latitude North and from 119 to 104 degrees of longitude West.
http://sites.science.oregonstate.edu/ocean.productivity/standard.product.php
Behrenfeld, M. J. and Falkowski, P. G. 1997 Photosynthetic rates derived from satellite-based chlorophyll concentration, Limnology and Oceanography, 42, 1–20.
data(dnpp) dnpp str(dnpp) plot(dnpp, col.sep = 100)
data(dnpp) dnpp str(dnpp) plot(dnpp, col.sep = 100)
Sea Surface Temperature (4 um nighttime; 8-day average; 4 km resolution) from March 29 to April 6 2013 off northwest Mexico.
data("dsst")
data("dsst")
Formal class 'satin' [package "satin"] with 6 slots
..@ lon | : num [1:360] -119 -119 -119 -119 -119 ... |
..@ lat | : num [1:360] 20 20.1 20.1 20.1 20.2 ... |
..@ data | : num [1:360, 1:360, 1] NA NA NA NA 18.2 ... |
..@ attribs :List of 6 | |
.. ..$ title | : chr "HMODISA Level-3 Standard Mapped Image" |
.. ..$ longname | : chr "4um Sea Surface Temperature" |
.. ..$ name | : chr "sst4" |
.. ..$ units | : chr "degree_C" |
.. ..$ temporal_range | : chr "8-day" |
.. ..$ spatial_resolution | : chr "4.64 km" |
..@ period :List of 2 | |
.. ..$ tmStart | : POSIXct[1:1], format: "2013-03-29 12:05:08" |
.. ..$ tmEnd | : POSIXct[1:1], format: "2013-04-06 14:50:08" |
..@ depth | : num(0) |
Source data file (A20130892013096.L3m_8D_SST4_sst4_4km.nc) was downloaded from the link below, then imported with the read.nasaoc
function. The selected area covers from 20 to 35 degrees of latitude North and from 119 to 104 degrees of longitude West.
https://oceancolor.gsfc.nasa.gov/cgi/l3
https://oceancolor.gsfc.nasa.gov/docs/technical/
data(dsst) dsst str(dsst) plot(dsst)
data(dsst) dsst str(dsst) plot(dsst)
Extract data values for pixels selected from an image of a satin object.
extractPts(X, points = NULL)
extractPts(X, points = NULL)
X |
a satin object as returned by |
points |
a data frame with point(s) longitude and latitude coordinates where to extract data values. |
If provided, points
must have two columns with x and y coordinates. When not specified, points
can be selected by clicking on the image. Note that for selecting the points in this manner, the plot of the satin object has to be created using colbar = FALSE
.
A data frame with at least 7 columns: For each point, a sequential id
number; (x, y
) coordinates, either specified via the points
argument or selected by clicking on the image; (lon
and lat
) coordinates of pixels closer to the desired points; and for quality control purposes, the distance between them (d
, km). The remaining column(s) are the parameter values for every image in the satin object.
Héctor Villalobos
# load data, define coordinates and extract values data(dsst) plot(dsst) coord <- data.frame(x = seq(-130, -114, 2), y = seq(20, 36, 2)) values <- extractPts(dsst, points = coord) values # if no points are given the user can select them by clicking on the image if (interactive()){ plot(dsst, colbar = FALSE) values2 <- extractPts(dsst) # *** click on the image *** values2 }
# load data, define coordinates and extract values data(dsst) plot(dsst) coord <- data.frame(x = seq(-130, -114, 2), y = seq(20, 36, 2)) values <- extractPts(dsst, points = coord) values # if no points are given the user can select them by clicking on the image if (interactive()){ plot(dsst, colbar = FALSE) values2 <- extractPts(dsst) # *** click on the image *** values2 }
Internal function called by plot.satin
and quiver
.
fmainPos(pu, main.pos)
fmainPos(pu, main.pos)
pu |
Obtained by par("usr"). |
main.pos |
Desired position, one among "topright", "topleft", "bottomright", "bottomleft"). |
Héctor Villalobos
The imageScale
function is wrapper for imageScale
and accepts the same arguments. It converts a vector of values (z
) to a vector of color levels. One must define the number of colors. The limits of the color scale ("zlim") or the break points for the color changes("breaks") can also be defined. When breaks and zlim are defined, breaks overrides zlim. All arguments are similar to those in the image
function. Appearance is best when incorporated with layout
.
imageScale(z, zlim, col = heat.colors(12), breaks, axis.pos = 1, add.axis = TRUE, xlim = NULL, ylim = NULL, log, ...)
imageScale(z, zlim, col = heat.colors(12), breaks, axis.pos = 1, add.axis = TRUE, xlim = NULL, ylim = NULL, log, ...)
z |
A vector or matrix of values. |
zlim |
Limits of the color scale values. |
col |
Vector of color values (default is 12 colors
from the |
breaks |
Break points for color changes. If breaks is specified then |
axis.pos |
Position of the axis (1=bottom, 2=left, 3=top, 4=right) (default = 1). |
add.axis |
Logical (TRUE/FALSE). Defines whether the axis is added (default: TRUE). |
xlim |
Limits for the x-axis. |
ylim |
Limits for the y-axis. |
log |
logical. If |
... |
Additional graphical parameters to pass to the |
Marc Taylor, modified for log scale by Héctor Villalobos
# Make color palettes pal.1=colorRampPalette(c("green4", "orange", "red", "white"), space="rgb", bias=0.5) pal.2=colorRampPalette(c("blue", "cyan", "yellow", "red", "pink"), space="rgb") # Make images with corresponding scales op <- par(no.readonly = TRUE) layout(matrix(c(1,2,3,0,4,0), nrow=2, ncol=3), widths=c(4,4,1), heights=c(4,1)) #layout.show(4) #1st image breaks <- seq(min(volcano), max(volcano),length.out=100) par(mar=c(1,1,1,1)) image(seq(dim(volcano)[1]), seq(dim(volcano)[2]), volcano, col=pal.1(length(breaks)-1), breaks=breaks-1e-8, xaxt="n", yaxt="n", ylab="", xlab="") #Add additional graphics levs <- pretty(range(volcano), 5) contour(seq(dim(volcano)[1]), seq(dim(volcano)[2]), volcano, levels=levs, add=TRUE) #Add scale par(mar=c(3,1,0,1)) imageScale(volcano, col=pal.1(length(breaks)-1), breaks=breaks-1e-8,axis.pos=1) abline(v=levs) box() #2nd image breaks <- c(0,100, 150, 170, 190, 200) par(mar=c(1,1,1,1)) image(seq(dim(volcano)[1]), seq(dim(volcano)[2]), volcano, col=pal.2(length(breaks)-1), breaks=breaks-1e-8, xaxt="n", yaxt="n", ylab="", xlab="") #Add additional graphics levs=breaks contour(seq(dim(volcano)[1]), seq(dim(volcano)[2]), volcano, levels=levs, add=TRUE) #Add scale par(mar=c(1,0,1,3)) imageScale(volcano, col=pal.2(length(breaks)-1), breaks=breaks-1e-8, axis.pos=4, add.axis=FALSE) axis(4,at=breaks, las=2) box() abline(h=levs) par(op)
# Make color palettes pal.1=colorRampPalette(c("green4", "orange", "red", "white"), space="rgb", bias=0.5) pal.2=colorRampPalette(c("blue", "cyan", "yellow", "red", "pink"), space="rgb") # Make images with corresponding scales op <- par(no.readonly = TRUE) layout(matrix(c(1,2,3,0,4,0), nrow=2, ncol=3), widths=c(4,4,1), heights=c(4,1)) #layout.show(4) #1st image breaks <- seq(min(volcano), max(volcano),length.out=100) par(mar=c(1,1,1,1)) image(seq(dim(volcano)[1]), seq(dim(volcano)[2]), volcano, col=pal.1(length(breaks)-1), breaks=breaks-1e-8, xaxt="n", yaxt="n", ylab="", xlab="") #Add additional graphics levs <- pretty(range(volcano), 5) contour(seq(dim(volcano)[1]), seq(dim(volcano)[2]), volcano, levels=levs, add=TRUE) #Add scale par(mar=c(3,1,0,1)) imageScale(volcano, col=pal.1(length(breaks)-1), breaks=breaks-1e-8,axis.pos=1) abline(v=levs) box() #2nd image breaks <- c(0,100, 150, 170, 190, 200) par(mar=c(1,1,1,1)) image(seq(dim(volcano)[1]), seq(dim(volcano)[2]), volcano, col=pal.2(length(breaks)-1), breaks=breaks-1e-8, xaxt="n", yaxt="n", ylab="", xlab="") #Add additional graphics levs=breaks contour(seq(dim(volcano)[1]), seq(dim(volcano)[2]), volcano, levels=levs, add=TRUE) #Add scale par(mar=c(1,0,1,3)) imageScale(volcano, col=pal.2(length(breaks)-1), breaks=breaks-1e-8, axis.pos=4, add.axis=FALSE) axis(4,at=breaks, las=2) box() abline(h=levs) par(op)
User defined isolines are interpolated from ocean data stored in a satin object and returned as polylines.
isolines(X, levels, period = 1, depth = 1, plot = TRUE)
isolines(X, levels, period = 1, depth = 1, plot = TRUE)
X |
a satin object as returned by |
levels |
a vector of desired isolines in data units. |
period |
an integer referring to the image number to process. |
depth |
an integer referring to a depth level. Only for Copernicus data that includes variables at different depths. |
plot |
logical, if |
Polyline coordinates of desired isolines are calculated via contourLines
and convCP
(from PBSMapping package). Perhaps only interesting with sea surface temperatures (isotherms). For smoother isolines, the function pixelate
can be used to spatialy re-scale the data. In order to use this function with Copernicus data returned from read.cmems
, the appropriate indexing should be previously done.
A list with two data frames of class "PolySet"
and "PolyData"
. See help(PolySet)
and help(PolyData)
for a complete description.
Héctor Villalobos, from code in examples of PBSMapping package
Schnute, J. T., Boers, N. M., Haigh, R. and Couture-Beil, A. 2011 PBS Mapping 2.62: user's guide revised from Canadian Technical Report of Fisheries and Aquatic Sciences 2549:vi + 112 p. Last updated Feb 29, 2011.
library(PBSmapping) data(dsst) # spatial re-scaling of the sst data for smoother isotherms sst <- pixelate(dsst, extent = 0.2) isotherms <- isolines(sst, levels = c(13, 17, 21)) plot(dsst, colbar = FALSE) addLines(isotherms$PolySet, col = "black", lwd = 1.5)
library(PBSmapping) data(dsst) # spatial re-scaling of the sst data for smoother isotherms sst <- pixelate(dsst, extent = 0.2) isotherms <- isolines(sst, levels = c(13, 17, 21)) plot(dsst, colbar = FALSE) addLines(isotherms$PolySet, col = "black", lwd = 1.5)
This function down-scales ocean data by quadrants of user defined size (in degrees) according to a given function.
pixelate(X, extent = 0.25, FUN = mean)
pixelate(X, extent = 0.25, FUN = mean)
X |
a satin object as returned by |
extent |
size in degrees of the squared quadrant for the new spatial scale. |
FUN |
function to be applied for obtaining the quadrants' values, defaults to |
The main interest of this function is to obtain smooth isolines for ocean data (e.g. isotherms). In order to use this function with Copernicus data returned from read.cmems
, the appropriate indexing should be done.
An object of class "satin"
. See satin-class
for details.
Héctor Villalobos
# load and plot sample SST data data(dsst) plot(dsst) # change spatial resolution to 0.5 degrees sst0.5 <- pixelate(dsst, extent = 0.5) plot(sst0.5)
# load and plot sample SST data data(dsst) plot(dsst) # change spatial resolution to 0.5 degrees sst0.5 <- pixelate(dsst, extent = 0.5) plot(sst0.5)
Visual representation of ocean data from satellite images (MODIS, AVHRR, etc.) or derived from models (ocean productivity; CMEMS).
## S3 method for class 'satin' plot(x, period = 1, depth = 1, xlim = NULL, ylim = NULL, zlim = NULL, map = NULL, map.col = "grey", map.outline = "black", scheme = "default", col.sep = 0.1, colbar = TRUE, main = NULL, main.pos = "topright", log = FALSE, units = NULL, xaxt = "s", yaxt = "s", atx = NULL, aty = NULL, restore.par = TRUE, ...)
## S3 method for class 'satin' plot(x, period = 1, depth = 1, xlim = NULL, ylim = NULL, zlim = NULL, map = NULL, map.col = "grey", map.outline = "black", scheme = "default", col.sep = 0.1, colbar = TRUE, main = NULL, main.pos = "topright", log = FALSE, units = NULL, xaxt = "s", yaxt = "s", atx = NULL, aty = NULL, restore.par = TRUE, ...)
x |
a satin object as returned by |
period |
an integer referring to the image number to plot. |
depth |
an integer referring to a depth level. Only for Copernicus data that includes variables at different depths. |
xlim |
minimum and maximum longitude values for the map. |
ylim |
minimum and maximum latitude values for the map. |
zlim |
minimum and maximum ocean data values. |
map |
a user defined map of class "SpatialPolygons". |
map.col |
color for the map. |
map.outline |
color for the map outline. |
scheme |
color scheme for the ocean data, either: "default" or a vector of valid color names. |
col.sep |
separation between colors in data units. |
colbar |
logical. If |
main |
title for the map, defaults to the corresponding selected image |
main.pos |
position for the title: "topright", "topleft", "bottomright" or "bottomleft". |
log |
logical. If |
units |
color bar label, defaults to |
xaxt , yaxt
|
"n" to supress axis. |
atx , aty
|
specify tick-mark locations for fine tuning axes annotations. |
restore.par |
logical. If |
... |
further arguments to pass to |
The only mandatory argument for this function to produce a map is an object of class "satin" (x
in this case). All the other arguments are optional and can be used to customize the plot. For chlorophyll concentration data, when log = TRUE
, the color scale is fixed to a maximum value of 20, which implies that values above it are set to this maximum before applying logarithms. Using restore.par = FALSE
to annotate plot, e.g. add isolines.
A plot including a map, of the corresponding parameter is produced.
Héctor Villalobos
read.nasaoc
, read.ghrsst
, read.osunpp
, and read.cmems
# SST data (Aqua Modis) library(sp) data(dsst, dmap) #load sample data and map # default plot plot(dsst) # adding a custom map plot(dsst, map = dmap) # Chl-a concentration data (Aqua Modis) in actual units and in logarithmic scale data(dchl) plot(dchl, map = dmap, xlim = c(-120, -105), ylim = c(20, 35)) dev.new() plot(dchl, map = dmap, xlim = c(-120, -105), ylim = c(20, 35), log = TRUE) # Copernicus data data(dcmems) plot(dcmems$thetao, map = dmap, period = 2, depth = 5)
# SST data (Aqua Modis) library(sp) data(dsst, dmap) #load sample data and map # default plot plot(dsst) # adding a custom map plot(dsst, map = dmap) # Chl-a concentration data (Aqua Modis) in actual units and in logarithmic scale data(dchl) plot(dchl, map = dmap, xlim = c(-120, -105), ylim = c(20, 35)) dev.new() plot(dchl, map = dmap, xlim = c(-120, -105), ylim = c(20, 35), log = TRUE) # Copernicus data data(dcmems) plot(dcmems$thetao, map = dmap, period = 2, depth = 5)
Plot vectors of ocean current velocities of varying size or color for Copernicus data.
quiver(u, v, period = 1, depth = 1, xlim = NULL, ylim = NULL, scale = 1, length = 0.05, colarrow = NULL, scheme = "default", ra.pos = NULL, ra.speed = NULL, map = NULL, map.col = "grey", map.outline = "black", colbar = FALSE, main = NULL, main.pos = "topright", add2map = FALSE, ...)
quiver(u, v, period = 1, depth = 1, xlim = NULL, ylim = NULL, scale = 1, length = 0.05, colarrow = NULL, scheme = "default", ra.pos = NULL, ra.speed = NULL, map = NULL, map.col = "grey", map.outline = "black", colbar = FALSE, main = NULL, main.pos = "topright", add2map = FALSE, ...)
u |
a satin object with eastward ocean current velocities (in m/s). |
v |
a satin object with northward ocean current velocities (in m/s). |
period |
an integer referring to the image number to plot. |
depth |
an integer referring to a depth level. |
xlim |
minimum and maximum longitude values for the map. |
ylim |
minimum and maximum latitude values for the map. |
scale |
this argument controls the arrow length. |
length |
this value controls the size of the arrow head. |
colarrow |
color(s) for the arrows; see details. |
scheme |
color scheme for the arrows. Either: "default" or a vector of valid color names. |
ra.pos |
position (lon, lat) for a reference arrow. |
ra.speed |
speed (in m/s) of the reference arrow. The mean is used by default. |
map |
a user defined map of class "SpatialPolygons". |
map.col |
color for the map. |
map.outline |
color for the map outline. |
colbar |
logical. If |
main |
title for the map, defaults to the corresponding selected image |
main.pos |
position for the title: "topright", "topleft", "bottomright" or "bottomleft". |
add2map |
a logical value. If |
... |
further arguments to pass to |
Usage and behavior of this function closely resembles that of plot.satin
. It differs in that two different satin objects are needed, one for each component of ocean current velocities. Also, the ocean current vectors can be overlayed to an existing plot of another variable, as the temperature, for instance.
A map of the ocean current velocities is produced.
Héctor Villalobos
if(interactive()){ # import copernicus data with potential temperatures and ocean current velocities oc <- read.cmems("global-reanalysis-phy-001-030-daily_1560792767602_GC_2013-14.nc") # Default plot quiver(u = oc$uo, v = oc$vo) # Using default colors for the arrows, color bar and reference arrow quiver(u = oc$uo, v = oc$vo, colarrow = TRUE, colbar = TRUE, ra.pos = c(-108, 30)) # Adding custom map and colors, and plotting another period and depth level quiver(u = oc$uo, v = oc$vo, image = 4, depth = 10, colbar = TRUE, colarrow = TRUE, scheme = c("mediumblue", "lightcyan", "red"), map = dmap, ra.pos = c(-108, 30), ra.speed = 0.2) # Overlay arrows to an existing plot of the potential temperature plot(oc$thetao, map = dmap, xlim = c(-112, -108), ylim = c(24, 28), colbar = FALSE) quiver(u = oc$uo, v = oc$vo, colarrow = TRUE, ra.pos = c(-108.5, 27), ra.speed = 0.15, main = "", length=0.02, scale = 0.7, add2map = TRUE) }
if(interactive()){ # import copernicus data with potential temperatures and ocean current velocities oc <- read.cmems("global-reanalysis-phy-001-030-daily_1560792767602_GC_2013-14.nc") # Default plot quiver(u = oc$uo, v = oc$vo) # Using default colors for the arrows, color bar and reference arrow quiver(u = oc$uo, v = oc$vo, colarrow = TRUE, colbar = TRUE, ra.pos = c(-108, 30)) # Adding custom map and colors, and plotting another period and depth level quiver(u = oc$uo, v = oc$vo, image = 4, depth = 10, colbar = TRUE, colarrow = TRUE, scheme = c("mediumblue", "lightcyan", "red"), map = dmap, ra.pos = c(-108, 30), ra.speed = 0.2) # Overlay arrows to an existing plot of the potential temperature plot(oc$thetao, map = dmap, xlim = c(-112, -108), ylim = c(24, 28), colbar = FALSE) quiver(u = oc$uo, v = oc$vo, colarrow = TRUE, ra.pos = c(-108.5, 27), ra.speed = 0.15, main = "", length=0.02, scale = 0.7, add2map = TRUE) }
Read data from netCDF files downloaded from Copernicus Marine Service (CMEMS).
read.cmems(nc)
read.cmems(nc)
nc |
name of the netCDF file to be read. |
The function can read data from netCDF files downloaded from CMEMS web page (https://marine.copernicus.eu/). It has been tested with Global Ocean Physical Reanalysis, and Global Ocean Biogeochemistry Hindcast databases. When downloading Copernicus data files, the user can select one or several variables (see references below), depth levels, daily or monthly means, time and spatial coverage. This makes every Copernicus netCDF file unique. The read.cmems
function attempts to read all the variables and depth levels at once. When only one variable is included in the file, a "satin"
object with one additional dimension in the data array to accommodate the different depth levels, is produced. On the other hand, when several variables are present, the function returns a named list, with every element being a "satin"
object corresponding to each variable.
A named list, with elements corresponding to each variable included in the netCDF file. Each list element (or when only one variable is present) is an object of class "satin"
. See satin-class
for details.
Héctor Villalobos
https://resources.marine.copernicus.eu/?option=com_csw&task=results
Fernandez, E. and Lellouche, J. M. 2018 Product User Manual for the Global Ocean Physical Reanalysis product, issue 1.1. EU Copernicus Marine Service.
Garric, G. and Parent, L. 2018 Product User Manual for the Global Ocean Reanalysis Products, issue 3.4. EU Copernicus Marine Service.
Perruche, C. 2019 Product User Manual for the Global Ocean Biogeochemistry Hindcast, issue 1.1. EU Copernicus Marine Service.
read.nasaoc
for reading NASA's oceancolor web page data, read.ghrsst
for JPL MUR SST data, and read.osunpp
for reading ocean productivity data.
if(interactive()){ # read Copernicus netcdf file with one variable cmems <- read.cmems("global-reanalysis-phy-001-030-monthly_1553098099635.nc") cmems str(cmems) # plotting the first period plot(cmems) # plotting the second period plot(cmems, period = 2) # read Copernicus netCDF file with several variables and depth levels cmems2 <- read.cmems("global-reanalysis-phy-001-030-monthly_1553051256930.nc") cmems2 # it is a list # readed variables names(cmems2) # example plots for potential temperature thetao <- cmems2$thetao thetao thetao$depth # depth levels plot(thetao) # potential temperature at first depth level (0.49 m) and first month plot(thetao, period = 2, depth = 5) # for fifth depth level (5.078 m), second month }
if(interactive()){ # read Copernicus netcdf file with one variable cmems <- read.cmems("global-reanalysis-phy-001-030-monthly_1553098099635.nc") cmems str(cmems) # plotting the first period plot(cmems) # plotting the second period plot(cmems, period = 2) # read Copernicus netCDF file with several variables and depth levels cmems2 <- read.cmems("global-reanalysis-phy-001-030-monthly_1553051256930.nc") cmems2 # it is a list # readed variables names(cmems2) # example plots for potential temperature thetao <- cmems2$thetao thetao thetao$depth # depth levels plot(thetao) # potential temperature at first depth level (0.49 m) and first month plot(thetao, period = 2, depth = 5) # for fifth depth level (5.078 m), second month }
Read, for a user defined area, SST data from netCDF files downloaded from JPL's Physical Oceanography Distributed Active Archive Center (podaac) web page.
read.ghrsst(nc, lons, lats)
read.ghrsst(nc, lons, lats)
nc |
name of the netCDF file(s) to be read. |
lons |
a vector with western- and eastern-most longitudes. |
lats |
a vector with southern- and northern-most latitudes. |
This function can read SST data from one or multiple netCDF files downloaded from Caltech Jet Propulsion Laboratory web page (https://podaac-opendap.jpl.nasa.gov/opendap/allData/ghrsst/data/GDS2/L4/GLOB/JPL/MUR/v4.1/). The user must specify the minimum and maximum latitude and longitude limits within the interval (-90, 90) and (-180, 180) respectively.
An object of class "satin"
. See satin-class
for details.
Héctor Villalobos and Eduardo González-Rodríguez
read.nasaoc
for reading NASA's oceancolor web page data, read.osunpp
for reading ocean productivity data, and read.cmems
for data from Copernicus Marine Service.
if(interactive()){ # read a single file, look at its structure and plot sst1km <- read.nasaoc("20130101090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc", lats=c(20, 30), lons=c(-130, -105)) sst1km str(sst1km) plot(sst1km) # read several files residing in the working directory files <- list.files(pattern = glob2rx("*.nc")) lats <- c(20, 30) lons <- c(-130, -105) mSST <- read.ghrsst(files, lats, lons) # plotting the first processed file plot(mSST) # plotting the second processed file plot(mSST, period = 2) }
if(interactive()){ # read a single file, look at its structure and plot sst1km <- read.nasaoc("20130101090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc", lats=c(20, 30), lons=c(-130, -105)) sst1km str(sst1km) plot(sst1km) # read several files residing in the working directory files <- list.files(pattern = glob2rx("*.nc")) lats <- c(20, 30) lons <- c(-130, -105) mSST <- read.ghrsst(files, lats, lons) # plotting the first processed file plot(mSST) # plotting the second processed file plot(mSST, period = 2) }
Read, for a user defined area, data from netCDF files downloaded from NASA's Oceancolor web page.
read.nasaoc(nc, lons, lats)
read.nasaoc(nc, lons, lats)
nc |
name of the netCDF file(s) to be read. |
lons |
a vector with western- and eastern-most longitudes. |
lats |
a vector with southern- and northern-most latitudes. |
This function can read data from one or multiple netCDF files downloaded from NASA's oceancolor web page (https://oceancolor.gsfc.nasa.gov/l3/). It has been tested mainly with sea surface temperature and chlorophyll concentration data from MODIS-Aqua and SeaWiFS sensors. It also works with Pathfinder AVHRR files v 5.2 and 5.3 (https://www.ncei.noaa.gov/products/avhrr-pathfinder-sst). The user must specify the minimum and maximum longitude and latitude limits within the interval (-180, 180) and (-90, 90) respectively.
An object of class "satin"
. See satin-class
for details.
Héctor Villalobos and Eduardo González-Rodríguez
read.ghrsst
for JPL MUR SST data, read.osunpp
for reading ocean productivity data, and read.cmems
for data from Copernicus Marine Service.
if(interactive()){ # read a single file, look at it and plot sst <- read.nasaoc("A20130892013096.L3m_8D_SST4_sst4_4km.nc", lats=c(20, 30), lons=c(-130, -105)) sst str(sst) plot(sst) # read several files residing in the working directory files <- list.files(pattern = glob2rx("*.nc")) lats <- c(20, 30) lons <- c(-130, -105) mSST <- read.nasaoc(files, lats, lons) # plotting the first processed file plot(mSST) # plotting the second processed file plot(mSST, period = 2) }
if(interactive()){ # read a single file, look at it and plot sst <- read.nasaoc("A20130892013096.L3m_8D_SST4_sst4_4km.nc", lats=c(20, 30), lons=c(-130, -105)) sst str(sst) plot(sst) # read several files residing in the working directory files <- list.files(pattern = glob2rx("*.nc")) lats <- c(20, 30) lons <- c(-130, -105) mSST <- read.nasaoc(files, lats, lons) # plotting the first processed file plot(mSST) # plotting the second processed file plot(mSST, period = 2) }
Read, for a user defined area, net primary production data from hdf files downloaded from OSU's Ocean Productivity home page.
read.osunpp(h5, lons, lats)
read.osunpp(h5, lons, lats)
h5 |
name of the hdf file(s) to be read. |
lons |
a vector with western- and eastern-most longitudes. |
lats |
a vector with southern- and northern-most latitudes. |
This function reads Oregon State University ocean productivity data files (http://sites.science.oregonstate.edu/ocean.productivity/standard.product.php). However, downloaded files should be first converted from hdf version 4 to version 5 with h4h5tools (https://portal.hdfgroup.org/display/support/Download+h4h5tools). The user must specify the minimum and maximum latitude and longitude limits within the interval (-90, 90) and (-180, 180) respectively.
An object of class "satin"
. See satin-class
for details.
Héctor Villalobos and Eduardo González-Rodríguez
read.nasaoc
for reading NASA's oceancolor web page data, read.ghrsst
for JPL MUR SST data, and read.cmems
for data from Copernicus Marine Service.
if(interactive()){ # read a single file, look at its structure and plot npp <- read.osunpp("vgpm.2013089.h5", lats=c(20, 30), lons=c(-130, -105)) npp str(npp) plot(npp) # read several files residing in the working directory files <- list.files(pattern = glob2rx("*.h5")) lats <- c(20, 30) lons <- c(-130, -105) mNPP <- read.osunpp(files, lats, lons) # plotting the first processed file plot(mNPP) # plotting the second processed file plot(mNPP, period = 2) }
if(interactive()){ # read a single file, look at its structure and plot npp <- read.osunpp("vgpm.2013089.h5", lats=c(20, 30), lons=c(-130, -105)) npp str(npp) plot(npp) # read several files residing in the working directory files <- list.files(pattern = glob2rx("*.h5")) lats <- c(20, 30) lons <- c(-130, -105) mNPP <- read.osunpp(files, lats, lons) # plotting the first processed file plot(mNPP) # plotting the second processed file plot(mNPP, period = 2) }
class for ocean data derived from satellites, imported from netCDF files.
Objects of class "satin"
are created by importing functions: read.nasaoc
, read.ghrsst
, read.cmems
, and read.osunpp
. They can also be created, though not recommended, by direct calls to satin
.
Object of class "numeric"
; vector of longitudes of the area of interest (aoi).
Object of class "numeric"
; vector of latitudes of the aoi.
Object of class "array"
; three or four dimensions array of ocean data corresponding to the lengths of lat
, lon
, period$tmStart
, and depth
vectors. The fourth dimension associated to depth levels will only be present in "satin"
objects derived from Copernicus data files.
Object of class "list"
; attributes of the data stored in the netCDF file: title
: title attribute from netCDF file; longname
: long name of ocean data variable; name
: short name of ocean data variable; units
: ocean data variable measurement units; temporal_range
: averaging period length, i.e. daily, monthly, etc.; spatial_resolution
: spatial resolution of the ocean data variable.
Object of class "list"
; a vector with start time (tmStart
) and a vector with end time (tmEnd
) of the averaging period of the data. Both vectors are of class "POSIXct"
.
Object of class "numeric"
; vector of depth levels in the data. Only meaningful for "satin"
objects derived from Copernicus data files.
signature(x = "satin", y = "missing")
: plot method for "satin"
objects. See details in plot.satin
signature(object = "satin")
: display a summary of the object. See example below
Héctor Villalobos
See read.nasaoc
; read.osunpp
; read.ghrsst
; and read.cmems
for functions producing "satin"
objects, and plot.satin
for a complete description of plotting arguments.
data(dsst) class(dsst) dsst str(dsst)
data(dsst) class(dsst) dsst str(dsst)
A satin object is reshaped as a data frame with longitude, latitude and remote sensed data column(s).
satinDataframe(X, reverse = FALSE)
satinDataframe(X, reverse = FALSE)
X |
a satin object as returned by |
reverse |
logical, |
This is mainly an utility function called by crop
, extractPts
, and pixelate
functions. However, it may be useful when the user wants to arrange the ocean data variables stored in a satin object as a data frame, with rows representing pixels whose longitude and latitude coordinates are in the first two columns and their data values in the remaining column(s). The attributes describing the data (name, units, period, etc.) are preserved. Specifying reverse = TRUE
reverses the operation.
When reverse = FALSE
, a data frame with at least three columns: "x", "y" for longitude and latitude coordinates, and data for the variable(s). When reverse = TRUE
a satin object as produced.
Héctor Villalobos
# load sample SST data data(dsst) # reshape into a data frame X <- satinDataframe(dsst) head(X) # reverse the operation Y <- satinDataframe(X, reverse = TRUE) Y plot(Y)
# load sample SST data data(dsst) # reshape into a data frame X <- satinDataframe(dsst) head(X) # reverse the operation Y <- satinDataframe(X, reverse = TRUE) Y plot(Y)
This function allows to average ocean data by a selected time period. For example, from daily data, the user may want to obtain weekly, monthly, quarterly or even yearly averages.
satinMean(X, by = "%m", depth = NULL)
satinMean(X, by = "%m", depth = NULL)
X |
a satin object as returned by |
by |
a character string specifying the averaging time period, see details. |
depth |
an integer referring to a given depth level (defaults to 1). Only meaningful for Copernicus data that includes variables at different depths. |
Accepted strings in by
follow the notation of conversion specifications described in strptime
. Currently implemented: "%Y"
, "%m"
, "%Y-%m"
, "%j"
, "%qtr"
, "%Y-%qtr"
, "%sem"
, "%Y-%sem"
, "%U"
, "%V"
, "%W"
, "%Y-%U"
, "%Y-%V"
, "%Y-%W"
. This includes two non-standard strings and their combinations with year: "%qtr"
, and "%sem"
, for quarter and semester, respectively, which are passed to lubridate's functions of the same names. This function is meant to be used in combination with anomaly
to obtain anomalies with respect to an average period.
An object of class "satin"
(see satin-class
for details) where the third dimension in the data array accomodates averages by time period. An extra element (labels
) is included in the slot attribs
to identify the time period used for the averages.
Héctor Villalobos and Eduardo González-Rodríguez
anomaly
for calculating anomalies of ocean data, and climatology
for climatologies.
if(interactive()){ sst.ym <- satinMean(sst, by = "%Y-%m") # sst is a satin object with 240 weekly # images, totalling five years of data. sst.ym # this will have 60 time periods, one for every month and year. sst.m <- satinMean(sst, by = "%m") # this will produce 12 monthly periods }
if(interactive()){ sst.ym <- satinMean(sst, by = "%Y-%m") # sst is a satin object with 240 weekly # images, totalling five years of data. sst.ym # this will have 60 time periods, one for every month and year. sst.m <- satinMean(sst, by = "%m") # this will produce 12 monthly periods }
This function allows to design and visualise color palettes to be used in ocean data plots.
satinPalette(zmin, zmax, col.sep = 0.1, scheme = "default", visu = FALSE)
satinPalette(zmin, zmax, col.sep = 0.1, scheme = "default", visu = FALSE)
zmin |
lower limit in data units. |
zmax |
upper limit in data units. |
col.sep |
separation between colors in data units. |
scheme |
color scheme, either: "default" or a vector of valid color names. |
visu |
logical. If |
This function is mainly intended to be called by plot.satin
, however it is possible to use it directly in order to have a first impression of a custom color palette.
A list with two elements
palette |
a vector of colors. |
breaks |
a vector of color breaks. |
Héctor Villalobos
plot.satin
satinPalette(zmin = 10, zmax = 35, visu = TRUE) satinPalette(zmin = 10, zmax = 35, col.sep = 0.2, scheme = c("white", "blue", "black"), visu = TRUE)
satinPalette(zmin = 10, zmax = 35, visu = TRUE) satinPalette(zmin = 10, zmax = 35, col.sep = 0.2, scheme = c("white", "blue", "black"), visu = TRUE)
Calculate ocean current speed and direction from eastward and northward components (Copernicus data).
velocity(u, v, depth = 1)
velocity(u, v, depth = 1)
u |
a satin object with eastward ocean current velocities (in m/s). |
v |
a satin object with northward ocean current velocities (in m/s). |
depth |
an integer referring to a depth level. |
This function calculates the resulting velocity vectors in the same way as the "quiver"
function. In addition, these values are returned togheter with their direction in degrees.
A list with 2 elements, “speed” and “rhumb”, both of class "satin"
. The former contains the resulting velocity vectors as drawn by "quiver"
, while the second their direction in degrees.
Héctor Villalobos
if(interactive()){ # import copernicus data with potential temperatures and ocean current velocities oc <- read.cmems("global-reanalysis-phy-001-030-daily_1560792767602_GC_2013-14.nc") vel <- velocity(u = oc$uo, v = oc$vo) # Plots overlaying velocity vectors plot(vel$speed) quiver(u = oc$uo, v = oc$vo, main = "", length=0.02, scale = 0.7, add2map = TRUE) plot(vel$rhumb, col.sep = 90, scheme = c('#d7301f', '#fc8d59','#fdcc8a', '#fef0d9')) quiver(u = oc$uo, v = oc$vo, main = "", add2map = TRUE) }
if(interactive()){ # import copernicus data with potential temperatures and ocean current velocities oc <- read.cmems("global-reanalysis-phy-001-030-daily_1560792767602_GC_2013-14.nc") vel <- velocity(u = oc$uo, v = oc$vo) # Plots overlaying velocity vectors plot(vel$speed) quiver(u = oc$uo, v = oc$vo, main = "", length=0.02, scale = 0.7, add2map = TRUE) plot(vel$rhumb, col.sep = 90, scheme = c('#d7301f', '#fc8d59','#fdcc8a', '#fef0d9')) quiver(u = oc$uo, v = oc$vo, main = "", add2map = TRUE) }
Extract ocean data available at different depth levels (Copernicus data) and plot CTD-like vertical profiles.
verticalProfiles(X, point = NULL, xlim = NULL, ylim = NULL)
verticalProfiles(X, point = NULL, xlim = NULL, ylim = NULL)
X |
a satin object with Copernicus data registered at different depths (i.e. potential temperature (thetao), salinity (so), etc.). |
point |
a data frame with point longitude and latitude coordinates where to extract data values. |
xlim |
limits for data variable. |
ylim |
vertical depth limits. |
Selected Copernicus data should be available at several depths, otherwise is meaningless. Also, if more than one point is selected, only the first will be processed.
Héctor Villalobos
# load sample Copernicus data data(dcmems) # available variables names(dcmems) # plot potential temperature plot(dcmems$thetao) # define point for extracting and plotting vertical profile pt <- data.frame(lon = -108.5, lat = 23.33) vp <- verticalProfiles(dcmems$thetao, point = pt) # inspect extracted data vp
# load sample Copernicus data data(dcmems) # available variables names(dcmems) # plot potential temperature plot(dcmems$thetao) # define point for extracting and plotting vertical profile pt <- data.frame(lon = -108.5, lat = 23.33) vp <- verticalProfiles(dcmems$thetao, point = pt) # inspect extracted data vp