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)});
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 1 row containing missing values or values outside the scale range
(`geom_line()`).
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)
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_col()`).
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: 1
# scans: 2086
=== station: 10
# scans: 1827
=== station: 11
# scans: 1768
=== station: 12
# scans: 3241
=== station: 13
# scans: 2172
=== station: 14
# scans: 3181
=== station: 15
# scans: 3259
=== station: 15.5
# scans: 7861
=== station: 16
# scans: 1791
=== station: 17
# scans: 2621
=== station: 18
# scans: 2117
=== station: 19
# scans: 1937
=== station: 2
# scans: 2006
=== station: 20
# scans: 2778
=== station: 21
# scans: 2913
=== station: 21.5
# scans: 8184
=== station: 22
# scans: 2327
=== station: 22.5
# scans: 9177
=== station: 23
# scans: 1942
=== station: 24
# scans: 2294
=== station: 25
# scans: 3841
=== station: 25.5
# scans: 13714
=== station: 26
# scans: 2765
=== station: 27
# scans: 2367
=== station: 28
# scans: 3306
=== station: 28.5
# scans: 3374
=== station: 29
# scans: 3456
=== station: 29.5
# scans: 2809
=== station: 3
# scans: 3574
=== station: 30
# scans: 2984
=== station: 31
# scans: 2170
=== station: 32
# scans: 3043
=== station: 33
# scans: 2941
=== station: 34
# scans: 2027
=== station: 39
# scans: 2433
=== station: 4
# scans: 1851
=== station: 40
# scans: 2750
=== station: 41
# scans: 2540
=== station: 42
# scans: 2515
=== station: 44
# scans: 2646
=== station: 45
# scans: 2058
=== station: 46
# scans: 2266
=== station: 47
# scans: 2580
=== station: 48
# scans: 2180
=== station: 49
# scans: 2526
=== station: 5
# scans: 2053
=== station: 5.5
# scans: 1616
=== station: 50
# scans: 2688
=== station: 51
# scans: 2807
=== station: 52
# scans: 2638
=== station: 53
# scans: 4680
=== station: 54
# scans: 2533
=== station: 55
# scans: 2411
=== station: 56
# scans: 2480
=== station: 57
# scans: 2683
=== station: 58
# scans: 3424
=== station: 59
# scans: 2626
=== station: 6
# scans: 3416
=== station: 6.5
# scans: 6731
=== station: 60
# scans: 2347
=== station: 61
# scans: 3846
=== station: 62
# scans: 2455
=== station: 63
# scans: 2320
=== station: 64
# scans: 2513
=== station: 65
# scans: 2160
=== station: 66
# scans: 2378
=== station: 67
# scans: 3270
=== station: 68
# scans: 2377
=== station: 69
# scans: 3046
=== station: 7
# scans: 1920
=== station: 70
# scans: 2311
=== station: 71
# scans: 1554
=== station: 8
# scans: 1780
=== station: 9
# scans: 2711
=== station: 9.5
# scans: 6632
=== station: CAL1
# scans: 2129
=== station: CAL2
# scans: 2508
=== station: CAL3
# scans: 3914
=== station: CAL4
# scans: 3208
=== station: CAL5
# scans: 3886
=== station: CH1
# scans: 3097
=== station: CH2
# scans: 5196
=== station: CH3
# scans: 3501
=== station: CH4
# scans: 6340
=== station: CH5
# scans: 5815
=== station: DT1
# scans: 2896
=== station: DT10
# scans: 2393
=== station: DT11
# scans: 2415
=== station: DT2
# scans: 2883
=== station: DT3
# scans: 3973
=== station: DT4
# scans: 5743
=== station: DT5
# scans: 4618
=== station: DT6
# scans: 6878
=== station: DT7
# scans: 19101
=== station: DT8
# scans: 8860
=== station: DT9
# scans: 4512
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 = 2086' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1827' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1768' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3241' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2172' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3181' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3259' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 7861' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1791' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2621' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2117' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1937' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2006' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2778' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2913' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 8184' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2327' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 9177' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1942' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2294' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3841' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 13714' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2765' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2367' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3306' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3374' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3456' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2809' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3574' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2984' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2170' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3043' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2941' 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 = 2433' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1851' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2750' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2540' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2515' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2646' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2058' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2266' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2580' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2180' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2526' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2053' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1616' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2688' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2807' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2638' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4680' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2533' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2411' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2480' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2683' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3424' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2626' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3416' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 6731' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2347' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3846' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2455' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2320' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2513' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2160' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2378' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3270' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2377' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3046' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1920' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2311' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1554' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 1780' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2711' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 6632' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2129' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2508' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3914' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3208' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3886' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3097' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5196' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3501' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 6340' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5815' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2896' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2393' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2415' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 2883' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 3973' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 5743' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4618' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 6878' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 19101' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 8860' in coercion to 'logical(1)'>
<simpleError in !is.null(x@metadata$station) && !is.na(x@metadata$station): 'length = 4512' 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"
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"
[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] "the condition has length > 1"
[1] "the condition has length > 1"
[1] "the condition has length > 1"
[1] "the condition has length > 1"
[1] "the condition has length > 1"
[1] "the condition has length > 1"
[1] "the condition has length > 1"
[1] "the condition has length > 1"
[1] "need finite 'xlim' values"
[1] "need finite 'xlim' values"
[1] "the condition has length > 1"
[1] "need finite 'xlim' values"
[1] "the condition has length > 1"
[1] "the condition has length > 1"
[1] "the condition has length > 1"
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)