forked from FIDUCEO/MMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
windsat-coriolis problem in compute distance to land post processing …
…plugin solution convert longitude values to match the range -180 .. 180 NaN, negative infinity and positive infinity are now also taken into account.
- Loading branch information
1 parent
5dbcc60
commit e1aae24
Showing
5 changed files
with
79 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,6 @@ | |
target/ | ||
/ingestion-tool/src/temp/ | ||
temp.txt | ||
temp.java | ||
temp.xml | ||
/out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
post-processing-tool/src/main/java/com/bc/fiduceo/post/util/PPUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.bc.fiduceo.post.util; | ||
|
||
import ucar.ma2.Array; | ||
import ucar.ma2.IndexIterator; | ||
|
||
public class PPUtils { | ||
|
||
public static void convertToFitTheRangeMinus180to180(Array lonArray) { | ||
final IndexIterator indexIterator = lonArray.getIndexIterator(); | ||
while (indexIterator.hasNext()) { | ||
double lonD = indexIterator.getDoubleNext(); | ||
if (Double.isFinite(lonD)) { | ||
while (lonD > 180) { | ||
lonD -= 360; | ||
} | ||
while (lonD < -180) { | ||
lonD += 360; | ||
} | ||
indexIterator.setDoubleCurrent(lonD); | ||
} | ||
} | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
post-processing-tool/src/test/java/com/bc/fiduceo/post/util/PPUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.bc.fiduceo.post.util; | ||
|
||
import org.junit.Test; | ||
import ucar.ma2.Array; | ||
|
||
import static org.hamcrest.Matchers.*; | ||
import static org.hamcrest.MatcherAssert.*; | ||
import static org.junit.Assert.*; | ||
|
||
public class PPUtilsTest { | ||
|
||
@Test | ||
public void convertToFitTheRangeMinus180to180() { | ||
final int farOutside = 360 * 200; | ||
|
||
final double[] lons = { | ||
-180, | ||
-179.999999999, | ||
179.999999999, | ||
180, | ||
-190, | ||
190, | ||
-30 - farOutside, | ||
40 + farOutside, | ||
Double.NaN, | ||
Double.NEGATIVE_INFINITY, | ||
Double.POSITIVE_INFINITY | ||
}; | ||
|
||
final Array lonArray = Array.makeFromJavaArray(lons); | ||
PPUtils.convertToFitTheRangeMinus180to180(lonArray); | ||
|
||
final double[] expected = { | ||
/* Before: -180 after -> */ -180, | ||
/* Before: -179.999999999 after -> */ -179.999999999, | ||
/* Before: 179.999999999 after -> */ 179.999999999, | ||
/* Before: 180 after -> */ 180, | ||
/* Before: -190 after -> */ 170, | ||
/* Before: 190 after -> */ -170, | ||
/* Before: -30 - farOutside after -> */ -30, | ||
/* Before: 40 + farOutside after -> */ 40, | ||
/* Before: Double.NaN after -> */ Double.NaN, | ||
/* Before: Double.NEGATIVE_INFINITY after -> */ Double.NEGATIVE_INFINITY, | ||
/* Before: Double.POSITIVE_INFINITY after -> */ Double.POSITIVE_INFINITY | ||
}; | ||
|
||
assertArrayEquals(expected, (double[]) lonArray.getStorage(), 0.000001); | ||
} | ||
} |