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)});
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: 10
# scans: 1866
=== station: 12
# scans: 5284
=== station: 16
# scans: 1726
=== station: 18
# scans: 6000
=== station: 2
# scans: 2027
=== station: 21/LK
# scans: 3474
=== station: 3
# scans: 4949
=== station: 30
# scans: 3602
=== station: 31
# scans: 3717
=== station: 33
# scans: 1578
=== station: 3B
# scans: 1053
=== station: 41
# scans: 1336
=== station: 45
# scans: 1531
=== station: 49
# scans: 1824
=== station: 51
# scans: 1527
=== station: 53
# scans: 1462
=== station: 54
# scans: 67
=== station: 54B
# scans: 531
=== station: 55
# scans: 1019
=== station: 55B
# scans: 279
=== station: 56
# scans: 688
=== station: 56B
# scans: 176
=== station: 57
# scans: 1393
=== station: 57.1
# scans: 880
=== station: 57.2
# scans: 1671
=== station: 57.2B
# scans: 1460
=== station: 57.3
# scans: 1515
=== station: 57.3B
# scans: 1951
=== station: 57.3SURF
# scans: 294
=== station: 57B
# scans: 259
=== station: 58
# scans: 2960
=== station: 59
# scans: 2034
=== station: 60
# scans: 1994
=== station: 62
# scans: 3
=== station: 64
# scans: 25
=== station: 65
# scans: 200
=== station: 68
# scans: 58
=== station: 7
# scans: 1273
=== station: 9
# scans: 5242
=== station: 9.5
# scans: 15069
=== station: MR
# scans: 4462
=== station: MRA
# scans: 1380
=== station: WS
# scans: 2304
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 = 1866' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5284' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1726' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 6000' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2027' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3474' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4949' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3602' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3717' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1578' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1053' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1336' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1531' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1824' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1527' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1462' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 67' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 531' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1019' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 279' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 688' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 176' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1393' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 880' 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 = 1460' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1515' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1951' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 259' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2960' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2034' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1994' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 25' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1273' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5242' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 15069' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4462' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1380' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2304' 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] "unknown xtype value (\"2.27342\")"
[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] "plot.new has not been called yet"
[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] "plot.new has not been called yet"
[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] "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] "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] "unknown xtype value (\"0.40281\")"
[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"
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)