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

download.MERRA() doesn't fully respect overwrite arg #2998

Closed
Aariq opened this issue Aug 1, 2022 · 3 comments
Closed

download.MERRA() doesn't fully respect overwrite arg #2998

Aariq opened this issue Aug 1, 2022 · 3 comments
Labels
Status: Stale Topic: Modules Not related to core workflow or specific models Type: Bug

Comments

@Aariq
Copy link
Collaborator

Aariq commented Aug 1, 2022

Bug Description

When do_conversions(settings, overwrite.met = FALSE) is run, files get overwritten. The overwrite.met arg isn't used to determine whether to write a .nc file in the following lines:

## Create output file
if (file.exists(loc.file)) {
PEcAn.logger::logger.warn(
"Target file ", loc.file, " already exists.",
"It will be overwritten."
)
}
loc <- ncdf4::nc_create(loc.file, var_list)
on.exit(ncdf4::nc_close(loc), add = TRUE)

Judging by the speed of the reprex below, the downloading isn't repeated (although a message indicating the download is happening is still printed)

To Reproduce

library(PEcAn.data.atmosphere)
#> Warning: package 'PEcAn.data.atmosphere' was built under R version 4.2.1
outdir <- tempdir()
start_date <- "2009-06-01"
end_date <- "2009-06-02"
dat <- 
  download.MERRA(outdir, start_date, end_date,
                 lat.in = 45.3, lon.in = -85.3, overwrite = FALSE)
#> 2022-08-01 17:36:03 DEBUG  [download.MERRA] : 
#>    Downloading 2009-06-01 (1 of 2) 
#> 2022-08-01 17:36:04 DEBUG  [download.MERRA] : 
#>    Downloading 2009-06-02 (2 of 2) 

dat <- 
  download.MERRA(outdir, start_date, end_date,
                 lat.in = 45.3, lon.in = -85.3, overwrite = FALSE)
#> 2022-08-01 17:36:51 DEBUG  [download.MERRA] : 
#>    Downloading 2009-06-01 (1 of 2) 
#> 2022-08-01 17:36:51 DEBUG  [download.MERRA] : 
#>    Downloading 2009-06-02 (2 of 2) 
#> 2022-08-01 17:36:51 WARN   [download.MERRA] : 
#>    Target file 
#>    /var/folders/wr/by_lst2d2fngf67mknmgf4340000gn/T//RtmpOn2aNs/file2da42ca43976/MERRA.2009.nc 
#>    already exists. It will be overwritten. 

Created on 2022-08-01 by the reprex package (v2.0.1)

Expected behavior

If overwrite = FALSE and the files exist, a different message should be printed and no attempt to write the file should be made.

@Aariq Aariq added Type: Bug Topic: Modules Not related to core workflow or specific models labels Aug 1, 2022
@Aariq
Copy link
Collaborator Author

Aariq commented Aug 1, 2022

Related to #1922 and possibly #1571

@github-actions
Copy link

github-actions bot commented Aug 2, 2023

This issue is stale because it has been open 365 days with no activity.

@meetagrawal09
Copy link
Collaborator

@Aariq I think this issue can be closed since it is resolved by #3169.

@Aariq Aariq closed this as completed Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Topic: Modules Not related to core workflow or specific models Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants