f.format("f"); else if (dataType == DataType.SHORT) { if (isUnsigned()) f.format("US"); else f.format("S"); } else if (dataType == DataType.BYTE) { if (isUnsigned()) f.format("UB"); else f.format("B"); } else if (dataType == DataType.LONG) { if (isUnsigned()) f.format("UL"); else f.format("L"); } else if (dataType == DataType.INT) { if (isUnsigned()) f.format("U");
f.format("f"); else if (dataType == DataType.SHORT) { if (isUnsigned()) f.format("US"); else f.format("S"); } else if (dataType == DataType.BYTE) { if (isUnsigned()) f.format("UB"); else f.format("B"); } else if (dataType == DataType.LONG) { if (isUnsigned()) f.format("UL"); else f.format("L"); } else if (dataType == DataType.INT) { if (isUnsigned()) f.format("U");
if (att.isUnsigned()) attElem.setAttribute("isUnsigned", "true"); return attElem; if (att.isUnsigned()) attElem.setAttribute("isUnsigned", "true");
} else if (attribName.startsWith("valid_")) { if ("valid_min".equals(attribName)) { if (attribute.isUnsigned()){ validMinMax[0] = getUShortAttribute(attribute); } else { if (attribute.isUnsigned()){ validMinMax[1] = getUShortAttribute(attribute); } else {
int field_typeid = att.isString() ? Nc4prototypes.NC_CHAR : convertDataType(att.getDataType(), att.isUnsigned()); // LOOK override String with CHAR
return; if (att.isUnsigned() != v.isUnsigned()) { log.warn("_FillValue isUnsigned must agree with var = " + v.getFullName() + " isUnsigned " + att.isUnsigned() + "!=" + v.isUnsigned()); return; if (att.isUnsigned()) ret = nc4.nc_put_att_uchar(grpid, varid, att.getShortName(), Nc4prototypes.NC_UBYTE, new SizeT(att.getLength()), (byte[]) values.getStorage()); else break; case INT: if (att.isUnsigned()) ret = nc4.nc_put_att_uint(grpid, varid, att.getShortName(), Nc4prototypes.NC_UINT, new SizeT(att.getLength()), (int[]) values.getStorage()); else break; case LONG: if (att.isUnsigned()) ret = nc4.nc_put_att_ulonglong(grpid, varid, att.getShortName(), Nc4prototypes.NC_UINT64, new SizeT(att.getLength()), (long[]) values.getStorage()); else break; case SHORT: if (att.isUnsigned()) ret = nc4.nc_put_att_ushort(grpid, varid, att.getShortName(), Nc4prototypes.NC_USHORT, new SizeT(att.getLength()), (short[]) values.getStorage()); else
public void testWriteFlagCoding() throws Exception { Band flagBand = new Band("flag_band", ProductData.TYPE_UINT8, 10, 10); FlagCoding flagCoding = new FlagCoding("some_flags"); flagBand.setSampleCoding(flagCoding); flagCoding.setDescription("A Flag Coding"); for (int i = 0; i < 8; i++) { addFlag(flagCoding, i); } NetcdfFileWriteable writeable = NetcdfFileWriteable.createNew("not stored"); writeable.addDimension("y", flagBand.getSceneRasterHeight()); writeable.addDimension("x", flagBand.getSceneRasterWidth()); final DataType ncDataType = DataTypeUtils.getNetcdfDataType(flagBand.getDataType()); Variable variable = writeable.addVariable(flagBand.getName(), ncDataType, writeable.getRootGroup().getDimensions()); CfBandPart.writeCfBandAttributes(flagBand, new N3Variable(variable, writeable)); CfFlagCodingPart.writeFlagCoding(flagBand, new N3FileWriteable(writeable)); Variable someFlagsVariable = writeable.findVariable("flag_band"); assertNotNull(someFlagsVariable); Attribute flagMasksAttrib = someFlagsVariable.findAttribute("flag_masks"); assertNotNull(flagMasksAttrib); assertEquals(someFlagsVariable.getDataType(), flagMasksAttrib.getDataType()); assertEquals(8, flagMasksAttrib.getLength()); assertTrue(flagMasksAttrib.isUnsigned()); for (int i = 0; i < 8; i++) { assertEquals(1 << i, flagMasksAttrib.getValues().getInt(i)); } Attribute descriptionAttrib = someFlagsVariable.findAttribute("long_name"); assertNotNull(flagCoding.getDescription(), descriptionAttrib.getStringValue()); }