pecan icon indicating copy to clipboard operation
pecan copied to clipboard

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

Open Aariq opened this issue 2 years ago • 1 comments

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: https://github.com/PecanProject/pecan/blob/01b370430304dfd965aa7b31e15f209ecc78775e/modules/data.atmosphere/R/download.MERRA.R#L103-L111

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 avatar Aug 01 '22 21:08 Aariq

Related to #1922 and possibly #1571

Aariq avatar Aug 01 '22 21:08 Aariq

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

github-actions[bot] avatar Aug 02 '23 00:08 github-actions[bot]

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

meetagrawal09 avatar Dec 11 '23 11:12 meetagrawal09