Given an adp object created by the oce package, this function
creates a NetCDF file that can later by read by ncdf2adp() to approximately
reproduce the original contents.
adp2ncdf(x, varTable = NULL, ncfile = NULL, force_v4 = TRUE, debug = 0)an oce object of class adp, as created by e.g. oce::read.adp().
character value indicating the variable-naming
scheme to be used, which is passed to read.varTable() to set
up variable names, units, etc.
character value naming the output file. Use NULL
for a file name to be created automatically (e.g. ctd.nc for
a CTD object).
logical value which controls the NetCDF file version during the nc_create step. The default here is TRUE, whereas the ncdf4-package defaults to FALSE (ensuring that the NetCDF file is compatible with NetCDF v3). Some features, including large data sizes, may require v4.
integer, 0 (the default) for quiet action apart from messages and warnings, or any larger value to see more output that describes the processing steps.
Note that adp2ncdf() defaults varTable to "adp".
The entire contents of the metadata slot are saved in the global attribute named
"metadata", in a JSON format. The JSON material is developed with
metadata2json(), which yields a value that can be decoded with
json2metadata().
In addition, the following metadata
items are saved as individual global attributes:
"beamAngle",
"frequency",
"instrumentType",
"instrumentSubtype",
"numberOfBeams",
"numberOfBeams",
and
"oceCoordinate".
Other things related to adp data:
ncdf2adp()
library(ocencdf)
# Example with an ADP file from `oce` package
data(adp, package = "oce")
summary(adp)
#> ADP Summary
#> -----------
#>
#> * Filename: "(redacted)"
#> * Instrument: adcp
#> * Manufacturer: teledyne rdi
#> * Serial number: (redacted)
#> * Firmware: 16.28
#> * Cell Size: 0.50 m
#> * Beam Angle: 20 deg
#> * Location: 47.88126 N, -69.73433 E
#> * Frequency: 600 kHz
#> * Ensemble Numbers: 5041, 5401, ..., 13321, 13681
#> * Transformation matrix::
#> 1.462 -1.462 0.000 0.000
#> 0.000 0.000 -1.462 1.462
#> 0.266 0.266 0.266 0.266
#> 1.034 1.034 -1.034 -1.034
#> * Time: 2008-06-26 to 2008-06-27 (25 samples, mean increment 1 hour)
#> * Data Overview
#>
#> Min. Mean Max. Dim. NAs
#> v [m/s] -0.97553 0.071645 1.4917 25x84x4 332
#> q NA NA NA 25x84x4 0
#> a NA NA NA 25x84x4 0
#> g NA NA NA 25x84x4 0
#> distance [m] 2.23 22.98 43.73 84 0
#> time 2008-06-26 2008-06-26 12:00:00 2008-06-27 25 0
#> pressure [dbar] 37.786 39.05 40.315 25 0
#> temperature [°C, ITS-90] 3.45 3.6904 4.05 25 0
#> salinity [PSS-78] 35 35 35 25 0
#> depth [m] 37.5 38.792 40.1 25 0
#> soundSpeed [m/s] 1465 1466.1 1468 25 0
#> heading [°] 260.61 273.62 294.98 25 0
#> pitch [°] -6.9303 -5.9062 -2.9328 25 0
#> roll [°] 3.36 4.4868 6.21 25 0
#> headingStd [°] 1 1 1 25 0
#> pitchStd [°] 0.1 0.1 0.1 25 0
#> rollStd [°] 0 0 0 25 0
#> pressureStd 79 111.24 152 25 0
#> xmitCurrent 89 91.92 96 25 0
#> xmitVoltage 134 138.2 143 25 0
#> ambientTemp 116 116.88 117 25 0
#> pressurePlus 82 82.64 83 25 0
#> pressureMinus 68 68.32 69 25 0
#> attitudeTemp 110 110.88 111 25 0
#> attitude [°] 130 130 130 25 0
#> contaminationSensor 159 159 159 25 0
#>
#> * Processing Log
#>
#> - 2019-08-12 15:29:36 UTC: `read.oce("/data/archive/sleiwex/2008/moorings/m09/adp/rdi_2615/raw/adp_rdi_2615.000", ...)`
#> - 2019-08-12 15:29:36 UTC: `beamToXyzAdp(x = beam)`
#> - 2019-08-12 15:29:36 UTC: `xyzToEnuAdp(x, declination=-18.1, debug=0)`
plot(adp)
# Transfer to NetCDF and back to see if results make sense.
# Use a temporary nc file to let package pass CRAN checks.
ncfile <- tempfile(pattern = "adp", fileext = ".nc")
oce2ncdf(adp, ncfile = ncfile)
ADP <- ncdf2adp(ncfile)
summary(ADP)
#> ADP Summary
#> -----------
#>
#> * Filename: "(redacted)"
#> * Instrument: adcp
#> * Manufacturer: teledyne rdi
#> * Serial number: (redacted)
#> * Firmware: 16.28
#> * Cell Size: 0.50 m
#> * Beam Angle: 20 deg
#> * Location: 47.88126 N, -69.73433 E
#> * Frequency: 600 kHz
#> * Ensemble Numbers: 5041, 5401, ..., 13321, 13681
#> * Transformation matrix::
#> 1.462 -1.462 0.000 0.000
#> 0.000 0.000 -1.462 1.462
#> 0.266 0.266 0.266 0.266
#> 1.034 1.034 -1.034 -1.034
#> * Time: 2008-06-26 to 2008-06-27 (25 samples, mean increment 1 hour)
#> * Data Overview
#>
#> Min. Mean Max. Dim. NAs
#> time 2008-06-26 2008-06-26 12:00:00 2008-06-27 25 0
#> distance [m] 2.23 22.98 43.73 84 0
#> v [m/s] -0.97553 0.071645 1.4917 25x84x4 332
#> a 52 95.313 211 25x84x4 0
#> g 0 95.352 100 25x84x4 0
#> q 24 113.49 248 25x84x4 0
#> pressure [dbar] 37.786 39.05 40.315 25 0
#> temperature [°C, ITS-90] 3.45 3.6904 4.05 25 0
#> salinity [PSS-78] 35 35 35 25 0
#> depth [m] 37.5 38.792 40.1 25 0
#> soundSpeed [m/s] 1465 1466.1 1468 25 0
#> heading [°] 260.61 273.62 294.98 25 0
#> pitch [°] -6.9303 -5.9062 -2.9328 25 0
#> roll [°] 3.36 4.4868 6.21 25 0
#> headingStd [°] 1 1 1 25 0
#> pitchStd [°] 0.1 0.1 0.1 25 0
#> rollStd [°] 0 0 0 25 0
#> pressureStd 79 111.24 152 25 0
#> xmitCurrent 89 91.92 96 25 0
#> xmitVoltage 134 138.2 143 25 0
#> ambientTemp 116 116.88 117 25 0
#> pressurePlus 82 82.64 83 25 0
#> pressureMinus 68 68.32 69 25 0
#> attitudeTemp 110 110.88 111 25 0
#> attitude [°] 130 130 130 25 0
#> contaminationSensor 159 159 159 25 0
#>
#> * Processing Log
#>
#> - 2024-02-22 00:13:47 UTC: `Create oce object`
plot(ADP)
file.remove(ncfile)
#> [1] TRUE