Issue #2262 Port ept to java.

Former-commit-id: a63079d509 [formerly e3b0b2b81f] [formerly fe739a6018] [formerly a63079d509 [formerly e3b0b2b81f] [formerly fe739a6018] [formerly b6a8c63cff [formerly fe739a6018 [formerly a11ef952b6a7cf3135e07fa3161662783df37f74]]]]
Former-commit-id: b6a8c63cff
Former-commit-id: 929dc23b78 [formerly c59c26b7ab] [formerly bd2d1d660838ddb8b1b7b81993088f4980ba82e0 [formerly 969c467922]]
Former-commit-id: 553b964144bf020a295c40c721e9f4c58df82ea5 [formerly a444860b90]
Former-commit-id: 5d561031f2
This commit is contained in:
Ben Steffensmeier 2013-08-26 14:28:36 -05:00
parent 52eec82e79
commit 1f2b07f3cc
6 changed files with 179 additions and 19 deletions

View file

@ -18,7 +18,6 @@ Require-Bundle: com.raytheon.uf.common.status;bundle-version="1.12.1174",
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.wxmath,
com.raytheon.edex.meteolib;bundle-version="1.12.1174"
com.raytheon.uf.common.wxmath
Export-Package: com.raytheon.uf.viz.derivparam.python,
com.raytheon.uf.viz.derivparam.python.function

View file

@ -31,7 +31,6 @@
from com.raytheon.uf.common.wxmath import PToZsa
from com.raytheon.uf.common.wxmath import ZToPsa
from com.raytheon.edex.meteoLib import Controller
from jep import jarray, JFLOAT_ID
import numpy
@ -59,14 +58,6 @@ def ptozsa(P):
return result
return P
def calctd2(P,T,Q):
jP = numpy2java(P)
jT = numpy2java(T)
jQ = numpy2java(Q)
jresult = Controller.calctd2(jP,jT,jQ,int(P.shape[0]),int(P.shape[1]))
result = java2numpy(jresult, P.shape)
return result
def numpy2java(a):
if (len(a.shape) == 1):
jA = jarray(a.shape[0], JFLOAT_ID, 0)

View file

@ -16,7 +16,6 @@ Require-Bundle: org.eclipse.core.runtime,
com.raytheon.viz.ui;bundle-version="1.12.1174",
com.raytheon.uf.viz.sounding;bundle-version="1.12.1174",
com.raytheon.viz.core.graphing;bundle-version="1.12.1174",
com.raytheon.edex.meteolib;bundle-version="1.12.1174",
javax.measure;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy

View file

@ -12,8 +12,8 @@ Require-Bundle: com.raytheon.uf.common.pointdata;bundle-version="1.11.31",
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
com.raytheon.edex.meteolib;bundle-version="1.12.1174",
javax.measure;bundle-version="1.0.0"
javax.measure;bundle-version="1.0.0",
com.raytheon.uf.common.wxmath
Export-Package: com.raytheon.uf.common.sounding,
com.raytheon.uf.common.sounding.adapter,
com.raytheon.uf.common.sounding.util

View file

@ -19,8 +19,9 @@
**/
package com.raytheon.uf.common.sounding;
import com.raytheon.edex.meteoLib.Controller;
import com.raytheon.uf.common.sounding.util.SoundingPrefs;
import com.raytheon.uf.common.wxmath.EquivalentPotentialTemperature;
import com.raytheon.uf.common.wxmath.TempOfTe;
import com.vividsolutions.jts.geom.Coordinate;
/**
@ -34,8 +35,9 @@ import com.vividsolutions.jts.geom.Coordinate;
* ------------ ---------- ----------- --------------------------
* 06 Nov 2006 jkorman Initial Coding
* 29 Sept 2008 dhladky Added more stuff to finish SkewT.
* 25 Jul 2013 2190 mschenke Moved common sounding calculation
* from PopupSkewTDialog to here
* 25 Jul 2013 2190 mschenke Moved common sounding calculation from
* PopupSkewTDialog to here
* Aug 26, 2013 2262 bsteffen Port ept to java.
* </pre>
*
* @author jkorman
@ -158,14 +160,14 @@ public class WxMath {
float tt = soundingData.get(i).getTemperature();
float td = soundingData.get(i).getDewpoint();
float p = soundingData.get(i).getPressure();
thetae = Controller.ept(tt, td, p);
thetae = (float) EquivalentPotentialTemperature.ept(tt, td, p);
if (thetae > maxthetae && soundingData.get(i).getPressure() > 500)
maxthetae = thetae;
}
for (int i = 0; i < muParcelTrajectoryPressures.length; ++i) {
float p = muParcelTrajectoryPressures[i];
etpar = (float) (maxthetae * (Math.pow(p / 1000.0f, 0.286f)));
tp = Controller.temp_of_te(etpar, p);
tp = (float) TempOfTe.temp_of_te(etpar, p);
muParcelTrajectory[20 - (int) (p / 50)] = tp;
}
return muParcelTrajectory;

View file

@ -0,0 +1,169 @@
/**
* 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.common.wxmath;
import static java.lang.Math.exp;
import static java.lang.Math.pow;
/**
* Calculates Equivalent Potential Temperature.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 26, 2013 2262 bsteffen Converted from meteolib thermoRtns.c
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class EquivalentPotentialTemperature {
/*
* EPS = RATIO OF THE MEAN MOLECULAR WEIGHT OF WATER (18.016 G/MOLE) TO THAT
* OF DRY AIR (28.966 G/MOLE)
*/
private static final double eps = 0.62197;
/* ES0 = SATURATION VAPOR RESSURE OVER LIQUID WATER AT 0C */
private static final double es0 = 6.1078;
/**
* THIS FUNCTION RETURNS THE EQUIVALENT POTENTIAL TEMP EPT (KELVIN) FOR A
* PARCEL OF AIR INITIALLY AT TEMP T (KELVIN), DEW POINT TD (KELVIN) AND
* PRESSURE P (MILLIBARS).
*/
public static double ept(double t, double td, double p) {
/*
* BAKER,SCHLATTER 17-MAY-1982 Original version
*
* THE FORMULA USED IS EQ.(43) IN BOLTON, DAVID, 1980: "THE COMPUTATION
* OF EQUIVALENT POTENTIAL TEMPERATURE," MONTHLY WEATHER REVIEW, VOL.
* 108, NO. 7 (JULY), PP. 1046-1053. THE MAXIMUM ERROR IN EPT IN 0.3C.
* IN MOST CASES THE ERROR IS LESS THAN 0.1C.
*/
/*
* COMPUTE THE MIXING RATIO (GRAMS OF WATER VAPOR PER KILOGRAM OF DRY
* AIR).
*/
double tdc = td - 273.16;
double w = wmr(p, tdc);
/* COMPUTE THE TEMP (CELSIUS) AT THE LIFTING CONDENSATION LEVEL. */
double tc = t - 273.16;
double tlcl = tcon(tc, tdc);
double tk = t; /* + 273.16; */
double tl = tlcl + 273.16;
double d1 = (1e3 / p);
double d2 = ((1.0 - w * 2.8e-4) * 0.2854);
double pt = tk * pow(d1, d2);
double eptk = pt * exp((3.376 / tl - 0.00254) * w * (w * 8.1e-4 + 1.0));
return eptk; /* - 273.16; */
}
/**
* THIS FUNCTION APPROXIMATES THE MIXING RATIO WMR (GRAMS OF WATER VAPOR PER
* KILOGRAM OF DRY AIR) GIVEN THE PRESSURE P (MB) AND THE TEMPERATURE T
* (CELSIUS).
*/
private static double wmr(double p, double t) {
/*
* BAKER,SCHLATTER 17-MAY-1982 Original version
*
* THE FORMULA USED IS GIVEN ON P. 302 OF THE SMITHSONIAN METEOROLOGICAL
* TABLES BY ROLAND LIST (6TH EDITION).
*/
/*
* THE NEXT TWO LINES CONTAIN A FORMULA BY HERMAN WOBUS FOR THE
* CORRECTION FACTOR WFW FOR THE DEPARTURE OF THE MIXTURE OF AIR AND
* WATER VAPOR FROM THE IDEAL GAS LAW. THE FORMULA FITS VALUES IN TABLE
* 89, P. 340 OF THE SMITHSONIAN METEOROLOGICAL TABLES, BUT ONLY FOR
* TEMPERATURES AND PRESSURES NORMALLY ENCOUNTERED IN IN THE ATMOSPHERE.
*/
double x = (t - 12.5 + 7500.0 / p) * 0.02;
double wfw = p * 4.5e-6 + 1.0 + x * 0.0014 * x;
double fwesw = wfw * esw(t);
double r = eps * fwesw / (p - fwesw);
/* CONVERT R FROM A DIMENSIONLESS RATIO TO GRAMS/KILOGRAM. */
return r * 1e3;
}
/**
* THIS FUNCTION RETURNS THE SATURATION VAPOR PRESSURE ESW (MILLIBARS) OVER
* LIQUID WATER GIVEN THE TEMPERATURE T (CELSIUS).
*/
private static double esw(double t) {
/*
* BAKER,SCHLATTER 17-MAY-1982 Original version
*
* THE POLYNOMIAL APPROXIMATION BELOW IS DUE TO HERMAN WOBUS, A
* MATHEMATICIAN WHO WORKED AT THE NAVY WEATHER RESEARCH FACILITY,
* NORFOLK, VIRGINIA, BUT WHO IS NOW RETIRED. THE COEFFICIENTS OF THE
* POLYNOMIAL WERE CHOSEN TO FIT THE VALUES IN TABLE 94 ON PP. 351-353
* OF THE SMITHSONIAN METEOROLOGICAL TABLES BY ROLAND LIST (6TH ED). THE
* APPROXIMATION IS VALID FOR -50 < T < 100C.
*/
double pol = t * -3.0994571e-20 + 1.1112018e-17;
pol = t * pol - 1.7892321e-15;
pol = t * pol + 2.1874425e-13;
pol = t * pol - 2.9883885e-11;
pol = t * pol + 4.3884187e-9;
pol = t * pol - 6.1117958e-7;
pol = t * pol + 7.8736169e-5;
pol = t * pol - 0.0090826951;
pol = t * pol + 0.99999683;
/* Computing 8th power */
pol *= pol;
pol *= pol;
pol *= pol;
return es0 / pol;
}
/**
* THIS FUNCTION RETURNS THE TEMPERATURE TCON (CELSIUS) AT THE LIFTING
* CONDENSATION LEVEL, GIVEN THE TEMPERATURE T (CELSIUS) AND THE DEW POINT D
* (CELSIUS).
*/
private static double tcon(double t, double d) {
/* BAKER,SCHLATTER 17-MAY-1982 Original version */
/* COMPUTE THE DEW POINT DEPRESSION S. */
double s = t - d;
/*
* THE APPROXIMATION BELOW, A THIRD ORDER POLYNOMIAL IN S AND T, IS DUE
* TO HERMAN WOBUS. THE SOURCE OF DATA FOR FITTING THE POLYNOMIAL IS
* UNKNOWN.
*/
double dlt = s
* (t * 0.001278 + 1.2185 + s
* (s * 1.173e-5 - 0.00219 - t * 5.2e-6));
return t - dlt;
}
}