Closed coleary-noaa closed 2 years ago
Made a couple of modifications to the batch processing SBE19(non-plus) files for the .psa after some additional reading.
Variable descent and ascent rates and relatively low resolution 4 Hz scan interval make it challenging to find a single alignment that works for all of the casts. Comparing multiple alignment values and selecting the best one seems to work reasonably well in the EBS/NBS:
Method in #31 seems promising for replacing step 5.
Method in #31 seems promising for replacing step 5.
Process using 'typical' parameters:
Process using estimated align and celltm parameters:
Select and clean profiles generated using the 'typical' or estimated method:
References: Garau, B., Ruiz, S., Zhang, W.G., Pascual, A., Heslop, E., Kerfoot, J., Tintoré, J., 2011. Thermal lag correction on slocum CTD glider data. J. Atmos. Ocean. Technol. 28, 1065–1071. https://doi.org/10.1175/JTECH-D-10-05030.1
Ullman, D.S., Hebert, D., 2014. Processing of underway CTD data. J. Atmos. Ocean. Technol. 31, 984–998. https://doi.org/10.1175/JTECH-D-13-00200.1
Example salinity profiles:
# 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 parameters
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",
)
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 correction parameters for aligned data
ctm_adjust_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"))),
optim_method = "SANN",
min_pressure = 4,
start_alpha = 0.04,
start_tau = 8,
obj_method = "area")
saveRDS(ctm_adjust_df, file = here::here("output", paste0(region, "_", year, "_", vessel, "_ctm_adjust_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_adjust")),
ctd_dir = ctd_dir,
ctm_df = readRDS(file = here::here("output", paste0(region, "_", year, "_", vessel, "_ctm_adjust_pars.rds"))))
# Compare results
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_adjust", "sbe19plus_v2"),
return_output = TRUE,
pattern_downcast = "downcast_binavg.cnv",
pattern_upcast = "upcast_binavg.cnv",
scale_vars = FALSE,
area_method = "ts")
##### MOVE FINAL FILES TO CNV DIR #####
gapctd::move_to_final_cnv(compare_df$best_df)
# Run density inversion check and correction
gapctd::correct_density_inversion(threshold = -1e-5,
threshold_method = "bv",
correct_inversion = TRUE,
cnv_dir = here::here("output", "sbe19plus_v0_ctm"), # Update to final_cnv
pattern = "binavg")
# Manually review and flag bad data. Remove and interpolate bad data.
gapctd::manual_flag_interpolate()
# Review final data
gapctd::manual_review()
# Package files into a .zip
gapctd::make_ctd_zip(region = region, vessel = vessel, year = year)
# Package data product
### Separate code