Skip to contents

Coerce Data Into a cm Object

Usage

as.cm(
  time,
  u = NULL,
  v = NULL,
  pressure = NULL,
  conductivity = NULL,
  temperature = NULL,
  salinity = NULL,
  longitude = NA,
  latitude = NA,
  filename = "",
  debug = getOption("oceDebug")
)

Arguments

time

A vector of times of observation, or an oce object from which time and two velocity components can be inferred, e.g. an adv object, or an adp object that has only one distance bin. If time is an oce object, then all of the following arguments are ignored.

u, v

optional numerical vectors containing the x and y components of velocity (m/s).

pressure, conductivity, salinity, temperature

optional numerical vectors containing pressure (dbar), electrical conductivity, practical salinity, and in-situ temperature (degree C).

longitude, latitude

optional position specified in degrees East and North.

filename

optional source file name.

debug

an integer specifying whether debugging information is to be printed during the processing. This is a general parameter that is used by many oce functions. Generally, setting debug=0 turns off the printing, while higher values suggest that more information be printed. If one function calls another, it usually reduces the value of debug first, so that a user can often obtain deeper debugging by specifying higher debug values.

Examples

library(oce)
# Example 1: creation from scratch
t <- Sys.time() + 0:50
u <- sin(2 * pi * 0:50 / 5) + rnorm(51)
v <- cos(2 * pi * 0:50 / 5) + rnorm(51)
p <- 100 + rnorm(51)
summary(as.cm(t, u, v, p))
#> Cm summary
#> ----------
#> 
#> * North:         magnetic
#> * Time: 2024-11-15 14:57:28 to 2024-11-15 14:58:18 (51 samples, mean increment 1 s)
#> * Data Overview
#> 
#>                     Min.                Mean                Max.                Dim. NAs
#>     time            2024-11-15 18:57:28 2024-11-15 18:57:53 2024-11-15 18:58:18 51   0  
#>     u [m/s]         -2.8628             0.0070087           3.2703              51   0  
#>     v [m/s]         -2.5653             0.23561             2.4359              51   0  
#>     pressure [dbar] 98.1                100.02              101.88              51   0  
#> 
#> * Processing Log
#> 
#>     - 2024-11-15 18:57:28 UTC: `create 'cm' object`
#>     - 2024-11-15 18:57:28 UTC: `as.cm(time = t, u = u, v = v, pressure = p)`

# Example 2: creation from an adv object
data(adv)
summary(as.cm(adv))
#> Cm summary
#> ----------
#> 
#> * File source:   "(file name redacted)"
#> * Serial Num.:   (serial number redacted)
#> * North:         magnetic
#> * Time: 2008-07-01 00:00:00 to 2008-07-01 00:00:59 (480 samples, mean increment 0.1250001 s)
#> * Data Overview
#> 
#>                     Min.                Mean                Max.                Dim. NAs
#>     time            2008-07-01 00:00:00 2008-07-01 00:00:30 2008-07-01 00:00:59 480  0  
#>     u [m/s]         -0.080871           -0.027275           0.012168            480  0  
#>     v [m/s]         -0.0090777          0.021877            0.057789            480  0  
#>     pressure [dbar] 16.85               16.866              16.879              480  0  
#> 
#> * Processing Log
#> 
#>     - 2015-12-23 17:53:39 UTC: `read.oce(file = "/data/archive/sleiwex/2008/moorings/m05/adv/nortek_1943/raw/adv_nortek_1943.vec",     from = as.POSIXct("2008-06-25 00:00:00", tz = "UTC"), to = as.POSIXct("2008-07-06 00:00:00",         tz = "UTC"), latitude = 47.87943, longitude = -69.72533)`
#>     - 2015-12-23 17:53:54 UTC: `retime(x = m05VectorBeam, a = 0.58, b = 6.3892e-07, t0 = as.POSIXct("2008-07-01 00:00:00",     tz = "UTC"))`
#>     - 2015-12-23 17:53:55 UTC: `subset(x, subset=as.POSIXct("2008-06-25 13:00:00", tz = "UTC") <= time & time <=      as.POSIXct("2008-07-03 00:50:00", tz = "UTC"))`
#>     - 2015-12-23 17:53:55 UTC: `oceEdit(x = m05VectorBeam, item = "transformationMatrix", value = rbind(c(11033,     -5803, -5238), c(347, -9622, 9338), c(-1418, -1476, -1333))/4096,     reason = "Nortek email 2011-02-14", person = "DEK")`
#>     - 2015-12-23 17:53:55 UTC: `use aquadoppHR heading; despike own pitch and roll`
#>     - 2015-12-23 17:54:11 UTC: `beamToXyzAdv(x = x)`
#>     - 2015-12-23 17:54:34 UTC: `xyzToEnu(x, declination=-18.099, horizontalCase=TRUE, sensorOrientiation=upward, debug=0)`
#>     - 2024-11-15 18:57:28 UTC: `as.cm(time = adv)`