Last updated: 2024-09-20

Checks: 7 0

Knit directory: heatwave_co2_flux_2023/analysis/

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(20240307) 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 59d4ded. 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/

Unstaged changes:
    Modified:   analysis/child/pCO2_product_synopsis.Rmd
    Modified:   code/Workflowr_project_managment.R

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/pco2_product_mapping_skill.Rmd) and HTML (docs/pco2_product_mapping_skill.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 59d4ded jens-daniel-mueller 2024-09-20 minor edits
html d6d6440 jens-daniel-mueller 2024-09-12 Build site.
Rmd 3bb52db jens-daniel-mueller 2024-09-12 maps created
html 756fa19 jens-daniel-mueller 2024-07-20 Build site.
Rmd de2e9c2 jens-daniel-mueller 2024-07-20 label v2 and fco2 products
html 0b5ffe4 jens-daniel-mueller 2024-07-11 Build site.
Rmd 7c286b2 jens-daniel-mueller 2024-07-11 rebuild all products
html 430e926 jens-daniel-mueller 2024-07-10 manual commit
Rmd b4a08ea jens-daniel-mueller 2024-06-26 high res analysis
html d2a80a9 jens-daniel-mueller 2024-06-14 Build site.
Rmd fe5eaa5 jens-daniel-mueller 2024-06-14 testrun on sea
html f03b1d8 jens-daniel-mueller 2024-06-12 Build site.
html d46002d jens-daniel-mueller 2024-06-12 manual commit
html e5cb4e9 jens-daniel-mueller 2024-06-12 Build site.
html 5261667 jens-daniel-mueller 2024-06-11 manual commit
Rmd dfc33c9 jens-daniel-mueller 2024-06-11 manual commit
html 6954c65 jens-daniel-mueller 2024-06-06 Build site.
html 6a16b4c jens-daniel-mueller 2024-06-05 Build site.
Rmd 8ff0fa3 jens-daniel-mueller 2024-06-05 SOCATv2024 comparison

center <- -160
boundary <- center + 180
target_crs <- paste0("+proj=robin +over +lon_0=", center)
# target_crs <- paste0("+proj=eqearth +over +lon_0=", center)
# target_crs <- paste0("+proj=eqearth +lon_0=", center)
# target_crs <- paste0("+proj=igh_o +lon_0=", center)

worldmap <- ne_countries(scale = 'small',
                         type = 'map_units',
                         returnclass = 'sf')

worldmap <- worldmap %>% st_break_antimeridian(lon_0 = center)
worldmap_trans <- st_transform(worldmap, crs = target_crs)

# ggplot() +
#   geom_sf(data = worldmap_trans)

coastline <- ne_coastline(scale = 'small', returnclass = "sf")
coastline <- st_break_antimeridian(coastline, lon_0 = 200)
coastline_trans <- st_transform(coastline, crs = target_crs)

# ggplot() +
#   geom_sf(data = worldmap_trans, fill = "grey", col="grey") +
#   geom_sf(data = coastline_trans)


bbox <- st_bbox(c(xmin = -180, xmax = 180, ymax = 65, ymin = -78), crs = st_crs(4326))
bbox <- st_as_sfc(bbox)
bbox_trans <- st_break_antimeridian(bbox, lon_0 = center)

bbox_graticules <- st_graticule(
  x = bbox_trans,
  crs = st_crs(bbox_trans),
  datum = st_crs(bbox_trans),
  lon = c(20, 20.001),
  lat = c(-78,65),
  ndiscr = 1e3,
  margin = 0.001
)

bbox_graticules_trans <- st_transform(bbox_graticules, crs = target_crs)
rm(worldmap, coastline, bbox, bbox_trans)

# ggplot() +
#   geom_sf(data = worldmap_trans, fill = "grey", col="grey") +
#   geom_sf(data = coastline_trans) +
#   geom_sf(data = bbox_graticules_trans)

lat_lim <- ext(bbox_graticules_trans)[c(3,4)]*1.002
lon_lim <- ext(bbox_graticules_trans)[c(1,2)]*1.005

# ggplot() +
#   geom_sf(data = worldmap_trans, fill = "grey90", col = "grey90") +
#   geom_sf(data = coastline_trans) +
#   geom_sf(data = bbox_graticules_trans, linewidth = 1) +
#   coord_sf(crs = target_crs,
#            ylim = lat_lim,
#            xlim = lon_lim,
#            expand = FALSE) +
#   theme(
#     panel.border = element_blank(),
#     axis.text = element_blank(),
#     axis.ticks = element_blank()
#   )

latitude_graticules <- st_graticule(
  x = bbox_graticules,
  crs = st_crs(bbox_graticules),
  datum = st_crs(bbox_graticules),
  lon = c(20, 20.001),
  lat = c(-60,-30,0,30,60),
  ndiscr = 1e3,
  margin = 0.001
)

latitude_graticules_trans <- st_transform(latitude_graticules, crs = target_crs)

latitude_labels <- data.frame(lat_label = c("60°N","30°N","Eq.","30°S","60°S"),
                 lat = c(60,30,0,-30,-60)-4, lon = c(35)-c(0,2,4,2,0))

latitude_labels <- st_as_sf(x = latitude_labels,
               coords = c("lon", "lat"),
               crs = "+proj=longlat")

latitude_labels_trans <- st_transform(latitude_labels, crs = target_crs)

# ggplot() +
#   geom_sf(data = worldmap_trans, fill = "grey", col = "grey") +
#   geom_sf(data = coastline_trans) +
#   geom_sf(data = bbox_graticules_trans) +
#   geom_sf(data = latitude_graticules_trans,
#           col = "grey60",
#           linewidth = 0.2) +
#   geom_sf_text(data = latitude_labels_trans,
#                aes(label = lat_label),
#                size = 3,
#                col = "grey60")
library(lubridate)
library(scales)
library(RColorBrewer)
library(ggtext)
library(ggnewscale)
files <- list.files(here::here("data/"),
                    pattern = paste0(2023,"_map_monthly_anomaly.csv"),
                    full.names = TRUE)

pco2_product_coarse_monthly_regression <-
  read_csv(files,
           id = "product")

pco2_product_coarse_monthly_regression <-
  pco2_product_coarse_monthly_regression %>% 
  mutate(product = str_extract(product, "OceanSODAv2|SOM-FFN|CMEMS|fCO2-Residual|ETHZ-CESM|FESOM-REcoM"))

all_product_list <- c("OceanSODAv2",
                      "SOM-FFN",
                      "fCO2-Residual",
                      "CMEMS",
                      "ETHZ-CESM",
                      "FESOM-REcoM")

pco2_product_coarse_monthly_regression <-
  pco2_product_coarse_monthly_regression %>%
  mutate(
    product = factor(product, levels = all_product_list)
  ) %>%
  filter(!is.na(name))

pco2_product_list <- c("OceanSODAv2", "SOM-FFN", "fCO2-Residual", "CMEMS")
map <-
  read_rds(here::here("data/map.rds"))

key_biomes <-
  read_rds(here::here("data/key_biomes.rds"))


biome_mask <-
  read_rds(here::here("data/biome_mask.rds"))

map +
  geom_tile(data = biome_mask,
            aes(fill = biome))

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
biome_mask <-
  bind_rows(biome_mask,
            biome_mask %>%
              filter(!str_detect(biome, "SO-SPSS|SO-ICE|Arctic")) %>%
              mutate(biome = "Global non-polar"))
SOCAT_gridded_monthly <-
  read_csv(
    here::here(
      "data/SOCATv2024_prelim/SOCATv2024_tracks_gridded_monthly.csv"
    ),
    skip = 241
  )

SOCAT_gridded_monthly <-
  SOCAT_gridded_monthly %>%
  mutate(year = year(DATE),
         month = month(DATE)) %>%
  select(year,
         month,
         lat = LAT,
         lon = LON,
         sfco2_obs = FCO2_AVE_WEIGHTED_YEAR) %>% 
  mutate(lon = if_else(lon < 20, lon + 360, lon))


SOCAT_gridded_monthly <-
  inner_join(
    SOCAT_gridded_monthly,
    biome_mask %>%
      filter(!str_detect(biome, "SO-SPSS|SO-ICE|Arctic|Global")) %>%
      select(lon, lat))

map +
  geom_tile(data = SOCAT_gridded_monthly %>% filter(year == 2023),
            aes(lon, lat, fill = sfco2_obs)) +
  scale_fill_viridis_c() +
  facet_wrap(~ month)

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
0a7394b jens-daniel-mueller 2024-06-11
6a16b4c jens-daniel-mueller 2024-06-05
map +
  geom_tile(data = SOCAT_gridded_monthly %>% count(lat, lon),
            aes(lon, lat, fill = n)) +
  scale_fill_scico(palette = "grayC", trans = "log10")

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
0b5ffe4 jens-daniel-mueller 2024-07-11
d2a80a9 jens-daniel-mueller 2024-06-14
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
0a7394b jens-daniel-mueller 2024-06-11
6a16b4c jens-daniel-mueller 2024-06-05
SOCAT_gridded_monthly_raster <- rast(SOCAT_gridded_monthly %>%
                                       count(lon, lat), crs = "+proj=longlat")


SOCAT_gridded_monthly_raster <- project(SOCAT_gridded_monthly_raster, target_crs, method = "near")

SOCAT_gridded_monthly_tibble <- SOCAT_gridded_monthly_raster %>%
  as.data.frame(xy = TRUE, na.rm = FALSE) %>%
  as_tibble() %>%
  rename(lon = x, lat = y) %>%
  drop_na()

SOCAT_gridded_monthly_raster_2023 <- rast(SOCAT_gridded_monthly %>%
                                       filter(year == 2023) %>% 
                                       count(lon, lat), crs = "+proj=longlat")


SOCAT_gridded_monthly_raster_2023 <- project(SOCAT_gridded_monthly_raster_2023, target_crs, method = "near")

SOCAT_gridded_monthly_tibble_2023 <- SOCAT_gridded_monthly_raster_2023 %>%
  as.data.frame(xy = TRUE, na.rm = FALSE) %>%
  as_tibble() %>%
  rename(lon = x, lat = y) %>%
  drop_na()



bbox <- st_bbox(c(xmin = -180, xmax = 180, ymax = 76, ymin = -54), crs = st_crs(4326))
bbox <- st_as_sfc(bbox)
bbox_trans <- st_break_antimeridian(bbox, lon_0 = center)

bbox_graticules <- st_graticule(
  x = bbox_trans,
  crs = st_crs(bbox_trans),
  datum = st_crs(bbox_trans),
  lon = c(20, 20.001),
  lat = c(-54,76),
  ndiscr = 1e3,
  margin = 0.001
)

bbox_graticules_trans <- st_transform(bbox_graticules, crs = target_crs)
rm(bbox, bbox_trans)

# ggplot() +
#   geom_sf(data = worldmap_trans, fill = "grey", col="grey") +
#   geom_sf(data = coastline_trans) +
#   geom_sf(data = bbox_graticules_trans)

lat_lim <- ext(bbox_graticules_trans)[c(3,4)]*1.002
lon_lim <- ext(bbox_graticules_trans)[c(1,2)]*1.005

stations <-
  tibble(
    lon = c(-64, -170, -12),
    lat = c(32, 0, 30)
    # label = c(1, 2, 3)
  )

stations <-
  stations %>% 
  mutate(lon = if_else(lon < 20, lon + 360, lon))

stations <-
  stations %>% as.matrix()

# pts = matrix(1:10, , 2)
# st_multipoint(pts)

stations <- st_multipoint(stations)

stations <- st_sfc(stations, crs = "+proj=longlat")
stations_trans <- st_transform(stations, crs = target_crs)

stations_tibble <- do.call(rbind, st_geometry(stations_trans)) %>% 
    as_tibble() %>% setNames(c("lon","lat"))

stations_tibble <- 
  bind_cols(stations_tibble, label = c(1,2,3))

# Bats: 31.5 - 32.5°N / 63.5 – 64.5°W
# Mid Pacific: 0.5°S-0.5°N/170.5°W
# VOS-Line: 29°N/13°W , 30°N/12°W , 31°N/11°W


ggplot() +
  geom_tile(data = SOCAT_gridded_monthly_tibble, aes(x = lon, y = lat, fill = n)) +
  scale_fill_scico(palette = "grayC",
                   begin = 0.2,
                   trans = "log10",
                   "Months with\nobservations\n1990-2022") +
  new_scale_fill() +
  geom_tile(data = SOCAT_gridded_monthly_tibble_2023, aes(x = lon, y = lat, fill = n)) +
  scale_fill_scico(palette = "buda",
                   trans = "log10",
                   "Months with\nobservations\n2023") +
  geom_sf(data = worldmap_trans,
          fill = "grey90",
          col = "grey90") +
  geom_sf(data = coastline_trans, linewidth = 0.3) +
  geom_sf(data = bbox_graticules_trans, linewidth = 0.5) +
  geom_label(data = stations_tibble, aes(x = lon, y = lat, label = label)) +
  coord_sf(
    crs = target_crs,
    ylim = lat_lim,
    xlim = lon_lim,
    expand = FALSE
  ) +
  theme(
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank(),
    panel.border = element_rect(colour = "transparent"),
    strip.background = element_blank(),
    legend.position = "top"
  )

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
0b5ffe4 jens-daniel-mueller 2024-07-11
d2a80a9 jens-daniel-mueller 2024-06-14
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
0a7394b jens-daniel-mueller 2024-06-11
6a16b4c jens-daniel-mueller 2024-06-05
ggsave(width = 8,
       height = 4.5,
       dpi = 600,
       filename = "../output/SOCAT_observations_map.jpg")



biome_mask_robin_raster <- rast(
  biome_mask %>%
    filter(!str_detect(biome, "SO-SPSS|SO-ICE|Arctic|Global")) %>%
    mutate(dist = 1) %>%
    mutate(biome = case_when(
      str_detect(biome, "SPSS") ~ "SPSS",
      str_detect(biome, "STSS") ~ "STSS",
      str_detect(biome, "STPS") ~ "STPS",
      TRUE ~ "Tropics"
    )) %>% 
    pivot_wider(names_from = biome, values_from = dist),
  crs = "+proj=longlat"
)


biome_mask_robin_raster <- project(biome_mask_robin_raster, target_crs, method = "near")

biome_mask_robin_tibble <- biome_mask_robin_raster %>%
  as.data.frame(xy = TRUE, na.rm = FALSE) %>%
  as_tibble() %>%
  rename(lon = x, lat = y) %>%
  pivot_longer(cols = -c("lon", "lat"),
               names_to = "biome",
               values_to = "dist") %>%
  drop_na() %>% 
  mutate(biome = as.character(biome))


ggplot() +
  geom_raster(
    data = biome_mask_robin_tibble %>% 
      mutate(biome = fct_inorder(biome)),
    aes(
      x = lon,
      y = lat,
      fill = biome
    )
  ) +
  geom_sf(data = worldmap_trans, fill = "grey90", col = "grey90") +
  geom_sf(data = coastline_trans, linewidth = 0.3) +
  geom_sf(data = bbox_graticules_trans, linewidth = 0.5) +
  coord_sf(
    crs = target_crs,
    ylim = lat_lim,
    xlim = lon_lim,
    expand = FALSE
  ) +
  scale_fill_viridis_d(option = "magma", begin = 0.1, end = 0.9)  +
  guides(fill = guide_legend(byrow = TRUE)) +
  theme(
    axis.title = element_blank(),
    axis.text = element_blank(),
    axis.ticks = element_blank(),
    panel.border = element_rect(colour = "transparent"),
    strip.background = element_blank(),
    legend.position = "top",
    legend.title = element_blank()
  )

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
0b5ffe4 jens-daniel-mueller 2024-07-11
ggsave(width = 8,
       height = 4.5,
       dpi = 600,
       filename = "../output/biome_map.jpg")

# SOCAT_gridded_monthly <-
#   m_grid_horizontal_coarse(SOCAT_gridded_monthly)
# 
# SOCAT_gridded_monthly <-
#   SOCAT_gridded_monthly %>%
#   mutate(area = earth_surf(lat, lon)) %>% 
#   group_by(year, month, lon_grid, lat_grid) %>%
#   summarise(across(sfco2_obs,
#                    ~ weighted.mean(., area, na.rm = TRUE))) %>%
#   ungroup() %>%
#   rename(lon = lon_grid, lat = lat_grid)
# 
# map +
#   geom_tile(data = SOCAT_gridded_monthly %>% filter(year == 2023),
#             aes(lon, lat, fill = sfco2_obs)) +
#   scale_fill_viridis_c() +
#   facet_wrap(~ month)

SOCAT_pCO2_product <-
  left_join(
    pco2_product_coarse_monthly_regression %>%
      filter(name == "sfco2"),
    SOCAT_gridded_monthly
  )


map +
  geom_tile(data = SOCAT_pCO2_product %>% filter(year == 2023),
            aes(lon, lat, fill = sfco2_obs)) +
  scale_fill_viridis_c() +
  facet_wrap(~ month)

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
SOCAT_pCO2_product <-
  SOCAT_pCO2_product %>%
  group_by(lon, lat, month, year) %>% 
  mutate(n = n()) %>% 
  ungroup() %>% 
  filter(n == 6) %>% 
  select(-n)

SOCAT_pCO2_product <-
  SOCAT_pCO2_product %>%
  mutate(sfco2_bias = value - sfco2_obs)

map +
  geom_tile(
    data = SOCAT_pCO2_product %>% filter(year == 2023,
                                         product %in% pco2_product_list) %>%
      group_by(lon, lat, month) %>%
      summarise(sfco2_bias = mean(sfco2_bias)) %>%
      ungroup(),
    aes(lon, lat, fill = sfco2_bias)
  ) +
  scale_fill_gradientn(
    colours = rev(brewer.pal(7, "Spectral")),
    rescaler = ~ scales::rescale_mid(.x, mid = 0),
    name = "fCO<sub>2,ocean</sub> bias<br>pred. - obs.<br>(µatm)",
    # limits = c(
    #   quantile(SOCAT_pCO2_product$sfco2_bias, .01),
    #   quantile(SOCAT_pCO2_product$sfco2_bias, .99)
    # ),
    oob = squish
  ) +
  guides(
    fill = guide_colorbar(
      barheight = unit(0.3, "cm"),
      barwidth = unit(6, "cm"),
      ticks = TRUE,
      ticks.colour = "grey20",
      frame.colour = "grey20",
      label.position = "top",
      direction = "horizontal"
    )
  ) +
  theme(legend.title = element_markdown(),
        legend.position = "top") +
  facet_wrap(~ month)

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
d2a80a9 jens-daniel-mueller 2024-06-14
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
0a7394b jens-daniel-mueller 2024-06-11
6a16b4c jens-daniel-mueller 2024-06-05
ggsave(width = 7,
       height = 4,
       dpi = 600,
       filename = "../output/SOCAT_fco2_bias_map_2023_ensemble_mean.jpg")


map +
  geom_tile(data = SOCAT_pCO2_product %>% filter(year == 2023),
            aes(lon, lat, fill = sfco2_bias)) +
  scale_fill_gradientn(
    colours = rev(brewer.pal(7, "Spectral")),
    rescaler = ~ scales::rescale_mid(.x, mid = 0),
    name = "fCO<sub>2,ocean</sub> bias<br>pred. - obs.<br>(µatm)",
    # limits = c(quantile(SOCAT_pCO2_product$sfco2_bias, .01), 
    #            quantile(SOCAT_pCO2_product$sfco2_bias, .99)),
    oob = squish
  ) +
  guides(
    fill = guide_colorbar(
      barheight = unit(0.3, "cm"),
      barwidth = unit(6, "cm"),
      ticks = TRUE,
      ticks.colour = "grey20",
      frame.colour = "grey20",
      label.position = "top",
      direction = "horizontal"
    )
  ) +
  theme(legend.title = element_markdown(),
        legend.position = "top") +
  facet_grid(month ~ product)

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
756fa19 jens-daniel-mueller 2024-07-20
0b5ffe4 jens-daniel-mueller 2024-07-11
d2a80a9 jens-daniel-mueller 2024-06-14
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
ggsave(width = 8,
       height = 7,
       dpi = 600,
       filename = "../output/SOCAT_fco2_bias_map_2023.jpg")
SOCAT_pCO2_product_biome <-
  inner_join(SOCAT_pCO2_product,
             biome_mask,
             relationship = "many-to-many")


SOCAT_pCO2_product_biome <-
  SOCAT_pCO2_product_biome %>%
  group_by(year, month, product, biome) %>%
  summarise(
    sfco2_bias = mean(sfco2_bias, na.rm = TRUE),
    sfco2_resid = mean(resid, na.rm = TRUE)
  ) %>%
  ungroup()
  
SOCAT_pCO2_product_biome %>%
  filter(biome %in% c("Global", key_biomes),
         year >= 2020,
         product %in% pco2_product_list) %>%
  group_by(biome, year, month) %>%
  summarise(sfco2_bias = mean(sfco2_bias, na.rm = TRUE)) %>%
  ungroup() %>%
  ggplot(aes(year + month / 12, sfco2_bias))+
  geom_hline(yintercept = 0) +
  geom_path() +
  geom_point(data = . %>% filter(year != 2023),
             aes(fill = "2020-2022"),
             size = 1) +
  scale_fill_manual(values = "grey70",name = "") +
  new_scale_fill() +
  geom_point(data = . %>% filter(year == 2023),
             aes(fill = month),
             shape = 21) +
  scale_fill_scico(
    palette = "buda",
    guide = guide_legend(reverse = TRUE,
                         order = 1),
    name = paste("Month\nof", 2023)
  ) +
  coord_cartesian(ylim = c(-50,50)) +
  scale_x_continuous(breaks = seq(1980, 2022, 2)) +
  labs(y = "fCO<sub>2,ocean</sub> bias<br>pred. - obs.<br>(µatm)",) +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_markdown()) +
  facet_wrap(~ biome)

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
0b5ffe4 jens-daniel-mueller 2024-07-11
d2a80a9 jens-daniel-mueller 2024-06-14
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
0a7394b jens-daniel-mueller 2024-06-11
6a16b4c jens-daniel-mueller 2024-06-05
ggsave(width = 7,
       height = 4,
       dpi = 600,
       filename = "../output/SOCAT_fco2_bias_timeseries_2018_2023_ensemble_mean.jpg")
  
SOCAT_pCO2_product_biome %>% 
  filter(biome %in% c("Global", key_biomes),
         year >= 2020) %>%
  ggplot(aes(year + month/12, sfco2_bias)) +
  geom_hline(yintercept = 0) +
  geom_path() +
  geom_point(data = . %>% filter(year != 2023),
             aes(fill = "2020-2022"),
             size = 1) +
  scale_fill_manual(values = "grey70",name = "") +
  new_scale_fill() +
  geom_point(data = . %>% filter(year == 2023),
             aes(fill = month),
             shape = 21) +
  scale_fill_scico(
    palette = "buda",
    guide = guide_legend(reverse = TRUE,
                         order = 1),
    name = paste("Month\nof", 2023)
  ) +
  coord_cartesian(ylim = c(-50,50)) +
  scale_x_continuous(breaks = seq(1980, 2022, 2)) +
  labs(y = "fCO<sub>2,ocean</sub> bias<br>pred. - obs.<br>(µatm)") +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_markdown()) +
  facet_grid(biome ~ product)

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
756fa19 jens-daniel-mueller 2024-07-20
0b5ffe4 jens-daniel-mueller 2024-07-11
d2a80a9 jens-daniel-mueller 2024-06-14
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
ggsave(width = 10,
       height = 7,
       dpi = 600,
       filename = "../output/SOCAT_fco2_bias_timeseries_2018_2023.jpg")
SOCAT_pCO2_product_biome %>%
  mutate(month = as.factor(month)) %>%
  filter(biome %in% c("Global", key_biomes),
         product %in% pco2_product_list) %>%
  group_by(biome, year, month) %>%
  summarise(sfco2_bias = mean(sfco2_bias, na.rm = TRUE),
            sfco2_resid = mean(sfco2_resid, na.rm = TRUE)) %>%
  ungroup() %>%
  ggplot(aes(sfco2_bias, sfco2_resid)) +
  geom_hline(yintercept = 0) +
  geom_vline(xintercept = 0) +
  geom_point(data = . %>% filter(year != 2023),
             alpha = 0.1) +
  geom_path(data = . %>% filter(year == 2023)) +
  geom_point(
    data = . %>% filter(year == 2023),
    aes(fill = month),
    shape = 21,
    size = 2
  ) +
  scale_fill_scico_d(
    palette = "buda",
    guide = guide_legend(reverse = TRUE,
                         order = 1),
    name = paste("Month\nof", 2023)
  ) +
  coord_fixed(ylim = c(-50, 50),
              xlim = c(-50, 50)) +
  labs(x = "fCO<sub>2,ocean</sub> bias<br>pred. - obs.<br>(µatm)",
       y = "fCO<sub>2,ocean</sub><br>anomaly<br>(µatm)") +
  facet_wrap(~ biome) +
  theme(
    axis.title.x = element_markdown(),
    axis.title.y = element_markdown()
  )

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
0b5ffe4 jens-daniel-mueller 2024-07-11
d2a80a9 jens-daniel-mueller 2024-06-14
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
0a7394b jens-daniel-mueller 2024-06-11
6a16b4c jens-daniel-mueller 2024-06-05
ggsave(width = 7,
       height = 4,
       dpi = 600,
       filename = "../output/SOCAT_fco2_anomaly_vs_bias_ensemble_mean.jpg")

SOCAT_pCO2_product_biome %>%
  mutate(month = as.factor(month)) %>%
  filter(biome %in% c("Global", key_biomes)) %>%
  ggplot(aes(sfco2_bias, sfco2_resid)) +
  geom_hline(yintercept = 0) +
  geom_vline(xintercept = 0) +
  geom_point(data = . %>% filter(year != 2023),
             alpha = 0.1) +
  geom_path(data = . %>% filter(year == 2023)) +
  geom_point(
    data = . %>% filter(year == 2023),
    aes(fill = month),
    shape = 21,
    size = 2
  ) +
  scale_fill_scico_d(
    palette = "buda",
    guide = guide_legend(reverse = TRUE,
                         order = 1),
    name = paste("Month\nof", 2023)
  ) +
  coord_fixed(ylim = c(-50, 50),
              xlim = c(-50, 50)) +
  labs(x = "fCO<sub>2,ocean</sub> bias<br>pred. - obs.<br>(µatm)",
       y = "fCO<sub>2,ocean</sub><br>anomaly<br>(µatm)") +
  facet_grid(biome ~ product) +
  theme(
    axis.title.x = element_markdown(),
    axis.title.y = element_markdown()
  )

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
756fa19 jens-daniel-mueller 2024-07-20
0b5ffe4 jens-daniel-mueller 2024-07-11
d2a80a9 jens-daniel-mueller 2024-06-14
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
0a7394b jens-daniel-mueller 2024-06-11
6a16b4c jens-daniel-mueller 2024-06-05
ggsave(width = 10,
       height = 7,
       dpi = 600,
       filename = "../output/SOCAT_fco2_anomaly_vs_bias.jpg")

SOCAT_pCO2_product_biome %>%
  mutate(month = as.factor(month)) %>%
  filter(biome %in% c("Global", key_biomes)) %>%
  ggplot(aes(sfco2_bias, sfco2_resid)) +
  geom_hline(yintercept = 0) +
  geom_vline(xintercept = 0) +
  geom_point(data = . %>% filter(year != 2023),
             alpha = 0.1) +
  geom_path(data = . %>% filter(year == 2023)) +
  geom_point(
    data = . %>% filter(year == 2023),
    aes(fill = month),
    shape = 21,
    size = 2
  ) +
  scale_fill_scico_d(
    palette = "buda",
    guide = guide_legend(reverse = TRUE,
                         order = 1),
    name = paste("Month\nof", 2023)
  ) +
  coord_fixed(ylim = c(-20, 20),
              xlim = c(-20, 20)) +
  labs(x = "fCO<sub>2,ocean</sub> bias<br>pred. - obs.<br>(µatm)",
       y = "fCO<sub>2,ocean</sub><br>anomaly<br>(µatm)") +
  facet_grid(biome ~ product) +
  theme(
    axis.title.x = element_markdown(),
    axis.title.y = element_markdown()
  )

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
756fa19 jens-daniel-mueller 2024-07-20
0b5ffe4 jens-daniel-mueller 2024-07-11
d2a80a9 jens-daniel-mueller 2024-06-14
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
ggsave(width = 10,
       height = 7,
       dpi = 600,
       filename = "../output/SOCAT_fco2_anomaly_vs_bias_zoom.jpg")
SOCAT_pCO2_product_biome %>%
  filter(biome %in% c("Global", key_biomes)) %>% 
  mutate(month = as.factor(month)) %>%
  ggplot(aes(sfco2_bias, product)) +
  geom_vline(xintercept = 0) +
  geom_jitter(data = . %>% filter(year != 2023),
             alpha = 0.1) +
  geom_jitter(
    data = . %>% filter(year == 2023),
    aes(fill = month),
    shape = 21,
    size = 2
  ) +
  scale_fill_scico_d(
    palette = "buda",
    guide = guide_legend(reverse = TRUE,
                         order = 1),
    name = paste("Month\nof", 2023)
  ) +
  scale_y_discrete(limits = rev) +
  coord_cartesian(xlim = c(-50, 50)) +
  labs(x = "fCO<sub>2,ocean</sub><br>bias<br>(µatm)") +
  facet_wrap( ~ biome) +
  theme(
    axis.title.x = element_markdown(),
    axis.title.y = element_markdown()
  )

Version Author Date
d6d6440 jens-daniel-mueller 2024-09-12
756fa19 jens-daniel-mueller 2024-07-20
0b5ffe4 jens-daniel-mueller 2024-07-11
d2a80a9 jens-daniel-mueller 2024-06-14
f03b1d8 jens-daniel-mueller 2024-06-12
de65385 jens-daniel-mueller 2024-06-12
e5cb4e9 jens-daniel-mueller 2024-06-12
0a7394b jens-daniel-mueller 2024-06-11
6a16b4c jens-daniel-mueller 2024-06-05
ggsave(width = 10,
       height = 10,
       dpi = 600,
       filename = "../output/SOCAT_fco2_anomaly.jpg")

sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE Leap 15.5

Matrix products: default
BLAS:   /usr/local/R-4.2.2/lib64/R/lib/libRblas.so
LAPACK: /usr/local/R-4.2.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] ggnewscale_0.4.8    ggtext_0.1.2        RColorBrewer_1.1-3 
 [4] scales_1.2.1        lubridate_1.9.0     timechange_0.1.1   
 [7] terra_1.7-65        sf_1.0-9            rnaturalearth_0.1.0
[10] geomtextpath_0.1.1  colorspace_2.0-3    marelac_2.1.10     
[13] shape_1.4.6         ggforce_0.4.1       metR_0.13.0        
[16] scico_1.3.1         patchwork_1.1.2     collapse_1.8.9     
[19] forcats_0.5.2       stringr_1.5.0       dplyr_1.1.3        
[22] purrr_1.0.2         readr_2.1.3         tidyr_1.3.0        
[25] tibble_3.2.1        ggplot2_3.4.4       tidyverse_1.3.2    
[28] workflowr_1.7.0    

loaded via a namespace (and not attached):
  [1] googledrive_2.0.0       ellipsis_0.3.2          class_7.3-20           
  [4] rprojroot_2.0.3         markdown_1.4            fs_1.5.2               
  [7] gridtext_0.1.5          rstudioapi_0.15.0       proxy_0.4-27           
 [10] farver_2.1.1            bit64_4.0.5             fansi_1.0.3            
 [13] xml2_1.3.3              codetools_0.2-18        cachem_1.0.6           
 [16] knitr_1.41              polyclip_1.10-4         jsonlite_1.8.3         
 [19] gsw_1.1-1               broom_1.0.5             dbplyr_2.2.1           
 [22] compiler_4.2.2          httr_1.4.4              backports_1.4.1        
 [25] assertthat_0.2.1        fastmap_1.1.0           gargle_1.2.1           
 [28] cli_3.6.1               later_1.3.0             tweenr_2.0.2           
 [31] htmltools_0.5.3         tools_4.2.2             rnaturalearthdata_0.1.0
 [34] gtable_0.3.1            glue_1.6.2              Rcpp_1.0.11            
 [37] cellranger_1.1.0        jquerylib_0.1.4         vctrs_0.6.4            
 [40] xfun_0.35               ps_1.7.2                rvest_1.0.3            
 [43] lifecycle_1.0.3         googlesheets4_1.0.1     oce_1.7-10             
 [46] getPass_0.2-2           MASS_7.3-58.1           vroom_1.6.0            
 [49] ragg_1.2.4              hms_1.1.2               promises_1.2.0.1       
 [52] parallel_4.2.2          yaml_2.3.6              memoise_2.0.1          
 [55] sass_0.4.4              stringi_1.7.8           highr_0.9              
 [58] e1071_1.7-12            checkmate_2.1.0         commonmark_1.8.1       
 [61] rlang_1.1.1             pkgconfig_2.0.3         systemfonts_1.0.4      
 [64] evaluate_0.18           lattice_0.20-45         SolveSAPHE_2.1.0       
 [67] labeling_0.4.2          bit_4.0.5               processx_3.8.0         
 [70] tidyselect_1.2.0        here_1.0.1              seacarb_3.3.1          
 [73] magrittr_2.0.3          R6_2.5.1                generics_0.1.3         
 [76] DBI_1.1.3               pillar_1.9.0            haven_2.5.1            
 [79] whisker_0.4             withr_2.5.0             units_0.8-0            
 [82] sp_1.5-1                modelr_0.1.10           crayon_1.5.2           
 [85] KernSmooth_2.23-20      utf8_1.2.2              tzdb_0.3.0             
 [88] rmarkdown_2.18          grid_4.2.2              readxl_1.4.1           
 [91] data.table_1.14.6       callr_3.7.3             git2r_0.30.1           
 [94] reprex_2.0.2            digest_0.6.30           classInt_0.4-8         
 [97] httpuv_1.6.6            textshaping_0.3.6       munsell_0.5.0          
[100] viridisLite_0.4.1       bslib_0.4.1