Skip to content
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

Fix for western-hemisphere extent issue that has CDS report extents f… #14

Merged
merged 1 commit into from
May 2, 2022
Merged
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
8 changes: 8 additions & 0 deletions R/download.R
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ if(SingularDL){ # If user forced download to happen in one
Era5_ras <- stack(Era5_ls)
}

## Fix for extent of some variables like evaporation_from_vegetation_transpiration for which the x-extent values come out weirdly despite the correct data being downloaded
MaxOffset <- max(abs(round(as.vector(extent(Era5_ras))-c(Extent[2], Extent[4], Extent[3], Extent[1]), 2))) # identify whether there is an issue (currently, we only know of cases where western-hemisphere data is reported as x-extents that are 360-x-Extent values)
if(MaxOffset > 270){
DataOffset <- min(abs(round(as.vector(extent(Era5_ras))-c(Extent[2], Extent[4], Extent[3], Extent[1]), 2))) # identify by how much grid had to be expanded for download
extent(Era5_ras) <- extent(Extent[2]-DataOffset, Extent[4]+DataOffset,
Extent[3]-DataOffset, Extent[1]+DataOffset) # the extent the object should have assigned to the object
}

### SingularDL limiting of data to original time-series requirements
## time-sequence of requested download by user
if(TResolution == "day" | TResolution == "hour"){
Expand Down