Skip to content

Commit

Permalink
Add tests for aggregations with a renamed dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
tdrwenski committed Apr 15, 2024
1 parent 5ff59f4 commit 487cc5d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cdm/core/src/test/data/ncml/aggregationRenameDim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">

<dimension name="newTime" orgName="time"/>
<variable name="newTime" orgName="time" />
<variable name="newTime" shape="newTime" />
<variable name="P" shape="newTime lat lon" />
<variable name="T" shape="newTime lat lon" />

<aggregation dimName="time" type="joinExisting">
<netcdf location="nc/jan.nc"/>
<netcdf location="nc/feb.nc"/>
</aggregation>
</netcdf>
13 changes: 13 additions & 0 deletions cdm/core/src/test/data/ncml/aggregationScanRenameDim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">

<dimension name="newTime" orgName="time"/>
<variable name="newTime" orgName="time" />
<variable name="newTime" shape="newTime" />
<variable name="P" shape="newTime lat lon" />
<variable name="T" shape="newTime lat lon" />

<aggregation dimName="time" type="joinExisting">
<scan location="nc/" regExp="^(jan.nc|feb.nc)$"/>
</aggregation>
</netcdf>
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,30 @@ public void shouldRenameDim() throws IOException {
assertThat(dataIter.getIntNext()).isEqualTo(18);
}
}

@Test
public void shouldRenameDimInAggregation() throws IOException {
final String filename = "file:./" + TestNcmlRead.topDir + "aggregationRenameDim.xml";

try (NetcdfFile ncfile = NcmlReader.readNcml(filename, null, null).build()) {
Dimension newDim = ncfile.findDimension("newTime");
assertThat(newDim).isNotNull();

Dimension oldDim = ncfile.findDimension("time");
assertThat(oldDim).isNull();
}
}

@Test
public void shouldRenameDimInAggregationScan() throws IOException {
final String filename = "file:./" + TestNcmlRead.topDir + "aggregationScanRenameDim.xml";

try (NetcdfFile ncfile = NcmlReader.readNcml(filename, null, null).build()) {
Dimension newDim = ncfile.findDimension("newTime");
assertThat(newDim).isNotNull();

Dimension oldDim = ncfile.findDimension("time");
assertThat(oldDim).isNull();
}
}
}

0 comments on commit 487cc5d

Please sign in to comment.