From 3871882405b43231c4b3e04ca8ff470cf767d1db Mon Sep 17 00:00:00 2001 From: Nate Jensen Date: Tue, 13 Aug 2013 14:06:43 -0500 Subject: [PATCH] Issue #2262 create new wxmath plugin seeded by Java derivparam functions Change-Id: If71c205a88ef17a2432267956bd05b9b10a56aa2 Former-commit-id: 959b50d1849564905ce2bef20f6466e18f6156af [formerly 23fe237b7e4a6529b052b56e842050b5555792f3 [formerly 09872d6713b596fe269cc87e93bb3881a9a066bb] [formerly 959b50d1849564905ce2bef20f6466e18f6156af [formerly f3d233aeff8017c521288affd4b5be668c9a890a]]] Former-commit-id: 23fe237b7e4a6529b052b56e842050b5555792f3 [formerly 09872d6713b596fe269cc87e93bb3881a9a066bb] Former-commit-id: 23fe237b7e4a6529b052b56e842050b5555792f3 Former-commit-id: 9df41ff246b291c04fd09fccaedee2bd37c8e6be --- .../feature.xml | 7 ++ .../META-INF/MANIFEST.MF | 3 +- .../derivedParameters/functions/Cape.py | 2 +- .../derivedParameters/functions/Dcape.py | 2 +- .../derivedParameters/functions/Filter.py | 2 +- .../function/CapeFuncPythonAdapter.java | 94 ++++++++++++++++ .../function/DCapeFuncPythonAdapter.java | 55 +++++++++ .../function/DistFilterPythonAdapter.java | 53 +++++++++ .../com.raytheon.uf.common.wxmath/.classpath | 7 ++ .../com.raytheon.uf.common.wxmath/.project | 28 +++++ .../.settings/org.eclipse.jdt.core.prefs | 7 ++ .../META-INF/MANIFEST.MF | 8 ++ .../build.properties | 4 + .../common/wxmath}/AdiabeticTemperature.java | 11 +- .../raytheon/uf/common/wxmath}/CalcTw.java | 17 +-- .../raytheon/uf/common/wxmath}/CapeFunc.java | 104 ++++++++---------- .../raytheon/uf/common/wxmath}/Constants.java | 5 +- .../raytheon/uf/common/wxmath}/DCapeFunc.java | 36 +++--- .../uf/common/wxmath}/DistFilter.java | 15 +-- .../raytheon/uf/common/wxmath}/TempOfTe.java | 7 +- 20 files changed, 361 insertions(+), 106 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFuncPythonAdapter.java create mode 100644 cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DCapeFuncPythonAdapter.java create mode 100644 cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DistFilterPythonAdapter.java create mode 100644 edexOsgi/com.raytheon.uf.common.wxmath/.classpath create mode 100644 edexOsgi/com.raytheon.uf.common.wxmath/.project create mode 100644 edexOsgi/com.raytheon.uf.common.wxmath/.settings/org.eclipse.jdt.core.prefs create mode 100644 edexOsgi/com.raytheon.uf.common.wxmath/META-INF/MANIFEST.MF create mode 100644 edexOsgi/com.raytheon.uf.common.wxmath/build.properties rename {cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function => edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath}/AdiabeticTemperature.java (81%) rename {cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function => edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath}/CalcTw.java (88%) rename {cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function => edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath}/CapeFunc.java (92%) rename {cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function => edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath}/Constants.java (91%) rename {cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function => edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath}/DCapeFunc.java (91%) rename {cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function => edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath}/DistFilter.java (94%) rename {cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function => edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath}/TempOfTe.java (95%) diff --git a/cave/com.raytheon.uf.viz.common.core.feature/feature.xml b/cave/com.raytheon.uf.viz.common.core.feature/feature.xml index 2f88b2970e..ef0fe5d24e 100644 --- a/cave/com.raytheon.uf.viz.common.core.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.common.core.feature/feature.xml @@ -159,4 +159,11 @@ version="0.0.0" unpack="false"/> + + diff --git a/cave/com.raytheon.uf.viz.derivparam.python/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.derivparam.python/META-INF/MANIFEST.MF index 3e3aaad52a..adbf91b0a4 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.derivparam.python/META-INF/MANIFEST.MF @@ -17,6 +17,7 @@ Require-Bundle: com.raytheon.uf.common.status;bundle-version="1.12.1174", org.eclipse.ui;bundle-version="3.6.1", org.eclipse.core.runtime;bundle-version="3.6.0", com.raytheon.uf.common.util;bundle-version="1.12.1174", - com.raytheon.uf.common.python.concurrent;bundle-version="1.0.0" + com.raytheon.uf.common.python.concurrent;bundle-version="1.0.0", + com.raytheon.uf.common.wxmath Export-Package: com.raytheon.uf.viz.derivparam.python, com.raytheon.uf.viz.derivparam.python.function diff --git a/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Cape.py b/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Cape.py index 61c86dce06..a7682df622 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Cape.py +++ b/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Cape.py @@ -18,7 +18,7 @@ # further licensing information. ## -from com.raytheon.uf.viz.derivparam.python.function import CapeFunc +from com.raytheon.uf.viz.derivparam.python.function import CapeFuncPythonAdapter as CapeFunc from numpy import zeros def execute(*args): diff --git a/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Dcape.py b/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Dcape.py index bb996fe7ab..49ffc2748e 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Dcape.py +++ b/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Dcape.py @@ -26,7 +26,7 @@ # Jun 05, 2013 2043 bsteffen Ported from meteolib C from numpy import zeros -from com.raytheon.uf.viz.derivparam.python.function import DCapeFunc +from com.raytheon.uf.viz.derivparam.python.function import DCapeFuncPythonAdapter as DCapeFunc def execute(threeDtemperature, threeDdewpoint, pressure, potentialTemperature, specificHumidity,maxEvaporation,maxRelativeHumidity,useVirtualTemp): diff --git a/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Filter.py b/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Filter.py index d5d0f9b97e..72a2b6293b 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Filter.py +++ b/cave/com.raytheon.uf.viz.derivparam.python/localization/derivedParameters/functions/Filter.py @@ -20,7 +20,7 @@ from numpy import ndarray, float32, NaN from numpy import sin, isnan, invert -from com.raytheon.uf.viz.derivparam.python.function import DistFilter +from com.raytheon.uf.viz.derivparam.python.function import DistFilterPythonAdapter as DistFilter MAX_WAVE_NUMBER = 15 diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFuncPythonAdapter.java b/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFuncPythonAdapter.java new file mode 100644 index 0000000000..09d64920bf --- /dev/null +++ b/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFuncPythonAdapter.java @@ -0,0 +1,94 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.derivparam.python.function; + +import jep.INumpyable; + +/** + * Calls {@link com.raytheon.uf.common.wxmath.CapeFunc} and transforms the + * output into an INumpyable. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 13, 2013            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class CapeFuncPythonAdapter { + + public static class CapeCinPair implements INumpyable { + + private final int nx; + + private final int ny; + + private final float[] cape; + + private final float[] cin; + + public CapeCinPair(int nx, int ny, float[] cape, float[] cin) { + this.nx = nx; + this.ny = ny; + this.cape = cape; + this.cin = cin; + } + + @Override + public Object[] getNumPy() { + return new Object[] { cape, cin }; + } + + @Override + public int getNumpyX() { + return nx; + } + + @Override + public int getNumpyY() { + return ny; + } + + } + + public static INumpyable capeFunc(float usetv, float[] p_dat, + float[] tve_dat, float[] p0, float[] th0, float[] sh0, int nx, + int ny, int nz) { + float[][] result = com.raytheon.uf.common.wxmath.CapeFunc.capeFunc( + usetv, p_dat, tve_dat, p0, th0, sh0, nx, ny, nz); + return new CapeCinPair(ny, nx, result[0], result[1]); + } + + public static INumpyable capeFuncTop(float usetv, float[] p_dat, + float[] tve_dat, float[] p0, float[] th0, float[] sh0, + float[] ptop, int nx, int ny, int nz) { + float[][] result = com.raytheon.uf.common.wxmath.CapeFunc.capeFuncTop( + usetv, p_dat, tve_dat, p0, th0, sh0, ptop, nx, ny, nz); + return new CapeCinPair(ny, nx, result[0], result[1]); + } + +} diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DCapeFuncPythonAdapter.java b/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DCapeFuncPythonAdapter.java new file mode 100644 index 0000000000..f505ceb252 --- /dev/null +++ b/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DCapeFuncPythonAdapter.java @@ -0,0 +1,55 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.derivparam.python.function; + +import jep.INumpyable; + +import com.raytheon.uf.common.python.PythonNumpyFloatArray; + +/** + * Calls {@link com.raytheon.uf.common.wxmath.DCapeFunc} and transforms the + * output into an INumpyable for python. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 13, 2013            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class DCapeFuncPythonAdapter { + + public static INumpyable dcapeFunc(float usetv, float[] p_dat, + float[] t_dat, float[] td_dat, float[] p0, float[] th0, + float[] sh0, int nx, int ny, int nz, float max_evap, float max_rh) { + float[] result = com.raytheon.uf.common.wxmath.DCapeFunc.dcapeFunc( + usetv, p_dat, t_dat, td_dat, p0, th0, sh0, nx, ny, nz, + max_evap, max_rh); + return new PythonNumpyFloatArray(result, ny, nx); + } + +} diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DistFilterPythonAdapter.java b/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DistFilterPythonAdapter.java new file mode 100644 index 0000000000..a3a8923baf --- /dev/null +++ b/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DistFilterPythonAdapter.java @@ -0,0 +1,53 @@ +/** + * This software was developed and / or modified by Raytheon Company, + * pursuant to Contract DG133W-05-CQ-1067 with the US Government. + * + * U.S. EXPORT CONTROLLED TECHNICAL DATA + * This software product contains export-restricted data whose + * export/transfer/disclosure is restricted by U.S. law. Dissemination + * to non-U.S. persons whether in the United States or abroad requires + * an export license or other authorization. + * + * Contractor Name: Raytheon Company + * Contractor Address: 6825 Pine Street, Suite 340 + * Mail Stop B8 + * Omaha, NE 68106 + * 402.291.0100 + * + * See the AWIPS II Master Rights File ("Master Rights File.pdf") for + * further licensing information. + **/ +package com.raytheon.uf.viz.derivparam.python.function; + +import jep.INumpyable; + +import com.raytheon.uf.common.python.PythonNumpyFloatArray; + +/** + * Calls {@link com.raytheon.uf.common.wxmath.DistFilter} and transforms the + * output into an INumpyable. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 13, 2013            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class DistFilterPythonAdapter { + + public static INumpyable filter(float[] input, float npts, int nx, int ny, + int times) { + float[] result = com.raytheon.uf.common.wxmath.DistFilter.filter(input, + npts, nx, ny, times); + return new PythonNumpyFloatArray(result, nx, ny); + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.wxmath/.classpath b/edexOsgi/com.raytheon.uf.common.wxmath/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.wxmath/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.common.wxmath/.project b/edexOsgi/com.raytheon.uf.common.wxmath/.project new file mode 100644 index 0000000000..191ed5b9ac --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.wxmath/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.common.wxmath + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.common.wxmath/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.common.wxmath/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..c537b63063 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.wxmath/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/edexOsgi/com.raytheon.uf.common.wxmath/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.wxmath/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..9ca8490468 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.wxmath/META-INF/MANIFEST.MF @@ -0,0 +1,8 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Wxmath +Bundle-SymbolicName: com.raytheon.uf.common.wxmath +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: RAYTHEON +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Export-Package: com.raytheon.uf.common.wxmath diff --git a/edexOsgi/com.raytheon.uf.common.wxmath/build.properties b/edexOsgi/com.raytheon.uf.common.wxmath/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.wxmath/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/AdiabeticTemperature.java b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/AdiabeticTemperature.java similarity index 81% rename from cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/AdiabeticTemperature.java rename to edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/AdiabeticTemperature.java index 6b715a07d7..00c1ad5706 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/AdiabeticTemperature.java +++ b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/AdiabeticTemperature.java @@ -17,11 +17,11 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.derivparam.python.function; +package com.raytheon.uf.common.wxmath; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c0; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c1; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c2; +import static com.raytheon.uf.common.wxmath.Constants.c0; +import static com.raytheon.uf.common.wxmath.Constants.c1; +import static com.raytheon.uf.common.wxmath.Constants.c2; import static java.lang.Math.exp; /** @@ -36,7 +36,8 @@ import static java.lang.Math.exp; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jun 3, 2013 2043 bsteffen Ported from meteolib C + * Jun 03, 2013 2043 bsteffen Ported from meteolib C + * Aug 13, 2013 2262 njensen Moved from deriv params * * * diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CalcTw.java b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/CalcTw.java similarity index 88% rename from cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CalcTw.java rename to edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/CalcTw.java index 8d308f51dc..60fce360bf 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CalcTw.java +++ b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/CalcTw.java @@ -17,14 +17,14 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.derivparam.python.function; +package com.raytheon.uf.common.wxmath; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c0; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c1; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c2; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c_1; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c_2; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.f; +import static com.raytheon.uf.common.wxmath.Constants.c0; +import static com.raytheon.uf.common.wxmath.Constants.c1; +import static com.raytheon.uf.common.wxmath.Constants.c2; +import static com.raytheon.uf.common.wxmath.Constants.c_1; +import static com.raytheon.uf.common.wxmath.Constants.c_2; +import static com.raytheon.uf.common.wxmath.Constants.f; import static java.lang.Math.abs; import static java.lang.Math.exp; import static java.lang.Math.log; @@ -57,7 +57,8 @@ import static java.lang.Math.sqrt; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jun 06, 2013 2043 bsteffen Ported from meteolib fortran + * Jun 06, 2013 2043 bsteffen Ported from meteolib fortran + * Aug 13, 2013 2262 njensen Moved from deriv params * * * diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFunc.java b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/CapeFunc.java similarity index 92% rename from cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFunc.java rename to edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/CapeFunc.java index 6d15e7af4b..9cb0b352ae 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/CapeFunc.java +++ b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/CapeFunc.java @@ -17,22 +17,21 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.derivparam.python.function; +package com.raytheon.uf.common.wxmath; -import static com.raytheon.uf.viz.derivparam.python.function.AdiabeticTemperature.adiabatic_te; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c0; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c1; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c2; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c_1; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c_2; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.kapa; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.kapa_1; -import static com.raytheon.uf.viz.derivparam.python.function.TempOfTe.temp_of_te; +import static com.raytheon.uf.common.wxmath.AdiabeticTemperature.adiabatic_te; +import static com.raytheon.uf.common.wxmath.Constants.c0; +import static com.raytheon.uf.common.wxmath.Constants.c1; +import static com.raytheon.uf.common.wxmath.Constants.c2; +import static com.raytheon.uf.common.wxmath.Constants.c_1; +import static com.raytheon.uf.common.wxmath.Constants.c_2; +import static com.raytheon.uf.common.wxmath.Constants.kapa; +import static com.raytheon.uf.common.wxmath.Constants.kapa_1; +import static com.raytheon.uf.common.wxmath.TempOfTe.temp_of_te; import static java.lang.Math.exp; import static java.lang.Math.log; import static java.lang.Math.pow; import static java.lang.Math.sqrt; -import jep.INumpyable; /** * We input theta and specific humidity for initial parcel because these are @@ -55,7 +54,8 @@ import jep.INumpyable; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jun 3, 2013 2043 bsteffen Ported from meteolib C + * Jun 03, 2013 2043 bsteffen Ported from meteolib C + * Aug 13, 2013 2262 njensen Moved from deriv params * * * @@ -65,7 +65,21 @@ import jep.INumpyable; public class CapeFunc { - public static CapeCinPair capeFunc(float usetv, float[] p_dat, + /** + * Cape function + * + * @param usetv + * @param p_dat + * @param tve_dat + * @param p0 + * @param th0 + * @param sh0 + * @param nx + * @param ny + * @param nz + * @return two float arrays, i.e. { cap, cin } + */ + public static float[][] capeFunc(float usetv, float[] p_dat, float[] tve_dat, float[] p0, float[] th0, float[] sh0, int nx, int ny, int nz) { int n2 = nx * ny; @@ -83,8 +97,7 @@ public class CapeFunc { double pp0 = p0[i]; double pp1 = pp0; if (Double.isNaN(pp0) || Double.isNaN(th0[i]) - || Double.isNaN(sh0[i]) - || sh0[i] < 0.0005) { + || Double.isNaN(sh0[i]) || sh0[i] < 0.0005) { tec = tvc = pc = Double.NaN; } else { double t0 = th0[i] * pow(pp0 / 1000, kapa); @@ -312,12 +325,26 @@ public class CapeFunc { pp1 = pp; } } - return new CapeCinPair(ny, nx, cap, cin); + return new float[][] { cap, cin }; } - // In this version we stop the computation at some arbitrary upper level, - // ptop. - public static CapeCinPair capeFuncTop(float usetv, float[] p_dat, + /** + * capeFuncTop. In this version we stop the computation at some arbitrary + * upper level, ptop. + * + * @param usetv + * @param p_dat + * @param tve_dat + * @param p0 + * @param th0 + * @param sh0 + * @param ptop + * @param nx + * @param ny + * @param nz + * @return two float arrays, i.e. { cap, cin } + */ + public static float[][] capeFuncTop(float usetv, float[] p_dat, float[] tve_dat, float[] p0, float[] th0, float[] sh0, float[] ptop, int nx, int ny, int nz) { int n2 = nx * ny; @@ -336,8 +363,7 @@ public class CapeFunc { double pp1 = pp0; double pfin = ptop[i]; if (Double.isNaN(pp0) || Double.isNaN(th0[i]) - || Double.isNaN(sh0[i]) || sh0[i] < 0.0005 - || pp0 < pfin) { + || Double.isNaN(sh0[i]) || sh0[i] < 0.0005 || pp0 < pfin) { tec = tvc = pc = Double.NaN; } else { double t0 = th0[i] * pow(pp0 / 1000, kapa); @@ -580,41 +606,7 @@ public class CapeFunc { pp1 = pp; } } - return new CapeCinPair(ny, nx, cap, cin); - } - - public static class CapeCinPair implements INumpyable { - - private final int nx; - - private final int ny; - - private final float[] cape; - - private final float[] cin; - - public CapeCinPair(int nx, int ny, float[] cape, float[] cin) { - this.nx = nx; - this.ny = ny; - this.cape = cape; - this.cin = cin; - } - - @Override - public Object[] getNumPy() { - return new Object[] { cape, cin }; - } - - @Override - public int getNumpyX() { - return nx; - } - - @Override - public int getNumpyY() { - return ny; - } - + return new float[][] { cap, cin }; } } diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/Constants.java b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/Constants.java similarity index 91% rename from cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/Constants.java rename to edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/Constants.java index 3dbe94953d..130783b4b6 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/Constants.java +++ b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/Constants.java @@ -17,7 +17,7 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.derivparam.python.function; +package com.raytheon.uf.common.wxmath; /** * Consolidated constants from various meteolib functions. @@ -28,7 +28,8 @@ package com.raytheon.uf.viz.derivparam.python.function; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jun 06, 2013 2043 bsteffen Ported from meteolib C + * Jun 06, 2013 2043 bsteffen Ported from meteolib C + * Aug 13, 2013 2262 njensen Moved from deriv params * * * diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DCapeFunc.java b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/DCapeFunc.java similarity index 91% rename from cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DCapeFunc.java rename to edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/DCapeFunc.java index e562efbe2d..68e7f4ae34 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DCapeFunc.java +++ b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/DCapeFunc.java @@ -17,25 +17,23 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.derivparam.python.function; +package com.raytheon.uf.common.wxmath; -import static com.raytheon.uf.viz.derivparam.python.function.AdiabeticTemperature.adiabatic_te; -import static com.raytheon.uf.viz.derivparam.python.function.CalcTw.mytw; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c0; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c1; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c2; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c_1; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.c_2; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.kapa; -import static com.raytheon.uf.viz.derivparam.python.function.Constants.kapa_1; -import static com.raytheon.uf.viz.derivparam.python.function.TempOfTe.temp_of_te; +import static com.raytheon.uf.common.wxmath.AdiabeticTemperature.adiabatic_te; +import static com.raytheon.uf.common.wxmath.CalcTw.mytw; +import static com.raytheon.uf.common.wxmath.Constants.c0; +import static com.raytheon.uf.common.wxmath.Constants.c1; +import static com.raytheon.uf.common.wxmath.Constants.c2; +import static com.raytheon.uf.common.wxmath.Constants.c_1; +import static com.raytheon.uf.common.wxmath.Constants.c_2; +import static com.raytheon.uf.common.wxmath.Constants.kapa; +import static com.raytheon.uf.common.wxmath.Constants.kapa_1; +import static com.raytheon.uf.common.wxmath.TempOfTe.temp_of_te; import static java.lang.Math.exp; import static java.lang.Math.log; import static java.lang.Math.pow; import static java.lang.Math.sqrt; -import com.raytheon.uf.common.python.PythonNumpyFloatArray; - /** * We input theta and specific humidity for surface conditions because these are * things that can be arithemitically averaged for a mixed layer. In order for a @@ -65,7 +63,8 @@ import com.raytheon.uf.common.python.PythonNumpyFloatArray; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jun 05, 2013 2043 bsteffen Ported from meteolib C + * Jun 05, 2013 2043 bsteffen Ported from meteolib C + * Aug 13, 2013 2262 njensen Moved from deriv params * * * @@ -75,9 +74,9 @@ import com.raytheon.uf.common.python.PythonNumpyFloatArray; public class DCapeFunc { - public static PythonNumpyFloatArray dcapeFunc(float usetv, float[] p_dat, - float[] t_dat, float[] td_dat, float[] p0, float[] th0, - float[] sh0, int nx, int ny, int nz, float max_evap, float max_rh) { + public static float[] dcapeFunc(float usetv, float[] p_dat, float[] t_dat, + float[] td_dat, float[] p0, float[] th0, float[] sh0, int nx, + int ny, int nz, float max_evap, float max_rh) { int n2 = nx * ny; int nzm = nz - 1; @@ -327,8 +326,7 @@ public class DCapeFunc { pp1 = pp; } } - return new PythonNumpyFloatArray(dcape, ny, nx); + return dcape; } - } diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DistFilter.java b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/DistFilter.java similarity index 94% rename from cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DistFilter.java rename to edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/DistFilter.java index 6a2c53bee9..85b3a6a8c7 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/DistFilter.java +++ b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/DistFilter.java @@ -17,16 +17,12 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.derivparam.python.function; +package com.raytheon.uf.common.wxmath; import java.util.Arrays; -import jep.INumpyable; - -import com.raytheon.uf.common.python.PythonNumpyFloatArray; - /** - * TODO Add Description + * Ported from dist_filter.c * *
  * 
@@ -35,6 +31,7 @@ import com.raytheon.uf.common.python.PythonNumpyFloatArray;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Aug 10, 2011            rjpeter     Initial creation
+ * Aug 13, 2013 2262       njensen     Moved from deriv params
  * 
  * 
* @@ -60,14 +57,14 @@ public class DistFilter { * @param times * @return */ - public static INumpyable filter(float[] input, float npts, int nx, int ny, + public static float[] filter(float[] input, float npts, int nx, int ny, int times) { float[] output = new float[input.length]; // copy the data if needed if (npts <= 1.0) { System.arraycopy(input, 0, output, 0, input.length); - return new PythonNumpyFloatArray(output, nx, ny); + return output; } int i, j, ii, jj; @@ -225,6 +222,6 @@ public class DistFilter { input = output; } - return new PythonNumpyFloatArray(output, nx, ny); + return output; } } diff --git a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/TempOfTe.java b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/TempOfTe.java similarity index 95% rename from cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/TempOfTe.java rename to edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/TempOfTe.java index 1b59a72929..2f9b62395d 100644 --- a/cave/com.raytheon.uf.viz.derivparam.python/src/com/raytheon/uf/viz/derivparam/python/function/TempOfTe.java +++ b/edexOsgi/com.raytheon.uf.common.wxmath/src/com/raytheon/uf/common/wxmath/TempOfTe.java @@ -17,9 +17,9 @@ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for * further licensing information. **/ -package com.raytheon.uf.viz.derivparam.python.function; +package com.raytheon.uf.common.wxmath; -import static com.raytheon.uf.viz.derivparam.python.function.AdiabeticTemperature.adiabatic_te; +import static com.raytheon.uf.common.wxmath.AdiabeticTemperature.adiabatic_te; import static java.lang.Math.sqrt; /** @@ -32,7 +32,8 @@ import static java.lang.Math.sqrt; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jun 3, 2013 2043 bsteffen Ported from meteolib C + * Jun 03, 2013 2043 bsteffen Ported from meteolib C + * Aug 13, 2013 2262 njensen Moved from deriv params * * *