Skip to content

Commit

Permalink
Merge pull request #13 from JGCRI/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mengqi-z authored Jan 9, 2024
2 parents 498f41e + f5a776c commit 1ccb0ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on:
push:
branches:
- main
- dev

name: docs

Expand All @@ -11,7 +12,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.PAT }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2

Expand All @@ -25,7 +26,7 @@ jobs:
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
Expand Down
12 changes: 6 additions & 6 deletions R/read_ncdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ read_ncdf <- function(ncdf = NULL,
ncdf_in <- ncdf4::nc_open(ncdf)
var_names <- attributes(ncdf_in$var)$names

# get unit
var_unit <- ncdf4::ncatt_get(ncdf_in, var_names)$unit[1]

dims <- c(ncdf_in$var[[var]]$dim[[1]]$name,
ncdf_in$var[[var]]$dim[[2]]$name,
ncdf_in$var[[var]]$dim[[3]]$name)
Expand All @@ -39,6 +36,9 @@ read_ncdf <- function(ncdf = NULL,
stop('Climate variable name is not valid. Please provide valid ncdf_var name.')
}

# get unit
var_unit <- ncdf4::ncatt_get(ncdf_in, var)$unit

# get the data time series
ncdf_brick <- raster::brick(ncdf, varname = var, ncdf = TRUE,
dims = dims_order, stopIfNotEqualSpaced = F)
Expand Down Expand Up @@ -120,9 +120,6 @@ read_ncdf <- function(ncdf = NULL,
ncdf_in <- ncdf4::nc_open(ncdf)
var_names <- attributes(ncdf_in$var)$names

# get unit
var_unit <- ncdf4::ncatt_get(ncdf_in, var_names)$unit[1]

dims <- c(ncdf_in$var[[var]]$dim[[1]]$name,
ncdf_in$var[[var]]$dim[[2]]$name,
ncdf_in$var[[var]]$dim[[3]]$name)
Expand All @@ -132,6 +129,9 @@ read_ncdf <- function(ncdf = NULL,
stop('Climate variable name is not valid. Please provide valid ncdf_var name.')
}

# get unit
var_unit <- ncdf4::ncatt_get(ncdf_in, var)$unit

ncdf_brick <- raster::brick(ncdf, varname = var, ncdf = TRUE,
dims = dims_order, stopIfNotEqualSpaced = F)

Expand Down

0 comments on commit 1ccb0ec

Please sign in to comment.