-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart_TS.R
More file actions
79 lines (62 loc) · 2.18 KB
/
start_TS.R
File metadata and controls
79 lines (62 loc) · 2.18 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#############################################################################
# This script calls the different steps of the plot (opening, plotting...)
# It should be called from bash, specifically from BGTS.sh
#############################################################################
library(ncdf4)
library(oce)
library(MASS)
library(stringr)
library(parallel)
library(stringi)
source("~/Documents/time_series/time_series_plot/pathways.R")
source(paste(path_to_source, "file_names.R", sep=""))
source(paste(path_to_source, "open_profiles.R", sep=""))
source(paste(path_to_source, "plot_TS.R", sep=""))
### Get command arguments
uf = commandArgs(trailingOnly = TRUE)
WMO = uf[1]
PARAM_NAME = uf[2]
zoom_pres = uf[3]
zoom_param = uf[4]
date_axis = as.logical(uf[5])
plot_name = uf[6]
core_files = as.logical(uf[7])
logscale = as.logical(uf[8])
full_path = uf[9]
zoom_x = uf[10]
max_qc = uf[11]
if (WMO=="NA" | PARAM_NAME=="NA") {
print("Please specify at least a WMO and a parameter name (see -h for help)")
stop()
}
if (plot_name=="NA") {
plot_name = paste("BGTS_", WMO, "_", PARAM_NAME, ".png", sep="")
}
if (full_path=="NA") {
full_path = NULL
}
# convert text inputs to usable data
if (zoom_pres=="NA") {
zoom_pres = NULL
} else {
zoom_pres = as.numeric(unlist(strsplit(zoom_pres, ";")))
}
if (zoom_param=="NA") {
zoom_param = NULL
} else {
zoom_param = as.numeric(unlist(strsplit(zoom_param, ";")))
}
if (zoom_x=="NA") {
zoom_x = NULL
} else {
zoom_x = as.numeric(unlist(strsplit(zoom_x, ";")))
}
### Build list of file names from WMO and argo_index
index_ifremer = read.table(path_to_index_ifremer, sep=",", header = T)
#index_greylist = read.csv(path_to_index_greylist, sep = ",") # if greylist is useful at some point
name_list = file_names(index_ifremer, path_to_netcdf, WMO, core_files, full_path)
### Get a list with information on all profiles
numCores = detectCores()
M = mcmapply(open_profiles, name_list, MoreArgs=list(PARAM_NAME, core_files), mc.cores=numCores, USE.NAMES=FALSE)
### plot
ret = plot_TS(M, PARAM_NAME=PARAM_NAME, plot_name=plot_name, zoom_pres=zoom_pres, zoom_param=zoom_param, zoom_x=zoom_x, date_axis=date_axis, logscale=logscale, max_qc=max_qc)