-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCastaway2ODF.R
119 lines (114 loc) · 5.17 KB
/
Castaway2ODF.R
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
ODF_castaway_header <- function(data, file_specification = data,
country_inst_code = "1810",
cruise_num = "SCDYYYYXXX, see data manager about cruise numbers",
organization = "St. Andrews Biological Station, Fisheries and Oceans Canada",
chief_scientist = "PI",
cruise_start_date = "DD-MMM-YYYY HH:MM:SS.SS",
cruise_end_date = "DD-MMM-YYYY HH:MM:SS.SS",
cruise_platform = "Boaty McBoatface",
cruise_name = "Project Name",
cruise_description = "Information about specific cruise if available",
data_type = "CTD",
event_number = "000",
event_qualifier1 = "",
event_quaifier2 = "",
creation_date = date(),
start_date_time = "DD-MMM-YYYY HH:MM:SS.SS",
end_date_time = "DD-MMM-YYYY HH:MM:SS.SS",
initial_lat = -99,
initial_lon = -999,
end_lat = -99,
end_lon = -999,
min_depth = "",
max_depth = "",
sampling_int = "0.2",
sounding = "",
depth_off_bottom = "",
event_comments = "",
inst_type = "Castaway CTD",
inst_model = "Castaway CTD",
inst_sn = "",
inst_description = "",
poly_parameter_name = "",
poly_calibration_date = "",
poly_application_date = "",
poly_n_coefficients = "",
poly_coefficients = "",
poly1_parameter_name = "",
poly1_calibration_date = "",
poly1_application_date = "",
poly1_n_coefficients = "",
poly1_coefficients = "",
poly2_parameter_name = "",
poly2_calibration_date = "",
poly2_application_date = "",
poly2_n_coefficients = "",
poly2_coefficients = "",
par1_type = "DOUB ",
par1_name = "time",
par1_units = "seconds",
par1_code = "TIME",
par1_null = "NA",
par1_print = "",
par1_print_dec = "",
par1_angle = "",
par1_mag_var = "",
par1_depth = "",
par1_min_value = "",
par1_max_value = "",
par1_num_valid = "",
par1_num_null = ""
) {
write(paste("ODF_HEADER,
FILE_SPECIFICATION='",file_specification,"'", sep =""), "ODF_test.ODF")
write(paste("CRUISE_HEADER,
COUNTRY_INSTITUTE_CODE='", country_inst_code,"',
CRUISE_NUMBER='", cruise_num, "',
ORGANIZATION='", organization, "',
CHIEF_SCIENTIST='", chief_scientist,"',
START_DATE='", cruise_start_date, "',
END_DATE='", cruise_end_date, "',
PLATFORM='", cruise_platform, "',
CRUISE_NAME='", cruise_name, "',
CRUISE_DESCRIPTION='", cruise_description, "'", sep =""), "ODF_test.ODF", append =TRUE)
write(paste("EVENT_HEADER,
DATA_TYPE='",data_type,"',
EVENT_NUMBER='", event_number, "',
EVENT_QUALIFIER1='", event_qualifier1, "',
EVENT_QUALIFIER2='", event_quaifier2,"'
CREATION_DATE='",creation_date,"',
START_DATE_TIME='", start_date_time, "',
END_DATE_TIME='", end_date_time, "',
INITIAL_LATITUDE='", initial_lat,"'
INITIAL_LONGITUDE='",initial_lon,"',
END_LATITUDE='", end_lat, "',
END_LONGITUDE='", end_lon, "',
MIN_DEPTH='", min_depth,"'
MAX_DEPTH='",max_depth,"',
SAMPLING_INTERVAL='",sampling_int,"',
SOUNDING='", sounding, "',
DEPTH_OFF_BOTTOM='", depth_off_bottom,"'
EVENT_COMMENTS='",event_comments,"'", sep =""), "ODF_test.ODF", append =TRUE)
write(paste("INSTRUMENT_HEADER,
INST_TYPE='",inst_type,"',
MODEL='", inst_model, "',
SERIAL_NUMBER='", inst_sn, "',
DESCRIPTION='", inst_description,"'", sep =""), "ODF_test.ODF", append =TRUE)
# There can be multiple polynomial calculation header sections as there will
# be a separate header section for each probe or sensor
write(paste("POLYNOMIAL_CAL_HEADER,
PARAMETER_NAME='", poly_parameter_name,"',
CALIBRATION_DATE='", poly_calibration_date, "',
APPLICATION_DATE='", poly_application_date, "',
NUMBER_COEFFICIENTS='", poly_n_coefficients,"',
COEFFICIENTS='", poly_coefficients,"'", sep =""), "ODF_test.ODF", append =TRUE)
write(paste("PARAMETER_HEADER,
TYPE='", par1_type,"',
NAME='", par1_name, "',
UNITS='", par1_units, "',
CODE='", par1_code,"',
NULL_VALUE='", par1_null,"',
PRINT_FIELD_WIDTH='". par1_print,"',
PRINT","'", sep =""), "ODF_test.ODF", append =TRUE)
write(" -- DATA -- ", "ODF_test.ODF", append =TRUE)
}