DOI-USGS / ncdfgeom

NetCDF-CF Geometry and Timeseries Tools for R: https://code.usgs.gov/water/ncdfgeom
https://doi-usgs.github.io/ncdfgeom/
15 stars 7 forks source link

Update docs on write_timeseries_dsg to ignore overwrite if add_to_existing is TRUE #76

Closed jordansread closed 2 years ago

jordansread commented 3 years ago

Seems overwrite would be ignored if add_to_existing is TRUE. Doc says it will error if the file exists.

Perhaps the doc is right and it will error if there is a file regardless of whether you want to add to it. Or perhaps this isn't the way it behaves and the docs should let you know it is ignored if you are adding to an existing file.

dblodgett-usgs commented 3 years ago

I remember this being a really annoying detail and just made it force the user to be really explicit.

Am rereading the documentation and don't really see where you think I would change it... :/

jordansread commented 3 years ago

From the docs it is unclear what happens when you have add_to_existing = TRUE and overwrite = TRUE. Based on you telling me people need to be really explicit, I am assuming the existing file is deleted and the add_to_existing arg is ignored.

I haven't played around with this though. I guess it errors if the file exists and overwrite is TRUE? Why wouldn't it just overwrite it if that is the case? From docs:

overwrite       boolean error if file exists
dblodgett-usgs commented 2 years ago

So this is all the logic for overwrite and add to existing.


  if(!overwrite & !add_to_existing & file.exists(nc_file)) stop("File already exists and overwrite is false.")
  if(overwrite & !add_to_existing) unlink(file.exists(nc_file))
  if(add_to_existing & !file.exists(nc_file)) add_to_existing=FALSE

These seem logical to me and the docs make OK sense.

I modified the docs for overwrite to read: overwrite: boolean unless set to true, error if file exists.

With that change, do you think we can close this issue?