forked from EOGrady21/ODF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathADCPexample
54 lines (36 loc) · 1.62 KB
/
ADCPexample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
###producing ODFs in R EXAMPLE####
###example processing procedure
###input: RAW ADCP file (.000), plus any extra metadata from log sheets (.csv)
###output: processed ADCP data in ODF file
library(oce)
library(ncdf4)
source('adcpToolbox.R')
source('ODFtoolbox.R')
# read in raw data and metadata
adp <- read.adp.easy('R:/Shared/ChisholmE/sample ADP process/M1996000.000', 'R:/Shared/ChisholmE/sample ADP process/metadataTemplateM1996.csv')
# adjust depth values based on pressure and latitude
adp[['depth']] <- swDepth(adp[['pressure']], (adp[['latitude']]))
# apply magnetic declination
adp <- applyMagneticDeclinationAdp(adp)
# limit depth by recovery/deployment times
adp <- limit_depthbytime(adp)
# limit time and other variables based on deployment/ recovery times
adp <- limit_time(adp)
# add microcat pressure data if relevant
#file <- list.files(path = '.', pattern = "MCTD*...*.ODF")
#adp <- insertInst(adp, var = 'pressure', file = file)
# flag data outside percent good/ error bounds
adp <- adpFlag(adp, 25, 0.46)
# set flags to NA
adpClean <- handleFlags(adp, flags = 4, actions = list('NA'))
# create saved adp object ###fix me: file too big to open, recompress?
save(adp, file =paste( 'adp', adp[['cruise_number']], adp[['mooring_number']], sep = '_'))
# processingLog export
adp <-exportPL(adp)
#write event comments
adpClean <- oceSetMetadata(adpClean, 'event_comments', 'WRITE EVENT COMMENTS HERE')
#write out all 50 ODF files
#oce2odf(obj = adpClean, write = TRUE)
#export only certain bins
b <- oce2odf( adpClean, write = FALSE)
binExport(b, bins = list(1, 2, 3))