Skip to content

Commit 9635cf4

Browse files
committed
corrected MODIS attribute splitting
1 parent bbebbb8 commit 9635cf4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/src/main/java/com/bc/fiduceo/reader/modis/MxD021KM_Reader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,15 +496,15 @@ protected void splitAttributes(Variable channelVariable, int index, int numChann
496496
if (dataType.isString()) {
497497
final String stringValue = attribute.getStringValue();
498498
final String[] tokens = StringUtils.split(stringValue, new char[]{','}, true);
499-
if (tokens.length == numChannels && !attributeName.contains("valid_range")) {
499+
if (tokens.length == numChannels) {
500500
final Attribute newAttribute = new Attribute(attributeName, tokens[index]);
501501
toAdd.add(newAttribute);
502502
} else {
503503
toAdd.add(attribute);
504504
}
505505
} else if (dataType.isNumeric()) {
506506
final int length = attribute.getLength();
507-
if (length == numChannels) {
507+
if (length == numChannels && !attributeName.contains("valid_range")) {
508508
final Number numericValue = attribute.getNumericValue(index);
509509
final Attribute newAttribute = new Attribute(attributeName, numericValue);
510510
toAdd.add(newAttribute);

core/src/test/java/com/bc/fiduceo/reader/modis/MxD021KM_Reader_IO_Test.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,12 @@ public void testGetVariables_Terra() throws IOException, InvalidRangeException {
236236
assertEquals("EV_250_Aggr1km_RefSB_ch01", variable.getShortName());
237237
assertEquals(DataType.USHORT, variable.getDataType());
238238
NCTestUtils.assertAttribute(variable, "corrected_counts_scales", "0.1249733");
239+
NCTestUtils.assertAttribute(variable, "valid_range", "0,32767");
239240

240241
variable = variables.get(83);
241242
assertEquals("EV_250_Aggr1km_RefSB_Samples_Used_ch02", variable.getShortName());
242243
assertEquals(DataType.BYTE, variable.getDataType());
244+
NCTestUtils.assertAttribute(variable, "valid_range", "0,28");
243245

244246
variable = variables.get(88);
245247
assertEquals("EV_500_Aggr1km_RefSB_ch07", variable.getShortName());
@@ -324,6 +326,7 @@ public void testGetVariables_Aqua() throws IOException, InvalidRangeException {
324326
assertEquals("EV_250_Aggr1km_RefSB_ch02", variable.getShortName());
325327
assertEquals(DataType.USHORT, variable.getDataType());
326328
NCTestUtils.assertAttribute(variable, "reflectance_scales", "2.8540927814901806E-5");
329+
NCTestUtils.assertAttribute(variable, "valid_range", "0,32767");
327330

328331
variable = variables.get(84);
329332
assertEquals("EV_500_Aggr1km_RefSB_ch03", variable.getShortName());

0 commit comments

Comments
 (0)