Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cdm/zarr/src/main/java/ucar/nc2/iosp/zarr/ZarrHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,8 @@ private List<Attribute> makeAttributes(RandomAccessDirectoryItem item) {

// create Attribute objects
List<Attribute> attrs = new ArrayList<>();
attrMap.keySet().forEach(key -> {
attrMap.forEach((key, val) -> {
Attribute.Builder attr = Attribute.builder(key);
Object val = attrMap.get(key);
if (val instanceof Collection<?>) {
Collection<?> collection = (Collection<?>) val;
if (collection.isEmpty() && key.equals(ARRAYDIMENSIONS)) {
Expand All @@ -349,7 +348,7 @@ private List<Attribute> makeAttributes(RandomAccessDirectoryItem item) {
} else if (val instanceof Number) {
attr.setNumericValue((Number) val, false);
} else {
attr.setStringValue((String) val);
attr.setStringValue(String.valueOf(val));
}
attrs.add(attr.build());
});
Expand Down
Binary file added cdm/zarr/src/test/data/z0_atm.zip
Binary file not shown.
19 changes: 14 additions & 5 deletions cdm/zarr/src/test/java/ucar/nc2/iosp/zarr/TestZarrIosp.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
import ucar.ma2.DataType;
import ucar.ma2.InvalidRangeException;
import ucar.ma2.Section;
import ucar.nc2.Dimension;
import ucar.nc2.Group;
import ucar.nc2.NetcdfFile;
import ucar.nc2.NetcdfFiles;
import ucar.nc2.Variable;
import ucar.nc2.*;

import java.io.IOException;
import java.nio.ByteOrder;
Expand All @@ -43,6 +39,7 @@ public class TestZarrIosp {
private static final String NON_ZARR_FILENAME = "nonZarrTestData.nc.zip";
private static final String FILL_VALUES_FILENAME = "fill_values.zarr";
private static final String SCALAR_GEOZARR_FILENAME = "geozarr/xyt-raster.zarr";
private static final String BOOLEAN_ATTRIBUTE_FILENAME = "z0_atm.zip";

// test store paths
private static final String OBJECT_STORE_ZARR_URI = ZarrTestsCommon.S3_PREFIX + ZarrTestsCommon.AWS_BUCKET_NAME + "?"
Expand All @@ -64,6 +61,10 @@ public class TestZarrIosp {
// scalar geozarr data
private static final String SCALAR_GEOZARR_DATA = ZarrTestsCommon.LOCAL_TEST_DATA_PATH + SCALAR_GEOZARR_FILENAME;

// Boolean attribute data
private static final String BOOLEAN_ATTRIBUTE_DATA =
ZarrTestsCommon.LOCAL_TEST_DATA_PATH + BOOLEAN_ATTRIBUTE_FILENAME;

private static List<String> stores;

@BeforeClass
Expand Down Expand Up @@ -277,6 +278,14 @@ public void testReadNonZarrZipFile() throws IOException {
}
}

@Test
public void testReadBooleanAttribute() throws IOException {
NetcdfFile ncfile = NetcdfFiles.open(BOOLEAN_ATTRIBUTE_DATA);
Variable var = ncfile.findVariable("CONST_inst_z0_atm/orog");
Attribute hiopy = var.findAttribute("hiopy::enable");
assertThat(hiopy.getValue(0).equals("true"));
}

@Test
public void testFOrder() throws IOException, InvalidRangeException {
// test reading F order stored array
Expand Down