Skip to content

Commit

Permalink
Merge pull request #1 from inSilecoInc/CST-335-progress-report
Browse files Browse the repository at this point in the history
CST-335 realease progress report template
  • Loading branch information
david-beauchesne authored Mar 27, 2024
2 parents f9ffa4f + 9bbe0f5 commit a0403d5
Show file tree
Hide file tree
Showing 85 changed files with 7,506 additions and 5,081 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ pof-stac-insileco*
figures/*
!figures/atlas/
!figures/webinar/
frontpage.svg
frontpage.svg
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Imports:
here,
iEat,
mapview,
quarto,
randomForest,
raster,
sf,
Expand Down
118 changes: 25 additions & 93 deletions R/fig_aoi.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,102 +3,34 @@
#' @export

fig_aoi <- function() {
# ------------------------------------------------------------------------
# Graph principal
out <- here::here("figures","aoi")
chk_create(out)
png(
here::here(out, "aoi.png"),
res = param$figures$resolution,
width = param$figures$width,
height = param$figures$height,
units = "mm",
pointsize = param$figures$pointsize
)

# ------------------
aoi <- sf::st_read("data/aoi/aoi.gpkg", quiet = TRUE)
can <- sf::st_read("data/basemap/canada.gpkg", quiet = TRUE)
canada <- sf::st_read("data/basemap/canada_full.gpkg", quiet = TRUE)
usa <- sf::st_read("data/basemap/usa.gpkg", quiet = TRUE)

# ------------------
# Labels
labs <- c("Study area")
# out <- here::here("figures", "aoi")
# chk_create(out)
# png(
# here::here(out, "aoi.png"),
# res = param$figures$resolution,
# width = param$figures$width,
# height = param$figures$height,
# units = "mm",
# pointsize = param$figures$pointsize
# )

# ------------------
global_parameters()
bbox <- param$bbox

# ------------------
yGap <- 1
par(family = 'serif', mar = c(.5, .5, .5, .5))
graphicsutils::plot0(x = c(bbox$xmin, bbox$xmax), y = c(bbox$ymin-yGap, bbox$ymax-yGap))
aoi <- sf::st_read(here::here("project-data/aoi/aoi.gpkg"), quiet = TRUE)
can <- sf::st_read(here::here("project-data/basemap/canada_full.gpkg"), quiet = TRUE)
usa <- sf::st_read(here::here("project-data/basemap/usa.gpkg"), quiet = TRUE)
gl <- sf::st_read(here::here("project-data/basemap/greenland.gpkg"), quiet = TRUE)
bbox <- sf::st_bbox(aoi)
par(family = "serif", mar = c(.5, .5, .5, .5))
graphicsutils::plot0(x = c(bbox$xmin, bbox$xmax), y = c(bbox$ymin, bbox$ymax))
plot(
sf::st_geometry(aoi),
lwd = 2,
border = param$col$aoi,
col = glue::glue("{param$col$focus}33"),
sf::st_geometry(aoi),
lwd = 2,
border = "#000000BB",
col = "#376e7d88",
add = TRUE
)
plot(sf::st_geometry(can), lwd = .5, col = param$col$coastline, add = TRUE)
plot(sf::st_geometry(usa), lwd = .5, col = param$col$coastline, add = TRUE)
plot(sf::st_geometry(can), lwd = .5, col = "#00000088", add = TRUE)
plot(sf::st_geometry(usa), lwd = .5, col = "#00000088", add = TRUE)
plot(sf::st_geometry(gl), lwd = .5, col = "#00000088", add = TRUE)
box()

# ------------------
# Text
rect(
bbox$xmin-.15,
bbox$ymax+.25-yGap,
bbox$xmin+2.8,
bbox$ymax-.275-yGap,
col = "#ffffffBB",
border = "#000000"
)
text(
x = bbox$xmin,
y = bbox$ymax-yGap,
labels = labs[1],
font = 2,
adj = c(0,.5),
cex = .8
)


#
# # ------------------
# # Cities
# plot(st_geometry(cities), add = TRUE, pch = 21, col = "#3e3e3e", bg = "#9f9f9f", cex = .4)
# for(i in 1:nrow(cities)) {
# text(x = cities$X[i]+cities$offX[i],
# y = cities$Y[i]+cities$offY[i],
# labels = cities$city[i],
# cex = .35,
# col = "#000000",
# adj = c(cities$adjX[i], .5))
# }
#
# # ---------------------------
# # Grille
# par(new = TRUE)
# par(fig = c(.035,.25,.6,.825), mar = c(0,0,0,0))
# # par(fig = c(.765,.965,.05,.25), mar = c(0,0,0,0))
# plot0(x = c(lacstpierre$xmin, lacstpierre$xmax), y = c(lacstpierre$ymin, lacstpierre$ymax))
# box(col = "#00000088")
# plotDat(trans = "FF")
# text(x = lacstpierre$xmin + 750, y = lacstpierre$ymax - 3000, labels = labs[4], cex = .5, font = 3, adj = c(0,.5))
#
# ---------------------------
# Canada
par(new = TRUE)
par(fig = c(.6,.965,.039,.36), mar = c(0,0,0,0))
bbox <- sf::st_bbox(canada)
graphicsutils::plot0(x = c(bbox$xmin, bbox$xmax), y = c(bbox$ymin, bbox$ymax))
plot(sf::st_geometry(canada), col = glue::glue("{param$col$coastline}33"), add = TRUE)
plot(sf::st_geometry(usa), col = glue::glue("{param$col$coastline}33"), add = TRUE)
plot(sf::st_geometry(aoi),lwd = 1, border = param$col$focus,col = param$col$focus, add = TRUE)
box(col = "#000000")

# ---------------------------
dev.off()
# dev.off()
}
16 changes: 1 addition & 15 deletions R/render_pubs.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,7 @@
#'
#' @export
render_report <- function() {
# file.copy("./figures/", "./report/", recursive = TRUE)
suppressWarnings({
setwd('./pubs/report/')
bookdown::render_book(
input = "index.Rmd",
output_format = "bookdown::gitbook",
config_file = "_bookdown.yml"
)
setwd('../../')
# file.copy("./figures/", "./report/", recursive = TRUE)
})
from <- here::here("pubs","report","docs")
to <- here::here("docs","report")
if (file.exists(to)) fs::file_delete(to)
fs::file_move(from, to)
quarto::quarto_render("pubs/report")
}

#' Render publications frontpage
Expand Down
11 changes: 11 additions & 0 deletions R/threat_pollution.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ threat_pollution <- function() {

# Remove downloaded data
# fs::dir_delete(tmp)

# Export partial data for use in report (this should be revisited)
out <- here::here("project-data", "partials")
pipedat::chk_create(out)
pipedat::masterwrite(neec, here::here(out, "neec"))
# ----------------------------------------------------------------
# To explore:
# Impact to Waterbody field. Consider if we should treat “actual” vs. “potential” spills differently. Data on “potential” spills only started being recorded in April 2021 onward (no differentiation before that). Some “Potential” spills may report very large amounts of substance that was not actually spilled (e.g. Incident Number NL-20200611-03045-20 was a disabled vessel with 400000 L of fuel on board, but nothing spilled). These “Potential” spills still represent risk even if no true pollution occurred.
Expand All @@ -93,6 +98,9 @@ threat_pollution <- function() {
dplyr::filter(!is.na(volume_l)) |>
dplyr::rename(geometry = geom)

# Export partial data for use in report (this should be revisited)
pipedat::masterwrite(nasp, here::here(out, "nasp"))

# =~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~= #
# ISTOP data
# =~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~= #
Expand All @@ -108,6 +116,9 @@ threat_pollution <- function() {
area = as.numeric(area)
)

# Export partial data for use in report (this should be revisited)
pipedat::masterwrite(istop, here::here(out, "istop"))

# =~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~= #
# Threat layer - diffusive model
# =~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~= #
Expand Down
Loading

0 comments on commit a0403d5

Please sign in to comment.