tryCatch({ plots <-list()for (station_name inunique(cruise_df$station)) { subset_df <-filter(cruise_df, station == station_name) plots[[station_name]] <-ggplot(subset_df, aes(x = time_elapsed)) +geom_point(aes(y = depth), color ="blue") +# Plot depth in bluegeom_line(aes(y = sea_water_pressure), color ="red") +# Plot sea water pressure in redggtitle(glue("{station_name}")) +theme(axis.title.x =element_blank(),axis.title.y =element_blank(),axis.text.x =element_blank(),axis.text.y =element_blank(),axis.ticks.x =element_blank(),axis.ticks.y =element_blank() ) # Remove individual axis titles and text }# drop nulls plots <- purrr::compact(plots)# Combine all plots into a grid combined_plot <-wrap_plots(plots) +plot_layout(ncol =4) +# Adjust ncol to set number of columns in the gridplot_annotation(title ="Depth (blue) and Pressure (red)",subtitle ="Each panel represents a different station",caption ="Time Elapsed (x-axis) vs Depth & Pressure (y-axis)" ) +theme(plot.tag =element_text(size =12, face ="bold"),plot.tag.position ="topleft",axis.title.x =element_text(margin =margin(t =10)),axis.title.y =element_text(margin =margin(r =10)) )print(combined_plot)}, error =function(er){print(er)});
plot across all stations
p <-ggplot(cruise_df, aes(x = time, y = depth, fill = station)) +geom_col() +# This creates the bars# geom_text(aes(label = station), vjust = -0.3) + # This adds labels to each bar, adjust vjust for positionlabs(x ="Time", y ="Depth", title ="Depth over Time by Station") +# Set labels and titletheme_minimal() # Use a minimal themeprint(p)
create oce.ctd objects from dataframes
ctd_load <-function(data, other_params =NULL) {# create csv into ctd object test_ctd <-as.ctd(salinity = data$sea_water_salinity,temperature = data$sea_water_temperature,pressure = data$sea_water_pressure,station = data$station )# add additional columns to ctd objectif (!is.null(other_params)) {for (param_name in other_params) { test_ctd <-oceSetData(object = test_ctd,name = param_name,value = data[[param_name]] ) } }print(glue("{data$station[1]}:\t{length(test_ctd@data$scan)} scans"))return(test_ctd)}# Define other parameters to addother_params <-c("cruise_id", "station", "time", "time_elapsed", "latitude", "longitude", "sea_water_electrical_conductivity", "CDOM", "dissolved_oxygen","oxygen_saturation", "chlorophyll_concentration", "chlorophyll_fluorescence", "photosynthetically_available_radiation", "beam_attenuation","beam_transmission", "depth", "sea_water_sigma_t","descent_rate", "sound_velocity","altimeter")# Split data by station and create data listctd_FK <- cruise_df %>%split(.$station) %>%map(~ctd_load(.x, other_params = other_params)) # ~ is a lambda(x)
for (i inseq(ctd_FK)){ cast <- ctd_FK[[i]] # 1 is selecting only the first sublist# print(i)print(glue("=== station: {cast@metadata$station[1]}"))print(glue("# scans: {length(cast@data$scan)}"))plotScan(cast)}
=== station: .002
# scans: 3445
=== station: .007
# scans: 29
=== station: .010
# scans: 1661
=== station: .016
# scans: 2491
=== station: .058
# scans: 2018
=== station: .060
# scans: 3042
=== station: .064
# scans: 10
=== station: .065
# scans: 1739
=== station: .068
# scans: 2500
=== station: .12
# scans: 3949
=== station: .18
# scans: 3949
=== station: .21LK
# scans: 5134
=== station: .30
# scans: 4839
=== station: .31
# scans: 5993
=== station: .33
# scans: 3568
=== station: .41
# scans: 2548
=== station: .45
# scans: 2187
=== station: .47
# scans: 2427
=== station: .51
# scans: 1988
=== station: .53
# scans: 807
=== station: .54
# scans: 450
=== station: .55
# scans: 41
=== station: .56
# scans: 268
=== station: .57
# scans: 2376
=== station: .57_1
# scans: 1599
=== station: .57_2
# scans: 2843
=== station: .57_3
# scans: 3016
=== station: .9
# scans: 3649
=== station: .AM18
# scans: 5253
=== station: .AM19
# scans: 4195
=== station: .AMI1
# scans: 4246
=== station: .AMI2
# scans: 2703
=== station: .AMI3
# scans: 3356
=== station: .AMI4
# scans: 3814
=== station: .AMI5
# scans: 3561
=== station: .AMI6
# scans: 3070
=== station: .AMI7
# scans: 3785
=== station: .BG1
# scans: 1671
=== station: .BG2
# scans: 1900
=== station: .BG3
# scans: 2097
=== station: .BG4
# scans: 2657
=== station: .CAL1
# scans: 3254
=== station: .CAL2
# scans: 2145
=== station: .CAL3
# scans: 2877
=== station: .CAL4
# scans: 5100
=== station: .CAL5
# scans: 3076
=== station: .CAL6
# scans: 3921
=== station: .GP5
# scans: 2940
=== station: .KW1
# scans: 1649
=== station: .KW2
# scans: 2213
=== station: .KW4
# scans: 3918
=== station: .MR
# scans: 3828
=== station: .RP1
# scans: 2363
=== station: .RP2
# scans: 2051
=== station: .RP3
# scans: 2100
=== station: .RP4
# scans: 2015
=== station: .TB1
# scans: 2796
=== station: .TB1_RECAST
# scans: 2138
=== station: .TB10
# scans: 5217
=== station: .TB2
# scans: 1714
=== station: .TB3
# scans: 3703
=== station: .TB4
# scans: 4615
=== station: .TB5
# scans: 5415
=== station: .V1
# scans: 3324
=== station: .V2
# scans: 2616
=== station: .V3
# scans: 4225
=== station: .V4
# scans: 4691
=== station: .V5
# scans: 4533
=== station: .V6
# scans: 4683
=== station: .V7
# scans: 3244
=== station: .V8
# scans: 3959
=== station: .V9
# scans: 4042
=== station: .WS
# scans: 3743
plotting each cast in the first list
for (i inseq(ctd_FK)){ cast <- ctd_FK[[i]] # 1 is selecting only the first sublisttryCatch({plot(ctdDecimate(ctdTrim(cast))) }, error =function(e){print(e) })}
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3445' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 29' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1661' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2491' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2018' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3042' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2500' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3949' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3949' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5134' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4839' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5993' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3568' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2548' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2187' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2427' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1988' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 807' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2376' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1599' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2843' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3016' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3649' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5253' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4195' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4246' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2703' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3356' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3814' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3561' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3070' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3785' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1671' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1900' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2097' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2657' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3254' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2145' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2877' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5100' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3076' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3921' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2940' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1649' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2213' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3918' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3828' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2363' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2051' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2100' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2015' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2796' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2138' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5217' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1714' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3703' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4615' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5415' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3324' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2616' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4225' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4691' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4533' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4683' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3244' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3959' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4042' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3743' in coercion to 'logical(1)'>
plotting other physical parameters for each cast
# Loop through each CTD castfor (i inseq(ctd_FK)){ cast <- ctd_FK[[i]] # Assuming each sublist contains only one relevant CTD objecttryCatch({# Extract metadata for station name and cruise ID station_name <- cast@metadata$station[1] cruise_id <- cast@data$cruise_id[1]# Generate a title with station name and cruise ID overall_title <- glue::glue("Station: {station_name}, Cruise ID: {cruise_id}")# Set margins: increase the outer margin for the titlepar(oma =c(0, 0, 3, 0)) # Top outer margin increased for title# Plotting function with specific parameters oce::plot(x =ctdDecimate(ctdTrim(cast)),which =c("sea_water_electrical_conductivity","descent_rate", "sound_velocity","sea_water_sigma_t","altimeter" ),main =""# No main title for individual subplots )# Place a single overall title at the top of the plot framemtext(overall_title, side =3, line =1, outer =TRUE, cex =1.5)# Reset outer margins to defaultpar(oma =c(0, 0, 0, 0)) }, error =function(e) {print(e$message) # Print any errors that occur during plotting })}
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
plotting other nutrient parameters for each cast
# Loop through each CTD castfor (i inseq(ctd_FK)){ cast <- ctd_FK[[i]] # Assuming each sublist contains only one relevant CTD objecttryCatch({# Extract metadata for station name and cruise ID station_name <- cast@metadata$station[1] cruise_id <- cast@data$cruise_id[1]# Generate a title with station name and cruise ID overall_title <- glue::glue("Station: {station_name}, Cruise ID: {cruise_id}")# Set margins: increase the outer margin for the titlepar(oma =c(0, 0, 3, 0)) # Top outer margin increased for title# Plotting function with specific parameters oce::plot(x =ctdDecimate(ctdTrim(cast)),which =c("CDOM", "dissolved_oxygen","oxygen_saturation","chlorophyll_concentration", "chlorophyll_fluorescence" ),main =""# No main title for individual subplots )# Place a single overall title at the top of the plot framemtext(overall_title, side =3, line =1, outer =TRUE, cex =1.5)# Reset outer margins to defaultpar(oma =c(0, 0, 0, 0)) }, error =function(e) {print(e$message) # Print any errors that occur during plotting })}
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
[1] "In plot,ctd-method() : which=\"CDOMdissolved_oxygenoxygen_saturationchlorophyll_concentrationchlorophyll_fluorescence\" cannot be handled"
plotting other optical parameters for each cast
# Loop through each CTD castfor (i inseq(ctd_FK)){ cast <- ctd_FK[[i]] # Assuming each sublist contains only one relevant CTD objecttryCatch({# Extract metadata for station name and cruise ID station_name <- cast@metadata$station[1] cruise_id <- cast@data$cruise_id[1]# Generate a title with station name and cruise ID overall_title <- glue::glue("Station: {station_name}, Cruise ID: {cruise_id}")# Set margins: increase the outer margin for the titlepar(oma =c(0, 0, 3, 0)) # Top outer margin increased for title# Plotting function with specific parameters oce::plot(x =ctdDecimate(ctdTrim(cast)),which =c("photosynthetically_available_radiation","beam_attenuation","beam_transmission" ),main =""# No main title for individual subplots )# Place a single overall title at the top of the plot framemtext(overall_title, side =3, line =1, outer =TRUE, cex =1.5)# Reset outer margins to defaultpar(oma =c(0, 0, 0, 0)) }, error =function(e) {print(e$message) # Print any errors that occur during plotting })}
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
[1] "In plot,ctd-method() : which=\"photosynthetically_available_radiationbeam_attenuationbeam_transmission\" cannot be handled"
loop through every cast, clean, & save
combined_df <-data.frame()for (i inseq(ctd_FK)){tryCatch({ cast <- ctd_FK[[i]] # 1 is selecting only the first sublist# print(class(cast))# clean cast trimmed_cast <-ctdTrim(cast) decimated_cast <-ctdDecimate(trimmed_cast, p =0.5) # binned to 0.5 m# convert to df cast_df <-as.data.frame(decimated_cast@data)# Add metadata# assumes station ID and cruise ID the same for all & just uses 1st one cast_df <-mutate( cast_df,station = cast@data$station[1],cruise_id = cast@data$cruise_id[1] )# drop NA rows left by cleaning cast_df <-subset(cast_df, !is.na(scan))# Append the data to the combined dataframe combined_df <-rbind(combined_df, cast_df) }, error =function(e){print(glue("error in cast {cast@metadata$station[1]}"))print(e) })}# Save to CSVfile_path <-here(glue("data/cleaned/{cruise_id}.csv"))write.csv(combined_df, file_path, row.names =FALSE)