Merge "Issue #1553 move radar units into common plugin for use in data access factory Change-Id: I32d01625bcbc6555b402048ebb34cee21f0b855f" into development
Former-commit-id: 358b990e43d0f5952ee3c33521778541bd1b7c04
This commit is contained in:
commit
f77a1dc85c
14 changed files with 278 additions and 308 deletions
|
@ -82,7 +82,7 @@
|
|||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"/>
|
||||
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.common.units"
|
||||
download-size="0"
|
||||
|
@ -220,7 +220,7 @@
|
|||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.common.spatial"
|
||||
download-size="0"
|
||||
|
@ -319,4 +319,11 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.common.image"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
|
|
|
@ -47,7 +47,6 @@ import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
|
|||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.grid.util.RadarAdapter;
|
||||
import com.raytheon.viz.grid.util.SliceUtil;
|
||||
import com.raytheon.viz.radar.util.DataUtilities;
|
||||
|
||||
/**
|
||||
* A requestable data record which wraps a RadarRecord and can convert radar
|
||||
|
@ -136,7 +135,7 @@ public class RadarRequestableData extends GridRequestableData {
|
|||
// to float
|
||||
ColorMapParameters cMapParams = RadarAdapter
|
||||
.getColorMap(radarSource);
|
||||
cMapParams.setDataUnit(DataUtilities.getDataUnit(radarSource));
|
||||
cMapParams.setDataUnit(radarSource.getDataUnit());
|
||||
/*
|
||||
* UnitConverter dataToImage =
|
||||
* DataUtilities.getDataToImageConverter( radarSource, cMapParams);
|
||||
|
|
|
@ -41,13 +41,6 @@
|
|||
renderingOrderId="IMAGE_LOCAL"
|
||||
resourceType="PLAN_VIEW"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="com.raytheon.uf.viz.core.units">
|
||||
<units
|
||||
class="com.raytheon.viz.radar.units.RadarUnits"
|
||||
name="RadarUnits">
|
||||
</units>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.commands">
|
||||
<command
|
||||
|
|
|
@ -44,11 +44,10 @@ import com.raytheon.uf.viz.core.style.StyleRule;
|
|||
import com.raytheon.uf.viz.core.style.VizStyleException;
|
||||
import com.raytheon.viz.core.style.image.ImagePreferences;
|
||||
import com.raytheon.viz.core.units.PiecewisePixel;
|
||||
import com.raytheon.viz.radar.util.DataUtilities;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Default interrogator for radar resource.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -264,7 +263,7 @@ public class RadarDefaultInterrogator implements IRadarInterrogator {
|
|||
protected UnitConverter getConverter(ColorMapParameters params,
|
||||
RadarRecord radarRecord) {
|
||||
UnitConverter converter = null;
|
||||
Unit<?> dataUnit = DataUtilities.getDataUnit(radarRecord);
|
||||
Unit<?> dataUnit = radarRecord.getDataUnit();
|
||||
if (dataUnit != null && !dataUnit.equals(params.getDataUnit())) {
|
||||
Unit<?> displayUnit = params.getDisplayUnit();
|
||||
if (dataUnit.isCompatible(displayUnit)) {
|
||||
|
|
|
@ -77,7 +77,8 @@ import com.raytheon.viz.radar.util.DataUtilities;
|
|||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Base resource for any radar record that can be displayed on a map as a
|
||||
* colormapped image.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -222,7 +223,7 @@ public class RadarImageResource<D extends IDescriptor> extends
|
|||
|
||||
// Setup the ColorMap settings
|
||||
int prodCode = record.getProductCode();
|
||||
Unit<?> dataUnit = DataUtilities.getDataUnit(record);
|
||||
Unit<?> dataUnit = record.getDataUnit();
|
||||
|
||||
params = ColorMapParameterFactory.build((Object) null, "" + prodCode,
|
||||
dataUnit, null, resourceData.mode);
|
||||
|
@ -460,7 +461,7 @@ public class RadarImageResource<D extends IDescriptor> extends
|
|||
// Sometimes the data unit may not match what is in the params so always
|
||||
// use what we really have
|
||||
UnitConverter dataToImage = null;
|
||||
Unit<?> dataUnit = DataUtilities.getDataUnit(record);
|
||||
Unit<?> dataUnit = record.getDataUnit();
|
||||
if (dataUnit != null && !dataUnit.equals(params.getDataUnit())) {
|
||||
Unit<?> imageUnit = params.getImageUnit();
|
||||
if (imageUnit != null && dataUnit.isCompatible(imageUnit)) {
|
||||
|
|
|
@ -42,10 +42,10 @@ import com.raytheon.viz.core.rsc.BestResResource;
|
|||
import com.raytheon.viz.radar.rsc.MosaicPaintProperties;
|
||||
import com.raytheon.viz.radar.rsc.RadarImageResource;
|
||||
import com.raytheon.viz.radar.rsc.mosaic.RadarMosaicRendererFactory.IRadarMosaicRenderer;
|
||||
import com.raytheon.viz.radar.util.DataUtilities;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* mosaic renderer that merges large low res raster products with smaller
|
||||
* highres raster products.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -181,8 +181,8 @@ public class MergeRasterRadarMosaicRenderer implements IRadarMosaicRenderer {
|
|||
RadarRecord rr1 = records.get(c - 1);
|
||||
RadarRecord rr2 = records.get(c);
|
||||
|
||||
Unit<?> unit1 = DataUtilities.getDataUnit(rr1);
|
||||
Unit<?> unit2 = DataUtilities.getDataUnit(rr2);
|
||||
Unit<?> unit1 = rr1.getDataUnit();
|
||||
Unit<?> unit2 = rr2.getDataUnit();
|
||||
if (!unit2.isCompatible(unit1)) {
|
||||
// No joining can occur
|
||||
continue;
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
/**
|
||||
* 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.viz.radar.units;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.ParsePosition;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.quantity.Velocity;
|
||||
import javax.measure.unit.BaseUnit;
|
||||
import javax.measure.unit.NonSI;
|
||||
import javax.measure.unit.SI;
|
||||
import javax.measure.unit.Unit;
|
||||
import javax.measure.unit.UnitFormat;
|
||||
|
||||
import com.raytheon.viz.core.units.IUnitRegistrar;
|
||||
import com.raytheon.viz.core.units.PiecewisePixel;
|
||||
|
||||
/**
|
||||
* RadarUnits: Defines a set of radar unit conversions
|
||||
*
|
||||
* Sample Usage (Convert velocity 2x resolution pixel to m/s):
|
||||
*
|
||||
* <PRE>
|
||||
* Unit<?> u1 = RadarUnits.VELOCITY_PIXEL_2X;
|
||||
*
|
||||
* Unit<?> u2 = SI.METER_PER_SECOND;
|
||||
*
|
||||
* UnitConverter uConv = u1.getConverterTo(u2);
|
||||
*
|
||||
* double inMs = uConv.convert(32.0);
|
||||
*
|
||||
* </PRE>
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 26, 2007 chammack Initial Creation.
|
||||
* Oct 09, 2007 465 randerso Updated to better support level 3
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1
|
||||
*/
|
||||
public class RadarUnits implements IUnitRegistrar {
|
||||
|
||||
public RadarUnits() {
|
||||
|
||||
}
|
||||
|
||||
public static final BaseUnit<Reflectivity> DBZ = new BaseUnit<Reflectivity>(
|
||||
"dBZ");
|
||||
|
||||
public static final Unit<Reflectivity> REFLECTIVITY_PIXEL = new PiecewisePixel<Reflectivity>(
|
||||
RadarUnits.DBZ, new double[] { 16, 33, 240, 255 }, new double[] {
|
||||
-32.5, -20.0, 75.0, 94.5 });
|
||||
|
||||
public static final Unit<Velocity> VELOCITY_PIXEL;
|
||||
static {
|
||||
UnitConverter ktsToMps = NonSI.KNOT
|
||||
.getConverterTo(SI.METERS_PER_SECOND);
|
||||
double[] knots = { -999, -247.0, -100.0, 100.0, 245.0 };
|
||||
double[] mps = new double[knots.length];
|
||||
|
||||
for (int i = 0; i < mps.length; i++) {
|
||||
mps[i] = ktsToMps.convert(knots[i]);
|
||||
}
|
||||
|
||||
VELOCITY_PIXEL = new PiecewisePixel<Velocity>(NonSI.KNOT, new double[] {
|
||||
1, 2, 26, 232, 255 }, mps);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.units.IUnitRegistrar#register()
|
||||
*/
|
||||
@Override
|
||||
public void register() {
|
||||
UnitFormat.getUCUMInstance().label(RadarUnits.DBZ, "dBZ");
|
||||
UnitFormat.getUCUMInstance().label(SI.KILO(NonSI.FOOT), "kft");
|
||||
UnitFormat.getUCUMInstance().label(NonSI.KNOT, "kts");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ParseException {
|
||||
Unit<Reflectivity> rp = RadarUnits.REFLECTIVITY_PIXEL;
|
||||
|
||||
System.out.println();
|
||||
int[] testPix = { 0, 8, 16, 20, 33, 50, 120, 240, 250, 255, 300 };
|
||||
UnitConverter toDBZ = rp.getConverterTo(RadarUnits.DBZ);
|
||||
for (int p : testPix) {
|
||||
System.out.println("pixel: " + p + " = " + toDBZ.convert(p)
|
||||
+ RadarUnits.DBZ.toString());
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
double[] testDBZ = { -33, -32.5, -30, -20, -10, 0, 10, 20, 30, 40, 50,
|
||||
60, 75, 80, 94.5, 100 };
|
||||
UnitConverter toPixel = RadarUnits.DBZ.getConverterTo(rp);
|
||||
for (double r : testDBZ) {
|
||||
System.out.println(r + RadarUnits.DBZ.toString() + " = pixel: "
|
||||
+ (int) toPixel.convert(r));
|
||||
}
|
||||
|
||||
Unit<?> imageUnit = RadarUnits.VELOCITY_PIXEL;
|
||||
Unit<?> dataUnit = UnitFormat.getUCUMInstance().parseProductUnit("m/s",
|
||||
new ParsePosition(0));
|
||||
dataUnit = dataUnit.plus(-64.5).times(0.5);
|
||||
|
||||
UnitConverter dataToImage = dataUnit.getConverterTo(imageUnit);
|
||||
|
||||
System.out.println();
|
||||
testPix = new int[] { 0, 1, 2, 26, 232, 255 };
|
||||
for (int p : testPix) {
|
||||
System.out.println("data: " + p + " image: "
|
||||
+ dataToImage.convert(p));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,14 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.viz.radar.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.Unit;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
|
||||
import com.raytheon.uf.common.dataplugin.radar.level3.DataLevelThreshold;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -35,11 +33,9 @@ import com.raytheon.uf.viz.core.style.StyleManager;
|
|||
import com.raytheon.uf.viz.core.style.StyleRule;
|
||||
import com.raytheon.uf.viz.core.style.VizStyleException;
|
||||
import com.raytheon.viz.core.style.image.ImagePreferences;
|
||||
import com.raytheon.viz.core.units.PiecewisePixel;
|
||||
import com.raytheon.viz.radar.units.DigitalVilUnit;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* provides static utility method for getting the correct units for radar data.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -64,147 +60,19 @@ public class DataUtilities {
|
|||
* @param record
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static Unit<?> getDataUnit(RadarRecord record) {
|
||||
Unit<?> rval = null;
|
||||
int numLevels = record.getNumLevels();
|
||||
Object[] thresholds = record.getDecodedThresholds();
|
||||
if (numLevels <= 16) {
|
||||
ArrayList<Integer> pixel = new ArrayList<Integer>();
|
||||
ArrayList<Float> real = new ArrayList<Float>();
|
||||
if ("V".equals(record.getDisplayModes())) {
|
||||
// V does this weird thing at zero, they have a data value of -1
|
||||
// at index 7 which just symbolizes that the data goes from -10
|
||||
// - 0, which seems pointless, and A1 also throws it out
|
||||
int p = 1;
|
||||
for (int i = 0; i < numLevels; i++) {
|
||||
if (i == 7) {
|
||||
continue;
|
||||
}
|
||||
if (thresholds[i] instanceof Float) {
|
||||
pixel.add(p);
|
||||
real.add((Float) thresholds[i]);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < numLevels; i++) {
|
||||
if (thresholds[i] instanceof Float) {
|
||||
if (real.contains(thresholds[i])) {
|
||||
// Try to determine if we can treat one of these
|
||||
// different
|
||||
Float fVal = (Float) thresholds[i];
|
||||
Integer prevI = pixel.get(real
|
||||
.indexOf(thresholds[i]));
|
||||
DataLevelThreshold prevThresh = new DataLevelThreshold(
|
||||
record.getThreshold(prevI));
|
||||
DataLevelThreshold currThresh = new DataLevelThreshold(
|
||||
record.getThreshold(i));
|
||||
if (prevThresh.isLessThan()
|
||||
|| prevThresh.isGtrThan()) {
|
||||
if (prevThresh.isLessThan()) {
|
||||
record.getDecodedThresholds()[prevI] = "<"
|
||||
+ fVal.intValue();
|
||||
} else {
|
||||
record.getDecodedThresholds()[prevI] = ">"
|
||||
+ fVal.intValue();
|
||||
}
|
||||
real.remove(fVal);
|
||||
real.add(fVal);
|
||||
pixel.remove(prevI);
|
||||
pixel.add(i);
|
||||
continue;
|
||||
} else if (currThresh.isLessThan()) {
|
||||
record.getDecodedThresholds()[i] = "<"
|
||||
+ fVal.intValue();
|
||||
continue;
|
||||
} else if (currThresh.isGtrThan()) {
|
||||
record.getDecodedThresholds()[i] = ">"
|
||||
+ fVal.intValue();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
pixel.add(i);
|
||||
real.add((Float) thresholds[i]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pixel.size() == 0) {
|
||||
return record.getUnitObject();
|
||||
}
|
||||
|
||||
double[] pix = new double[pixel.size()];
|
||||
int i = 0;
|
||||
for (Integer p : pixel) {
|
||||
pix[i++] = p;
|
||||
}
|
||||
|
||||
double[] std = new double[real.size()];
|
||||
|
||||
boolean allZeroes = true;
|
||||
|
||||
i = 0;
|
||||
for (Float r : real) {
|
||||
allZeroes = allZeroes && (r == 0);
|
||||
std[i++] = r;
|
||||
}
|
||||
if (allZeroes) {
|
||||
// allZeroes is not a valid unit and is basically disgarded,
|
||||
// this check is done for CFC
|
||||
rval = record.getUnitObject();
|
||||
} else {
|
||||
rval = new PiecewisePixel(record.getUnitObject(), pix, std);
|
||||
}
|
||||
} else if (record.getProductCode() == 134) {
|
||||
// Digital Vil is all messy in the spec.
|
||||
rval = new DigitalVilUnit(record.getThresholds());
|
||||
} else if (record.getThreshold(5) == 0) {
|
||||
// The offset and scale are set as ints
|
||||
double offset = record.getThreshold(0);
|
||||
double scale = record.getThreshold(1);
|
||||
int nLevels = record.getThreshold(2);
|
||||
// I believe all products have at least one flag value and DHR is
|
||||
// reporting 256 levels
|
||||
if (nLevels > 255) {
|
||||
nLevels = 255;
|
||||
}
|
||||
double[] pix = { 256 - nLevels, 255 };
|
||||
if (record.getProductCode() == 155) {
|
||||
pix = new double[] { 129, 149 };
|
||||
}
|
||||
|
||||
double[] data = { offset, offset + (nLevels - 1) * scale };
|
||||
rval = new PiecewisePixel(record.getUnitObject(), pix, data);
|
||||
|
||||
} else {
|
||||
// The offset and scale are set as floats
|
||||
double scale = Float.intBitsToFloat((record.getThreshold(0) << 16)
|
||||
+ record.getThreshold(1));
|
||||
if (scale == 0.0) {
|
||||
// 0.0 is sometimes used by HC and leads to a massively invalid
|
||||
// data range.
|
||||
scale = 1.0;
|
||||
}
|
||||
double offset = Float.intBitsToFloat((record.getThreshold(2) << 16)
|
||||
+ record.getThreshold(3));
|
||||
int nLevels = record.getThreshold(5);
|
||||
if (nLevels < 0) {
|
||||
// Only for DPR, the 65536 can't be encoded in a short
|
||||
nLevels = record.getNumLevels();
|
||||
}
|
||||
int nFlags = record.getThreshold(6);
|
||||
|
||||
double[] pix = { nFlags, nLevels };
|
||||
double[] data = { (nFlags - offset) / scale,
|
||||
(nLevels - offset) / scale };
|
||||
|
||||
rval = new PiecewisePixel(record.getUnitObject(), pix, data);
|
||||
|
||||
}
|
||||
return rval;
|
||||
return record.getDataUnit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns dataUnit but first checks style rules for alternative units for
|
||||
* different display modes. Used for VIL displayed as reflectivity.
|
||||
*
|
||||
* @param record
|
||||
* @param mode
|
||||
* @return
|
||||
*/
|
||||
public static Unit<?> getDataUnit(RadarRecord record, String mode) {
|
||||
// The purpose of this block is to find a new data Unit in the
|
||||
// style rules, a style rule with a creating entity is assumed
|
||||
|
@ -242,6 +110,6 @@ public class DataUtilities {
|
|||
return prefs.getDisplayUnits();
|
||||
}
|
||||
}
|
||||
return DataUtilities.getDataUnit(record);
|
||||
return record.getDataUnit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
|
||||
com.raytheon.edex.common,
|
||||
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.site;bundle-version="1.12.1174"
|
||||
com.raytheon.uf.common.site;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.image;bundle-version="1.0.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.uf.common.dataplugin.radar;
|
||||
|
@ -33,6 +34,7 @@ Export-Package: com.raytheon.uf.common.dataplugin.radar;
|
|||
com.raytheon.uf.common.dataplugin.radar.level3.generic;uses:="com.raytheon.uf.common.serialization",
|
||||
com.raytheon.uf.common.dataplugin.radar.projection,
|
||||
com.raytheon.uf.common.dataplugin.radar.request;uses:="com.raytheon.uf.common.serialization.comm",
|
||||
com.raytheon.uf.common.dataplugin.radar.units,
|
||||
com.raytheon.uf.common.dataplugin.radar.util;
|
||||
uses:="com.raytheon.uf.common.dataplugin.radar,
|
||||
com.raytheon.uf.common.datastorage,
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="radarUnitsRegisterd"
|
||||
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="targetClass">
|
||||
<value>com.raytheon.uf.common.dataplugin.radar.units.RadarUnits</value>
|
||||
</property>
|
||||
<property name="targetMethod">
|
||||
<value>register</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -90,11 +90,13 @@ import com.raytheon.uf.common.dataplugin.radar.level3.WindBarbPacket.WindBarbPoi
|
|||
import com.raytheon.uf.common.dataplugin.radar.level3.generic.AreaComponent;
|
||||
import com.raytheon.uf.common.dataplugin.radar.level3.generic.GenericDataComponent;
|
||||
import com.raytheon.uf.common.dataplugin.radar.level3.generic.GenericDataParameter;
|
||||
import com.raytheon.uf.common.dataplugin.radar.units.DigitalVilUnit;
|
||||
import com.raytheon.uf.common.dataplugin.radar.util.RadarConstants;
|
||||
import com.raytheon.uf.common.dataplugin.radar.util.RadarConstants.MapValues;
|
||||
import com.raytheon.uf.common.geospatial.CRSCache;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialEnabled;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.image.units.PiecewisePixel;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
@ -748,6 +750,153 @@ public class RadarRecord extends PersistablePluginDataObject implements
|
|||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual unit of the raw bytes with any scale/offset or other
|
||||
* information from the thresholds.
|
||||
*
|
||||
* @return a unit object that describes the actual byte values.
|
||||
*/
|
||||
public Unit<?> getDataUnit() {
|
||||
Unit<?> rval = null;
|
||||
int numLevels = getNumLevels();
|
||||
Object[] thresholds = getDecodedThresholds();
|
||||
if (numLevels <= 16) {
|
||||
ArrayList<Integer> pixel = new ArrayList<Integer>();
|
||||
ArrayList<Float> real = new ArrayList<Float>();
|
||||
if ("V".equals(getDisplayModes())) {
|
||||
// V does this weird thing at zero, they have a data value of -1
|
||||
// at index 7 which just symbolizes that the data goes from -10
|
||||
// - 0, which seems pointless, and A1 also throws it out
|
||||
int p = 1;
|
||||
for (int i = 0; i < numLevels; i++) {
|
||||
if (i == 7) {
|
||||
continue;
|
||||
}
|
||||
if (thresholds[i] instanceof Float) {
|
||||
pixel.add(p);
|
||||
real.add((Float) thresholds[i]);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < numLevels; i++) {
|
||||
if (thresholds[i] instanceof Float) {
|
||||
if (real.contains(thresholds[i])) {
|
||||
// Try to determine if we can treat one of these
|
||||
// different
|
||||
Float fVal = (Float) thresholds[i];
|
||||
Integer prevI = pixel.get(real
|
||||
.indexOf(thresholds[i]));
|
||||
DataLevelThreshold prevThresh = new DataLevelThreshold(
|
||||
getThreshold(prevI));
|
||||
DataLevelThreshold currThresh = new DataLevelThreshold(
|
||||
getThreshold(i));
|
||||
if (prevThresh.isLessThan()
|
||||
|| prevThresh.isGtrThan()) {
|
||||
if (prevThresh.isLessThan()) {
|
||||
getDecodedThresholds()[prevI] = "<"
|
||||
+ fVal.intValue();
|
||||
} else {
|
||||
getDecodedThresholds()[prevI] = ">"
|
||||
+ fVal.intValue();
|
||||
}
|
||||
real.remove(fVal);
|
||||
real.add(fVal);
|
||||
pixel.remove(prevI);
|
||||
pixel.add(i);
|
||||
continue;
|
||||
} else if (currThresh.isLessThan()) {
|
||||
getDecodedThresholds()[i] = "<"
|
||||
+ fVal.intValue();
|
||||
continue;
|
||||
} else if (currThresh.isGtrThan()) {
|
||||
getDecodedThresholds()[i] = ">"
|
||||
+ fVal.intValue();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
pixel.add(i);
|
||||
real.add((Float) thresholds[i]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pixel.size() == 0) {
|
||||
return getUnitObject();
|
||||
}
|
||||
|
||||
double[] pix = new double[pixel.size()];
|
||||
int i = 0;
|
||||
for (Integer p : pixel) {
|
||||
pix[i++] = p;
|
||||
}
|
||||
|
||||
double[] std = new double[real.size()];
|
||||
|
||||
boolean allZeroes = true;
|
||||
|
||||
i = 0;
|
||||
for (Float r : real) {
|
||||
allZeroes = allZeroes && (r == 0);
|
||||
std[i++] = r;
|
||||
}
|
||||
if (allZeroes) {
|
||||
// allZeroes is not a valid unit and is basically disgarded,
|
||||
// this check is done for CFC
|
||||
rval = getUnitObject();
|
||||
} else {
|
||||
rval = new PiecewisePixel(getUnitObject(), pix, std);
|
||||
}
|
||||
} else if (getProductCode() == 134) {
|
||||
// Digital Vil is all messy in the spec.
|
||||
rval = new DigitalVilUnit(getThresholds());
|
||||
} else if (getThreshold(5) == 0) {
|
||||
// The offset and scale are set as ints
|
||||
double offset = getThreshold(0);
|
||||
double scale = getThreshold(1);
|
||||
int nLevels = getThreshold(2);
|
||||
// I believe all products have at least one flag value and DHR is
|
||||
// reporting 256 levels
|
||||
if (nLevels > 255) {
|
||||
nLevels = 255;
|
||||
}
|
||||
double[] pix = { 256 - nLevels, 255 };
|
||||
if (getProductCode() == 155) {
|
||||
pix = new double[] { 129, 149 };
|
||||
}
|
||||
|
||||
double[] data = { offset, offset + (nLevels - 1) * scale };
|
||||
rval = new PiecewisePixel(getUnitObject(), pix, data);
|
||||
|
||||
} else {
|
||||
// The offset and scale are set as floats
|
||||
double scale = Float.intBitsToFloat((getThreshold(0) << 16)
|
||||
+ getThreshold(1));
|
||||
if (scale == 0.0) {
|
||||
// 0.0 is sometimes used by HC and leads to a massively invalid
|
||||
// data range.
|
||||
scale = 1.0;
|
||||
}
|
||||
double offset = Float.intBitsToFloat((getThreshold(2) << 16)
|
||||
+ getThreshold(3));
|
||||
int nLevels = getThreshold(5);
|
||||
if (nLevels < 0) {
|
||||
// Only for DPR, the 65536 can't be encoded in a short
|
||||
nLevels = getNumLevels();
|
||||
}
|
||||
int nFlags = getThreshold(6);
|
||||
|
||||
double[] pix = { nFlags, nLevels };
|
||||
double[] data = { (nFlags - offset) / scale,
|
||||
(nLevels - offset) / scale };
|
||||
|
||||
rval = new PiecewisePixel(getUnitObject(), pix, data);
|
||||
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unit
|
||||
* the unit to set
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.raytheon.viz.radar.units;
|
||||
package com.raytheon.uf.common.dataplugin.radar.units;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.quantity.Quantity;
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* 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.dataplugin.radar.units;
|
||||
|
||||
import javax.measure.unit.BaseUnit;
|
||||
import javax.measure.unit.NonSI;
|
||||
import javax.measure.unit.SI;
|
||||
import javax.measure.unit.Unit;
|
||||
import javax.measure.unit.UnitFormat;
|
||||
|
||||
import com.raytheon.uf.common.image.units.PiecewisePixel;
|
||||
|
||||
|
||||
/**
|
||||
* RadarUnits: Defines a set of radar unit conversions
|
||||
*
|
||||
* Sample Usage (Convert velocity 2x resolution pixel to m/s):
|
||||
*
|
||||
* <PRE>
|
||||
* Unit<?> u1 = RadarUnits.VELOCITY_PIXEL_2X;
|
||||
*
|
||||
* Unit<?> u2 = SI.METER_PER_SECOND;
|
||||
*
|
||||
* UnitConverter uConv = u1.getConverterTo(u2);
|
||||
*
|
||||
* double inMs = uConv.convert(32.0);
|
||||
*
|
||||
* </PRE>
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 26, 2007 chammack Initial Creation.
|
||||
* Oct 09, 2007 465 randerso Updated to better support level 3
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1
|
||||
*/
|
||||
public class RadarUnits {
|
||||
|
||||
public static final BaseUnit<Reflectivity> DBZ = new BaseUnit<Reflectivity>(
|
||||
"dBZ");
|
||||
|
||||
public static final Unit<Reflectivity> REFLECTIVITY_PIXEL = new PiecewisePixel<Reflectivity>(
|
||||
RadarUnits.DBZ, new double[] { 16, 33, 240, 255 }, new double[] {
|
||||
-32.5, -20.0, 75.0, 94.5 });
|
||||
|
||||
public static boolean register() {
|
||||
UnitFormat.getUCUMInstance().label(RadarUnits.DBZ, "dBZ");
|
||||
UnitFormat.getUCUMInstance().label(SI.KILO(NonSI.FOOT), "kft");
|
||||
UnitFormat.getUCUMInstance().label(NonSI.KNOT, "kts");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.viz.radar.units;
|
||||
package com.raytheon.uf.common.dataplugin.radar.units;
|
||||
|
||||
import javax.measure.quantity.Quantity;
|
||||
import javax.measure.unit.Unit;
|
Loading…
Add table
Reference in a new issue