twhiteaker / CFGeom

CF Convention for Representing Simple Geometry Types
MIT License
9 stars 4 forks source link

should we use 'a' or 'w' when writing netcdf? #87

Closed twhiteaker closed 6 years ago

twhiteaker commented 6 years ago

Do we allow append (mode='a') or overwrite (mode='w')? Probably should.

dblodgett-usgs commented 6 years ago

a .. people might want to write their time series in one step and geoms in another. Glad you are coming back to this work!!

twhiteaker commented 6 years ago

Other libraries like pandas overwrite existing files with their .to_format functions. I suggest we follow that behavior, and add a new export method called .append_to_netcdf, which appends to an existing file. That function will also take an optional list of variable names to assign the geometry to, which just means setting their geometry attribute to be the name of the geometry container.

dblodgett-usgs commented 6 years ago

Makes sense to me. That or error if the file exists unless the user says overwrite or append?

twhiteaker commented 6 years ago

After reading through every function and adding docstrings today, I was reminded of how Ben already solved this problem. Ben accommodated 'a' when he allowed the write_netcdf function to accept either a path to a netCDF file or a netCDF Dataset instance. If the former, any existing file is overwritten. If the latter, you can append.

Thus, I'm closing this issue for now. I welcome raising the issue again if this solution irks anyone.