Feature #969

Strip history field from netCDF file

Added by Florian 9 months ago. Updated 9 months ago.

Status:FeedbackStart date:2016-09-27
Priority:NormalDue date:
Assignee:Paul% Done:

0%

Category:-
Target version:Candidate for next bugfix release
Platform:

Description

I need to remove (maybe edit) the command history attribute from a GMT-generated netCDF file. This should probably be an extension to grdedit. One way would be to extend the -D option. But empty strings are considered "leave as is" by -D. So should we introduce a new option for that or modify the -D behavior? The latter could break backwards compatibility. Any thoughts?

History

#1 Updated by Paul 9 months ago

  • Status changed from New to Feedback

Given it is a netCDF file, are there generic tools that can do this? Otherwise, I can think of two ways to handle this in grdedit:

  1. Let the hyphen, if given to the xname, yname, zname, title and remark strings mean "reset to blank".
  2. Add a new option -T to changes the "leave as is" mode to "reset to blank" if empty strings are given.

The second scheme should be fully backwards compatible whereas the first would torment fools who wish to assign a hyphen to any of those strings...

#2 Updated by Joaquim 9 months ago

Definitively, 1.

#3 Updated by Remko 9 months ago

Or just use NCO's ncatted.

ncatted -hO -a history,global,d,, file.nc

#4 Updated by Paul 9 months ago

I guess a change to grdedit would benefit all grid format where history etc are stored and not just netcdf. So perhaps this is a good solution (i.e., option 1)?

#5 Updated by Florian 9 months ago

Or just use NCO's ncatted.

Thanks for the hint, Remko. I was not aware of that tool. I used ncdump/ncgen but that is clumsy.

#6 Updated by Florian 9 months ago

I guess a change to grdedit would benefit all grid format where history etc are stored and not just netcdf. So perhaps this is a good solution (i.e., option 1)?

Yes.

Btw, I like the history append feature of NCO: http://nco.sourceforge.net/nco.html#History-Attribute We should add this to the wish list as well.

#7 Updated by Joaquim 9 months ago

We already have the cumulative history, I think.

#8 Updated by Paul 9 months ago

  • Assignee set to Paul
  • Target version set to Candidate for next bugfix release

I realized that the history is not one of the items in -D; it is instead automatically added as the current command. So doing things with -D will not make any changes. We would need a special option to remove it. So here the suggestion might be -C for "clean history". BTW, the netcdf machinery checks if title and remark are blank and only if they are not does it update the attributes in the file. So while -D can set remark to blank (via -) we would need to change the writing part as well. Note that the native grids have no such check so I would think this is a bug (that we are not allowed to set remark and title to blank. Agree?

Also available in: Atom PDF