netcdf-java icon indicating copy to clipboard operation
netcdf-java copied to clipboard

[5.x]: Ncml remove attribute fails for aggregation with scan

Open tdrwenski opened this issue 3 years ago • 1 comments

Versions impacted by the bug

v5.x

What went wrong?

Removing and renaming attributes in ncml fails for an aggregation with a scan element. Found in https://github.com/Unidata/tds/issues/268

For example, in the snippet below long_name is not removed. In addition, uncommenting the renamed_units line gives an error that the ncml cannot be read.

<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">

  <variable name="T">
    <attribute name="new_attribute" type="string" value="new attribute value"/>
<!--    <attribute name="renamed_units" orgName="units"/> TODO this causes an error when reading the ncml-->
    <remove type="attribute" name="long_name"/>
  </variable>

  <aggregation dimName="time" type="joinExisting">
    <scan location="nc/" regExp="^(jan.nc|feb.nc)$"/>
  </aggregation>

</netcdf>

However, if we replace the aggregation with

  <aggregation dimName="time" type="joinExisting">
    <netcdf location="nc/jan.nc"/>
    <netcdf location="nc/feb.nc"/>
  </aggregation>

both the removal and the renaming of attributes works as expected.

Relevant stack trace

No response

Relevant log messages

No response

If you have an example file that you can share, please attach it to this issue.

If so, may we include it in our test datasets to help ensure the bug does not return once fixed? Note: the test datasets are publicly accessible without restriction.

N/A

Code of Conduct

  • [X] I agree to follow the UCAR/Unidata Code of Conduct

tdrwenski avatar Aug 18 '22 19:08 tdrwenski

Tests located here: fix-ncml-modify-attributes

tdrwenski avatar Oct 18 '22 21:10 tdrwenski