Skip to content

[pre-commit.ci] pre-commit autoupdate #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .Rprofile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ options(
radian.tab_size = 2,
radian.complete_while_typing = TRUE,
scipen = 999,

clustermq.template = "slurm_clustermq.tmpl",

precommit.executable = "/home/patrick/.local/bin/pre-commit",

renv.settings.auto.snapshot = TRUE
)
suppressMessages(require(drake))
Expand All @@ -49,4 +46,3 @@ if (interactive() && "tibble" %in% rownames(utils::installed.packages())) {
# knitr::purl(rmd, output = tempR)
# sys.source(tempR, envir = envir)
# }

4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.0.0.9027
rev: v0.2.0
hooks:
# any R project
- id: style-files
Expand All @@ -17,7 +17,7 @@ repos:
# - id: deps-in-desc
# - id: codemeta-description-updated
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v4.0.1
hooks:
- id: check-added-large-files
args: ['--maxkb=200']
3 changes: 2 additions & 1 deletion R/04-fun-sentinel-processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ get_records <- function(aoi, date, processing_level) {
login_CopHub("be-marc", password = "ISQiwQDl")

# Get records from Sentinel-2 in time range
records <- getSpatialData::get_records(time_range = date,
records <- getSpatialData::get_records(
time_range = date,
products = "Sentinel-2", as_sf = FALSE
)

Expand Down
10 changes: 3 additions & 7 deletions _drake.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,17 @@ R.utils::sourceDirectory("code")
plan_paper <- bind_plans(
download_data_plan,
hyperspectral_processing_plan,

data_preprocessing_plan,
tasks_plan,

filter_eda_plan,
param_sets_plan,
learners_plan,
filter_wrapper_plan,
resampling_plan,
tune_ctrl_plan,
tune_wrapper_plan,

benchmark_plan,
bm_aggregated_plan,

feature_imp_plan,
reports_plan_paper
)
Expand All @@ -58,11 +54,11 @@ plan_paper <- bind_plans(

# config for long running tasks
drake_config(plan_paper,
targets = c(
# replace this with the target name that should be computed
targets = c(
# replace this with the target name that should be computed
# c("eda_wfr")
"benchmark_no_models"
),
),
verbose = 1,
lazy_load = "eager",
packages = NULL,
Expand Down
2 changes: 0 additions & 2 deletions analysis/eda.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ R.utils::sourceDirectory("code")
loadd(
vi_data, nri_data,
bands_data, coords_vi_nri_clean,

filter_values,
filter_info_gain_nbins,

trees_with_bands,
trees_with_bands_no_buffer
)
Expand Down
3 changes: 0 additions & 3 deletions analysis/eval-performance.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,14 @@ df_tbl <- getBMRTuneResults(bmr_inspect_tune, as.df = TRUE) %>%
learner.id == "XGBOOST MBO Borda" & iter == 2 ~ "Laukiz1",
learner.id == "XGBOOST MBO Borda" & iter == 3 ~ "Oiartzun",
learner.id == "XGBOOST MBO Borda" & iter == 4 ~ "Laukiz2",

learner.id == "SVM MBO Car" & iter == 1 ~ "Laukiz1",
learner.id == "SVM MBO Car" & iter == 2 ~ "Oiartzun",
learner.id == "SVM MBO Car" & iter == 3 ~ "Luiando",
learner.id == "SVM MBO Car" & iter == 4 ~ "Laukiz2",

learner.id == "RF MBO Car" & iter == 1 ~ "Luiando",
learner.id == "RF MBO Car" & iter == 2 ~ "Laukiz2",
learner.id == "RF MBO Car" & iter == 3 ~ "Laukiz1",
learner.id == "RF MBO Car" & iter == 4 ~ "Oiartzun",

TRUE ~ as.character(iter)
)) %>%
dplyr::rename(Learner = learner.id) %>%
Expand Down
54 changes: 25 additions & 29 deletions analysis/feature-importance.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ loadd(
# Slurm resources suggestion: at least 20 cores and 2 GB / core = 40 GB pro job
fi_permut_hr,
fi_permut_vi,

fi_ale_hr,
fi_ale_vi,
fi_ale_hr_gs20,
fi_ale_vi_gs20,

df_wavelengths_from_indices,
spec_sigs
)
Expand All @@ -66,7 +64,7 @@ fi_ranked_hr

fi_ranked_vi <- fi_permut_vi$res %>%
tibble::rownames_to_column("measure") %>%
dplyr::select(-contains("ID..")) %>%
dplyr::select(-contains("ID..")) %>%
tidyr::pivot_longer(
cols = !measure,
values_to = "importance", names_to = "feature"
Expand Down Expand Up @@ -203,7 +201,6 @@ plot_reflectance_imp_hr <- function(data) {
size = 3,
na.rm = TRUE
) +

scale_color_manual(values = c(
"HR: Rank 11:122" = "grey",
"HR: Rank 1:10" = "black",
Expand Down Expand Up @@ -317,7 +314,6 @@ plot_reflectance_imp_vi <- function(data) {
aes(x = wavelength, y = importance, group = class, color = "VI: Rank 11:89"),
size = 0.2, linetype = "dashed"
) +

scale_color_manual(values = c(
"VI: Rank 11:89" = "grey",
"VI: Rank 1:10" = "black",
Expand Down Expand Up @@ -471,7 +467,7 @@ ALE plots via package {iml}
Top ten HR features from permutation Vimp

```{r fi-hr-ale, dev = c("png", "pdf"), warning=FALSE}
ale_p1 = fi_ale_hr$plot(
ale_p1 <- fi_ale_hr$plot(
features = df_wavelengths_from_hr$class,
ncol = 2
) & scale_y_continuous(
Expand All @@ -487,27 +483,27 @@ ale_p1 = fi_ale_hr$plot(
)

# Custom y axis breaks for subplots
ale_p1[[2]] = ale_p1[[2]] + scale_y_continuous(
ale_p1[[2]] <- ale_p1[[2]] + scale_y_continuous(
n.breaks = 3
)

ale_p1[[3]] = ale_p1[[3]] + scale_y_continuous(
ale_p1[[3]] <- ale_p1[[3]] + scale_y_continuous(
n.breaks = 4
)

ale_p1[[7]] = ale_p1[[7]] + scale_y_continuous(
ale_p1[[7]] <- ale_p1[[7]] + scale_y_continuous(
n.breaks = 4
)

ale_p1[[8]] = ale_p1[[8]] + scale_y_continuous(
ale_p1[[8]] <- ale_p1[[8]] + scale_y_continuous(
n.breaks = 4
)

ale_p1[[9]] = ale_p1[[9]] + scale_y_continuous(
ale_p1[[9]] <- ale_p1[[9]] + scale_y_continuous(
n.breaks = 4
)

ale_p1[[10]] = ale_p1[[10]] + scale_y_continuous(
ale_p1[[10]] <- ale_p1[[10]] + scale_y_continuous(
n.breaks = 4
)
ale_p1
Expand All @@ -518,7 +514,7 @@ ale_p1
Top ten HR features from permutation Vimp

```{r, warning=FALSE, message=FALSE}
ale_p2 = fi_ale_hr_gs20$plot(
ale_p2 <- fi_ale_hr_gs20$plot(
features = df_wavelengths_from_hr$class,
ncol = 2
) & scale_y_continuous(
Expand All @@ -534,25 +530,25 @@ ale_p2 = fi_ale_hr_gs20$plot(
)

# Custom y axis breaks for subplots
ale_p2[[1]] = ale_p2[[1]] + scale_y_continuous(
ale_p2[[1]] <- ale_p2[[1]] + scale_y_continuous(
n.breaks = 4
)
ale_p2[[2]] = ale_p2[[2]] + scale_y_continuous(
ale_p2[[2]] <- ale_p2[[2]] + scale_y_continuous(
n.breaks = 5
)
ale_p2[[3]] = ale_p2[[3]] + scale_y_continuous(
ale_p2[[3]] <- ale_p2[[3]] + scale_y_continuous(
n.breaks = 4
)
ale_p2[[4]] = ale_p2[[4]] + scale_y_continuous(
ale_p2[[4]] <- ale_p2[[4]] + scale_y_continuous(
n.breaks = 4
)
ale_p2[[6]] = ale_p2[[6]] + scale_y_continuous(
ale_p2[[6]] <- ale_p2[[6]] + scale_y_continuous(
n.breaks = 4
)
ale_p2[[7]] = ale_p2[[7]] + scale_y_continuous(
ale_p2[[7]] <- ale_p2[[7]] + scale_y_continuous(
n.breaks = 4
)
ale_p2[[10]] = ale_p2[[10]] + scale_y_continuous(
ale_p2[[10]] <- ale_p2[[10]] + scale_y_continuous(
n.breaks = 3
)
ale_p2
Expand All @@ -565,7 +561,7 @@ ale_p2
Top ten VI features from permutation Vimp

```{r fi-vi-ale, dev = c("png", "pdf"), warning=FALSE}
ale_p3 = fi_ale_vi$plot(
ale_p3 <- fi_ale_vi$plot(
features = df_wavelengths_from_indices_label$class,
ncol = 2
) & scale_y_continuous(
Expand All @@ -581,16 +577,16 @@ ale_p3 = fi_ale_vi$plot(
)

# Custom y axis breaks for subplots
ale_p3[[1]] = ale_p3[[1]] + scale_y_continuous(
ale_p3[[1]] <- ale_p3[[1]] + scale_y_continuous(
n.breaks = 4
)
ale_p3[[2]] = ale_p3[[2]] + scale_y_continuous(
ale_p3[[2]] <- ale_p3[[2]] + scale_y_continuous(
n.breaks = 4
)
ale_p3[[3]] = ale_p3[[3]] + scale_y_continuous(
ale_p3[[3]] <- ale_p3[[3]] + scale_y_continuous(
n.breaks = 4
)
ale_p3[[4]] = ale_p3[[4]] + scale_y_continuous(
ale_p3[[4]] <- ale_p3[[4]] + scale_y_continuous(
n.breaks = 4
)
ale_p3
Expand All @@ -601,7 +597,7 @@ ale_p3
Top ten HR features from permutation Vimp

```{r, warning=FALSE}
ale_p4 = fi_ale_vi_gs20$plot(
ale_p4 <- fi_ale_vi_gs20$plot(
features = df_wavelengths_from_indices_label$class,
ncol = 2
) & scale_y_continuous(
Expand All @@ -617,13 +613,13 @@ ale_p4 = fi_ale_vi_gs20$plot(
)

# Custom y axis breaks for subplots
ale_p4[[2]] = ale_p3[[2]] + scale_y_continuous(
ale_p4[[2]] <- ale_p3[[2]] + scale_y_continuous(
n.breaks = 4
)
ale_p4[[3]] = ale_p3[[3]] + scale_y_continuous(
ale_p4[[3]] <- ale_p3[[3]] + scale_y_continuous(
n.breaks = 4
)
ale_p4[[4]] = ale_p3[[4]] + scale_y_continuous(
ale_p4[[4]] <- ale_p3[[4]] + scale_y_continuous(
n.breaks = 4
)
ale_p4
Expand Down
1 change: 0 additions & 1 deletion analysis/filter-correlation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ R.utils::sourceDirectory("R")
drake::loadd(
filter_values,
filter_values_fselectorrcpp,

filter_info_gain_nbins
)
```
Expand Down
2 changes: 1 addition & 1 deletion analysis/license.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ editor_options:
# MIT License

```{r echo = FALSE, results='asis'}
year = lubridate::year(lubridate::today())
year <- lubridate::year(lubridate::today())
cat(sprintf("Copyright (c) 2019-%s Patrick Schratz", year))
```

Expand Down
3 changes: 1 addition & 2 deletions analysis/report-defoliation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ loadd(
defoliation_raster_relative,
defoliation_df,
defoliation_df_relative,

tune_xgboost_plan_project
)
```
Expand Down Expand Up @@ -179,6 +178,6 @@ suppressMessages(print(hist))
```

```{r echo = FALSE}
#system("rsync -rlptDivzog --chown=*:www-data --chmod=g+r,o+r /home/patrick/papers/2019-feature-selection/docs/figure/report-defoliation.Rmd/defol* [email protected]:/home/www/life-healthy-forest/action-B1-spatial-mapping/defoliation-maps/")
# system("rsync -rlptDivzog --chown=*:www-data --chmod=g+r,o+r /home/patrick/papers/2019-feature-selection/docs/figure/report-defoliation.Rmd/defol* [email protected]:/home/www/life-healthy-forest/action-B1-spatial-mapping/defoliation-maps/")
```

6 changes: 4 additions & 2 deletions analysis/spectral-signatures.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ wavelength <- c(
```

```{r spectral-signatures-3 }
speclibs <- purrr::map(data_hs_preprocessed_paper,
~ hsdar::speclib(.x, wavelength))
speclibs <- purrr::map(
data_hs_preprocessed_paper,
~ hsdar::speclib(.x, wavelength)
)
```

```{r spectral-signatures, dev=c("png", "pdf"), warning=FALSE}
Expand Down
24 changes: 13 additions & 11 deletions analysis/test/cloud-cover.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ author: "Marc Becker"
---

```{r setup, include=FALSE}
knitr::opts_knit$set(base.dir = 'analysis/rmd/')
knitr::opts_chunk$set(fig.retina = 3, fig.align = 'center', fig.width = 6.93,
fig.height = 6.13, out.width = "100%")
knitr::opts_knit$set(base.dir = "analysis/rmd/")
knitr::opts_chunk$set(
fig.retina = 3, fig.align = "center", fig.width = 6.93,
fig.height = 6.13, out.width = "100%"
)
source(here::here("code/99-packages.R"))

loadd(records, aoi, cloud_mosaic)
Expand All @@ -17,40 +19,40 @@ loadd(records, aoi, cloud_mosaic)
records %<>% split(records[[2]]$beginposition)

# Unique dates
date_scenes =
date_scenes <-
records %>%
map(~ dplyr::select(., beginposition)) %>%
map(~ unique(.)) %>%
map_chr(~ str_sub(., 1, 10))

# Scenes per mosaic/ date
count_scenes =
count_scenes <-
records %>%
map_dbl(~ nrow(.))

# Row number of mosaic
row_scenes =
row_scenes <-
records %>%
map(~ dplyr::select(., relativeorbitnumber)) %>%
map(~ pull(.)) %>%
map_chr(~ unique(.))

# Calculate area of aoi
aoi_area = st_area(aoi) %>%
aoi_area <- st_area(aoi) %>%
sum()

# Calculate cloud cover
cloud_scenes =
cloud_scenes <-
cloud_mosaic %>%
map(~ st_read(., quiet=TRUE)) %>%
map(~ st_read(., quiet = TRUE)) %>%
map(~ st_set_crs(., 25830)) %>%
map(~ st_intersection(st_buffer(., 0), aoi)) %>%
map(possibly(~ st_union(.), NA)) %>%
map(possibly(~ st_area(.), NA)) %>%
map_dbl(possibly(~ sum(.), NA)) %>%
map_dbl(possibly(~ ./aoi_area, NA))
map_dbl(possibly(~ . / aoi_area, NA))

ext_scenes =
ext_scenes <-
records %>%
map(~ dplyr::select(., footprint)) %>%
map_depth(2, ~ st_as_sfc(.)) %>%
Expand Down
Loading