Last updated: 2021-04-15

Checks: 7 0

Knit directory: emlr_obs_analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20210412) 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 71e6c6f. 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:    output/Gruber_2019_comparison/
    Ignored:    output/publication/

Untracked files:
    Untracked:  code/Workflowr_project_managment.R

Unstaged changes:
    Modified:   analysis/_site.yml

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/publication.Rmd) and HTML (docs/publication.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 71e6c6f jens-daniel-mueller 2021-04-15 add publication figures
html 117a5c3 jens-daniel-mueller 2021-04-14 Build site.
Rmd 56f179d jens-daniel-mueller 2021-04-14 add publication figures

1 Data sources

Following Cant estimates are used:

  • Zonal mean (basin, lat, depth)
  • Inventories (lat, lon)
cant_inv <-
  read_csv(paste(path_version_data,
                 "cant_inv.csv",
                 sep = ""))

cant_inv_mod_truth <-
  read_csv(paste(path_version_data,
                 "cant_inv_mod_truth.csv",
                 sep = ""))

cant_inv <- bind_rows(cant_inv, cant_inv_mod_truth)

GLODAP_clean <-
  read_csv(paste(path_version_data,
                 "GLODAPv2.2020_clean.csv",
                 sep = ""))

GLODAP_preprocessed <-
  read_csv(
    paste(
      path_preprocessing_model,
      "GLODAPv2.2020_preprocessed_model_runA_both.csv",
      sep = ""
    )
  )
cant_inv <- cant_inv %>%
  filter(inv_depth == params_global$inventory_depth_standard)

2 Inventory map

var_name <- expression(atop(Delta * C["ant"],
                            (mol ~ m ^ {
                              -2
                            })))

GLODAP_grid <- GLODAP_clean %>% 
  distinct(lon, lat, era)

GLODAP_grid_both <- GLODAP_grid %>% 
  count(lon, lat) %>% 
  mutate(n = as.factor(n))


cant_inv %>%
  filter(data_source == "obs") %>% 
  ggplot(aes(cant_pos_inv)) +
  geom_histogram()

Version Author Date
117a5c3 jens-daniel-mueller 2021-04-14
coastlines <- ne_coastline(scale = "small", returnclass = "sf")
coastlines_re <- ne_coastline(scale = "small", returnclass = "sf")
worldmap <- ne_countries(scale = "small", returnclass = "sf")
worldmap_re <- ne_countries(scale = "small", returnclass = "sf")

# 
# ggplot() +
#   geom_raster(data = cant_inv %>% filter(data_source == "obs"),
#               aes(lon, lat, fill = cant_pos_inv)) +
#   geom_sf(data = coastlines, fill="grey", color="black") +
#   scale_fill_scico(palette = "tokyo")

set_breaks <- c(-Inf, seq(0, 20, 2), Inf)

library(sf)
st_geometry(worldmap_re) <- st_geometry(worldmap_re) + c(360, 0)
st_crs(worldmap_re) <- st_crs(worldmap)
st_geometry(coastlines_re) <- st_geometry(coastlines_re) + c(360, 0)
st_crs(coastlines_re) <- st_crs(coastlines)

# coastline_raster <- stars::st_rasterize(coastlines, options = "ALL_TOUCHED=TRUE") %>% 
#   as.tibble()


ggplot() +
  geom_raster(
    data = cant_inv %>% filter(data_source == "obs"),
    aes(lon, lat, fill = cut(cant_inv, set_breaks))) +
  scale_fill_viridis_d(option = "A", name = var_name,
                       guide = guide_colorsteps()) +
  new_scale_fill() +
  geom_contour_fill(
    data = cant_inv %>% filter(data_source == "obs"),
    aes(lon, lat, z = cant_inv, fill = stat(level)),
    breaks = set_breaks
    #na.fill = 0
  ) +
  scale_fill_viridis_d(option = "A", name = var_name,
                       guide = guide_colorsteps()) +
  new_scale_fill() +
  geom_raster(data = GLODAP_grid_both,
              aes(lon, lat, fill=n)) +
  scale_fill_manual(values = c("grey50", "gold"),
                    name = "Eras\noccupied") +
  theme(axis.text = element_blank(),
        axis.ticks = element_blank(),
        axis.title = element_blank()) +
  geom_sf(data = worldmap_re, fill="grey80", color="grey80") +
  geom_sf(data = worldmap, fill="grey80", color="grey80") +
  geom_sf(data = coastlines, color="grey20") +
  geom_sf(data = coastlines_re, color="grey20") +
  coord_sf(ylim = c(-77,64.5), xlim = c(20.5,379.5), expand = 0)

Version Author Date
117a5c3 jens-daniel-mueller 2021-04-14
ggsave(path = "output/publication",
       filename = "dCant_inventory_map.png",
       height = 4,
       width = 10)

3 Data time series histogram

time_histo <- GLODAP_preprocessed %>% 
  filter(!is.na(tco2)) %>% 
  count(basin_AIP, year)

time_histo %>% 
  ggplot(aes(year, n, fill=basin_AIP)) + 
  geom_col() +
  scale_fill_brewer(palette = "Dark2") +
  scale_x_continuous(breaks = seq(1900,2100,5)) +
  scale_y_continuous(name = "") +
  coord_cartesian(expand = 0) +
  labs(title = "GLODAPv2.2020 | Observations coverage")

Version Author Date
117a5c3 jens-daniel-mueller 2021-04-14

4 Spatial time coverage

time_histo <- GLODAP_preprocessed %>% 
  filter(year >= 2000) %>% 
  distinct(lat, lon, year)

map + 
  geom_raster(data = time_histo, aes(lon, lat)) +
  facet_wrap(~ year)

Version Author Date
117a5c3 jens-daniel-mueller 2021-04-14

5 Model offset

GLODAP_sp <- GLODAP %>% 
  filter(depth == 150)

map +
  geom_raster(data = GLODAP_sp,
              aes(lon, lat, fill = temp)) +
  scale_fill_viridis_c()

class(GLODAP_sp)

GLODAP_sp <- GLODAP_sp %>% 
  mutate(lon = if_else(lon > 180, lon - 360, lon))

ggplot() +
  geom_raster(data = GLODAP_sp,
              aes(lon, lat, fill = temp)) +
  scale_fill_viridis_c() +
  coord_quickmap()

GLODAP_sp <- as.data.frame(GLODAP_sp)

library(sp)
coordinates(GLODAP_sp) = ~lon+lat
class(GLODAP_sp)

summary(GLODAP_sp)

is.projected(GLODAP_sp)
proj4string(GLODAP_sp) <-
  CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")


GLODAP_sp_grid <- GLODAP_sp

gridded(GLODAP_sp_grid) <- TRUE


spplot(GLODAP_sp,
       zcol = "temp")

spplot(GLODAP_sp_grid,
       zcol = "temp")

library(sf)
library(stars)
GLODAP_sf <- st_as_sf(GLODAP_sp_grid)
GLODAP_stars <- st_as_stars(GLODAP_sp_grid)
class(GLODAP_stars)

plot(GLODAP_stars)

ggplot() +
  geom_stars(data = GLODAP_stars,
             aes(x, y, fill = temp)) +
  scale_fill_viridis_c(na.value = "transparent") +
  coord_quickmap(expand = 0)


coastlines <- ne_coastline(scale = "small", returnclass = "sf")

ggplot() +
  geom_sf(data = GLODAP_sf,
             aes(col = temp)) +
  scale_fill_viridis_c(na.value = "transparent") +
  geom_sf(data = st_wrap_dateline(coastlines),
          colour = "black") +
  coord_sf(crs = st_crs('ESRI:54030')) +
  theme_bw()

summary(GLODAP_sp)

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE Leap 15.2

Matrix products: default
BLAS:   /usr/local/R-4.0.3/lib64/R/lib/libRblas.so
LAPACK: /usr/local/R-4.0.3/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] sf_0.9-8            ggnewscale_0.4.5    rnaturalearth_0.1.0
 [4] metR_0.9.0          scico_1.2.0         patchwork_1.1.1    
 [7] collapse_1.5.0      forcats_0.5.0       stringr_1.4.0      
[10] dplyr_1.0.5         purrr_0.3.4         readr_1.4.0        
[13] tidyr_1.1.2         tibble_3.0.4        ggplot2_3.3.3      
[16] tidyverse_1.3.0     workflowr_1.6.2    

loaded via a namespace (and not attached):
 [1] fs_1.5.0                 lubridate_1.7.9          RColorBrewer_1.1-2      
 [4] httr_1.4.2               rprojroot_2.0.2          tools_4.0.3             
 [7] backports_1.1.10         R6_2.5.0                 KernSmooth_2.23-17      
[10] rgeos_0.5-5              DBI_1.1.0                colorspace_1.4-1        
[13] withr_2.3.0              sp_1.4-4                 tidyselect_1.1.0        
[16] rnaturalearthdata_0.1.0  compiler_4.0.3           git2r_0.27.1            
[19] cli_2.1.0                rvest_0.3.6              xml2_1.3.2              
[22] isoband_0.2.2            labeling_0.4.2           scales_1.1.1            
[25] checkmate_2.0.0          classInt_0.4-3           digest_0.6.27           
[28] rmarkdown_2.5            pkgconfig_2.0.3          htmltools_0.5.0         
[31] dbplyr_1.4.4             rlang_0.4.10             readxl_1.3.1            
[34] rstudioapi_0.13          generics_0.0.2           farver_2.0.3            
[37] jsonlite_1.7.1           magrittr_1.5             Matrix_1.2-18           
[40] Rcpp_1.0.5               munsell_0.5.0            fansi_0.4.1             
[43] lifecycle_1.0.0          stringi_1.5.3            whisker_0.4             
[46] yaml_2.2.1               plyr_1.8.6               grid_4.0.3              
[49] blob_1.2.1               parallel_4.0.3           promises_1.1.1          
[52] crayon_1.3.4             lattice_0.20-41          haven_2.3.1             
[55] hms_0.5.3                knitr_1.30               pillar_1.4.7            
[58] reprex_0.3.0             glue_1.4.2               evaluate_0.14           
[61] RcppArmadillo_0.10.1.2.0 data.table_1.13.2        modelr_0.1.8            
[64] vctrs_0.3.5              httpuv_1.5.4             cellranger_1.1.0        
[67] gtable_0.3.0             assertthat_0.2.1         xfun_0.18               
[70] broom_0.7.5              RcppEigen_0.3.3.7.0      e1071_1.7-4             
[73] later_1.1.0.1            viridisLite_0.3.0        class_7.3-17            
[76] units_0.6-7              ellipsis_0.3.1