diff --git a/edexOsgi/com.raytheon.uf.common.sounding/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.sounding/META-INF/MANIFEST.MF index b865cfffdc..436879c9e1 100644 --- a/edexOsgi/com.raytheon.uf.common.sounding/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.sounding/META-INF/MANIFEST.MF @@ -4,10 +4,14 @@ Bundle-Name: Sounding Plug-in Bundle-SymbolicName: com.raytheon.uf.common.sounding Bundle-Version: 1.12.1174.qualifier Bundle-Vendor: RAYTHEON +Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: com.raytheon.uf.common.pointdata;bundle-version="1.11.31", com.raytheon.uf.common.dataplugin;bundle-version="1.11.31", com.raytheon.uf.common.geospatial;bundle-version="1.12.1174", + 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" Export-Package: com.raytheon.uf.common.sounding, diff --git a/edexOsgi/com.raytheon.uf.common.sounding/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject b/edexOsgi/com.raytheon.uf.common.sounding/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject new file mode 100644 index 0000000000..62c91c7bb2 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.sounding/META-INF/services/com.raytheon.uf.common.serialization.ISerializableObject @@ -0,0 +1 @@ +com.raytheon.uf.common.sounding.util.SoundingPrefs \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/WxMath.java b/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/WxMath.java index 84ba78e510..691619a5dc 100644 --- a/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/WxMath.java +++ b/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/WxMath.java @@ -20,6 +20,7 @@ package com.raytheon.uf.common.sounding; import com.raytheon.edex.meteoLib.Controller; +import com.raytheon.uf.common.sounding.util.SoundingPrefs; import com.vividsolutions.jts.geom.Coordinate; /** @@ -33,9 +34,8 @@ 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 - * Aug 20, 2013 2259 bsteffen Delete old skewt plugin. + * 25 Jul 2013 2190 mschenke Moved common sounding calculation + * from PopupSkewTDialog to here * * * @author jkorman @@ -205,6 +205,46 @@ public class WxMath { return new Coordinate(spd, dir); } + /** + * Convert a pressure and temperature to a skew-t x,y coordinate in + * centimeters where 0,0 occurs at 1000 hPa and 0 degrees Celsius. + * + * @param pressure + * The pressure in hectoPascals (millibars). + * @param temperature + * The temperature in degrees Celsius. + * @return The calculated coordinate in centimeters. + */ + public static final Coordinate getSkewTXY(double pressure, + double temperature) { + temperature -= SoundingPrefs.getSoundingPrefs().getTemperatureOffset(); + Coordinate point = new Coordinate(); + + point.y = 132.182 - 44.061 * Math.log10(pressure); + point.x = (0.54 * temperature) + (0.90692 * point.y); + + return point; + } + + /** + * Reverse a skewT coordinate (in centimeters) to the corresponding + * temperature and pressure. + * + * @param point + * @return The temperature and pressure. coordinate.x = temperature in + * Celsius, coordinate.y = the pressure in hectoPascals (millibars). + */ + public static final Coordinate reverseSkewTXY(Coordinate point) { + Coordinate tempPressure = new Coordinate(); + tempPressure.y = Math.pow(10, ((point.y - 132.182) / -44.061)); + tempPressure.x = (point.x - (0.90692 * point.y)) / 0.54; + + tempPressure.x += SoundingPrefs.getSoundingPrefs() + .getTemperatureOffset(); + + return tempPressure; + } + /** * Compute the final temperature of a parcel moved dry adiabatically from * its initial pressure and temperature to a final pressure. diff --git a/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/util/SoundingPrefs.java b/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/util/SoundingPrefs.java new file mode 100644 index 0000000000..c2709c408d --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.sounding/src/com/raytheon/uf/common/sounding/util/SoundingPrefs.java @@ -0,0 +1,103 @@ +/** + * 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.sounding.util; + +import java.io.File; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.localization.LocalizationContext; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; +import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; +import com.raytheon.uf.common.localization.PathManagerFactory; +import com.raytheon.uf.common.serialization.SerializationException; +import com.raytheon.uf.common.serialization.SerializationUtil; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; + +/** + * + * Allows the temperature range visible on a skewT chart to be changed by the + * user/site. + * + *
+ * + * SOFTWARE HISTORY + * + * Date Ticket# Engineer Description + * ------------ ---------- ----------- -------------------------- + * Jun 15, 2011 bsteffen Initial creation + * Aug 21, 2013 2259 bsteffen Add javadoc + * + * + *+ * + * @author bsteffen + * @version 1.0 + */ +@XmlAccessorType(XmlAccessType.NONE) +@XmlRootElement +public class SoundingPrefs { + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(SoundingPrefs.class); + + private static final String SOUNDING_PREFS_FILE = "sounding/soundingPrefs.xml"; + + @XmlElement + private double temperatureOffset = 0.0; + + public double getTemperatureOffset() { + return temperatureOffset; + } + + public void setTemperatureOffset(double temperatureOffset) { + this.temperatureOffset = temperatureOffset; + } + + private static SoundingPrefs soundingPrefs; + + public static SoundingPrefs getSoundingPrefs() { + if(soundingPrefs == null) { + IPathManager pathMgr = PathManagerFactory.getPathManager(); + LocalizationContext lc = pathMgr.getContext( + LocalizationType.COMMON_STATIC, LocalizationLevel.SITE); + File file = pathMgr.getFile(lc, SOUNDING_PREFS_FILE); + if(file == null || !file.exists()) { + lc = pathMgr.getContext( + LocalizationType.COMMON_STATIC, LocalizationLevel.BASE); + file = pathMgr.getFile(lc, SOUNDING_PREFS_FILE); + } + try { + soundingPrefs = (SoundingPrefs) SerializationUtil.jaxbUnmarshalFromXmlFile(file); + } catch (SerializationException e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); + soundingPrefs = new SoundingPrefs(); + } + } + return soundingPrefs; + + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.sounding/utility/common_static/base/sounding/soundingPrefs.xml b/edexOsgi/com.raytheon.uf.common.sounding/utility/common_static/base/sounding/soundingPrefs.xml new file mode 100644 index 0000000000..2719b27052 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.sounding/utility/common_static/base/sounding/soundingPrefs.xml @@ -0,0 +1,3 @@ +