Closed sean-rohan-NOAA closed 2 years ago
library(gapctd)
vessel <- 94
year <- 2021
region <- "BS"
try_method <- "sbe19plus_v0"
ctd_dir <- "G:/RACE_CTD/data/2021/ebs/v94_ctd1"
channel <- gapctd::get_connected(schema = "AFSC")
# Run using 'typical' parameters
gapctd::run_method(vessel = vessel,
year = year,
region = region,
channel = channel,
processing_method = "sbe19plus_v2",
storage_directory = here::here("output", "sbe19plus_v2"),
ctd_dir = ctd_dir)
# Process without alignment or cell thermal mass correction
gapctd::run_method(vessel = vessel,
year = year,
region = region,
channel = channel,
processing_method = try_method,
storage_directory = here::here("output", try_method),
ctd_dir = ctd_dir)
# Estimate alignment module parameters for temperature
alignment_df <-
gapctd::run_alignment_calcs(
profile_files = sort(c(
list.files(
here::here("output", try_method),
full.names = TRUE,
pattern = "downcast.cnv"
),
list.files(
here::here("output", try_method),
full.names = TRUE,
pattern = "upcast.cnv"
)
)),
make_diagnostic_plots = TRUE,
min_pressure = 4,
cor_method = "spearman",
)
# Save alignment parameters to .rds
saveRDS(object = alignment_df, here::here("output", paste0(region, "_", year, "_", vessel, "_align_pars.rds")))
# Align profile data
gapctd::run_method(vessel = vessel,
year = year,
region = region,
channel = channel,
processing_method = try_method,
storage_directory = here::here("output", paste0(try_method, "_align")),
ctd_dir = ctd_dir,
alignment_df = readRDS(file = here::here("output", paste0(region, "_", year, "_", vessel, "_align_pars.rds"))))
# Estimate cell thermal mass (CTM) correction module parameters for aligned data
ctm_df <- gapctd::run_ctm_adjust_tsarea(profile_files = sort(c(list.files(here::here("output", "sbe19plus_v0_align"),
full.names = TRUE, pattern = "downcast.cnv"),
list.files(here::here("output", "sbe19plus_v0_align"),
full.names = TRUE, pattern = "upcast.cnv"))),
min_pressure = 4,
optim_method = "BFGS", #"SANN",
optim_maxit = 500,
start_alpha = 0.04,
start_tau = 8)
# Save CTM correction parameters to .rds
saveRDS(ctm_df, file = here::here("output", paste0(region, "_", year, "_", vessel, "_ctm_area_pars.rds")))
# Apply cell thermal mass correction
gapctd::run_method(vessel = vessel,
year = year,
region = region,
channel = channel,
processing_method = try_method,
storage_directory = here::here("output", paste0(try_method, "_ctm_area")),
ctd_dir = ctd_dir,
ctm_df = readRDS(file = here::here("output", paste0(region, "_", year, "_", vessel, "_ctm_area_pars.rds"))))
# Compare profiles based on the area between salinity profiles
compare_df <- gapctd::compare_methods(prefix = "/binavg/align_ctd_method",
method_labels = c("Estimated (Raw)", "Estimated (Aligned)", "Estimated (CTM-Area)", "Typical method"),
processing_method = c("sbe19plus_v0", "sbe19plus_v0_align", "sbe19plus_v0_ctm_area", "sbe19plus_v2"),
return_output = TRUE,
min_pressure_bin = 4,
pattern_downcast = "downcast_binavg.cnv",
pattern_upcast = "upcast_binavg.cnv")
Baseline test case with BS data worked succesfully. My only comment is probably worth adding text to the readme about having to click through the SBEData processing text boxes after some of the run_method() functions, it's not super obvious which buttons to push. Will test on a GOA data subset next.
Thanks, Cecilia. I added error documentation here for now: https://github.com/afsc-gap-products/gapctd/blob/main/doc/SBE_data_processing_errors.md
Testing on GOA data
Reminders: -make sure .xlmcon file is named with "_DeployYEAR.xmlcon" appended at the end (e.g., "19-8104_Deploy2021.xmlcon" works and "19-810.xlmcon" does not work in batch file processing)
Changes made to code to work with GOA data too:
Retested on BS data after changes made and seems to still work, might want to check on your system too.
Reminders: -make sure .xlmcon file is named with "_DeployYEAR.xmlcon" appended at the end (e.g., "19-8104_Deploy2021.xmlcon" works and "19-810.xlmcon" does not work in batch file processing)
@coleary-noaa Can you provide a bit more detail about this issue? I didn't think it mattered what the config (.xmlcon) file is called as long as the filename extension is correct and the config file settings match the settings of the config that was used when the CTD was deployed. In the batch processing routines, the .xmlcon file in the source directory is copied to /psa_xmlcon/ then automatically detected and passed as an argument to SBE Data Processing via command line (system()
function):
In the EBS, there was one vessel where the config file wasn't correct even though the serial number matched. The issue seemed to be that the config file was the old file from when the CTDs were setup in the vertical deployment configuration and included extra channels for oxygen and pH, whereas the proper file was the config file for the horizontal configuration with only temperature, conductivity, and pressure (included Deploy in the name). I could definitely be wrong though since swapping the config files also meant the replacement config file had the same name as the config file that was used during deployment. But I recall there was an error message that made me think the name wasn't the problem.
There was another issue where multiple CTDs were used on one vessel but all of the files were in the same directory. I solved that problem by moving each unit to its own directory.
Retested on BS data after changes made and seems to still work, might want to check on your system too.
Yep, still works!
@coleary-noaa Can you provide a bit more detail about this issue? I didn't think it mattered what the config (.xmlcon) file is called as long as the filename extension is correct and the config file settings match the settings of the config that was used when the CTD was deployed. In the batch processing routines, the .xmlcon file in the source directory is copied to /psa_xmlcon/ then automatically detected and passed as an argument to SBE Data Processing via command line (system() function):
I just tried to replicate the issue and had no problems with any .xmlcon file regardless of how it was named as long as it matched the config file, so you're right. Guess it was just a fluke error. The first time I tried it it just said it couldn't find any .xmlcon file ( "run_sbe_batch: No .xmlcon file found in ", getwd(), "/psa_xmlcon/. Must have a valid .xmlcon file.") error ) and when I switched it from "19-8104.xmlcon" to "19-8104_Deploy2021.xmlcon" the error went away. Now it works with either, so perhaps it was related to some of the other issues I fixed or just a bug the first time I ran it. Either way, not an issue now so ignore!
Phew! Thanks for checking.
Automated processing end-to-end test.
Install the package:
Run the code: