Last updated: 2022-03-14
Checks: 7 0
Knit directory: emlr_obs_preprocessing/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20200707)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 19cd114. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: data/
Ignored: output/
Untracked files:
Untracked: code/IO_1990_own_crossover_analysis_backup.R
Untracked: code/read_GLODAPv2_2020.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/read_GLODAPv2_2021.Rmd
) and HTML (docs/read_GLODAPv2_2021.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 19cd114 | jens-daniel-mueller | 2022-03-14 | revised cruise mean offset plots |
html | 744b90f | jens-daniel-mueller | 2022-03-11 | Build site. |
Rmd | aae5fc5 | jens-daniel-mueller | 2022-03-11 | revised cruise mean offsets |
html | 84ca078 | jens-daniel-mueller | 2022-03-11 | Build site. |
Rmd | f9a4a5b | jens-daniel-mueller | 2022-03-11 | revised cruise-by_cruise |
html | efd6581 | jens-daniel-mueller | 2022-03-11 | Build site. |
Rmd | a5262b7 | jens-daniel-mueller | 2022-03-11 | revised cruise-by_cruise |
html | 25fef5b | jens-daniel-mueller | 2022-03-11 | Build site. |
Rmd | 064dea1 | jens-daniel-mueller | 2022-03-11 | revised cruise-by_cruise |
html | 02a01ef | jens-daniel-mueller | 2022-03-10 | Build site. |
Rmd | c6d5f07 | jens-daniel-mueller | 2022-03-10 | revised crossover analysis |
html | e3d1a2b | jens-daniel-mueller | 2022-03-10 | Build site. |
Rmd | a706c3e | jens-daniel-mueller | 2022-03-10 | revised xover analysis |
html | 070ca03 | jens-daniel-mueller | 2022-03-09 | Build site. |
Rmd | 204f92a | jens-daniel-mueller | 2022-03-09 | revised crossover analysis |
html | 9db485e | jens-daniel-mueller | 2022-02-25 | Build site. |
Rmd | ad16b56 | jens-daniel-mueller | 2022-02-25 | added cruise by cruise annual mean offset analysis |
html | fecc329 | jens-daniel-mueller | 2022-02-25 | Build site. |
Rmd | 4030fe6 | jens-daniel-mueller | 2022-02-25 | added cruise by cruise offset analysis |
html | 29af13b | jens-daniel-mueller | 2022-02-16 | Build site. |
Rmd | 9755b16 | jens-daniel-mueller | 2022-02-16 | cruise wise crossover analysis |
html | 6e65117 | jens-daniel-mueller | 2022-02-16 | Build site. |
Rmd | fc1cf80 | jens-daniel-mueller | 2022-02-15 | rerun with flux products |
html | cf43743 | jens-daniel-mueller | 2022-02-15 | Build site. |
Rmd | 04014b7 | jens-daniel-mueller | 2022-02-15 | decadal crossover evaluation pre subbasin |
html | 4a7550e | jens-daniel-mueller | 2022-02-15 | Build site. |
Rmd | 856705f | jens-daniel-mueller | 2022-02-15 | decadal crossover evaluation pre subbasin |
html | 8804a83 | jens-daniel-mueller | 2022-02-15 | Build site. |
Rmd | 0c2d719 | jens-daniel-mueller | 2022-02-15 | decadal crossover evaluation pre subbasin |
html | e1243c2 | jens-daniel-mueller | 2022-02-15 | Build site. |
Rmd | 8eced63 | jens-daniel-mueller | 2022-02-15 | decadal crossover evaluation pre subbasin |
html | efc2025 | jens-daniel-mueller | 2022-02-15 | Build site. |
Rmd | 73fc278 | jens-daniel-mueller | 2022-02-15 | decadal crossover evaluation pre subbasin |
html | 4d9d1cd | jens-daniel-mueller | 2022-01-17 | Build site. |
Rmd | 0a1ca07 | jens-daniel-mueller | 2022-01-17 | rerun without saving expocodes |
html | 9075296 | jens-daniel-mueller | 2022-01-12 | Build site. |
Rmd | 86182f0 | jens-daniel-mueller | 2022-01-12 | data contribution per cruise |
html | ecc669f | jens-daniel-mueller | 2022-01-04 | Build site. |
Rmd | 98d874a | jens-daniel-mueller | 2022-01-04 | calculate crossover of gap filled data |
html | 2620d02 | jens-daniel-mueller | 2022-01-03 | Build site. |
Rmd | ee1e44a | jens-daniel-mueller | 2022-01-03 | plot crossover of gap filled data |
html | ca3a146 | jens-daniel-mueller | 2022-01-03 | Build site. |
Rmd | f71bc69 | jens-daniel-mueller | 2022-01-03 | plot crossover of gap filled data |
html | 6e1b56c | jens-daniel-mueller | 2022-01-03 | Build site. |
Rmd | c5258b1 | jens-daniel-mueller | 2022-01-03 | plot crossover of gap filled data |
html | 9febbb8 | jens-daniel-mueller | 2022-01-03 | Build site. |
Rmd | cd89345 | jens-daniel-mueller | 2022-01-03 | plot crossover of gap filled data |
html | 1a9c797 | jens-daniel-mueller | 2022-01-03 | Build site. |
Rmd | cde43c6 | jens-daniel-mueller | 2022-01-03 | plot crossover of gap filled data |
html | 494beda | jens-daniel-mueller | 2022-01-03 | Build site. |
Rmd | 47811bd | jens-daniel-mueller | 2022-01-03 | plot crossover of gap filled data |
html | 51ec1fe | jens-daniel-mueller | 2021-12-23 | Build site. |
Rmd | 468c324 | jens-daniel-mueller | 2021-12-23 | added crossover cruise subsetting |
html | 28ed51f | jens-daniel-mueller | 2021-12-21 | Build site. |
Rmd | f99a7ce | jens-daniel-mueller | 2021-12-21 | print tables with flagging number |
html | fcff192 | jens-daniel-mueller | 2021-12-21 | Build site. |
Rmd | e60be65 | jens-daniel-mueller | 2021-12-21 | added flagging profiles |
html | a87f8c7 | jens-daniel-mueller | 2021-12-20 | Build site. |
Rmd | 7511f8c | jens-daniel-mueller | 2021-12-20 | revised IO analysis |
html | 2704ff6 | jens-daniel-mueller | 2021-12-20 | Build site. |
Rmd | f4696af | jens-daniel-mueller | 2021-12-20 | added cruise maps |
html | 7f65d3a | jens-daniel-mueller | 2021-12-20 | Build site. |
Rmd | 208283d | jens-daniel-mueller | 2021-12-20 | revised missing cruise crossover analysis |
html | 6106236 | jens-daniel-mueller | 2021-12-20 | Build site. |
Rmd | 953ac0a | jens-daniel-mueller | 2021-12-20 | revised missing cruise crossover analysis |
html | d5ef2c6 | jens-daniel-mueller | 2021-12-20 | Build site. |
Rmd | 0b0800e | jens-daniel-mueller | 2021-12-20 | restructured IO crossover analysis |
html | 00227e6 | jens-daniel-mueller | 2021-12-20 | Build site. |
Rmd | 8728169 | jens-daniel-mueller | 2021-12-20 | added IO crossover analysis |
html | e810585 | jens-daniel-mueller | 2021-12-16 | Build site. |
Rmd | aca9273 | jens-daniel-mueller | 2021-12-16 | added maps per expocode |
html | 6aa4b75 | jens-daniel-mueller | 2021-12-16 | Build site. |
Rmd | 3511fa7 | jens-daniel-mueller | 2021-12-16 | f == 9 analysis added |
html | 163f976 | jens-daniel-mueller | 2021-12-16 | Build site. |
Rmd | 7fa3a99 | jens-daniel-mueller | 2021-12-16 | added cumulative data contribution as threshold |
html | be0850d | jens-daniel-mueller | 2021-12-16 | Build site. |
Rmd | 8db3760 | jens-daniel-mueller | 2021-12-16 | plot maps of f and qc data loss |
html | 61d5f49 | jens-daniel-mueller | 2021-12-15 | Build site. |
Rmd | be2f94e | jens-daniel-mueller | 2021-12-15 | analyse IO 1990 CRM data from Millero 1998 - TA only |
html | d454df1 | jens-daniel-mueller | 2021-12-15 | Build site. |
Rmd | 7802f47 | jens-daniel-mueller | 2021-12-15 | analyse IO 1990 CRM data from Millero 1998 |
html | ce6cdae | jens-daniel-mueller | 2021-12-15 | Build site. |
Rmd | acff553 | jens-daniel-mueller | 2021-12-15 | plot qc data loss by cruise size |
html | 7ace7ab | jens-daniel-mueller | 2021-12-15 | Build site. |
Rmd | 554383a | jens-daniel-mueller | 2021-12-15 | plot qc data loss by cruise size |
html | faa6b3c | jens-daniel-mueller | 2021-12-15 | Build site. |
Rmd | be8751d | jens-daniel-mueller | 2021-12-15 | started data loss assesment |
html | 70923f2 | jens-daniel-mueller | 2021-12-14 | Build site. |
Rmd | 1acf7ff | jens-daniel-mueller | 2021-12-14 | checked P18 nitrate data - quadratic fit |
html | b68b58e | jens-daniel-mueller | 2021-12-13 | Build site. |
Rmd | 4c002c1 | jens-daniel-mueller | 2021-12-13 | checked P18 nitrate data |
html | de20732 | jens-daniel-mueller | 2021-12-08 | Build site. |
Rmd | badaed2 | jens-daniel-mueller | 2021-12-08 | plotted f maps |
html | daa43b9 | jens-daniel-mueller | 2021-12-06 | Build site. |
Rmd | b578bd9 | jens-daniel-mueller | 2021-12-06 | plotted qc maps |
html | 2b22ffe | jens-daniel-mueller | 2021-11-24 | Build site. |
Rmd | 1b7ec1f | jens-daniel-mueller | 2021-11-24 | revised combined IO NS and EW analysis |
html | 0ef46e8 | jens-daniel-mueller | 2021-11-23 | Build site. |
Rmd | 7fb15cf | jens-daniel-mueller | 2021-11-23 | combined IO NS and EW analysis |
html | f2871b9 | jens-daniel-mueller | 2021-11-20 | Build site. |
Rmd | 46c1246 | jens-daniel-mueller | 2021-11-19 | rerun with GLODAP cast column |
html | 375d7c7 | jens-daniel-mueller | 2021-11-18 | Build site. |
Rmd | 1839007 | jens-daniel-mueller | 2021-11-18 | delta EW crossover values determined |
html | f30883c | jens-daniel-mueller | 2021-11-18 | Build site. |
Rmd | 7acd48c | jens-daniel-mueller | 2021-11-18 | delta crossover values determined |
html | 2e6c3f1 | jens-daniel-mueller | 2021-11-18 | Build site. |
Rmd | 49ca05c | jens-daniel-mueller | 2021-11-18 | delta crossover values determined |
html | 16dab59 | jens-daniel-mueller | 2021-11-18 | Build site. |
Rmd | 620b6f4 | jens-daniel-mueller | 2021-11-18 | delta crossover values determined |
html | 42965b9 | jens-daniel-mueller | 2021-11-18 | Build site. |
Rmd | 69dbb5f | jens-daniel-mueller | 2021-11-18 | crossing checks |
html | c9363ce | jens-daniel-mueller | 2021-11-18 | Build site. |
Rmd | 6bc79d6 | jens-daniel-mueller | 2021-11-18 | crossing checks |
html | 0908ee5 | jens-daniel-mueller | 2021-11-15 | Build site. |
html | 6d6a23e | jens-daniel-mueller | 2021-11-01 | Build site. |
Rmd | 2f36786 | jens-daniel-mueller | 2021-11-01 | preprocess adjustment table, create new basinmaps |
html | 2a50fa9 | jens-daniel-mueller | 2021-10-28 | Build site. |
Rmd | 67de9ab | jens-daniel-mueller | 2021-10-28 | preprocess tracers |
html | a96bf9e | jens-daniel-mueller | 2021-10-27 | Build site. |
Rmd | d99b131 | jens-daniel-mueller | 2021-10-27 | added time series plots |
html | fde6c32 | jens-daniel-mueller | 2021-10-27 | Build site. |
Rmd | db93d9f | jens-daniel-mueller | 2021-10-27 | added time series plots |
html | 7db7e6a | jens-daniel-mueller | 2021-10-27 | Build site. |
Rmd | d6fb0dc | jens-daniel-mueller | 2021-10-27 | added time series plots |
html | 68d67e7 | jens-daniel-mueller | 2021-10-27 | Build site. |
Rmd | b4ea199 | jens-daniel-mueller | 2021-10-27 | added time series plots |
html | 7987bb7 | jens-daniel-mueller | 2021-10-21 | Build site. |
Rmd | b64c54d | jens-daniel-mueller | 2021-10-21 | added inventory layer depth |
html | 8d1aaf8 | jens-daniel-mueller | 2021-10-20 | Build site. |
Rmd | 5bce752 | jens-daniel-mueller | 2021-10-20 | corrected qc flag in glodap |
html | dc8d958 | jens-daniel-mueller | 2021-10-20 | Build site. |
Rmd | b2ccc04 | jens-daniel-mueller | 2021-10-20 | corrected qc flag in glodap |
html | 2438c5a | jens-daniel-mueller | 2021-08-30 | Build site. |
Rmd | 4296433 | jens-daniel-mueller | 2021-08-30 | rerun GLODAP preprocessing with officially released file |
html | e49875a | jens-daniel-mueller | 2021-07-07 | Build site. |
html | 6312bd4 | jens-daniel-mueller | 2021-07-07 | Build site. |
Rmd | 4905409 | jens-daniel-mueller | 2021-07-07 | rerun with new setup_obs.Rmd file |
html | 58bc706 | jens-daniel-mueller | 2021-07-06 | Build site. |
Rmd | 0db89e1 | jens-daniel-mueller | 2021-07-06 | rerun with revised variable names |
html | f600971 | jens-daniel-mueller | 2021-07-02 | Build site. |
html | 98599d8 | jens-daniel-mueller | 2021-06-27 | Build site. |
Rmd | 4f9c370 | jens-daniel-mueller | 2021-06-27 | update to latest GLODAP pre-release |
html | 265c4ef | jens-daniel-mueller | 2021-06-04 | Build site. |
html | c79346a | jens-daniel-mueller | 2021-06-03 | Build site. |
html | 9d8353f | jens-daniel-mueller | 2021-05-31 | Build site. |
Rmd | b948168 | jens-daniel-mueller | 2021-05-31 | ingest GLODAPv2_2021 beta data |
path_glodapv2_2021 <- "/nfs/kryo/work/updata/glodapv2_2021/"
path_glodapv2_CRM <- "/nfs/kryo/work/updata/glodapv2_CRM/"
path_crossover <- "/nfs/kryo/work/updata/glodapv2_crossover"
path_preprocessing <- paste(path_root, "/observations/preprocessing/", sep = "")
Main data source for this project is GLODAPv2.2021_Merged_Master_File.csv
downloaded from https://www.ncei.noaa.gov/data/oceans/ncei/ocads/data/0237935/GLODAPv2.2021_Merged_Master_File.csv
on Aug 30, 2021.
GLODAP <-
read_csv(
paste(
path_glodapv2_2021,
"GLODAPv2.2021_Merged_Master_File_20210830.csv",
sep = ""
),
na = "-9999",
col_types = cols(.default = col_double())
)
GLODAP <- GLODAP %>%
rename_with(~str_remove(., 'G2'))
GLODAP_adjustments <-
read_csv(
paste(
path_glodapv2_2021,
"GLODAPv2.2021_adjustments_last_updated_on_2021_05_10.csv",
sep = ""
),
na = c("-666", "-777", "-888", "-999"),
skip = 2
)
GLODAP_expocodes <-
read_tsv(
paste(
path_glodapv2_2021,
"EXPOCODES.txt",
sep = ""
),
col_names = c("cruise", "cruise_expocode")
)
# tables from glodapv2, provided by Steven van Heuven
glodapv2_xover_files <- fs::dir_ls(paste0(path_crossover, "/glodapv2"))
glodapv2_xover <- glodapv2_xover_files %>%
map_dfr(read_csv, .id = "parameter")
glodapv2_xover <- glodapv2_xover %>%
mutate(parameter = str_remove(parameter, ".csv"),
parameter = str_sub(parameter, -3))
glodapv2_xover <- glodapv2_xover %>%
mutate(parameter = recode(parameter,
"ALK" = "talk",
"DIC" = "tco2",
"NO3" = "nitrate",
"_O2" = "oxygen",
"PO4" = "phosphate",
"SAL" = "salinity",
"SIL" = "silicate"))
# Note: In the files provided by Steven von Heuven
# the column names sigma_ratio and sigma_offset_sd were swapped
glodapv2_xover_absolute <- glodapv2_xover %>%
filter(parameter %in% c("salinity", "talk", "tco2")) %>%
select(parameter,
offset = sigma_offset,
offset_sd = sigma_ratio,
cruise_A = CruiseA_EXPOCODE,
cruise_B = CruiseB_EXPOCODE)
glodapv2_xover_ratio <- glodapv2_xover %>%
filter(!(parameter %in% c("salinity", "talk", "tco2"))) %>%
select(parameter,
offset = sigma_offset_sd,
offset_sd = sigma_ratio_sd,
cruise_A = CruiseA_EXPOCODE,
cruise_B = CruiseB_EXPOCODE)
glodapv2_xover <- bind_rows(
glodapv2_xover_absolute,
glodapv2_xover_ratio
)
rm(glodapv2_xover_files,
glodapv2_xover_absolute, glodapv2_xover_ratio)
# tables created between glodapv2 and glodapv2.2021
# provided by Nico Lange
glodapv2_2021_xover_files <- fs::dir_ls(paste0(path_crossover, "/glodapv2_2021"))
glodapv2_2021_xover <- glodapv2_2021_xover_files %>%
map_dfr(readxl::read_excel)
glodapv2_2021_xover <- glodapv2_2021_xover %>%
rename(parameter = Parameter) %>%
mutate(parameter = recode(parameter,
"alkalinity" = "talk")) %>%
filter(
parameter %in%
c(
"tco2",
"nitrate",
"oxygen",
"phosphate",
"salinity",
"silicate",
"talk"
)
)
glodapv2_2021_xover <- glodapv2_2021_xover %>%
rename(offset = Offset,
offset_sd = Std,
cruise_A = Cruise_A,
cruise_B = Cruise_B)
rm(glodapv2_2021_xover_files)
# tables for data not qc'ed in the regular GLODAP release
# provided by Nico Lange
glodapv2_2021_xover_files_add <-
fs::dir_ls(paste0(path_crossover, "/glodapv2_2021_additional_crossover"))
glodapv2_2021_xover_add <- glodapv2_2021_xover_files_add %>%
map_dfr(readxl::read_excel)
glodapv2_2021_xover_add <- glodapv2_2021_xover_add %>%
rename(parameter = Parameter) %>%
mutate(parameter = recode(parameter,
"alkalinity" = "talk"))
glodapv2_2021_xover_add <- glodapv2_2021_xover_add %>%
rename(offset = Offset,
offset_sd = Std,
cruise_A = Cruise_A,
cruise_B = Cruise_B)
rm(glodapv2_2021_xover_files_add)
I generated this file manually based on the analysis presented in the Data loss section below.
GLODAP_cruises_missing <-
read_csv(
paste(
path_glodapv2_2021,
"GLODAPv2.2021_major_cruises_missing_flagged.csv",
sep = ""
)
)
CRM_IO_meas <-
read_csv(
paste(
path_glodapv2_CRM,
"/Millero_1998_Tab2.csv",
sep = ""
)
)
CRM_ref_values <-
read_csv(
paste(
path_glodapv2_CRM,
"/Dickson_CRM_reference_values_20211215.csv",
sep = ""
)
)
From an email conversation with Nico Lange
Yes, we are aware of these faulty(!) calculated TA data (using DIC and fCO2). It is linked to v2.2020 where we’ve added fCO2 to the “missing carbon calculation matrix”. Overall, including fCO2 in these calculations has worked great to fill some missing carbon gaps. However, for this cruise in particular the fCO2 values have most likely been converted wrongly to 20°C and are thus off! The problem of this all is that we haven’t really done a 2nd QC on the fCO2 values neither have we defined the corresponding “G2fCO2qc” variable, hence for the sake of consistency we kept all fCO2 values in. Again and unfortunately, in this particular case it led to the bad calculations of TA data…. We plan to do a full 2nd QC on all (!) fCO2 data for v3.
But you have indeed found a flaw in our merging script, as the corresponding calculated TA values should not have received a 2nd QC flag of 1! I missed out on adding a line to our merging script to accommodate for the non-existence of 2nd fCO2 flags in the carbon calculation matrix.
So long story short: Thank you very much for finding this flaw and letting me know of it!
and
Yes, the all calculated TA data from cruise 695 should have a talkqc of 0 (as they are based upon un QC’d fCO2 data…).
And no (thanks to your hint and questions), I figured that this wrongly assigned 2nd QC flag is a problem for all calculated carbon data, which used fCO2 for the calculations. However, luckily this is not really often the case.
You can check if thats the case by looking at which other carbon parameters are measured, i.e. by checking their primary flags (e.g. G2talkf, G2tco2f and G2phts25p0f and G2fco2f). If only two are measured and one of them is fCO2, it means that the other carbon parameters (the ones with a primary flag of 0) are calculated using fCO2. Hence, for these instances no 2nd QC is done and the corresponding qc flag should be 0 and not 1.
# calculate number of measured co2 system variables
GLODAP <- GLODAP %>%
mutate(measured_CO2_vars = rowSums(select(., c(
tco2f, talkf, fco2f, phts25p0f
)) == 2))
# identify cruises on which talk/tco2 was calculated
talk_qc_error_cruises <- GLODAP %>%
select(cruise, tco2:phtsqc, measured_CO2_vars) %>%
filter(measured_CO2_vars == 2,
fco2f == 2,
talkf == 0) %>%
distinct(cruise, talkf, talkqc, fco2f)
tco2_qc_error_cruises <- GLODAP %>%
select(cruise, tco2:phtsqc, measured_CO2_vars) %>%
filter(measured_CO2_vars == 2,
fco2f == 2,
tco2f == 0) %>%
distinct(cruise, tco2f, tco2qc, fco2f)
talk_qc_error_cruises %>%
write_csv("data/talk_qc_error_cruises_GLODAPv2_2021.csv")
tco2_qc_error_cruises %>%
write_csv("data/tco2_qc_error_cruises_GLODAPv2_2021.csv")
rm(talk_qc_error_cruises, tco2_qc_error_cruises)
# set qc = 0 for tco2 and talk values calculated from fco2
GLODAP <- GLODAP %>%
mutate(tco2qc = if_else(measured_CO2_vars == 2 &
fco2f == 2 & tco2f == 0,
0,
tco2qc))
GLODAP <- GLODAP %>%
mutate(talkqc = if_else(measured_CO2_vars == 2 &
fco2f == 2 & talkf == 0,
0,
talkqc))
GLODAP <- GLODAP %>%
select(-measured_CO2_vars)
# create date column
GLODAP <- GLODAP %>%
mutate(date = ymd(paste(year, month, day))) %>%
relocate(date)
# harmonize column names
GLODAP <- GLODAP %>%
rename(sal = salinity,
temp = temperature)
# harmonize coordinates
GLODAP <- GLODAP %>%
rename(lon = longitude,
lat = latitude) %>%
mutate(lon = if_else(lon < 20, lon + 360, lon))
For merging with other data sets, all observations were grouped into latitude intervals of:
GLODAP <- m_grid_horizontal(GLODAP)
# use only three basin to assign general basin mask
# ie this is not specific to the MLR fitting
basinmask_5 <- basinmask %>%
filter(MLR_basins == "5") %>%
select(lat, lon, basin)
basinmask <- basinmask %>%
filter(MLR_basins == "2") %>%
select(lat, lon, basin_AIP)
GLODAP <- inner_join(GLODAP, basinmask)
GLODAP <- right_join(
GLODAP_expocodes,
GLODAP)
GLODAP <- GLODAP %>%
mutate(row_number = row_number()) %>%
relocate(row_number)
Measurements of CO2 system and other biogeochemical parameters are separated from the measurements of halogenated tracers.
# remove irrelevant columns
GLODAP <- GLODAP %>%
select(-c(region,
month:minute,
maxsampdepth, sigma0:sigma4,
nitrite:nitritef))
GLODAP_tracer <- GLODAP %>%
select(row_number:gamma,
cfc11:sf6f,
basin_AIP)
# select relevant columns
GLODAP <- GLODAP %>%
select(row_number:talkqc,
basin_AIP)
The vast majority of rows is removed due to missing tco2
observations.
GLODAP <- GLODAP %>%
filter(!is.na(tco2))
Rows are removed if no tracer observation is available.
GLODAP_tracer <- GLODAP_tracer %>%
filter(if_any(
c(
cfc11,
cfc12,
cfc113,
ccl4,
sf6,
pcfc11,
pcfc12,
pcfc113,
pccl4,
psf6
),
~ !is.na(.)
))
GLODAP_obs_grid <- GLODAP %>%
count(lat, lon)
GLODAP_grid_year <- GLODAP %>%
count(lat, lon, year)
map +
geom_tile(data = GLODAP_grid_year,
aes(lon, lat)) +
facet_wrap(~ year, ncol=3)
GLODAP_obs_grid_tracer <- GLODAP_tracer %>%
count(lat, lon)
GLODAP_grid_year_tracer <- GLODAP_tracer %>%
count(lat, lon, year)
map +
geom_tile(data = GLODAP_grid_year_tracer,
aes(lon, lat)) +
facet_wrap(~ year, ncol=3)
In this sections, I explore the data coverage with respect to the flagging scheme. Data are not manipulated in this section.
qc_flag <- GLODAP %>%
mutate(decade = m_grid_decade(year),
.after = year) %>%
filter(!is.na(decade)) %>%
select(lon, lat, basin_AIP, decade, cruise_expocode, ends_with("qc"))
qc_flag_grid <- qc_flag %>%
pivot_longer(ends_with("qc"),
names_to = "parameter",
values_to = "value") %>%
count(lon, lat, decade, parameter, value)
p_qc_flag_map <- qc_flag_grid %>%
group_split(value) %>%
# head(1) %>%
map(
~ map +
geom_tile(data = .x,
aes(lon, lat, fill = n)) +
facet_grid(parameter ~ decade) +
labs(title = paste("qc flag =", unique(.x$value))) +
scale_fill_viridis_c(
option = "magma",
direction = -1,
trans = "log10"
)
)
p_qc_flag_map
[[1]]
[[2]]
pdf("output/qc_flag_coverage_maps.pdf")
p_qc_flag_map
[[1]]
[[2]]
dev.off()
png
2
qc_flag_grid_all_1 <- qc_flag %>%
filter(
if_all(ends_with("qc"), ~ . == 1)) %>%
count(lon, lat, decade)
map +
geom_tile(data = qc_flag_grid_all_1,
aes(lon, lat, fill = n)) +
facet_grid(decade ~ .) +
labs(title = "All parameters qc == 1") +
scale_fill_viridis_c(option = "magma",
direction = -1,
trans = "log10")
Version | Author | Date |
---|---|---|
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
rm(qc_flag, qc_flag_grid, p_qc_flag_map, qc_flag_grid_all_1)
f_flag <- GLODAP %>%
mutate(decade = m_grid_decade(year),
.after = year) %>%
filter(!is.na(decade)) %>%
select(lon, lat, basin_AIP, decade, cruise_expocode, ends_with("f"))
f_flag_grid <- f_flag %>%
pivot_longer(ends_with("f"),
names_to = "parameter",
values_to = "value") %>%
count(lon, lat, decade, parameter, value)
p_f_flag_map <- f_flag_grid %>%
group_split(value) %>%
# head(1) %>%
map(
~map +
geom_tile(data = .x,
aes(lon, lat, fill=n)) +
facet_grid(parameter ~ decade) +
labs(title = paste("f flag =", unique(.x$value))) +
scale_fill_viridis_c(option = "magma",
direction = -1,
trans = "log10")
)
p_f_flag_map
[[1]]
[[2]]
[[3]]
pdf("output/f_flag_coverage_maps.pdf")
p_f_flag_map
[[1]]
[[2]]
[[3]]
dev.off()
png
2
f_flag_grid_all_2 <- f_flag %>%
filter(
if_all(ends_with("f"), ~ . == 2)) %>%
count(lon, lat, decade)
map +
geom_tile(data = f_flag_grid_all_2,
aes(lon, lat, fill = n)) +
facet_grid(decade ~ .) +
labs(title = "All parameters f == 2") +
scale_fill_viridis_c(option = "magma",
direction = -1,
trans = "log10")
Version | Author | Date |
---|---|---|
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
rm(f_flag, f_flag_grid, p_f_flag_map, f_flag_grid_all_2)
In this section, I explore the potential loss of data if certain quality quality flag criteria are not met by the observations.
loss_all <- GLODAP %>%
mutate(decade = m_grid_decade(year),
.after = year) %>%
filter(!is.na(decade))
loss <- loss_all %>%
filter(if_all(ends_with("f"), ~ . != 9))
map +
geom_tile(data = loss_all %>% distinct(lon, lat, decade),
aes(lon, lat, fill = "incl f = 9")) +
geom_tile(data = loss %>% distinct(lon, lat, decade),
aes(lon, lat, fill = "excl f = 9")) +
scale_fill_brewer(palette = "Set1") +
facet_grid(decade ~ .) +
labs(title = "All available data") +
theme(legend.title = element_blank())
loss_all_n <- loss_all %>%
count(basin_AIP, decade)
loss_n <- loss %>%
count(basin_AIP, decade)
Here, I analysis the loss of data due to qc flagging, based on the samples were all parameters are available (i.e. where f-flag != 9).
# prepare qc loss data
loss_qc <- loss %>%
select(lon, lat, basin_AIP, decade, cruise_expocode, ends_with("qc")) %>%
pivot_longer(ends_with("qc"),
names_to = "parameter",
values_to = "value") %>%
mutate(parameter = str_remove(parameter, "qc"))
# compute fraction of qc loss per parameters and cruise
loss_qc <- loss_qc %>%
count(cruise_expocode, basin_AIP, decade, parameter, value) %>%
pivot_wider(
names_from = value,
names_prefix = "qc_",
values_from = n,
values_fill = 0
) %>%
mutate(n_cruise = qc_0 + qc_1,
category = if_else(qc_0 <= 0.1 * (n_cruise), "OK", "loss"))
# calculate number of parameters with loss
# separately for target/predictor variables
loss_qc_cruise <- loss_qc %>%
mutate(parameter_class = if_else(
parameter %in% c("tco2", "talk", "phosphate"),
"target",
"predictor"
)) %>%
count(cruise_expocode,
basin_AIP,
decade,
n_cruise,
parameter_class,
category) %>%
pivot_wider(names_from = category,
values_from = n,
values_fill = 0) %>%
select(-OK) %>%
pivot_wider(names_from = parameter_class,
values_from = loss) %>%
group_by(basin_AIP, decade) %>%
mutate(rank_n_cruise = rank(-n_cruise)) %>%
ungroup()
# combine with total number of observations
loss_qc_cruise <- full_join(loss_qc_cruise, loss_n)
# calculate relative contribution of cruise samples to total
loss_qc_cruise <- loss_qc_cruise %>%
mutate(n_cruise_rel = 100 * n_cruise / n) %>%
arrange(basin_AIP, decade, -n_cruise_rel) %>%
group_by(basin_AIP, decade) %>%
mutate(n_cruise_rel_cum = cumsum(n_cruise_rel)) %>%
ungroup() %>%
select(-n)
loss_qc_cruise <- loss_qc_cruise %>%
pivot_longer(predictor:target,
names_to = "parameter_class",
values_to = "loss") %>%
mutate(loss = as.factor(loss))
grey_plasma <- c("grey80", viridisLite::plasma(4))
# filter large cruises
loss_qc_cruise <- loss_qc_cruise %>%
filter(n_cruise_rel >= 3)
loss_qc_cruise %>%
group_split(basin_AIP) %>%
# head(3) %>%
map(
~ ggplot(data = .x,
aes(rank_n_cruise, n_cruise_rel, fill = loss)) +
geom_point(shape = 21, size = 2) +
scale_fill_manual(values = grey_plasma,
name = "variables missing") +
facet_grid(decade ~ parameter_class) +
labs(title = paste("basin_AIP:", unique(.x$basin_AIP))) +
ylim(0, NA)
)
[[1]]
[[2]]
[[3]]
loss_qc_cruise %>%
filter(loss != 0) %>%
select(basin_AIP,
decade,
parameter_class,
rank_n_cruise,
cruise_expocode,
loss) %>%
arrange(basin_AIP, decade, parameter_class, rank_n_cruise) %>%
kable() %>%
kable_styling() %>%
scroll_box(height = "300px")
basin_AIP | decade | parameter_class | rank_n_cruise | cruise_expocode | loss |
---|---|---|---|---|---|
Atlantic | 1989-1999 | target | 11 | 06MT19900123 | 1 |
Atlantic | 1989-1999 | target | 12 | 33LK19960415 | 1 |
Atlantic | 2000-2009 | predictor | 8 | 35TH20010823 | 3 |
Atlantic | 2000-2009 | predictor | 14 | 33RO20070710 | 1 |
Atlantic | 2000-2009 | target | 8 | 35TH20010823 | 2 |
Atlantic | 2000-2009 | target | 9 | 74DI20040404 | 1 |
Atlantic | 2000-2009 | target | 10 | 35TH20080610 | 1 |
Atlantic | 2000-2009 | target | 12 | 35TH20040604 | 1 |
Atlantic | 2000-2009 | target | 13 | 35TH20020611 | 1 |
Atlantic | 2010-2020 | predictor | 5 | 74EQ20151206 | 1 |
Atlantic | 2010-2020 | target | 12 | 35TH20100608 | 1 |
Atlantic | 2010-2020 | target | 13 | 29AH20160617 | 1 |
Indian | 1989-1999 | target | 11 | 320619960503 | 1 |
Pacific | 1989-1999 | predictor | 2 | 31DS19940126 | 1 |
Pacific | 1989-1999 | predictor | 4 | 31DS19920907 | 3 |
Pacific | 1989-1999 | target | 4 | 31DS19920907 | 3 |
Pacific | 1989-1999 | target | 6 | 316N19930222 | 1 |
Pacific | 1989-1999 | target | 7 | 316N19921006 | 1 |
Pacific | 1989-1999 | target | 8 | 90KD19920214 | 1 |
loss_grid <- loss %>% distinct(lon, lat, cruise_expocode)
loss_qc_grid <- left_join(loss_qc_cruise,
loss_grid)
map +
geom_tile(data = loss_qc_grid,
aes(lon, lat, fill = loss)) +
facet_grid(decade ~ parameter_class) +
scale_fill_manual(values = grey_plasma)
loss_qc_grid %>% filter(loss != 0) %>%
group_split(parameter_class, decade) %>%
# head(1) %>%
map(
~ map +
geom_tile(data = .x,
aes(lon, lat, fill = cruise_expocode)) +
scale_fill_brewer(palette = "Paired") +
facet_grid(decade ~ parameter_class)
)
[[1]]
[[2]]
[[3]]
[[4]]
[[5]]
[[6]]
Version | Author | Date |
---|---|---|
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
rm(loss_qc_cruise, loss_qc_grid)
Here, I analysis the loss of data due to f flagging, based on the samples were all parameters are available (i.e. where f-flag != 9).
# prepare qc loss data
loss_f <- loss %>%
select(lon, lat, basin_AIP, decade, cruise_expocode, ends_with("f")) %>%
pivot_longer(ends_with("f"),
names_to = "parameter",
values_to = "value") %>%
mutate(parameter = str_remove(parameter, "f"))
# compute fraction of qc loss per parameters and cruise
loss_f <- loss_f %>%
count(cruise_expocode, basin_AIP, decade, parameter, value) %>%
pivot_wider(
names_from = value,
names_prefix = "f_",
values_from = n,
values_fill = 0
) %>%
mutate(n_cruise = f_0 + f_2,
category = if_else(f_0 <= 0.1 * (n_cruise), "OK", "loss"))
# calculate number of parameters with loss
# separately for target/predictor variables
loss_f_cruise <- loss_f %>%
mutate(parameter_class = if_else(
parameter %in% c("tco2", "talk", "phosphate"),
"target",
"predictor"
)) %>%
count(cruise_expocode,
basin_AIP,
decade,
n_cruise,
parameter_class,
category) %>%
pivot_wider(names_from = category,
values_from = n,
values_fill = 0) %>%
select(-OK) %>%
pivot_wider(names_from = parameter_class,
values_from = loss) %>%
group_by(basin_AIP, decade) %>%
mutate(rank_n_cruise = rank(-n_cruise)) %>%
ungroup()
# combine with total number of observations
loss_f_cruise <- full_join(loss_f_cruise, loss_n)
# calculate relative contribution of cruise samples to total
loss_f_cruise <- loss_f_cruise %>%
mutate(n_cruise_rel = 100 * n_cruise / n) %>%
arrange(basin_AIP, decade, -n_cruise_rel) %>%
group_by(basin_AIP, decade) %>%
mutate(n_cruise_rel_cum = cumsum(n_cruise_rel)) %>%
ungroup() %>%
select(-n)
loss_f_cruise <- loss_f_cruise %>%
pivot_longer(predictor:target,
names_to = "parameter_class",
values_to = "loss") %>%
mutate(loss = as.factor(loss))
grey_plasma <- c("grey80", viridisLite::plasma(4))
# filter large cruises
loss_f_cruise <- loss_f_cruise %>%
filter(n_cruise_rel >= 3)
loss_f_cruise %>%
group_split(basin_AIP) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(rank_n_cruise, n_cruise, fill = loss)) +
geom_point(shape = 21, size = 2) +
scale_fill_manual(values = grey_plasma,
name = "variables missing") +
facet_grid(decade ~ parameter_class) +
labs(title = paste("basin_AIP:", unique(.x$basin_AIP))) +
ylim(0, NA)
)
[[1]]
[[2]]
[[3]]
loss_f_cruise %>%
filter(loss != 0) %>%
select(basin_AIP,
decade,
parameter_class,
rank_n_cruise,
cruise_expocode,
loss) %>%
arrange(basin_AIP, decade, parameter_class, rank_n_cruise) %>%
kable() %>%
kable_styling() %>%
scroll_box(height = "300px")
basin_AIP | decade | parameter_class | rank_n_cruise | cruise_expocode | loss |
---|---|---|---|---|---|
Atlantic | 1989-1999 | target | 1 | 323019940104 | 1 |
Atlantic | 1989-1999 | target | 7 | 33RO19980123 | 1 |
Atlantic | 1989-1999 | target | 9 | 35A319950113 | 1 |
Atlantic | 1989-1999 | target | 11 | 06MT19900123 | 1 |
Atlantic | 1989-1999 | target | 12 | 33LK19960415 | 1 |
Atlantic | 2000-2009 | target | 8 | 35TH20010823 | 1 |
Atlantic | 2000-2009 | target | 9 | 74DI20040404 | 1 |
Atlantic | 2000-2009 | target | 10 | 35TH20080610 | 1 |
Atlantic | 2000-2009 | target | 12 | 35TH20040604 | 1 |
Atlantic | 2000-2009 | target | 13 | 35TH20020611 | 1 |
Atlantic | 2010-2020 | target | 9 | 33RO20110926 | 1 |
Atlantic | 2010-2020 | target | 12 | 35TH20100608 | 1 |
Atlantic | 2010-2020 | target | 13 | 29AH20160617 | 1 |
Indian | 1989-1999 | target | 11 | 320619960503 | 1 |
Indian | 2000-2009 | target | 3 | 33RR20080204 | 1 |
Pacific | 1989-1999 | target | 3 | 31DS19960105 | 1 |
Pacific | 1989-1999 | target | 6 | 316N19930222 | 1 |
Pacific | 1989-1999 | target | 7 | 316N19921006 | 1 |
Pacific | 1989-1999 | target | 8 | 90KD19920214 | 1 |
Pacific | 2000-2009 | target | 1 | 33RO20071215 | 1 |
Pacific | 2000-2009 | target | 6 | 318M20091121 | 1 |
Pacific | 2010-2020 | target | 4 | 320620170703 | 1 |
Pacific | 2010-2020 | target | 9 | 318M20091121 | 2 |
rm(loss_n)
loss_grid <- loss %>% distinct(lon, lat, cruise_expocode)
loss_f_grid <- left_join(loss_f_cruise,
loss_grid)
map +
geom_tile(data = loss_f_grid,
aes(lon, lat, fill = loss)) +
facet_grid(decade ~ parameter_class) +
scale_fill_manual(values = grey_plasma)
loss_f_grid %>% filter(loss != 0) %>%
group_split(parameter_class, decade) %>%
# head(1) %>%
map(
~ map +
geom_tile(data = .x,
aes(lon, lat, fill = cruise_expocode)) +
scale_fill_brewer(palette = "Paired") +
facet_grid(decade ~ parameter_class)
)
[[1]]
[[2]]
[[3]]
rm(loss_f_cruise, loss_f_grid)
rm(loss_grid)
Here, I analysis the loss of data due to unavailability (i.e. where f-flag == 9).
loss_f9 <- loss_all %>%
select(lon, lat, basin_AIP, decade, cruise_expocode, ends_with("f")) %>%
pivot_longer(ends_with("f"),
names_to = "parameter",
values_to = "value") %>%
mutate(parameter = str_remove(parameter, "f"))
loss_f9 <- loss_f9 %>%
count(cruise_expocode, basin_AIP, decade, parameter, value) %>%
pivot_wider(
names_from = value,
names_prefix = "f_",
values_from = n,
values_fill = 0
) %>%
mutate(n_cruise = f_0 + f_2 + f_9,
category = if_else(f_9 <= 0.1 * (n_cruise), "OK", "loss"))
loss_f9_cruise <- loss_f9 %>%
mutate(parameter_class = if_else(
parameter %in% c("tco2", "talk", "phosphate"),
"target",
"predictor"
)) %>%
count(cruise_expocode,
basin_AIP,
decade,
n_cruise,
parameter_class,
category) %>%
pivot_wider(names_from = category,
values_from = n,
values_fill = 0) %>%
select(-OK) %>%
pivot_wider(names_from = parameter_class,
values_from = loss) %>%
group_by(basin_AIP, decade) %>%
mutate(rank_n_cruise = rank(-n_cruise)) %>%
ungroup()
loss_f9_cruise <- full_join(loss_f9_cruise, loss_all_n)
loss_f9_cruise <- loss_f9_cruise %>%
mutate(n_cruise_rel = 100 * n_cruise / n) %>%
arrange(basin_AIP, decade, -n_cruise_rel) %>%
group_by(basin_AIP, decade) %>%
mutate(n_cruise_rel_cum = cumsum(n_cruise_rel)) %>%
ungroup() %>%
select(-n)
loss_f9_cruise <- loss_f9_cruise %>%
pivot_longer(predictor:target,
names_to = "parameter_class",
values_to = "loss") %>%
mutate(loss = as.factor(loss))
grey_plasma <- c("grey80", viridisLite::plasma(4))
loss_f9_cruise <- loss_f9_cruise %>%
filter(n_cruise_rel >= 3)
loss_f9_cruise %>%
group_split(basin_AIP) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(rank_n_cruise, n_cruise, fill = loss)) +
geom_point(shape = 21, size = 2) +
scale_fill_manual(values = grey_plasma,
name = "variables missing") +
facet_grid(decade ~ parameter_class) +
labs(title = paste("basin_AIP:", unique(.x$basin_AIP))) +
ylim(0, NA)
)
[[1]]
[[2]]
[[3]]
loss_f9_cruise %>%
filter(loss != 0) %>%
select(basin_AIP, decade, parameter_class, rank_n_cruise, cruise_expocode) %>%
arrange(basin_AIP, decade, parameter_class, rank_n_cruise) %>%
kable() %>%
kable_styling() %>%
scroll_box(height = "300px")
basin_AIP | decade | parameter_class | rank_n_cruise | cruise_expocode |
---|---|---|---|---|
Atlantic | 1989-1999 | predictor | 2 | 316N19871123 |
Atlantic | 1989-1999 | predictor | 4 | 06AQ19980328 |
Atlantic | 1989-1999 | predictor | 6 | 74DI19970807 |
Atlantic | 1989-1999 | target | 2 | 316N19871123 |
Atlantic | 1989-1999 | target | 3 | 33RO19980123 |
Atlantic | 1989-1999 | target | 4 | 06AQ19980328 |
Atlantic | 1989-1999 | target | 6 | 74DI19970807 |
Atlantic | 1989-1999 | target | 7 | 33MW19930704 |
Atlantic | 2000-2009 | target | 1 | 33RO20050111 |
Atlantic | 2000-2009 | target | 2 | 33RO20030604 |
Atlantic | 2000-2009 | target | 3 | 06AQ20050122 |
Atlantic | 2000-2009 | target | 4 | 06AQ20080210 |
Atlantic | 2010-2020 | predictor | 10 | 06M220170104 |
Atlantic | 2010-2020 | predictor | 11 | 06AQ20120107 |
Atlantic | 2010-2020 | target | 3 | 33RO20110926 |
Atlantic | 2010-2020 | target | 6 | 29HE20130320 |
Atlantic | 2010-2020 | target | 10 | 06M220170104 |
Indian | 1989-1999 | predictor | 1 | 316N19951202 |
Indian | 1989-1999 | predictor | 3 | 316N19950310 |
Indian | 1989-1999 | predictor | 7 | 35MF19960220 |
Indian | 1989-1999 | target | 1 | 316N19951202 |
Indian | 1989-1999 | target | 5 | 316N19941201 |
Indian | 1989-1999 | target | 8 | 320619960503 |
Indian | 1989-1999 | target | 10 | 316N19950611 |
Indian | 1989-1999 | target | 12 | 35MF19930123 |
Indian | 2000-2009 | predictor | 10 | 09AR20071216 |
Indian | 2000-2009 | target | 7 | 09AR20060102 |
Indian | 2010-2020 | predictor | 8 | 09AR20141205 |
Indian | 2010-2020 | target | 5 | 325020190403 |
Indian | 2010-2020 | target | 8 | 09AR20141205 |
Pacific | 1989-1999 | predictor | 6 | 33MW19920224 |
Pacific | 1989-1999 | target | 1 | 316N19920502 |
Pacific | 1989-1999 | target | 6 | 33MW19920224 |
Pacific | 2000-2009 | predictor | 8 | 325020060213 |
loss_all_grid <- loss_all %>% distinct(lon, lat, cruise_expocode)
loss_f9_grid <- left_join(loss_f9_cruise,
loss_all_grid)
map +
geom_tile(data = loss_f9_grid,
aes(lon, lat, fill = loss)) +
facet_grid(decade ~ parameter_class) +
scale_fill_manual(values = grey_plasma)
loss_f9_grid %>% filter(loss != 0) %>%
group_split(parameter_class, decade) %>%
# head(1) %>%
map(
~ map +
geom_tile(data = .x,
aes(lon, lat, fill = cruise_expocode)) +
scale_fill_brewer(palette = "Paired") +
facet_grid(decade ~ parameter_class)
)
[[1]]
[[2]]
[[3]]
[[4]]
[[5]]
[[6]]
rm(loss_f9_cruise, loss_f9_grid)
rm(loss_all_grid)
rm(loss_all_n)
rm(loss)
Below, I plot the most relevant cruises that would be lost when applying the strictest quality flagging criteria. These cruises were hand-picked, based on the relevance analysis shown above.
expocodes_missing <- GLODAP_cruises_missing %>%
distinct(cruise_expocode) %>%
pull()
missing_cruise_grid <- loss_all %>%
filter(cruise_expocode %in% expocodes_missing) %>%
distinct(cruise_expocode, decade, lon, lat)
missing_cruise_grid %>%
group_split(decade) %>%
# head(1) %>%
map(
~ map +
geom_tile(data = .x,
aes(lon, lat, fill = str_sub(
cruise_expocode, 1, 4
))) +
facet_grid(decade ~ .) +
scale_fill_brewer(palette = "Paired",
name = "RV")
)
[[1]]
Version | Author | Date |
---|---|---|
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
[[2]]
Version | Author | Date |
---|---|---|
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
[[3]]
Version | Author | Date |
---|---|---|
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
Here I analyse the phosphate data from section P18, which was repeated 3 times.
P18 <- GLODAP %>%
filter(cruise_expocode %in% c("33RO20161119",
"33RO20071215",
"31DS19940126"))
# plot raw data section
P18 %>%
filter(!is.na(nitrate)) %>%
ggplot(aes(lat, depth, col= nitrate)) +
geom_point() +
scale_color_viridis_c() +
scale_y_reverse() +
facet_grid(cruise_expocode ~.)
# grid section data
P18_grid <- P18 %>%
select(lat, lon, depth, cruise_expocode, nitrate) %>%
mutate(depth = as.numeric(as.character(cut(depth,
seq(0,1e4, 500),
seq(250,1e4,500))))) %>%
group_by(lat, depth, cruise_expocode) %>%
summarise(nitrate = mean(nitrate, na.rm=TRUE)) %>%
ungroup()
P18_grid %>%
ggplot(aes(lat, depth, fill= nitrate)) +
geom_tile() +
scale_fill_viridis_c() +
scale_y_reverse() +
facet_grid(cruise_expocode ~.)
# calculate gridded offsets
P18_grid_offset <- P18_grid %>%
pivot_wider(names_from = cruise_expocode,
values_from = nitrate) %>%
mutate(
delta_nitrate_1994_2007 = (`31DS19940126` - `33RO20071215`) / `33RO20071215`,
delta_nitrate_1994_2016 = (`31DS19940126` - `33RO20161119`) / `33RO20071215`,
delta_nitrate_2007_2016 = (`33RO20071215` - `33RO20161119`) / `33RO20071215`
) %>%
select(lat, depth, starts_with("delta")) %>%
pivot_longer(
starts_with("delta"),
values_to = "delta_nitrate",
names_to = "years",
names_prefix = "delta_nitrate_"
) %>%
filter(delta_nitrate > -20,
depth > 1500)
P18_grid_offset %>%
ggplot(aes(lat, depth, fill = delta_nitrate)) +
geom_tile() +
scale_fill_divergent() +
scale_y_reverse() +
facet_grid(years ~.)
P18_grid_offset %>%
group_by(lat, years) %>%
summarise(delta_nitrate = mean(delta_nitrate, na.rm = TRUE)) %>%
ungroup() %>%
ggplot(aes(lat, delta_nitrate, col = years, fill = years)) +
geom_hline(yintercept = 0) +
stat_smooth(method = "lm", formula = y ~ x + I(x ^ 2)) +
geom_point() +
geom_line()
rm(P18, P18_grid, P18_grid_offset)
A16 <- GLODAP %>%
filter(cruise_expocode %in% c(
"33MW19930704" #A16N-1993
))
map +
geom_tile(data = A16 %>% distinct(lon, lat),
aes(lon, lat))
A16 %>%
select(ends_with(c("qc"))) %>%
pivot_longer(everything(),
names_to = "flag",
values_to = "value") %>%
distinct(flag, value)
# A tibble: 9 × 2
flag value
<chr> <dbl>
1 salinityqc 1
2 oxygenqc 1
3 nitrateqc 1
4 silicateqc 1
5 phosphateqc 1
6 tco2qc 1
7 talkqc 1
8 talkqc 0
9 tco2qc 0
rm(A16)
Typically, the reasons for multiple expocode entries of the same cruise in the adjustment table list are:
-> How to merge? Based on first and last station? Cruise_ID not in GLODAP merged master file.
-> How to merge? Based on first and last station?
For the expocodes not listed in the expocode list the reason is that INDIGO has been splitted into three cruises: 35MF1985-1987 and the same holds for SAVE (316N1987 - 6legs). Further 49HH20011208 has been assigned wrongly and corrected to 49HH20011127.
Remove expocode INDIGO and maintain only 35MF19850224. Remove expocode SAVE and maintain only 316N1987.
GLODAP_adjustments <- GLODAP_adjustments %>%
select(cruise_expocode,
first_station, last_station,
version,
calculated_carbon_parameter,
ends_with("_adj")) %>%
rename(talk_adj = alkalinity_adj)
# Remove cruises INDIGO and SAVE
GLODAP_adjustments <-
GLODAP_adjustments %>%
filter(!(cruise_expocode %in% c("INDIGO", "SAVE")))
# correct expocode 49HH20011208 to 49HH20011127
GLODAP_adjustments <-
GLODAP_adjustments %>%
mutate(cruise_expocode = if_else(
cruise_expocode == "49HH20011208",
"49HH20011127",
cruise_expocode
))
# select latest adjustment versions
GLODAP_adjustments <-
GLODAP_adjustments %>%
group_by(cruise_expocode, first_station) %>%
mutate(n = n(),
version_max = max(version)) %>%
ungroup() %>%
filter(version == version_max | is.na(version)) %>%
select(-c(version_max, version, n))
# harmonize multiple cruise expocodes of 316N1987
GLODAP_adjustments <- GLODAP_adjustments %>%
mutate(cruise_expocode = str_split(cruise_expocode,
"\\.",
simplify = TRUE)[,1])
# correct one wrong last_cruise label
GLODAP_adjustments <- GLODAP_adjustments %>%
mutate(
last_station = if_else(
cruise_expocode == "318M20091121" &
first_station == 1,
127,
last_station
)
)
# merge with expocode table
GLODAP_adjustments <-
full_join(GLODAP_adjustments, GLODAP_expocodes) %>%
relocate(cruise)
GLODAP_adjustments_NA_cruises <-
GLODAP_adjustments %>%
filter(is.na(cruise))
GLODAP_adjustments_duplicated_cruises <-
GLODAP_adjustments %>%
group_by(cruise_expocode, cruise) %>%
mutate(n = n()) %>%
ungroup() %>%
filter(n != 1)
GLODAP_adjustments %>%
pivot_longer(salinity_adj:c13_adj,
names_to = "parameter",
values_to = "adjustment") %>%
ggplot(aes(adjustment)) +
geom_histogram() +
scale_y_log10() +
facet_wrap(~ parameter, scales = "free_x")
Version | Author | Date |
---|---|---|
6d6a23e | jens-daniel-mueller | 2021-11-01 |
rm(GLODAP_adjustments_duplicated_cruises,
GLODAP_adjustments_NA_cruises)
GLODAP_adjustments_long <- GLODAP_adjustments %>%
select(
cruise_expocode,
first_station,
last_station,
tco2_adj,
talk_adj,
phosphate_adj,
nitrate_adj,
oxygen_adj,
silicate_adj,
salinity_adj
) %>%
pivot_longer(tco2_adj:salinity_adj,
names_to = "parameter",
values_to = "adjustment") %>%
mutate(parameter = str_remove(parameter, "_adj"))
p_adjustment_histo <- GLODAP_adjustments_long %>%
ggplot(aes(adjustment)) +
geom_histogram() +
scale_y_log10() +
facet_wrap(~ parameter, scales = "free_x", ncol = 1)
p_xover_histo <-
ggplot() +
geom_histogram(data = glodapv2_xover,
aes(offset)) +
labs(title = "v2") +
scale_y_log10() +
facet_wrap(~ parameter, scales = "free_x", ncol = 1)
p_xover_histo_2021 <-
ggplot() +
geom_histogram(data = glodapv2_2021_xover,
aes(offset)) +
labs(title = "v2_2021") +
scale_y_log10() +
facet_wrap(~ parameter, scales = "free_x", ncol = 1)
p_xover_histo + p_xover_histo_2021 + p_adjustment_histo
rm(p_xover_histo, p_xover_histo_2021, p_adjustment_histo)
The crossover analysis I received refer to unadjusted data. In order to analyse remaining crossover biases that are relevant for the adjusted data, the crossover results are adjusted with the same value that was also applied to the data.
# join crossover and adjustments
glodapv2_xover <- left_join(
glodapv2_xover,
GLODAP_adjustments_long %>%
select(
cruise_A = cruise_expocode,
parameter,
first_station_A = first_station,
last_station_A = last_station,
adjustment_A = adjustment
)
)
glodapv2_xover <- left_join(
glodapv2_xover,
GLODAP_adjustments_long %>%
select(
cruise_B = cruise_expocode,
parameter,
first_station_B = first_station,
last_station_B = last_station,
adjustment_B = adjustment
)
)
glodapv2_xover <- glodapv2_xover %>%
mutate(adjustment_A = if_else(
parameter %in% c("salinity", "talk", "tco2"),
replace_na(adjustment_A, 0),
replace_na(adjustment_A, 1)
)) %>%
mutate(adjustment_B = if_else(
parameter %in% c("salinity", "talk", "tco2"),
replace_na(adjustment_B, 0),
replace_na(adjustment_B, 1)
))
# apply adjustment to crossover
glodapv2_xover <- glodapv2_xover %>%
mutate(offset_adj =
if_else(parameter %in% c("salinity", "talk", "tco2"),
offset + adjustment_A - adjustment_B,
offset * adjustment_A / adjustment_B))
# join crossover and adjustments
glodapv2_2021_xover <- left_join(
glodapv2_2021_xover,
GLODAP_adjustments_long %>%
select(
cruise_A = cruise_expocode,
parameter,
first_station_A = first_station,
last_station_A = last_station,
adjustment_A = adjustment
)
)
glodapv2_2021_xover <- left_join(
glodapv2_2021_xover,
GLODAP_adjustments_long %>%
select(
cruise_B = cruise_expocode,
parameter,
first_station_B = first_station,
last_station_B = last_station,
adjustment_B = adjustment
)
)
glodapv2_2021_xover <- glodapv2_2021_xover %>%
mutate(adjustment_A = if_else(
parameter %in% c("salinity", "talk", "tco2"),
replace_na(adjustment_A, 0),
replace_na(adjustment_A, 1)
)) %>%
mutate(adjustment_B = if_else(
parameter %in% c("salinity", "talk", "tco2"),
replace_na(adjustment_B, 0),
replace_na(adjustment_B, 1)
))
# apply adjustment to crossover
glodapv2_2021_xover <- glodapv2_2021_xover %>%
mutate(offset_adj =
if_else(parameter %in% c("salinity", "talk", "tco2"),
offset + adjustment_A,
offset * adjustment_A))
xover <- bind_rows(glodapv2_xover,
glodapv2_2021_xover)
rm(glodapv2_xover,
glodapv2_2021_xover)
xover <- xover %>%
mutate(date_A = ymd(str_sub(cruise_A, 5, 12)),
date_B = ymd(str_sub(cruise_B, 5, 12)))
# Remove cruises with expocodes starting with "OMEX"
# for which dates cannot be extracted from expocode
xover <- xover %>%
filter(!is.na(date_A),
!is.na(date_B))
xover <- xover %>%
filter(!is.na(offset_adj))
# reverse cruise A and B
m_xover_reverse <- function(df) {
df_rev <- df %>%
rename(
cruise_A_back = cruise_A,
cruise_A = cruise_B,
date_A_back = date_A,
date_A = date_B,
n_A_back = n_A,
n_A = n_B,
adjustment_A_back = adjustment_A,
adjustment_A = adjustment_B
) %>%
rename(cruise_B = cruise_A_back,
date_B = date_A_back,
n_B = n_A_back,
adjustment_B = adjustment_A_back) %>%
mutate(
offset = if_else(
parameter %in% c("salinity", "talk", "tco2"),
-offset,
1 / offset
),
offset_adj = if_else(
parameter %in% c("salinity", "talk", "tco2"),
-offset_adj,
1 / offset_adj
)
)
return(df_rev)
}
# extract cruise based on expocode
m_xover_cruise_extractation <- function (df, expocode) {
xover_cruise_A <- df %>%
filter(cruise_A %in% expocode)
xover_cruise_B <- df %>%
filter(cruise_B %in% expocode)
xover_cruise_B_rev <- m_xover_reverse(df = xover_cruise_B)
xover_cruise <- bind_rows(xover_cruise_A,
xover_cruise_B_rev)
return(xover_cruise)
}
Analyse crossover results for cruises that cause a relevant data gap, with the aim to inform the use of data from these cruises.
hline_intercept <-
tibble(parameter = unique(xover$parameter)) %>%
mutate(intercept = if_else(parameter %in% c("salinity", "talk", "tco2"),
0,
1))
for (i_expocodes_missing in expocodes_missing) {
# i_expocodes_missing <- expocodes_missing[1]
cruise <- GLODAP %>%
filter(cruise_expocode == i_expocodes_missing) %>%
rename(salinity = sal)
# extract parameter that cause qc loss
parameter_qc <- loss_qc %>%
filter(cruise_expocode == i_expocodes_missing,
category == "loss")
parameter_qc <- parameter_qc %>%
pull(parameter)
print(paste("qc parameter:", parameter_qc))
if (length(parameter_qc) > 0) {
parameter_qc <- parameter_qc %>% str_c(.,"qc")
}
# extract parameter that cause f loss
parameter_f <- loss_f %>%
filter(cruise_expocode == i_expocodes_missing,
category == "loss")
parameter_f <- parameter_f %>%
pull(parameter)
print(paste("f parameter:", parameter_f))
if (length(parameter_f) > 0) {
parameter_f <- parameter_f %>% str_c(.,"f")
}
# extract parameter that cause f9 loss
parameter_f9 <- loss_f9 %>%
filter(cruise_expocode == i_expocodes_missing,
category == "loss")
parameter_f9 <- parameter_f9 %>%
pull(parameter)
print(paste("f9 parameter:", parameter_f9))
if (length(parameter_f9) > 0) {
parameter_f9 <- parameter_f9 %>% str_c(.,"f")
}
# extract unique loss parameters
parameter_check <-
unique(c(parameter_qc, parameter_f, parameter_f9))
rm(parameter_qc, parameter_f, parameter_f9)
xover_cruise <- m_xover_cruise_extractation(
df = xover %>% mutate(n_A = 0,
n_B = 0),
expocode = i_expocodes_missing
)
for (i_parameter_check in parameter_check) {
# i_parameter_check <- parameter_check[1]
cruise_flag_count <- cruise %>%
count(lon, lat, !!sym(i_parameter_check)) %>%
group_by(lon, lat) %>%
mutate(n_rel = 100 * n / sum(n)) %>%
ungroup()
print(
map +
geom_tile(data = cruise_flag_count,
aes(lon, lat, fill = n_rel)) +
scale_fill_viridis_c(option = "magma",
direction = -1) +
facet_wrap(i_parameter_check, ncol = 2) +
labs(title = i_expocodes_missing,
subtitle = i_parameter_check)
)
i_parameter_check_var <- str_remove(i_parameter_check, "f")
i_parameter_check_var <- str_remove(i_parameter_check_var, "qc")
print(
cruise %>%
ggplot(aes(!!sym(i_parameter_check_var), depth, fill=station)) +
geom_point(alpha = 0.2, shape = 21) +
scale_fill_viridis_c() +
scale_y_reverse() +
facet_wrap(i_parameter_check, ncol = 2) +
labs(title = i_expocodes_missing,
subtitle = i_parameter_check)
)
}
p_crossover_ts <- xover_cruise %>%
ggplot(aes(date_B, offset_adj)) +
geom_vline(xintercept = ymd(str_sub(i_expocodes_missing, 5)),
col = "red") +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point() +
facet_grid(parameter ~ ., scales = "free_y") +
labs(title = i_expocodes_missing,
subtitle = str_c(parameter_check, collapse = "+")) +
theme(
legend.position = "bottom",
legend.direction = "vertical",
axis.title.x = element_blank()
)
xover_cruise_decade <- xover_cruise %>%
mutate(decade = m_grid_decade(year(date_B))) %>%
filter(!is.na(decade)) %>%
group_by(parameter, decade) %>%
mutate(n = n()) %>%
ungroup() %>%
filter(n > 2)
p_crossover_decadal <-
ggplot() +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_violin(
data = xover_cruise_decade,
aes(x = decade, y = offset_adj),
fill = "gold"
) +
geom_boxplot(
data = xover_cruise_decade,
aes(x = decade, y = offset_adj),
width = 0.2
) +
labs(title = "Decadal averages") +
facet_grid(parameter ~ ., scales = "free_y") +
theme(axis.title.x = element_blank(),
axis.text.x = element_text(angle = 90))
print(
p_crossover_ts + p_crossover_decadal +
plot_layout(widths = c(2, 1))
)
rm(p_crossover_ts, p_crossover_decadal)
}
[1] "qc parameter: "
[1] "f parameter: talk"
[1] "f9 parameter: "
[1] "qc parameter: "
[1] "f parameter: talk"
[1] "f9 parameter: "
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: aou"
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: nitrate" "f9 parameter: phosphate"
[3] "f9 parameter: silicate" "f9 parameter: talk"
[1] "qc parameter: talk" "qc parameter: talk"
[1] "f parameter: talk" "f parameter: talk"
[1] "f9 parameter: talk" "f9 parameter: aou" "f9 parameter: talk"
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: aou" "f9 parameter: talk"
[1] "qc parameter: talk"
[1] "f parameter: talk"
[1] "f9 parameter: phosphate" "f9 parameter: talk"
[1] "qc parameter: talk"
[1] "f parameter: talk"
[1] "f9 parameter: talk"
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: talk"
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: aou" "f9 parameter: salinity"
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: talk"
[1] "qc parameter: "
[1] "f parameter: tco2" "f parameter: talk" "f parameter: tco2"
[1] "f9 parameter: "
[1] "qc parameter: nitrate"
[1] "f parameter: "
[1] "f9 parameter: "
[1] "qc parameter: "
[1] "f parameter: talk"
[1] "f9 parameter: "
[1] "qc parameter: talk"
[1] "f parameter: talk"
[1] "f9 parameter: phosphate"
[1] "qc parameter: "
[1] "f parameter: talk"
[1] "f9 parameter: phosphate"
[1] "qc parameter: "
[1] "f parameter: talk"
[1] "f9 parameter: "
[1] "qc parameter: "
[1] "f parameter: tco2"
[1] "f9 parameter: phosphate"
[1] "qc parameter: "
[1] "f parameter: tco2"
[1] "f9 parameter: "
[1] "qc parameter: "
[1] "f parameter: tco2"
[1] "f9 parameter: aou"
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: phosphate"
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: silicate"
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: tco2"
[1] "f parameter: tco2"
[1] "f9 parameter: "
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: tco2"
[1] "f parameter: tco2"
[1] "f9 parameter: nitrate"
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: tco2"
[1] "f parameter: tco2"
[1] "f9 parameter: "
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: nitrate" "f9 parameter: phosphate"
[3] "f9 parameter: silicate"
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: talk"
[1] "f parameter: talk"
[1] "f9 parameter: "
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: nitrate"
[1] "f parameter: "
[1] "f9 parameter: "
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: phosphate"
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: phosphate"
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: "
[1] "f parameter: nitrate" "f parameter: phosphate" "f parameter: silicate"
[1] "f9 parameter: talk" "f9 parameter: nitrate"
[3] "f9 parameter: phosphate" "f9 parameter: silicate"
[5] "f9 parameter: talk"
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: talk"
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
[1] "qc parameter: "
[1] "f parameter: "
[1] "f9 parameter: phosphate"
Version | Author | Date |
---|---|---|
fcff192 | jens-daniel-mueller | 2021-12-21 |
rm(xover_cruise, xover_cruise_decade)
IO_1990_expocodes <- GLODAP %>%
filter(str_detect(cruise_expocode, "316N199") &
basin_AIP == "Indian") %>%
distinct(cruise_expocode) %>%
pull()
xover_IO_1990 <-
m_xover_cruise_extractation(df = xover %>% mutate(n_A = 0,
n_B = 0),
expocode = IO_1990_expocodes)
xover_IO_1990 <- xover_IO_1990 %>%
mutate(RV = if_else(str_detect(cruise_B, "316N"),
"316N",
"other"))
xover_IO_1990_decade <- xover_IO_1990 %>%
mutate(decade = m_grid_decade(year(date_B))) %>%
filter(!is.na(decade),
RV != "316N") %>%
arrange(date_B)
xover_IO_1990_decade %>%
group_by(parameter, decade) %>%
summarise(offset_adj_mean = mean(offset_adj, na.rm = TRUE),
offset_adj_median = median(offset_adj, na.rm = TRUE)) %>%
ungroup() %>%
kable() %>%
kable_styling() %>%
scroll_box(height = "300px")
parameter | decade | offset_adj_mean | offset_adj_median |
---|---|---|---|
nitrate | 1989-1999 | 0.9959899 | 0.9952475 |
nitrate | 2000-2009 | 1.0018716 | 1.0034000 |
nitrate | 2010-2020 | 0.9942423 | 0.9954335 |
oxygen | 1989-1999 | 0.9986282 | 0.9974067 |
oxygen | 2000-2009 | 0.9983700 | 1.0002000 |
oxygen | 2010-2020 | 0.9992518 | 0.9981748 |
phosphate | 1989-1999 | 0.9926563 | 0.9962076 |
phosphate | 2000-2009 | 1.0050862 | 1.0052750 |
phosphate | 2010-2020 | 1.0016116 | 1.0031516 |
salinity | 1989-1999 | -0.0016439 | -0.0012000 |
salinity | 2000-2009 | -0.0009812 | -0.0012000 |
salinity | 2010-2020 | -0.0008173 | -0.0009442 |
silicate | 1989-1999 | 0.9994382 | 1.0012621 |
silicate | 2000-2009 | 1.0045634 | 1.0058000 |
silicate | 2010-2020 | 1.0076910 | 1.0101825 |
talk | 1989-1999 | 3.0075385 | 2.5782000 |
talk | 2000-2009 | 2.3614576 | 2.9766000 |
talk | 2010-2020 | 3.3860085 | 3.8736858 |
tco2 | 1989-1999 | -0.7801709 | -0.3723461 |
tco2 | 2000-2009 | -2.6973312 | -2.5524500 |
tco2 | 2010-2020 | -2.0787148 | -1.9810457 |
p_crossover_ts <- xover_IO_1990 %>%
ggplot(aes(date_B, offset, col = RV)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(shape = 21) +
scale_color_brewer(palette = "Set1") +
facet_grid(parameter ~ ., scales = "free_y") +
labs(title = "Crossover 316N199XXXXX") +
theme(
legend.position = "bottom",
legend.direction = "vertical",
axis.title.x = element_blank()
)
p_crossover_decadal <-
ggplot() +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_violin(data = xover_IO_1990_decade,
aes(x = decade, y = offset), fill="gold") +
geom_boxplot(data = xover_IO_1990_decade,
aes(x = decade, y = offset),
width = 0.2) +
facet_grid(parameter ~ ., scales = "free_y") +
labs(title = "Decadal offsets") +
theme(axis.title.x = element_blank(),
axis.text.x = element_text(angle = 90))
p_crossover_ts + p_crossover_decadal +
plot_layout(widths = c(2, 1))
rm(p_crossover_ts, p_crossover_decadal)
p_crossover_ts <- xover_IO_1990 %>%
ggplot(aes(date_B, offset_adj, col = RV)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(shape = 21) +
scale_color_brewer(palette = "Set1") +
facet_grid(parameter ~ ., scales = "free_y") +
labs(title = "Crossover 316N199XXXXX") +
theme(
legend.position = "bottom",
legend.direction = "vertical",
axis.title.x = element_blank()
)
p_crossover_decadal <-
ggplot() +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_violin(data = xover_IO_1990_decade,
aes(x = decade, y = offset_adj), fill="gold") +
geom_boxplot(data = xover_IO_1990_decade,
aes(x = decade, y = offset_adj),
width = 0.2) +
facet_grid(parameter ~ ., scales = "free_y") +
labs(title = "Decadal offsets") +
theme(axis.title.x = element_blank(),
axis.text.x = element_text(angle = 90))
p_crossover_ts + p_crossover_decadal +
plot_layout(widths = c(2, 1))
rm(p_crossover_ts, p_crossover_decadal)
rm(xover_IO_1990, xover_IO_1990_decade)
In this section, I analyse GLODAP’s crossover data separately for each of 5 subbasins. For this purpose, each cruise is taken into account that provided at least one measurement in the respective subbasin, irrespective of measurements done outside this subbasin.
Here, I filter all crossover and use only those were both cruises covered the basin of interest.
# reformat basin labels
basinmask_5 <- basinmask_5 %>%
mutate(
basin = str_replace(basin, "_", ". "),
basin = fct_relevel(
basin,
"N. Pacific",
"S. Pacific",
"N. Atlantic",
"S. Atlantic",
"Indian"
)
)
basins <- unique(basinmask_5$basin)
GLODAP <- inner_join(GLODAP, basinmask_5)
GLODAP <- GLODAP %>%
mutate(decade = m_grid_decade(year))
# loop over all 5 subbasins
for (i_basin in basins) {
# i_basin <- basins[5]
# retrieve subbasin expocodes
GLODAP_basin <- GLODAP %>%
filter(basin == i_basin,
!is.na(decade))
expocodes_basin <- GLODAP_basin %>%
count(cruise_expocode)
# subset cruise with all qc flag = 1
expocodes_basin_qc <- GLODAP_basin %>%
select(cruise_expocode, ends_with("qc")) %>%
filter(if_all(ends_with("qc"), ~ . == 1)) %>%
distinct(cruise_expocode) %>%
pull(cruise_expocode)
# subset cruise with all f flag = 2
expocodes_basin_f <- GLODAP_basin %>%
select(cruise_expocode, ends_with("f")) %>%
filter(if_all(ends_with("f"), ~ . == 2)) %>%
distinct(cruise_expocode) %>%
pull(cruise_expocode)
# join qc and f cruises and identify lower number of observations
expocodes_basin <- expocodes_basin %>%
mutate(
parameter_coverage = if_else(
cruise_expocode %in% expocodes_basin_qc &
cruise_expocode %in% expocodes_basin_f,
"full",
"partial"
)
)
rm(expocodes_basin_f, expocodes_basin_qc)
GLODAP_basin_grid <- GLODAP_basin %>%
count(cruise_expocode, lat, lon, decade)
print(
map +
geom_tile(data = GLODAP_basin_grid,
aes(lon, lat, fill = n)) +
scale_fill_viridis_c(
option = "magma",
direction = -1,
trans = "log10"
) +
labs(title = i_basin) +
facet_grid(decade ~ .) +
theme(legend.title = element_blank())
)
GLODAP_basin_grid <- full_join(GLODAP_basin_grid %>% select(-n),
expocodes_basin)
print(
map +
geom_tile(
data = GLODAP_basin_grid %>% filter(parameter_coverage == "partial"),
aes(lon, lat, fill = "partial")
) +
geom_tile(
data = GLODAP_basin_grid %>% filter(parameter_coverage == "full"),
aes(lon, lat, fill = "full")
) +
scale_fill_brewer(palette = "Set1") +
labs(title = i_basin) +
facet_grid(decade ~ .) +
theme(legend.title = element_blank())
)
# filter crossover with both cruises falling into subbasin
xover_basin <- xover %>%
filter(
cruise_A %in% expocodes_basin$cruise_expocode &
cruise_B %in% expocodes_basin$cruise_expocode
)
xover_basin <- xover_basin %>%
mutate(basin = i_basin)
# combine with cruise meta data
xover_basin <- left_join(
xover_basin,
expocodes_basin %>%
rename(
cruise_A = cruise_expocode,
n_A = n,
parameter_coverage_A = parameter_coverage
)
)
xover_basin <- left_join(
xover_basin,
expocodes_basin %>%
rename(
cruise_B = cruise_expocode,
n_B = n,
parameter_coverage_B = parameter_coverage
)
)
xover_basin <- xover_basin %>%
mutate(
parameter_coverage = if_else(
parameter_coverage_A == "full" & parameter_coverage_B == "full",
"full",
"partial"
),
n = n_A + n_B
) %>%
select(-c(parameter_coverage_A, parameter_coverage_B))
# reverse later cruise to cruise A
xover_basin_A <- xover_basin %>%
filter(date_A > date_B)
xover_basin_B <- xover_basin %>%
filter(date_A <= date_B)
xover_basin_B_rev <- m_xover_reverse(df = xover_basin_B)
xover_basin <- bind_rows(xover_basin_A,
xover_basin_B_rev)
rm(xover_basin_A,
xover_basin_B,
xover_basin_B_rev)
if (exists("xover_basin_all")) {
xover_basin_all <-
bind_rows(xover_basin_all, xover_basin)
}
if (!exists("xover_basin_all")) {
xover_basin_all <- xover_basin
}
print(
xover_basin %>%
filter(
!is.na(offset_adj),
parameter %in% c("talk", "tco2"),
parameter_coverage == "full"
) %>%
mutate(offset_adj = cut(
offset_adj, c(-Inf, -5, -2, -1, 1, 2, 5, Inf)
)) %>%
group_split(parameter) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(
date_A, date_B, fill = offset_adj, size = n
)) +
geom_point(alpha = 0.5, shape = 21) +
scale_fill_discrete_diverging(palette = "Blue-Red") +
labs(title = paste(i_basin, "|", .x$parameter, "| full")) +
coord_fixed(xlim = c(ymd("1990-01-01"), ymd("2021-01-01")),
ylim = c(ymd("1990-01-01"), ymd("2021-01-01")))
)
)
print(
xover_basin %>%
filter(
!is.na(offset_adj),
parameter %in% c("phosphate"),
parameter_coverage == "full"
) %>%
mutate(offset_adj = cut(
offset_adj, 1 + c(-Inf, -5, -2, -1, 1, 2, 5, Inf) /
100
)) %>%
group_split(parameter) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(
date_A, date_B, fill = offset_adj, size = n
)) +
geom_point(alpha = 0.5, shape = 21) +
scale_fill_discrete_diverging(palette = "Blue-Red") +
labs(title = paste(i_basin, "|", .x$parameter, "| full")) +
coord_fixed(xlim = c(ymd("1990-01-01"), ymd("2021-01-01")),
ylim = c(ymd("1990-01-01"), ymd("2021-01-01")))
)
)
print(
xover_basin %>%
filter(!is.na(offset_adj),
parameter %in% c("talk", "tco2")) %>%
mutate(offset_adj = cut(
offset_adj, c(-Inf, -5, -2, -1, 1, 2, 5, Inf)
)) %>%
group_split(parameter) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(
date_A, date_B, fill = offset_adj, size = n
)) +
geom_point(alpha = 0.5, shape = 21) +
scale_fill_discrete_diverging(palette = "Blue-Red") +
labs(title = paste(i_basin, "|", .x$parameter, "| partial")) +
coord_fixed(xlim = c(ymd("1990-01-01"), ymd("2021-01-01")),
ylim = c(ymd("1990-01-01"), ymd("2021-01-01")))
)
)
print(
xover_basin %>%
filter(!is.na(offset_adj),
parameter %in% c("phosphate")) %>%
mutate(offset_adj = cut(
offset_adj, 1 + c(-Inf, -5, -2, -1, 1, 2, 5, Inf) /
100
)) %>%
group_split(basin, parameter) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(
date_A, date_B, fill = offset_adj, size = n
)) +
geom_point(alpha = 0.5, shape = 21) +
scale_fill_discrete_diverging(palette = "Blue-Red") +
labs(title = paste(i_basin, "|", .x$parameter, "| partial")) +
coord_fixed(xlim = c(ymd("1990-01-01"), ymd("2021-01-01")),
ylim = c(ymd("1990-01-01"), ymd("2021-01-01")))
)
)
}
Version | Author | Date |
---|---|---|
25fef5b | jens-daniel-mueller | 2022-03-11 |
Version | Author | Date |
---|---|---|
25fef5b | jens-daniel-mueller | 2022-03-11 |
[[1]]
[[2]]
[[1]]
[[1]]
[[2]]
[[1]]
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[2]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
[[2]]
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[2]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
[[2]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[2]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
[[2]]
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[2]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
Version | Author | Date |
---|---|---|
84ca078 | jens-daniel-mueller | 2022-03-11 |
[[1]]
[[2]]
[[1]]
rm(xover_basin, GLODAP_basin, GLODAP_basin_grid, expocodes_basin)
xover_basin <- xover_basin_all
rm(xover_basin_all)
The aim of the decadal scale analysis is to investigate mean crossover offsets between all cruises from two decades.
expocodes_basin <- unique(c(xover_basin$cruise_A, xover_basin$cruise_B))
# loop over each cruises
# determine the mean decadal crossover from other cruises
for (i_cruise_expocode in expocodes_basin) {
# i_cruise_expocode <- expocodes_basin[1]
xover_cruise <- m_xover_cruise_extractation(df = xover_basin,
expocode = i_cruise_expocode)
# calculate mean cruise-by-cruise offset (in case more than one leg was compared)
xover_cruise <- xover_cruise %>%
group_by(basin,
cruise_A,
cruise_B,
date_A,
date_B,
n_A,
n_B,
n,
parameter,
parameter_coverage) %>%
summarise(
offset = mean(offset, na.rm = TRUE),
offset_adj = mean(offset_adj, na.rm = TRUE)
) %>%
ungroup()
# calculate long-term mean offsets for cruise
# Note: weighting is only done based on size of cruise B
xover_cruise_partial <- xover_cruise %>%
group_by(cruise_A, date_A, n_A, parameter, basin) %>%
summarise(
offset_adj_mean = mean(offset_adj, na.rm = TRUE),
offset_adj_mean_weighted = weighted.mean(x = offset_adj, w = n_B, na.rm = TRUE)
) %>%
ungroup()
xover_cruise_full <- xover_cruise %>%
filter(parameter_coverage == "full") %>%
group_by(cruise_A, date_A, n_A, parameter, basin) %>%
summarise(
offset_adj_mean = mean(offset_adj, na.rm = TRUE),
offset_adj_mean_weighted = weighted.mean(x = offset_adj, w = n_B, na.rm = TRUE)
) %>%
ungroup()
xover_cruise_long_term <- bind_rows(
xover_cruise_full %>% mutate(parameter_coverage = "full"),
xover_cruise_partial %>% mutate(parameter_coverage = "partial")
)
rm(xover_cruise_full,
xover_cruise_partial)
if (exists("xover_cruise_long_term_all")) {
xover_cruise_long_term_all <-
bind_rows(xover_cruise_long_term_all, xover_cruise_long_term)
}
if (!exists("xover_cruise_long_term_all")) {
xover_cruise_long_term_all <- xover_cruise_long_term
}
# cut cruise B date into decades
xover_cruise <- xover_cruise %>%
mutate(decade = m_grid_decade(year(date_B))) %>%
arrange(date_B)
# calculate decadal mean offsets for cruise
# Note: weighting is only done based on size of cruise B
xover_cruise_decade_partial <- xover_cruise %>%
group_by(cruise_A, date_A, n_A, parameter, decade, basin) %>%
summarise(
offset_adj_mean = mean(offset_adj, na.rm = TRUE),
offset_adj_mean_weighted = weighted.mean(x = offset_adj, w = n_B, na.rm = TRUE)
) %>%
ungroup()
xover_cruise_decade_full <- xover_cruise %>%
filter(parameter_coverage == "full") %>%
group_by(cruise_A, date_A, n_A, parameter, decade, basin) %>%
summarise(
offset_adj_mean = mean(offset_adj, na.rm = TRUE),
offset_adj_mean_weighted = weighted.mean(x = offset_adj, w = n_B, na.rm = TRUE)
) %>%
ungroup()
xover_cruise_decade <- bind_rows(
xover_cruise_decade_full %>% mutate(parameter_coverage = "full"),
xover_cruise_decade_partial %>% mutate(parameter_coverage = "partial")
)
rm(xover_cruise_decade_full,
xover_cruise_decade_partial)
if (exists("xover_cruise_decade_all")) {
xover_cruise_decade_all <-
bind_rows(xover_cruise_decade_all, xover_cruise_decade)
}
if (!exists("xover_cruise_decade_all")) {
xover_cruise_decade_all <- xover_cruise_decade
}
}
hline_intercept <- hline_intercept %>%
filter(parameter %in% c("talk", "tco2", "phosphate"))
xover_cruise_long_term_all %>%
filter(parameter %in% c("talk", "tco2", "phosphate")) %>%
group_split(basin, parameter_coverage) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(date_A, offset_adj_mean_weighted, size = n_A)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = paste(.x$basin, "|", .x$parameter_coverage)) +
facet_grid(parameter ~ ., scales = "free_y")
)
[[1]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
9db485e | jens-daniel-mueller | 2022-02-25 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[2]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[3]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[4]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[5]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
9db485e | jens-daniel-mueller | 2022-02-25 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[6]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[7]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[8]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[9]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
9db485e | jens-daniel-mueller | 2022-02-25 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[10]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
xover_cruise_decade_all %>%
filter(parameter %in% c("talk", "tco2", "phosphate")) %>%
group_split(basin, parameter_coverage) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(date_A, offset_adj_mean_weighted, size = n_A)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = paste(.x$basin, "|", .x$parameter_coverage)) +
facet_grid(parameter ~ decade, scales = "free_y")
)
[[1]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[2]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[3]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
9db485e | jens-daniel-mueller | 2022-02-25 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[4]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[5]]
[[6]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[7]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
9db485e | jens-daniel-mueller | 2022-02-25 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[8]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[9]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
[[10]]
Version | Author | Date |
---|---|---|
744b90f | jens-daniel-mueller | 2022-03-11 |
25fef5b | jens-daniel-mueller | 2022-03-11 |
e3d1a2b | jens-daniel-mueller | 2022-03-10 |
070ca03 | jens-daniel-mueller | 2022-03-09 |
6e65117 | jens-daniel-mueller | 2022-02-16 |
4a7550e | jens-daniel-mueller | 2022-02-15 |
8804a83 | jens-daniel-mueller | 2022-02-15 |
e1243c2 | jens-daniel-mueller | 2022-02-15 |
#
# print(
# xover_subbasin_decade_stats %>%
# kable(caption = paste0(i_basin, " | ", i_decade_start, "s")) %>%
# kable_styling() %>%
# scroll_box(height = "300px")
# )
#
#
# p_crossover_ts <- xover_subbasin_decade %>%
# ggplot(aes(date_B, offset_adj)) +
# geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
# geom_point(shape = 21) +
# scale_color_brewer(palette = "Set1") +
# facet_grid(parameter ~ ., scales = "free_y") +
# labs(title = paste0(i_basin, " | ", i_decade_start, "s")) +
# theme(
# legend.position = "bottom",
# legend.direction = "vertical",
# axis.title.x = element_blank()
# )
#
# p_crossover_decadal <-
# ggplot() +
# geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
# geom_violin(data = xover_subbasin_decade,
# aes(x = decade, y = offset_adj),
# fill = "gold") +
# geom_boxplot(data = xover_subbasin_decade,
# aes(x = decade, y = offset_adj),
# width = 0.2) +
# facet_grid(parameter ~ ., scales = "free_y") +
# labs(title = "Decadal offsets") +
# theme(axis.title.x = element_blank(),
# axis.text.x = element_text(angle = 90))
#
# print(p_crossover_ts + p_crossover_decadal +
# plot_layout(widths = c(2, 1)))
#
# rm(p_crossover_ts, p_crossover_decadal)
#
# }
# }
#
# rm(xover_subbasin, xover_cruise_decade, xover_subbasin_decade, xover_subbasin_decade_stats)
xover_cruise_long_term_all %>%
filter(parameter %in% c("talk", "tco2", "phosphate")) %>%
group_split(basin, parameter_coverage) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(n_A, offset_adj_mean_weighted, size = n_A)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = paste(.x$basin, "|", .x$parameter_coverage)) +
facet_grid(parameter ~ ., scales = "free_y")
)
[[1]]
[[2]]
[[3]]
[[4]]
[[5]]
[[6]]
[[7]]
[[8]]
[[9]]
[[10]]
xover_cruise_decade_all %>%
filter(parameter %in% c("talk", "tco2", "phosphate")) %>%
group_split(basin, parameter_coverage) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(n_A, offset_adj_mean_weighted, size = n_A)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = paste(.x$basin, "|", .x$parameter_coverage)) +
facet_grid(parameter ~ decade, scales = "free_y")
)
[[1]]
[[2]]
[[3]]
[[4]]
[[5]]
[[6]]
[[7]]
[[8]]
[[9]]
[[10]]
xover_cruise_long_term_all %>%
filter(parameter %in% c("talk", "tco2", "phosphate")) %>%
group_split(basin, parameter_coverage) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(n_A, offset_adj_mean_weighted, size = n_A)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = paste(.x$basin, "|", .x$parameter_coverage)) +
facet_grid(parameter ~ ., scales = "free_y")
)
xover_cruise_decade_all %>%
filter(parameter %in% c("talk", "tco2", "phosphate")) %>%
group_split(basin, parameter_coverage) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(n_A, offset_adj_mean_weighted, size = n_A)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = paste(.x$basin, "|", .x$parameter_coverage)) +
facet_grid(parameter ~ decade, scales = "free_y")
)
xover_subbasin_decade_stats_all <- xover_subbasin_decade_stats_all %>%
mutate(
basin = fct_relevel(
basin,
"N. Pacific",
"S. Pacific",
"N. Atlantic",
"S. Atlantic",
"Indian"
)
)
xover_subbasin_decade_stats_all_cstar <- xover_subbasin_decade_stats_all %>%
filter(parameter %in% c("talk", "phosphate", "tco2")) %>%
select(
parameter,
basin,
decade,
decade_start,
offset_adj_mean_weighted,
) %>%
pivot_wider(names_from = parameter,
values_from = offset_adj_mean_weighted) %>%
mutate(cstar = tco2 -
(117 * (1 - phosphate) * 2e-6) - 0.5 *
(talk - (16 * (1 - phosphate) * 2e-6))) %>%
pivot_longer(phosphate:cstar,
values_to = "offset_adj_mean_weighted",
names_to = "parameter")
xover_subbasin_decade_stats_all_cstar %>%
ggplot(aes(decade_start, offset_adj_mean_weighted)) +
geom_hline(data = hline_intercept %>%
filter(parameter %in% c("talk", "tco2", "phosphate")),
aes(yintercept = intercept)) +
geom_point(aes(fill = basin), shape = 21) +
geom_line(aes(col = basin)) +
scale_fill_brewer(palette = "Paired") +
scale_color_brewer(palette = "Paired") +
scale_x_continuous(breaks = seq(1990, 2010, 10)) +
facet_grid(parameter ~ decade, scales = "free_y")
xover_subbasin_decade_stats_all %>%
filter(parameter %in% c("talk", "tco2", "phosphate")) %>%
ggplot(aes(decade_start, offset_adj_sd)) +
geom_point(aes(fill = basin), shape = 21) +
geom_line(aes(col = basin)) +
scale_fill_brewer(palette = "Paired") +
scale_color_brewer(palette = "Paired") +
scale_x_continuous(breaks = seq(1990, 2010, 10)) +
facet_grid(parameter ~ decade, scales = "free_y")
xover_cruise_decade_all <- xover_cruise_decade_all %>%
mutate(basin = fct_relevel(
basin,
"N. Pacific",
"S. Pacific",
"N. Atlantic",
"S. Atlantic",
"Indian"
))
expocodes <- inner_join(GLODAP, basinmask_5)
expocodes <- expocodes %>%
count(basin, cruise_expocode)
xover_cruise_decade_all <- left_join(xover_cruise_decade_all,
expocodes)
xover_cruise_decade_all_cstar <- xover_cruise_decade_all %>%
filter(parameter %in% c("talk", "phosphate", "tco2")) %>%
select(parameter,
date_A,
basin,
decade,
cruise_expocode,
n,
offset_adj_mean_weighted,) %>%
pivot_wider(names_from = parameter,
values_from = offset_adj_mean_weighted) %>%
mutate(cstar = tco2 -
(117 * (1 - phosphate) * 2e-6) - 0.5 *
(talk - (16 * (1 - phosphate) * 2e-6))) %>%
pivot_longer(phosphate:cstar,
values_to = "offset_adj_mean_weighted",
names_to = "parameter")
hline_intercept <-
tibble(parameter = unique(xover_cruise_decade_all_cstar$parameter)) %>%
mutate(intercept = if_else(parameter %in% c("cstar", "talk", "tco2"),
0,
1))
xover_cruise_decade_all_cstar %>%
filter(year(date_A) >= 1989) %>%
group_by(basin) %>%
group_split() %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(date_A, offset_adj_mean_weighted, size = n)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = .x$basin) +
facet_grid(parameter ~ decade, scales = "free_y")
)
for (i_basin in unique(basinmask_5$basin)) {
# i_basin <- unique(basinmask_5$basin)[4]
expocodes_subbasin <- inner_join(GLODAP, basinmask_5) %>%
filter(basin == i_basin)
# subset cruise with all qc flag = 1
expocodes_subbasin_qc <- expocodes_subbasin %>%
select(row_number, cruise_expocode, ends_with("qc")) %>%
pivot_longer(ends_with("qc"),
names_to = "parameter",
values_to = "value") %>%
filter(value == 1) %>%
pivot_wider(names_from = parameter,
values_from = value) %>%
drop_na() %>%
count(cruise_expocode)
# subset cruise with all f flag = 2
expocodes_subbasin_f <- expocodes_subbasin %>%
select(row_number, cruise_expocode, ends_with("f")) %>%
pivot_longer(ends_with("f"),
names_to = "parameter",
values_to = "value") %>%
filter(value == 2) %>%
pivot_wider(names_from = parameter,
values_from = value) %>%
drop_na() %>%
count(cruise_expocode)
# join qc and f cruises and identify lower number of observations
expocodes_subbasin <-
inner_join(expocodes_subbasin_f %>% rename(n_f = n),
expocodes_subbasin_qc %>% rename(n_qc = n)) %>%
mutate(n = if_else(n_f < n_qc, n_f, n_qc)) %>%
select(-starts_with("n_"))
rm(expocodes_subbasin_f, expocodes_subbasin_qc)
expocodes_subbasin_all <- inner_join(GLODAP, basinmask_5) %>%
filter(basin == i_basin)
expocodes_subbasin_clean <- inner_join(GLODAP, basinmask_5) %>%
filter(basin == i_basin,
cruise_expocode %in% expocodes_subbasin$cruise_expocode)
print(
map +
geom_tile(
data = expocodes_subbasin_all %>%
mutate(decade = m_grid_decade(year)) %>%
distinct(lon, lat, decade) %>%
drop_na(),
aes(lon, lat, fill="all")
) +
geom_tile(
data = expocodes_subbasin_clean %>%
mutate(decade = m_grid_decade(year)) %>%
distinct(lon, lat, decade) %>%
drop_na(),
aes(lon, lat, fill="filtered")
) +
scale_fill_brewer(palette = "Set1", direction = -1) +
labs(title = i_basin) +
facet_grid(decade ~ .) +
theme(legend.title = element_blank())
)
rm(expocodes_subbasin_all, expocodes_subbasin_clean)
xover_subbasin <- xover %>%
filter(
cruise_A %in% expocodes_subbasin$cruise_expocode &
cruise_B %in% expocodes_subbasin$cruise_expocode
)
xover_subbasin <- xover_subbasin %>%
mutate(date_A = ymd(str_sub(cruise_A, 5, 12)),
date_B = ymd(str_sub(cruise_B, 5, 12)))
xover_subbasin <- left_join(
xover_subbasin,
expocodes_subbasin %>% rename(cruise_A = cruise_expocode,
n_A = n)
)
xover_subbasin <- left_join(
xover_subbasin,
expocodes_subbasin %>% rename(cruise_B = cruise_expocode,
n_B = n)
)
xover_subbasin <- xover_subbasin %>%
mutate(n = n_A + n_B) %>%
select(-starts_with("n_"))
xover_cruise_A <- xover_subbasin %>%
filter(date_A > date_B)
xover_cruise_B <- xover_subbasin %>%
filter(date_A <= date_B)
xover_cruise_B_rev <- xover_cruise_B %>%
rename(
cruise_A_back = cruise_A,
cruise_A = cruise_B,
date_A_back = date_A,
date_A = date_B,
adjustment_A_back = adjustment_A,
adjustment_A = adjustment_B
) %>%
rename(cruise_B = cruise_A_back,
date_B = date_A_back,
adjustment_B = adjustment_A_back) %>%
mutate(
offset = if_else(
parameter %in% c("salinity", "talk", "tco2"),
-offset,
1 / offset
),
offset_adj = if_else(
parameter %in% c("salinity", "talk", "tco2"),
-offset_adj,
1 / offset_adj
)
)
xover_cruise <- bind_rows(xover_cruise_A,
xover_cruise_B_rev)
rm(xover_cruise_A, xover_cruise_B, xover_cruise_B_rev)
print(
xover_cruise %>%
filter(date_A > ymd("1989-01-01") &
date_B > ymd("1989-01-01") &
!is.na(offset_adj)) %>%
filter(parameter %in% c("talk", "tco2")) %>%
mutate(offset_adj = cut(offset_adj, c(-Inf, -5, -2, -1, 1, 2, 5, Inf))) %>%
group_split(parameter) %>%
map(
~ ggplot(data = .x,
aes(date_A, date_B, col = offset_adj, size = n)) +
geom_point(alpha = 0.5) +
scale_color_discrete_diverging(palette = "Blue-Red") +
labs(title = paste(i_basin, "|", .x$parameter)) +
coord_fixed()
)
)
print(
xover_cruise %>%
filter(date_A > ymd("1989-01-01") &
date_B > ymd("1989-01-01") &
!is.na(offset_adj)) %>%
filter(parameter %in% c("phosphate")) %>%
mutate(offset_adj = cut(offset_adj, 1 + c(-Inf, -5, -2, -1, 1, 2, 5, Inf)/100)) %>%
group_split(parameter) %>%
map(
~ ggplot(data = .x,
aes(date_A, date_B, col = offset_adj, size = n)) +
geom_point(alpha = 0.5) +
scale_color_discrete_diverging(palette = "Blue-Red") +
labs(title = paste(i_basin, "|", .x$parameter)) +
coord_fixed()
)
)
print(
xover_cruise %>%
filter(date_A > ymd("1989-01-01") &
date_B > ymd("1989-01-01") &
!is.na(offset_adj)) %>%
filter(parameter %in% c("talk", "tco2")) %>%
mutate(yearA = year(date_A),
yearB = year(date_B)) %>%
group_by(parameter, yearA, yearB) %>%
summarise(offset_adj_weighted_mean = weighted.mean(x = offset_adj, w=n, na.rm = TRUE),
n = sum(n)) %>%
ungroup() %>%
mutate(offset_adj_weighted_mean = cut(offset_adj_weighted_mean, c(-Inf, -5, -2, -1, 1, 2, 5, Inf))) %>%
group_split(parameter) %>%
map(
~ ggplot(data = .x,
aes(yearA, yearB, col = offset_adj_weighted_mean, size =n)) +
geom_point(alpha = 0.5) +
scale_color_discrete_diverging(palette = "Blue-Red") +
labs(title = paste(i_basin, "|", .x$parameter)) +
coord_fixed()
)
)
print(
xover_cruise %>%
filter(date_A > ymd("1989-01-01") &
date_B > ymd("1989-01-01") &
!is.na(offset_adj)) %>%
filter(parameter %in% c("phosphate")) %>%
mutate(yearA = year(date_A),
yearB = year(date_B)) %>%
group_by(parameter, yearA, yearB) %>%
summarise(offset_adj_weighted_mean = weighted.mean(x = offset_adj, w=n, na.rm = TRUE),
n = sum(n)) %>%
ungroup() %>%
mutate(offset_adj_weighted_mean = cut(offset_adj_weighted_mean, 1 + c(-Inf, -5, -2, -1, 1, 2, 5, Inf)/100)) %>%
group_split(parameter) %>%
map(
~ ggplot(data = .x,
aes(yearA, yearB, col = offset_adj_weighted_mean, size = n)) +
geom_point(alpha = 0.5) +
scale_color_discrete_diverging(palette = "Blue-Red") +
labs(title = paste(i_basin, "|", .x$parameter)) +
coord_fixed()
)
)
}
xover_cruise_decade_all_cstar %>%
filter(basin == "N. Pacific",
decade == "2000-2009",
year(date_A) >= 1989) %>%
group_by(basin) %>%
group_split() %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(date_A, offset_adj_mean_weighted, size = n)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = .x$basin) +
facet_grid(parameter ~ decade, scales = "free_y")
)
xover_cruise_decade_all_cstar %>%
filter(basin == "N. Pacific",
decade == "2000-2009",
year(date_A) >= 2010) %>%
group_by(basin) %>%
group_split() %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(n, offset_adj_mean_weighted, size = n)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = .x$basin) +
facet_grid(parameter ~ decade, scales = "free_y")
)
xover_cruise_decade_all_cstar %>%
filter(basin == "N. Pacific",
decade == "2010-2019",
year(date_A) >= 1989) %>%
group_by(basin) %>%
group_split() %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(date_A, offset_adj_mean_weighted, size = n)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = .x$basin) +
facet_grid(parameter ~ decade, scales = "free_y")
)
xover_cruise_decade_all_cstar %>%
filter(basin == "N. Pacific",
decade == "2010-2019",
year(date_A) >= 2000,
year(date_A) < 2010) %>%
group_by(basin) %>%
group_split() %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(n, offset_adj_mean_weighted, size = n)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(alpha = 0.3) +
labs(title = .x$basin) +
facet_grid(parameter ~ decade, scales = "free_y")
)
GLODAP_counts <- GLODAP %>%
mutate(decade = m_grid_decade(year),
.after = year) %>%
filter(!is.na(decade))
GLODAP_counts <- GLODAP_counts %>%
mutate(RV = str_sub(cruise_expocode, 1, 4))
RV_activity <- GLODAP_counts %>%
count(decade, basin_AIP, RV) %>%
group_by(decade, basin_AIP) %>%
mutate(n_total = sum(n)) %>%
ungroup() %>%
mutate(n_prop = 100* n / n_total)
RV_activity <-RV_activity %>%
group_by(decade, basin_AIP) %>%
mutate(rank = rank(-n_prop)) %>%
ungroup()
RV_activity %>%
ggplot(aes(rank, n_prop)) +
geom_line() +
geom_point() +
geom_text(data = RV_activity %>% filter(n_prop > 20),
aes(rank, n_prop, label = RV),
nudge_x = 5) +
labs(y = "proportion of tco2 samples (%)") +
facet_grid(decade ~ basin_AIP)
rm(RV_activity)
large_cruises <- GLODAP_counts %>%
count(decade, basin_AIP, cruise_expocode) %>%
group_by(decade, basin_AIP) %>%
mutate(n_total = sum(n)) %>%
ungroup() %>%
mutate(n_prop = 100* n / n_total)
large_cruises <- large_cruises %>%
group_by(decade, basin_AIP) %>%
mutate(rank = rank(-n_prop)) %>%
ungroup()
large_cruises %>%
group_split(decade, basin_AIP) %>%
head(1) %>%
map(
~
ggplot(data = .x,
aes(rank, n_prop)) +
geom_line() +
geom_point(
data = .x %>% filter(rank <= 5),
aes(rank, n_prop, fill = cruise_expocode), shape = 21) +
scale_fill_brewer(palette = "Set1") +
xlim(0, max(large_cruises$rank)) +
labs(y = "proportion of tco2 samples (%)") +
facet_grid(decade ~ basin_AIP)
)
[[1]]
large_cruises %>%
filter(rank <= 5) %>%
select(decade, basin_AIP, rank, n_prop, cruise_expocode) %>%
mutate(n_prop = round(n_prop, 1)) %>%
arrange(decade, basin_AIP, rank) %>%
kable() %>%
kable_styling() %>%
scroll_box(height = "300px")
decade | basin_AIP | rank | n_prop | cruise_expocode |
---|---|---|---|---|
1989-1999 | Atlantic | 1 | 5.0 | 323019940104 |
1989-1999 | Atlantic | 2 | 4.9 | 316N19871123 |
1989-1999 | Atlantic | 3 | 3.5 | 33RO19980123 |
1989-1999 | Atlantic | 4 | 3.5 | 06AQ19980328 |
1989-1999 | Atlantic | 5 | 3.3 | 316N19970530 |
1989-1999 | Indian | 1 | 7.8 | 316N19951202 |
1989-1999 | Indian | 2 | 7.8 | 316N19950124 |
1989-1999 | Indian | 3 | 7.5 | 316N19950310 |
1989-1999 | Indian | 4 | 7.1 | 316N19950829 |
1989-1999 | Indian | 5 | 6.8 | 316N19941201 |
1989-1999 | Pacific | 1 | 5.7 | 316N19920502 |
1989-1999 | Pacific | 2 | 5.6 | 31DS19960105 |
1989-1999 | Pacific | 3 | 5.6 | 31DS19940126 |
1989-1999 | Pacific | 4 | 5.5 | 318M19940327 |
1989-1999 | Pacific | 5 | 4.2 | 31DS19920907 |
2000-2009 | Atlantic | 1 | 4.6 | 33RO20050111 |
2000-2009 | Atlantic | 2 | 4.5 | 33RO20030604 |
2000-2009 | Atlantic | 3 | 4.1 | 06AQ20050122 |
2000-2009 | Atlantic | 4 | 3.5 | 06AQ20080210 |
2000-2009 | Atlantic | 5 | 2.7 | 35MF20080207 |
2000-2009 | Indian | 1 | 19.4 | 33RR20090320 |
2000-2009 | Indian | 2 | 10.4 | 33RR20070322 |
2000-2009 | Indian | 3 | 9.1 | 33RR20070204 |
2000-2009 | Indian | 4 | 9.0 | 33RR20080204 |
2000-2009 | Indian | 5 | 8.2 | 49NZ20031209 |
2000-2009 | Pacific | 1 | 7.0 | 33RO20071215 |
2000-2009 | Pacific | 2 | 6.0 | 318M20040615 |
2000-2009 | Pacific | 3 | 4.9 | 49NZ20030803 |
2000-2009 | Pacific | 4 | 4.6 | 49NZ20090410 |
2000-2009 | Pacific | 5 | 4.6 | 49NZ20051031 |
2010-2020 | Atlantic | 1 | 6.8 | 33RO20100308 |
2010-2020 | Atlantic | 2 | 6.3 | 33RO20130803 |
2010-2020 | Atlantic | 3 | 5.7 | 33RO20110926 |
2010-2020 | Atlantic | 4 | 5.5 | 740H20180228 |
2010-2020 | Atlantic | 5 | 5.1 | 33RO20131223 |
2010-2020 | Indian | 1 | 17.7 | 33RO20180423 |
2010-2020 | Indian | 2 | 16.8 | 33RR20160321 |
2010-2020 | Indian | 3 | 11.4 | 33RR20160208 |
2010-2020 | Indian | 4 | 9.6 | 096U20180111 |
2010-2020 | Indian | 5 | 8.8 | 325020190403 |
2010-2020 | Pacific | 1 | 5.9 | 33RO20161119 |
2010-2020 | Pacific | 2 | 4.1 | 318M20130321 |
2010-2020 | Pacific | 3 | 4.1 | 320620180309 |
2010-2020 | Pacific | 4 | 4.0 | 320620170703 |
2010-2020 | Pacific | 5 | 3.6 | 49RY20110515 |
rm(GLODAP_count, large_cruises)
CRM_IO_meas <- CRM_IO_meas %>%
fill(cruise:batch) %>%
select(-starts_with("ph")) %>%
rename(talk_meas = talk_ave,
tco2_meas = tco2_ave)
CRM_ref_values <- CRM_ref_values %>%
select(-c(date, comment, sal)) %>%
rename(talk_ref = talk,
tco2_ref = tco2)
IO_CRM_offset <-
left_join(CRM_IO_meas,
CRM_ref_values) %>%
mutate(batch = as.factor(batch))
IO_CRM_offset <- IO_CRM_offset %>%
mutate(talk_offset = talk_meas - talk_ref,
tco2_offset = tco2_meas - tco2_ref)
IO_CRM_offset <- IO_CRM_offset %>%
select(-c(talk_meas:talk_ref)) %>%
pivot_longer(ends_with("_offset"),
values_to = "offset",
names_to = "parameter") %>%
mutate(parameter = str_remove(parameter, "_offset"),
start_date = mdy(start_date))
IO_CRM_offset %>%
ggplot(aes(offset)) +
geom_histogram(binwidth = 1) +
facet_wrap(~ parameter)
Version | Author | Date |
---|---|---|
d454df1 | jens-daniel-mueller | 2021-12-15 |
IO_CRM_offset <- IO_CRM_offset %>%
filter(cell != "All")
IO_CRM_offset_mean <- IO_CRM_offset %>%
group_by(parameter) %>%
summarise(offset_mean = mean(offset),
offset_sd = sd(offset)) %>%
ungroup()
IO_CRM_offset %>%
filter(parameter == "talk") %>%
ggplot() +
scale_fill_brewer(palette = "Set1",
name = "CRM batch") +
geom_hline(data = IO_CRM_offset_mean %>% filter(parameter == "talk"),
aes(yintercept = offset_mean)) +
geom_hline(
data = IO_CRM_offset_mean %>% filter(parameter == "talk"),
aes(yintercept = offset_mean - offset_sd),
linetype = 2
) +
geom_hline(
data = IO_CRM_offset_mean %>% filter(parameter == "talk"),
aes(yintercept = offset_mean + offset_sd),
linetype = 2
) +
geom_point(aes(start_date, offset, fill = batch, size=n),
shape = 21) +
scale_size(name = "Nr of\nmeasurements") +
labs(x = "Cruise start date",
y = "TA offset meas-CRM (µmol/kg)",
title = "RV Knorr IO 1990 - TA reference measurements",
subtitle = "Data source: Tables 1 and 2 from Millero et al. (1998)")
GLODAP %>%
select(-cruise_expocode) %>%
write_csv(paste(path_preprocessing,
"GLODAPv2.2021_preprocessed.csv",
sep = ""))
GLODAP_tracer %>%
write_csv(paste(
path_preprocessing,
"GLODAPv2.2021_preprocessed_tracer.csv",
sep = ""
))
GLODAP_adjustments %>%
write_csv(paste(path_preprocessing,
"GLODAPv2.2021_adustments.csv",
sep = ""))
# GLODAP_adjustments_NA_cruises %>%
# select(cruise_expocode, cruise) %>%
# write_csv(paste(
# path_preprocessing,
# "GLODAPv2.2021_adustments_NA_cruises.csv",
# sep = ""
# ))
#
# GLODAP_adjustments_duplicated_cruises %>%
# drop_na() %>%
# write_csv(
# paste(
# path_preprocessing,
# "GLODAPv2.2021_adustments_duplicated_cruises.csv",
# sep = ""
# )
# )
For the following plots, the cleaned data set was re-opened and observations were gridded spatially to intervals of:
GLODAP <- m_grid_horizontal_coarse(GLODAP)
GLODAP_histogram_lat <- GLODAP %>%
group_by(lat_grid) %>%
tally() %>%
ungroup()
GLODAP_histogram_lat %>%
ggplot(aes(lat_grid, n)) +
geom_col() +
coord_flip() +
theme(legend.title = element_blank())
rm(GLODAP_histogram_lat)
GLODAP_histogram_year <- GLODAP %>%
group_by(year) %>%
tally() %>%
ungroup()
GLODAP_histogram_year %>%
ggplot() +
geom_col(aes(year, n)) +
theme(
axis.title.x = element_blank()
)
rm(GLODAP_histogram_year)
GLODAP_hovmoeller_year <- GLODAP %>%
group_by(year, lat_grid) %>%
tally() %>%
ungroup()
GLODAP_hovmoeller_year %>%
ggplot(aes(year, lat_grid, fill = log10(n))) +
geom_tile() +
geom_vline(xintercept = c(1999.5, 2012.5)) +
scale_fill_viridis_c(option = "magma", direction = -1) +
theme(legend.position = "top",
axis.title.x = element_blank())
rm(GLODAP_hovmoeller_year)
map +
geom_raster(data = GLODAP_obs_grid,
aes(lon, lat, fill = log10(n))) +
scale_fill_viridis_c(option = "magma",
direction = -1)
GLODAP_obs_grid_all_vars <- GLODAP %>%
select(year, lat, lon, cruise, sal, temp, oxygen,
phosphate, nitrate, silicate, tco2, talk) %>%
pivot_longer(cols = sal:talk,
names_to = "parameter",
values_to = "value") %>%
mutate(presence = if_else(is.na(value), "missing", "available")) %>%
count(year, lat, lon, parameter, presence)
GLODAP_obs_grid_all_vars_wide <- GLODAP_obs_grid_all_vars %>%
pivot_wider(names_from = "presence",
values_from = n,
values_fill = 0) %>%
mutate(ratio_available = available/(available+missing))
all_plots <- GLODAP_obs_grid_all_vars_wide %>%
# mutate(cruise = as.factor(cruise)) %>%
group_split(year) %>%
# tail(3) %>%
map(
~ map +
geom_tile(
data = .x,
aes(
x = lon,
y = lat,
width = 1,
height = 1,
fill = ratio_available
)
) +
scale_fill_scico(palette = "berlin",
limits = c(0,1)) +
labs(title = unique(.x$year)) +
facet_wrap(~ parameter)
)
pdf(file = paste0(path_preprocessing, "GLODAPv2.2021_preprocessed_coverage_maps.pdf"),
width = 10,
height = 5)
all_plots
[[1]]
[[2]]
[[3]]
[[4]]
[[5]]
[[6]]
[[7]]
[[8]]
[[9]]
[[10]]
[[11]]
[[12]]
[[13]]
[[14]]
[[15]]
[[16]]
[[17]]
[[18]]
[[19]]
[[20]]
[[21]]
[[22]]
[[23]]
[[24]]
[[25]]
[[26]]
[[27]]
[[28]]
[[29]]
[[30]]
[[31]]
[[32]]
[[33]]
[[34]]
[[35]]
[[36]]
[[37]]
[[38]]
[[39]]
[[40]]
[[41]]
[[42]]
[[43]]
[[44]]
[[45]]
dev.off()
png
2
GLODAP_time_series <- GLODAP %>%
select(year, basin_AIP, lat, depth, sal, temp,
oxygen, aou, nitrate, silicate, phosphate,
tco2, talk)
GLODAP_time_series <- GLODAP_time_series %>%
mutate(depth_grid = cut(depth, seq(0,1e4,1000)))
GLODAP_time_series <- GLODAP_time_series %>%
pivot_longer(sal:talk,
names_to = "parameter",
values_to = "value") %>%
filter(!is.na(value),
!is.na(depth_grid))
GLODAP_time_series %>%
group_split(basin_AIP, depth_grid) %>%
# head(1) %>%
map(
~ ggplot(data = .x,
aes(year, value, col = lat)) +
geom_jitter(alpha = 0.1) +
scale_color_divergent() +
facet_grid(parameter ~ depth_grid,
scales = "free_y") +
labs(title = paste(
"basin_AIP:",
unique(.x$basin_AIP),
"| depth_grid:",
unique(.x$depth_grid)
))
)
source("/net/kryo/work/uptools/co2_calculation/CANYON-B/CANYONB.R")
GLODAP_CB <- GLODAP %>%
mutate(lon = if_else(lon > 180, lon - 360, lon)) %>%
arrange(year) %>%
select(row_number, year, date, lat, lon, depth, basin_AIP,
temp, sal, oxygen,
talk, tco2, nitrate, phosphate, silicate)
# filter rows with essential variables for Canyon-B
GLODAP_CB <- GLODAP_CB %>%
filter(across(c(lat, lon, depth,
temp, sal, oxygen), ~ !is.na(.x)))
GLODAP_CB <- GLODAP_CB %>%
mutate(as_tibble(
CANYONB(
date = paste0(as.character(date), " 12:00"),
lat = lat,
lon = lon,
pres = depth,
temp = temp,
psal = sal,
doxy = oxygen,
param = c("AT", "CT", "NO3", "PO4", "SiOH4")
)
))
GLODAP_CB <- GLODAP_CB %>%
select(-ends_with(c("_cim", "_cin", "_cii")))
GLODAP_CB <- GLODAP_CB %>%
rename(
"talk_CANYONB" = "AT",
"tco2_CANYONB" = "CT",
"nitrate_CANYONB" = "NO3",
"phosphate_CANYONB" = "PO4",
"silicate_CANYONB" = "SiOH4"
)
variables <- c("talk", "tco2", "nitrate", "phosphate", "silicate")
for (i_variable in variables) {
# i_variable <- variables[1]
# calculate equal axis limits and binwidth
axis_lims <- GLODAP_CB %>%
drop_na() %>%
summarise(max_value = max(c(max(
!!sym(i_variable)
),
max(!!sym(
paste0(i_variable, "_CANYONB")
)))),
min_value = min(c(min(
!!sym(i_variable)
),
min(!!sym(
paste0(i_variable, "_CANYONB")
)))))
binwidth_value <- (axis_lims$max_value - axis_lims$min_value) / 60
axis_lims <- c(axis_lims$min_value, axis_lims$max_value)
print(
ggplot(GLODAP_CB, aes(
x = !!sym(i_variable),
y = !!sym(paste0(i_variable, "_CANYONB"))
)) +
geom_bin2d(binwidth = binwidth_value) +
scale_fill_viridis_c(trans = "log10") +
geom_abline(slope = 1, col = 'red') +
coord_equal(xlim = axis_lims,
ylim = axis_lims) +
facet_wrap( ~ basin_AIP) +
labs(title = "All years")
)
# for (i_year in unique(GLODAP_CB$year)) {
# # i_year <- 2017
#
# print(
# ggplot(
# GLODAP_CB %>% filter(year == i_year),
# aes(x = !!sym(i_variable),
# y = !!sym(paste0(
# i_variable, "_CANYONB"
# )))
# ) +
# geom_bin2d(binwidth = binwidth_value) +
# scale_fill_viridis_c(trans = "log10") +
# geom_abline(slope = 1, col = 'red') +
# coord_equal(xlim = axis_lims,
# ylim = axis_lims) +
# facet_wrap( ~ basin_AIP) +
# labs(title = paste("Year:", i_year))
# )
# }
}
GLODAP_CB %>%
select(row_number,
talk_CANYONB, tco2_CANYONB,
nitrate_CANYONB, phosphate_CANYONB, silicate_CANYONB) %>%
write_csv(paste(path_preprocessing,
"GLODAPv2.2021_Canyon-B.csv",
sep = ""))
GLODAP_CB <-
read_csv(paste(path_preprocessing,
"GLODAPv2.2021_Canyon-B.csv",
sep = ""))
cruises_phosphate_gap_fill <-
c("33MW19930704",
"33RO20030604",
"33RO20050111",
"33RO19980123")
cruises_talk_gap_fill <-
c("06AQ19980328")
cruises_tco2_calc <-
c("35TH20040604",
"29AH20160617")
cruises_talk_calc <-
c("06MT19900123",
"316N19920502",
"316N19921006")
xover_add_decade <- glodapv2_2021_xover_add %>%
mutate(date_A = ymd(str_sub(cruise_A, 5, 12)),
date_B = ymd(str_sub(cruise_B, 5, 12))) %>%
mutate(decade = cut(
year(date_B),
c(1989, 1999, 2009, 2019),
labels = c("1989-1999", "2000-2009", "2010-2019")
)) %>%
filter(!is.na(decade),
!is.na(offset)) %>%
arrange(date_B)
xover_add_decade %>%
group_by(parameter, cruise_A) %>%
summarise(offset_mean = mean(offset, na.rm = TRUE)) %>%
ungroup() %>%
kable(caption = "Long-term average per cruise and parameter") %>%
kable_styling() %>%
scroll_box(height = "250px")
parameter | cruise_A | offset_mean |
---|---|---|
phosphate | 06AQ19980328 | 1.0076477 |
phosphate | 06MT19900123 | 0.9952731 |
phosphate | 29AH20160617 | 0.9848944 |
phosphate | 316N19920502 | 1.0081928 |
phosphate | 316N19921006 | 1.0099657 |
phosphate | 33MW19930704 | 0.9890182 |
phosphate | 33RO19980123 | 0.9965710 |
phosphate | 33RO20030604 | 0.9966745 |
phosphate | 33RO20050111 | 1.0019318 |
phosphate | 35TH20040604 | 0.9740753 |
talk | 06AQ19980328 | 0.5163006 |
talk | 06MT19900123 | -3.5574819 |
talk | 29AH20160617 | 1.5479474 |
talk | 316N19920502 | -4.3333542 |
talk | 316N19921006 | -1.0527798 |
talk | 33MW19930704 | -0.6041569 |
talk | 33RO19980123 | -0.8518579 |
talk | 33RO20030604 | -1.8164213 |
talk | 33RO20050111 | 1.6308865 |
talk | 35TH20040604 | 0.3672771 |
tco2 | 06AQ19980328 | -0.5510192 |
tco2 | 06MT19900123 | -2.6515513 |
tco2 | 29AH20160617 | 6.3313796 |
tco2 | 316N19920502 | 0.2705865 |
tco2 | 316N19921006 | 0.7551445 |
tco2 | 33MW19930704 | -1.3349429 |
tco2 | 33RO19980123 | 0.5594899 |
tco2 | 33RO20030604 | -0.7151763 |
tco2 | 33RO20050111 | -0.3622474 |
tco2 | 35TH20040604 | 1.2796712 |
xover_add_decade %>%
group_by(parameter, decade, cruise_A) %>%
summarise(offset_mean = mean(offset, na.rm = TRUE)) %>%
ungroup() %>%
kable(caption = "Decadal average per cruise and parameter") %>%
kable_styling() %>%
scroll_box(height = "250px")
parameter | decade | cruise_A | offset_mean |
---|---|---|---|
phosphate | 1989-1999 | 06AQ19980328 | 1.0088276 |
phosphate | 1989-1999 | 06MT19900123 | 0.9925257 |
phosphate | 1989-1999 | 29AH20160617 | 0.9796380 |
phosphate | 1989-1999 | 316N19920502 | 1.0067578 |
phosphate | 1989-1999 | 316N19921006 | 1.0017277 |
phosphate | 1989-1999 | 33MW19930704 | 0.9882398 |
phosphate | 1989-1999 | 33RO19980123 | 0.9952849 |
phosphate | 1989-1999 | 33RO20030604 | 1.0012928 |
phosphate | 1989-1999 | 33RO20050111 | 1.0009821 |
phosphate | 1989-1999 | 35TH20040604 | 0.9712452 |
phosphate | 2000-2009 | 06AQ19980328 | 1.0053414 |
phosphate | 2000-2009 | 06MT19900123 | 1.0010033 |
phosphate | 2000-2009 | 29AH20160617 | 0.9899738 |
phosphate | 2000-2009 | 316N19920502 | 1.0075795 |
phosphate | 2000-2009 | 316N19921006 | 1.0137857 |
phosphate | 2000-2009 | 33MW19930704 | 0.9846140 |
phosphate | 2000-2009 | 33RO19980123 | 1.0037495 |
phosphate | 2000-2009 | 33RO20030604 | 0.9921003 |
phosphate | 2000-2009 | 33RO20050111 | 1.0025604 |
phosphate | 2000-2009 | 35TH20040604 | 0.9765408 |
phosphate | 2010-2019 | 06AQ19980328 | 1.0092836 |
phosphate | 2010-2019 | 06MT19900123 | 0.9922316 |
phosphate | 2010-2019 | 29AH20160617 | 0.9904749 |
phosphate | 2010-2019 | 316N19920502 | 1.0127004 |
phosphate | 2010-2019 | 316N19921006 | 1.0143839 |
phosphate | 2010-2019 | 33MW19930704 | 0.9964602 |
phosphate | 2010-2019 | 33RO19980123 | 0.9950980 |
phosphate | 2010-2019 | 33RO20030604 | 0.9944871 |
phosphate | 2010-2019 | 33RO20050111 | 1.0032793 |
phosphate | 2010-2019 | 35TH20040604 | 0.9766304 |
talk | 1989-1999 | 06AQ19980328 | 4.2986091 |
talk | 1989-1999 | 06MT19900123 | -1.7866112 |
talk | 1989-1999 | 29AH20160617 | 1.5510114 |
talk | 1989-1999 | 316N19920502 | -0.0551690 |
talk | 1989-1999 | 316N19921006 | 0.4878711 |
talk | 1989-1999 | 33MW19930704 | -0.6029753 |
talk | 1989-1999 | 33RO19980123 | 0.1289735 |
talk | 1989-1999 | 33RO20030604 | -2.6727990 |
talk | 1989-1999 | 33RO20050111 | 1.2382129 |
talk | 1989-1999 | 35TH20040604 | 0.3314651 |
talk | 2000-2009 | 06AQ19980328 | -0.2162355 |
talk | 2000-2009 | 06MT19900123 | -4.0659303 |
talk | 2000-2009 | 29AH20160617 | 2.3884257 |
talk | 2000-2009 | 316N19920502 | -4.0265274 |
talk | 2000-2009 | 316N19921006 | -0.9215473 |
talk | 2000-2009 | 33MW19930704 | -0.3195600 |
talk | 2000-2009 | 33RO19980123 | -5.2032065 |
talk | 2000-2009 | 33RO20030604 | -0.9500663 |
talk | 2000-2009 | 33RO20050111 | 1.2662351 |
talk | 2000-2009 | 35TH20040604 | 1.1230941 |
talk | 2010-2019 | 06AQ19980328 | 0.7206032 |
talk | 2010-2019 | 06MT19900123 | -3.9344689 |
talk | 2010-2019 | 29AH20160617 | -0.1395747 |
talk | 2010-2019 | 316N19920502 | -6.9326869 |
talk | 2010-2019 | 316N19921006 | -2.7246632 |
talk | 2010-2019 | 33MW19930704 | -0.9855887 |
talk | 2010-2019 | 33RO19980123 | 0.3001826 |
talk | 2010-2019 | 33RO20030604 | -1.7612909 |
talk | 2010-2019 | 33RO20050111 | 1.8786579 |
talk | 2010-2019 | 35TH20040604 | -1.0676170 |
tco2 | 1989-1999 | 06AQ19980328 | 1.1144077 |
tco2 | 1989-1999 | 06MT19900123 | -0.2131875 |
tco2 | 1989-1999 | 29AH20160617 | 8.1120081 |
tco2 | 1989-1999 | 316N19920502 | 0.1582007 |
tco2 | 1989-1999 | 316N19921006 | 0.2100602 |
tco2 | 1989-1999 | 33MW19930704 | -0.1342253 |
tco2 | 1989-1999 | 33RO19980123 | 0.4187870 |
tco2 | 1989-1999 | 33RO20030604 | 0.8379332 |
tco2 | 1989-1999 | 33RO20050111 | 1.4562572 |
tco2 | 1989-1999 | 35TH20040604 | 2.7288076 |
tco2 | 2000-2009 | 06AQ19980328 | -1.3551591 |
tco2 | 2000-2009 | 06MT19900123 | -3.4099140 |
tco2 | 2000-2009 | 29AH20160617 | 6.1180167 |
tco2 | 2000-2009 | 316N19920502 | 0.5997351 |
tco2 | 2000-2009 | 316N19921006 | 0.8386702 |
tco2 | 2000-2009 | 33MW19930704 | -1.6191444 |
tco2 | 2000-2009 | 33RO19980123 | 1.0463619 |
tco2 | 2000-2009 | 33RO20030604 | -1.2259491 |
tco2 | 2000-2009 | 33RO20050111 | 1.0973981 |
tco2 | 2000-2009 | 35TH20040604 | 1.2641341 |
tco2 | 2010-2019 | 06AQ19980328 | -1.1823577 |
tco2 | 2010-2019 | 06MT19900123 | -3.9523709 |
tco2 | 2010-2019 | 29AH20160617 | 1.1923250 |
tco2 | 2010-2019 | 316N19920502 | -0.1669434 |
tco2 | 2010-2019 | 316N19921006 | 1.2167030 |
tco2 | 2010-2019 | 33MW19930704 | -3.8756236 |
tco2 | 2010-2019 | 33RO19980123 | 0.4491628 |
tco2 | 2010-2019 | 33RO20030604 | -2.5484791 |
tco2 | 2010-2019 | 33RO20050111 | -2.0013224 |
tco2 | 2010-2019 | 35TH20040604 | -3.0344442 |
xover_add_decade %>%
filter(cruise_A %in% cruises_talk_calc,
parameter == "talk") %>%
group_by(parameter, decade, cruise_A) %>%
summarise(offset_mean = mean(offset, na.rm = TRUE)) %>%
ungroup() %>%
kable(caption = "Decadal talk average per cruise") %>%
kable_styling() %>%
scroll_box(height = "250px")
parameter | decade | cruise_A | offset_mean |
---|---|---|---|
talk | 1989-1999 | 06MT19900123 | -1.7866112 |
talk | 1989-1999 | 316N19920502 | -0.0551690 |
talk | 1989-1999 | 316N19921006 | 0.4878711 |
talk | 2000-2009 | 06MT19900123 | -4.0659303 |
talk | 2000-2009 | 316N19920502 | -4.0265274 |
talk | 2000-2009 | 316N19921006 | -0.9215473 |
talk | 2010-2019 | 06MT19900123 | -3.9344689 |
talk | 2010-2019 | 316N19920502 | -6.9326869 |
talk | 2010-2019 | 316N19921006 | -2.7246632 |
xover_add_decade %>%
filter(cruise_A %in% cruises_talk_calc,
parameter == "talk") %>%
group_by(parameter, decade) %>%
summarise(offset_mean = mean(offset, na.rm = TRUE)) %>%
ungroup() %>%
kable(caption = "Decadal talk average") %>%
kable_styling() %>%
scroll_box(height = "250px")
parameter | decade | offset_mean |
---|---|---|
talk | 1989-1999 | -0.7851301 |
talk | 2000-2009 | -3.6581063 |
talk | 2010-2019 | -4.6182733 |
xover_add_decade %>%
filter(cruise_A %in% cruises_talk_calc,
parameter == "talk") %>%
group_by(parameter) %>%
summarise(offset_mean = mean(offset, na.rm = TRUE)) %>%
ungroup() %>%
kable(caption = "talk average") %>%
kable_styling() %>%
scroll_box(height = "250px")
parameter | offset_mean |
---|---|
talk | -3.407015 |
xover_add_decade %>%
filter(cruise_A %in% cruises_talk_calc,
parameter == "talk") %>%
group_by(parameter, cruise_A) %>%
summarise(offset_mean = mean(offset, na.rm = TRUE)) %>%
ungroup() %>%
kable(caption = "talk average per cruise") %>%
kable_styling() %>%
scroll_box(height = "250px")
parameter | cruise_A | offset_mean |
---|---|---|
talk | 06MT19900123 | -3.557482 |
talk | 316N19920502 | -4.333354 |
talk | 316N19921006 | -1.052780 |
hline_intercept <- hline_intercept %>%
filter(parameter %in% unique(xover_add_decade$parameter))
p_crossover_ts <- xover_add_decade %>%
ggplot(aes(date_B, offset)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(shape = 21) +
scale_color_brewer(palette = "Set1") +
facet_grid(parameter ~ ., scales = "free_y") +
theme(
legend.position = "bottom",
legend.direction = "vertical",
axis.title.x = element_blank()
)
p_crossover_decadal <-
ggplot() +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_violin(data = xover_add_decade,
aes(x = decade, y = offset), fill="gold") +
geom_boxplot(data = xover_add_decade,
aes(x = decade, y = offset),
width = 0.2) +
facet_grid(parameter ~ ., scales = "free_y") +
labs(title = "Decadal offsets") +
theme(axis.title.x = element_blank(),
axis.text.x = element_text(angle = 90))
p_crossover_ts + p_crossover_decadal +
plot_layout(widths = c(2, 1))
GLODAP <- left_join(GLODAP,
GLODAP_CB %>%
select(row_number, ends_with("_CANYONB")))
# fill missing phosphate with CANYON-B estimate
GLODAP_phosphate_fill <- GLODAP %>%
filter(cruise_expocode %in% cruises_phosphate_gap_fill,
is.na(phosphate),
oxygenqc == 1)
GLODAP_phosphate_fill <- GLODAP_phosphate_fill %>%
mutate(phosphate = phosphate_CANYONB) %>%
filter(!is.na(phosphate))
map +
geom_tile(data = GLODAP_phosphate_fill %>%
distinct(lon, lat, cruise_expocode),
aes(lon, lat, fill = cruise_expocode)) +
scale_fill_brewer(palette = "Set1")
for (i_cruise in cruises_phosphate_gap_fill) {
# i_cruise <- cruises_phosphate_gap_fill[1]
p_crossover_ts <- xover_add_decade %>%
filter(cruise_A %in% i_cruise) %>%
ggplot(aes(date_B, offset)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(shape = 21) +
scale_color_brewer(palette = "Set1") +
facet_grid(parameter ~ ., scales = "free_y") +
labs(title = i_cruise) +
theme(
legend.position = "bottom",
legend.direction = "vertical",
axis.title.x = element_blank()
)
p_crossover_decadal <-
ggplot() +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_violin(
data = xover_add_decade %>%
filter(cruise_A %in% i_cruise),
aes(x = decade, y = offset),
fill = "gold"
) +
geom_boxplot(
data = xover_add_decade %>%
filter(cruise_A %in% i_cruise),
aes(x = decade, y = offset),
width = 0.2
) +
facet_grid(parameter ~ ., scales = "free_y") +
theme(axis.title.x = element_blank(),
axis.text.x = element_text(angle = 90))
print(
p_crossover_ts + p_crossover_decadal +
plot_layout(widths = c(2, 1))
)
}
# fill missing talk with CANYON-B estimate
GLODAP_talk_fill <- GLODAP %>%
filter(cruise_expocode %in% cruises_talk_gap_fill,
is.na(talk),
oxygenqc == 1)
GLODAP_talk_fill <- GLODAP_talk_fill %>%
mutate(talk = talk_CANYONB) %>%
filter(!is.na(talk))
map +
geom_tile(data = GLODAP_talk_fill %>%
distinct(lon, lat, cruise_expocode),
aes(lon, lat, fill = cruise_expocode)) +
scale_fill_brewer(palette = "Set1")
for (i_cruise in cruises_talk_gap_fill) {
# i_cruise <- cruises_phosphate_gap_fill[1]
p_crossover_ts <- xover_add_decade %>%
filter(cruise_A %in% i_cruise) %>%
ggplot(aes(date_B, offset)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(shape = 21) +
scale_color_brewer(palette = "Set1") +
facet_grid(parameter ~ ., scales = "free_y") +
labs(title = i_cruise) +
theme(
legend.position = "bottom",
legend.direction = "vertical",
axis.title.x = element_blank()
)
p_crossover_decadal <-
ggplot() +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_violin(
data = xover_add_decade %>%
filter(cruise_A %in% i_cruise),
aes(x = decade, y = offset),
fill = "gold"
) +
geom_boxplot(
data = xover_add_decade %>%
filter(cruise_A %in% i_cruise),
aes(x = decade, y = offset),
width = 0.2
) +
facet_grid(parameter ~ ., scales = "free_y") +
theme(axis.title.x = element_blank(),
axis.text.x = element_text(angle = 90))
print(p_crossover_ts + p_crossover_decadal +
plot_layout(widths = c(2, 1)))
}
GLODAP_gap_fill <- bind_rows(
GLODAP_phosphate_fill,
GLODAP_talk_fill
)
GLODAP_tco2_calc <- GLODAP %>%
filter(cruise_expocode %in% cruises_tco2_calc,
tco2f == 0)
map +
geom_tile(data = GLODAP_tco2_calc %>%
distinct(lon, lat, cruise_expocode),
aes(lon, lat, fill = cruise_expocode)) +
scale_fill_brewer(palette = "Set1")
for (i_cruise in cruises_tco2_calc) {
# i_cruise <- cruises_phosphate_gap_fill[1]
p_crossover_ts <- xover_add_decade %>%
filter(cruise_A %in% i_cruise) %>%
ggplot(aes(date_B, offset)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(shape = 21) +
scale_color_brewer(palette = "Set1") +
facet_grid(parameter ~ ., scales = "free_y") +
labs(title = i_cruise) +
theme(
legend.position = "bottom",
legend.direction = "vertical",
axis.title.x = element_blank()
)
p_crossover_decadal <-
ggplot() +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_violin(
data = xover_add_decade %>%
filter(cruise_A %in% i_cruise),
aes(x = decade, y = offset),
fill = "gold"
) +
geom_boxplot(
data = xover_add_decade %>%
filter(cruise_A %in% i_cruise),
aes(x = decade, y = offset),
width = 0.2
) +
facet_grid(parameter ~ ., scales = "free_y") +
theme(axis.title.x = element_blank(),
axis.text.x = element_text(angle = 90))
print(p_crossover_ts + p_crossover_decadal +
plot_layout(widths = c(2, 1)))
}
GLODAP_talk_calc <- GLODAP %>%
filter(cruise_expocode %in% cruises_talk_calc,
talkf == 0)
map +
geom_tile(data = GLODAP_talk_calc %>%
distinct(lon, lat, cruise_expocode),
aes(lon, lat, fill = cruise_expocode)) +
scale_fill_brewer(palette = "Set1")
for (i_cruise in cruises_talk_calc) {
# i_cruise <- cruises_phosphate_gap_fill[1]
p_crossover_ts <- xover_add_decade %>%
filter(cruise_A %in% i_cruise) %>%
ggplot(aes(date_B, offset)) +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_point(shape = 21) +
scale_color_brewer(palette = "Set1") +
facet_grid(parameter ~ ., scales = "free_y") +
labs(title = i_cruise) +
theme(
legend.position = "bottom",
legend.direction = "vertical",
axis.title.x = element_blank()
)
p_crossover_decadal <-
ggplot() +
geom_hline(data = hline_intercept, aes(yintercept = intercept)) +
geom_violin(
data = xover_add_decade %>%
filter(cruise_A %in% i_cruise),
aes(x = decade, y = offset),
fill = "gold"
) +
geom_boxplot(
data = xover_add_decade %>%
filter(cruise_A %in% i_cruise),
aes(x = decade, y = offset),
width = 0.2
) +
facet_grid(parameter ~ ., scales = "free_y") +
theme(axis.title.x = element_blank(),
axis.text.x = element_text(angle = 90))
print(
p_crossover_ts + p_crossover_decadal +
plot_layout(widths = c(2, 1))
)
}
GLODAP_calc <- bind_rows(
GLODAP_tco2_calc,
GLODAP_talk_calc
)
GLODAP_crossover <- bind_rows(
GLODAP_gap_fill,
GLODAP_calc
)
GLODAP_crossover_write <- GLODAP_crossover %>%
select(
EXPOCODE = cruise_expocode,
STNNBR = station,
CASTNO = cast,
BTLNBR = bottle,
DATE = date,
LATITUDE = lat,
LONGITUDE = lon,
CTDPRS = pressure,
CTDTMP = temp,
CTDSAL = sal,
CTDSAL_FLAG_W = salinityf,
PHSPHT = phosphate,
PHSPHT_FLAG_W = phosphatef,
TCARBN = tco2,
TCARBN_FLAG_W = tco2f,
ALKALI = talk,
ALKALI_FLAG_W = talkf)
GLODAP_crossover_write <- GLODAP_crossover_write %>%
mutate(DATE = format(DATE, "%Y%m%d"))
last_line <- "END_DATA"
for (i_EXPOCODE in unique(GLODAP_crossover_write$EXPOCODE)) {
# i_EXPOCODE <- unique(GLODAP_crossover_write$EXPOCODE)[1]
temp <- GLODAP_crossover_write %>%
filter(EXPOCODE == i_EXPOCODE) %>%
add_row(.before = 1)
cat("Bottle",
"\n",
file = paste0(
path_preprocessing,
"crossover_cruises/",
i_EXPOCODE,
".exc.csv"
)
)
temp %>%
write_csv(
file = paste0(
path_preprocessing,
"crossover_cruises/",
i_EXPOCODE,
".exc.csv"
),
na = "",
append = TRUE,
col_names = TRUE
)
write(
last_line,
file = paste0(
path_preprocessing,
"crossover_cruises/",
i_EXPOCODE,
".exc.csv"
),
append = TRUE
)
}
sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE Leap 15.3
Matrix products: default
BLAS: /usr/local/R-4.1.2/lib64/R/lib/libRblas.so
LAPACK: /usr/local/R-4.1.2/lib64/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] colorspace_2.0-2 kableExtra_1.3.4 ggrepel_0.9.1 lubridate_1.8.0
[5] marelac_2.1.10 shape_1.4.6 ggforce_0.3.3 metR_0.11.0
[9] scico_1.3.0 patchwork_1.1.1 collapse_1.7.0 forcats_0.5.1
[13] stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4 readr_2.1.1
[17] tidyr_1.1.4 tibble_3.1.6 ggplot2_3.3.5 tidyverse_1.3.1
[21] workflowr_1.7.0
loaded via a namespace (and not attached):
[1] nlme_3.1-155 fs_1.5.2 bit64_4.0.5 gsw_1.0-6
[5] RColorBrewer_1.1-2 webshot_0.5.2 httr_1.4.2 rprojroot_2.0.2
[9] tools_4.1.2 backports_1.4.1 bslib_0.3.1 utf8_1.2.2
[13] R6_2.5.1 mgcv_1.8-38 DBI_1.1.2 withr_2.4.3
[17] tidyselect_1.1.1 processx_3.5.2 bit_4.0.4 compiler_4.1.2
[21] git2r_0.29.0 cli_3.1.1 rvest_1.0.2 xml2_1.3.3
[25] labeling_0.4.2 sass_0.4.0 scales_1.1.1 checkmate_2.0.0
[29] SolveSAPHE_2.1.0 callr_3.7.0 systemfonts_1.0.3 digest_0.6.29
[33] svglite_2.0.0 rmarkdown_2.11 oce_1.5-0 pkgconfig_2.0.3
[37] htmltools_0.5.2 highr_0.9 dbplyr_2.1.1 fastmap_1.1.0
[41] rlang_0.4.12 readxl_1.3.1 rstudioapi_0.13 jquerylib_0.1.4
[45] generics_0.1.1 farver_2.1.0 jsonlite_1.7.3 vroom_1.5.7
[49] magrittr_2.0.1 Matrix_1.4-0 Rcpp_1.0.8 munsell_0.5.0
[53] fansi_1.0.2 lifecycle_1.0.1 stringi_1.7.6 whisker_0.4
[57] yaml_2.2.1 MASS_7.3-55 grid_4.1.2 parallel_4.1.2
[61] promises_1.2.0.1 crayon_1.4.2 lattice_0.20-45 splines_4.1.2
[65] haven_2.4.3 hms_1.1.1 seacarb_3.3.0 knitr_1.37
[69] ps_1.6.0 pillar_1.6.4 reprex_2.0.1 glue_1.6.0
[73] evaluate_0.14 getPass_0.2-2 data.table_1.14.2 modelr_0.1.8
[77] vctrs_0.3.8 tzdb_0.2.0 tweenr_1.0.2 httpuv_1.6.5
[81] cellranger_1.1.0 gtable_0.3.0 polyclip_1.10-0 assertthat_0.2.1
[85] xfun_0.29 broom_0.7.11 later_1.3.0 viridisLite_0.4.0
[89] ellipsis_0.3.2