Skip to content

Commit

Permalink
fix(ci): add pre-commit to check R/ path and apply
Browse files Browse the repository at this point in the history
  • Loading branch information
spool committed Nov 22, 2023
1 parent cf7be9f commit 6049fca
Show file tree
Hide file tree
Showing 14 changed files with 420 additions and 433 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ env:

on:
pull_request:
branches: ['main', 'docker-config']
branches: ['main', 'ruth-notebook-for-workshop']
paths-ignore: ['docs/**']

push:
branches: ['main', 'docker-config']
branches: ['main', 'ruth-notebook-for-workshop']
paths-ignore: ['docs/**']

concurrency:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: "R|data"
exclude: "data"
repos:
- repo: https://github.com/psf/black
rev: "23.9.1"
Expand Down
51 changes: 24 additions & 27 deletions R/LCAT/Data_Processing_todf.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
## Data Processing UK HadsGrid CPM data from raster to data.frame


## 0. About

# Many of the methods packages for applying bias correction to climate date take as input vector, matrix or data.frame,
# Many of the methods packages for applying bias correction to climate date take as input vector, matrix or data.frame,
# rather than a spatial file or raster
# This may not be the most effective way of analysising this data
# This may not be the most effective way of analysising this data


rm(list=ls())
Expand Down Expand Up @@ -47,62 +47,59 @@ cores <- detectCores()
cl <- makeCluster(cores[1]-1)
registerDoParallel(cl)

foreach(x = x,
foreach(x = x,
.packages = c("terra", "tidyverse"),
.errorhandling = 'pass') %dopar% {
.errorhandling = 'pass') %dopar% {

f <- paste0(dd,'shapefiles/NUTS_Level_1_January_2018_FCB_in_the_United_Kingdom_2022_7279368953270783580/NUTS_Level_1_January_2018_FCB_in_the_United_Kingdom.shp')
UK.shape <-vect(f)
crop.area <- UK.shape[which(UK.shape$nuts118cd==x)]

var <- c("rainfall", "tasmax", "tasmin", "tas")

hads19802010_read_crop_df_write(var = var,
fp = paste0(dd, "Processed/HadsUKgrid/resampled_2.2km/"),
name1 = "HadsUK",
crop=T,
crop.area=crop.area,
cropname=x,
rd=rd)

}
stopCluster(cl)

stopCluster(cl)
gc()


### Processing CPM

x <- regioncd


cores <- detectCores()
cl <- makeCluster(cores[1]-1)
registerDoParallel(cl)
foreach(x = x,

foreach(x = x,
.packages = c("terra", "tidyverse"),
.errorhandling = 'pass') %dopar% {
.errorhandling = 'pass') %dopar% {

f <- paste0(dd,'shapefiles/NUTS_Level_1_January_2018_FCB_in_the_United_Kingdom_2022_7279368953270783580/NUTS_Level_1_January_2018_FCB_in_the_United_Kingdom.shp')
UK.shape <-vect(f)
crop.area <- UK.shape[which(UK.shape$nuts118cd==x)]

runs <- c("05", "07", "08", "06")
var <- c("tasmax", "tasmin","pr", "tas")
rd <- paste0(dd, "Interim/CPM/Data_as_df")

cpm_read_crop_df_write(runs=runs, var=var, fp=paste0(dd, "Reprojected/UKCP2.2/"),
year1=2060, year2=2080, #Ran sep for each year segment
name1="CPM", crop = T,
year1=2060, year2=2080, #Ran sep for each year segment
name1="CPM", crop = T,
crop.area = crop.area, cropname = x,
rd=paste0(dd, "Interim/CPM/Data_as_df"))


}
stopCluster(cl)

stopCluster(cl)
gc()



Loading

0 comments on commit 6049fca

Please sign in to comment.