diff --git a/cave/com.raytheon.viz.satellite/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.satellite/META-INF/MANIFEST.MF index 562f578c2e..3186ca34c3 100644 --- a/cave/com.raytheon.viz.satellite/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.satellite/META-INF/MANIFEST.MF @@ -25,7 +25,10 @@ Require-Bundle: org.eclipse.ui, com.raytheon.viz.core, javax.measure, com.raytheon.uf.common.inventory;bundle-version="1.14.0", - com.raytheon.uf.viz.datacube;bundle-version="1.14.0" + com.raytheon.uf.viz.datacube;bundle-version="1.14.0", + com.raytheon.uf.common.dataplugin.level, + com.raytheon.uf.common.comm, + com.raytheon.uf.common.numeric Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.viz.satellite, com.raytheon.viz.satellite.rsc diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedCONUSSatellite.xml b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedCONUSSatellite.xml index 27a695d178..d9cae0ae54 100644 --- a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedCONUSSatellite.xml +++ b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedCONUSSatellite.xml @@ -1,77 +1,98 @@ + + - - - + + + - - - - - - - - PLAIN_VIEW - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedCompositeSatellite.xml b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedCompositeSatellite.xml index a55bb63544..534324c306 100644 --- a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedCompositeSatellite.xml +++ b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedCompositeSatellite.xml @@ -1,21 +1,39 @@ + + - + - + - + - + - - - - + - + - + - - - - - + + - - - @@ -82,21 +88,14 @@ - - + - + - - - - - + + - - - - + - - + - + - - - - - + + - - - - - - - - + + - - - @@ -198,20 +175,13 @@ - - + - + - - - - + - - - diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedPOESSatellite.xml b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedPOESSatellite.xml index 7c19d6c02e..05edbd0a20 100644 --- a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedPOESSatellite.xml +++ b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedPOESSatellite.xml @@ -1,37 +1,53 @@ - + + - - - - - - - - - PLAN_VIEW - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + - - - - - - - + + + + + + + + + diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedSatellite.xml b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedSatellite.xml index 5898a9cc83..a528bcdec7 100644 --- a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedSatellite.xml +++ b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedSatellite.xml @@ -1,43 +1,61 @@ - + + - - - - - - - - - - - - PLAN_VIEW - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + + - - - - - - - + + + + + + + + + + + + diff --git a/cave/com.raytheon.viz.satellite/plugin.xml b/cave/com.raytheon.viz.satellite/plugin.xml index c7d3cc2bce..f917820dcd 100644 --- a/cave/com.raytheon.viz.satellite/plugin.xml +++ b/cave/com.raytheon.viz.satellite/plugin.xml @@ -55,4 +55,11 @@ itemProvider="com.raytheon.viz.satellite.menu.SatBundleMenuContribution"> + + + + diff --git a/cave/com.raytheon.viz.satellite/res/spring/satellite-datacube-spring.xml b/cave/com.raytheon.viz.satellite/res/spring/satellite-datacube-spring.xml index 37c16e1f3f..ce81af56b0 100644 --- a/cave/com.raytheon.viz.satellite/res/spring/satellite-datacube-spring.xml +++ b/cave/com.raytheon.viz.satellite/res/spring/satellite-datacube-spring.xml @@ -2,7 +2,7 @@ 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-3.1.xsd"> - + - * - * SOFTWARE HISTORY - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Jul 27, 2009 jsanchez Initial creation - * Nov 21, 2009 3576 rjpeter Refactored use of DerivParamDesc. - * Aug 03, 2012 798 jkorman Explicitly set interpolationLevels from - * "source" record. - * Apr 08, 2013 1293 bkowal Removed references to hdffileid. - * Jun 04, 2013 2041 bsteffen Switch derived parameters to use - * concurrent python for threading. - * Sep 9, 2013 2277 mschenke Got rid of ScriptCreator references - * - * - * @author jsanchez - * @version 1.0 - */ - -public class SatelliteDataCubeAdapter extends DefaultDataCubeAdapter { - - private static final String PE = "physicalElement"; - - public static final String DERIVED = "DERIVED"; - - private Map derParLibrary; - - /** - * @param pluginName - */ - public SatelliteDataCubeAdapter() { - super(SatelliteRecord.PLUGIN_ID); - } - - @Override - public PluginDataObject[] getData( - Map constraints, DataTime[] selectedTimes) - throws DataCubeException { - Map originalQuery = constraints; - if (originalQuery.containsKey(DERIVED) == false) { - return super.getData(originalQuery, selectedTimes); - } - - String requestedParam; - List initResponses = new ArrayList(); - List listOfRequests = new ArrayList(); - Map modifiedQuery = new HashMap( - originalQuery); - modifiedQuery.remove(DERIVED); - modifiedQuery.remove(PE); - - if (!originalQuery.containsKey(PE) - || !originalQuery.containsKey("pluginName")) { - throw new DataCubeException("getData method requires more query " - + "information for plugin : " - + originalQuery.get("pluginName").getConstraintValue()); - } else { - String[] physicalElements = originalQuery.get(PE) - .getConstraintValue().split(","); - requestedParam = physicalElements[physicalElements.length - 1]; - } - - List baseParams; - try { - baseParams = new ArrayList(Arrays.asList(CatalogQuery - .performQuery(PE, modifiedQuery))); - } catch (VizException e) { - throw new DataCubeException(e); - } - - if (!baseParams.contains(requestedParam) - && derParLibrary.containsKey(requestedParam)) { - DerivParamDesc desc = derParLibrary.get(requestedParam); - DerivParamMethod method = desc.getMethods().get(0); - boolean requestInitialized = false; - - for (IDerivParamField ifield : method.getFields()) { - DerivParamField field = (DerivParamField) ifield; - Map query = modifyQuery( - modifiedQuery, field); - - PluginDataObject[] pdos = super.getData(query, selectedTimes); - for (PluginDataObject pdo : pdos) { - SatelliteRecord record = (SatelliteRecord) pdo; - if (requestInitialized) { - for (DerivedParameterRequest definedRequest : listOfRequests) { - if (record.getDataTime().compareTo( - definedRequest.getBaseTime()) != 0) { - continue; - } - definedRequest.addBaseParam(record); - break; - } - } else { - DerivedParameterRequest request = new DerivedParameterRequest(); - request.setParameterAbbreviation(requestedParam); - request.setMethod(method.getName()); - request.addBaseParam(record); - request.setBaseTime(record.getDataTime()); - listOfRequests.add(request); - SatelliteRecord derivedRecord = new SatelliteRecord( - record.getDataURI()); - // Make sure to get the number of interpolation levels! - derivedRecord.setInterpolationLevels(record - .getInterpolationLevels()); - - derivedRecord.setPhysicalElement(originalQuery.get(PE) - .getConstraintValue()); - derivedRecord.setMessageData(request); - derivedRecord.setCoverage(record.getCoverage()); - // Reset dataURI after setting fields - derivedRecord.setDataURI(null); - - initResponses.add(derivedRecord); - } - } - requestInitialized = true; - } - for (int i = 0; i < initResponses.size(); i++) { - Object satObject = initResponses.get(i); - SatelliteRecord record = (SatelliteRecord) satObject; - DerivedParameterRequest currentRequest = (DerivedParameterRequest) record - .getMessageData(); - if (currentRequest.getBaseParams().size() != method.getFields() - .size()) { - if (initResponses.remove(satObject)) { - i--; - } - } - } - return initResponses.toArray(new PluginDataObject[0]); - } else { - return super.getData(originalQuery, selectedTimes); - } - } - - @Override - public IDataRecord[] getRecord(PluginDataObject obj) - throws DataCubeException { - if (obj.getMessageData() == null) { - return super.getRecord(obj); - } - - return null; - } - - @Override - public IDataRecord[] getRecord(PluginDataObject obj, Request req, - String dataset) throws DataCubeException { - if (obj.getMessageData() == null) { - return super.getRecord(obj, req, dataset); - } - - boolean interpolate = false; - int targetWidth = 0; - int targetHeight = 0; - ArrayList hdf5Files = new ArrayList(); - ArrayList datasets = new ArrayList(); - ArrayList records = new ArrayList(); - ArrayList bytes = new ArrayList(); - DerivedParameterRequest derivedRequest = (DerivedParameterRequest) obj - .getMessageData(); - // clone the request in case of multiple threads. - derivedRequest = new DerivedParameterRequest(derivedRequest); - for (Object param : derivedRequest.getBaseParams()) { - records.add((SatelliteRecord) param); - hdf5Files.add(HDF5Util.findHDF5Location((SatelliteRecord) param)); - datasets.add(getDataset(((SatelliteRecord) param).getDataURI(), - dataset)); - } - - int largestRecIdx = 0; - /* - * Need to update to take into account if more than 2 sat records are - * used in derived parameter - */ - GridGeometry2D geo = null; - if (!records.get(0).getCoverage().getNx() - .equals(records.get(1).getCoverage().getNx()) - || !records.get(0).getCoverage().getNy() - .equals(records.get(1).getCoverage().getNy())) { - interpolate = true; - SatMapCoverage coverage = records.get(largestRecIdx).getCoverage(); - geo = coverage.getGridGeometry(); - targetWidth = coverage.getNx(); - targetHeight = coverage.getNy(); - } - - try { - int i = 0; - for (File file : hdf5Files) { - IDataStore ds = DataStoreFactory.getDataStore(file); - IDataRecord rec = null; - if (interpolate && i != largestRecIdx) { - if (obj.getRecord() == null) { - rec = ds.retrieve("", datasets.get(i), Request.ALL); - int w = (int) ((ByteDataRecord) rec).getSizes()[0]; - int h = (int) ((ByteDataRecord) rec).getSizes()[1]; - obj.setRecord(interpolate((ByteDataRecord) rec, w, h, - targetWidth, targetHeight, geo)); - } - // cut out the tiles from that interpolated dataset - // and make an image from just that small subset - ByteDataRecord bdr = cutTile( - (ByteDataRecord) obj.getRecord(), req); - bytes.add(bdr); - } else { - rec = ds.retrieve("", datasets.get(i), req); - bytes.add((ByteDataRecord) rec); - } - - i++; - } - } catch (Exception e) { - throw new DataCubeException("Error in Satellite Data Cube", e); - } - - derivedRequest.setArgumentRecords(bytes.toArray(new Object[] {})); - List finalResult; - try { - finalResult = DerivedParameterGenerator.calculate(derivedRequest); - } catch (ExecutionException e) { - throw new DataCubeException(e); - } - - if (finalResult != null && finalResult.size() == 1) { - return new IDataRecord[] { ((ByteDataRecord) finalResult.get(0)) }; - } - return null; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecords(java - * .util.List, com.raytheon.uf.common.datastorage.Request, java.lang.String) - */ - @Override - public void getRecords(List objs, Request req, - String dataset) throws DataCubeException { - for (PluginDataObject obj : objs) { - IDataRecord[] records = getRecord(obj, req, dataset); - obj.setMessageData(records); - } - } - - @Override - public void initInventory() { - derParLibrary = DerivedParameterGenerator.getDerParLibrary(); - } - - private String getDataset(String dataUri, String dataset) { - return "/" + dataUri + "/" + dataset; - } - - private ByteDataRecord interpolate(ByteDataRecord bdr, int width, - int height, int targetWidth, int targetHeight, GridGeometry2D geo) { - int[] nBits = new int[] { 8 }; - GridCoverageFactory factory = new GridCoverageFactory(); - ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY); - ColorModel cm = new ComponentColorModel(cs, nBits, false, true, - Transparency.OPAQUE, DataBuffer.TYPE_BYTE); - DataBufferByte data = new DataBufferByte(bdr.getByteData(), height - * width); - SampleModel sm = cm.createCompatibleSampleModel(width, height); - WritableRaster writeRaster = WritableRaster.createWritableRaster(sm, - data, null); - - // Create the coverage for the image - GridCoverage2D gc = factory - .create("in", writeRaster, geo.getEnvelope()); - GridCoverage2D projected = MapUtil.reprojectCoverage(gc, - geo.getCoordinateReferenceSystem(), geo, - Interpolation.getInstance(Interpolation.INTERP_NEAREST)); - - Raster currSatRaster = projected.getRenderedImage().getData(); - byte[] currSat = ((DataBufferByte) currSatRaster.getDataBuffer()) - .getData(); - - long newSizes[] = { (long) targetWidth, (long) targetHeight }; - - ByteDataRecord rval = new ByteDataRecord(bdr.getName(), bdr.getGroup(), - currSat, bdr.getDimension(), newSizes); - return rval; - } - - private ByteDataRecord cutTile(ByteDataRecord bdr, Request req) { - int minTileX = req.getMinIndexForSlab()[0]; - int minTileY = req.getMinIndexForSlab()[1]; - int maxTileX = req.getMaxIndexForSlab()[0]; - int maxTileY = req.getMaxIndexForSlab()[1]; - int widthOfWholeImage = (int) bdr.getSizes()[0]; - int newWidth = maxTileX - minTileX; - int newHeight = maxTileY - minTileY; - long newSizes[] = { (long) newWidth, (long) newHeight }; - - byte bytes[] = bdr.getByteData(); - byte newBytes[] = new byte[newHeight * newWidth]; - - int index = 0; - for (int j = minTileY; j < maxTileY; j++) { - for (int i = minTileX; i < maxTileX; i++) { - newBytes[index++] = bytes[j * widthOfWholeImage + i]; - - } - } - - ByteDataRecord rval = new ByteDataRecord(bdr.getName(), bdr.getGroup(), - newBytes, bdr.getDimension(), newSizes); - return rval; - } - - private static String getPhysicalElement(DerivParamField field) { - return field.getParam().replace("_", " ").replace("pp", ".") - .replace("oo", "(").replace("cc", ")").replace("hh", "-"); - } - - @Override - public List> getBaseUpdateConstraints( - Map constraints) { - if (constraints.containsKey(DERIVED)) { - - constraints = new HashMap(constraints); - constraints.remove(DERIVED); - RequestConstraint pe = constraints.remove(PE); - DerivParamDesc desc = derParLibrary.get(pe.getConstraintValue()); - DerivParamMethod method = desc.getMethods().get(0); - - pe = new RequestConstraint(null, ConstraintType.IN); - - for (IDerivParamField ifield : method.getFields()) { - DerivParamField field = (DerivParamField) ifield; - pe.addToConstraintValueList(getPhysicalElement(field)); - } - constraints.put(PE, pe); - } - return super.getBaseUpdateConstraints(constraints); - } - - @Override - public List> timeQuery(List requests) - throws DataCubeException { - Map derivedRequests = new HashMap(); - List baseRequests = new ArrayList( - requests.size()); - for (TimeQueryRequest request : requests) { - if (!request.getQueryTerms().containsKey("DERIVED")) { - baseRequests.add(request); - } else { - List derived = getDerivedRequests(request, - request.getBinOffset()); - derivedRequests.put(request, derived.size()); - baseRequests.addAll(derived); - // TODO it might be possible to merge the derived requests that - // have dependencies that are the same as some of the non - // derived requests to avoid hitting the db twice. - } - } - TimeQueryRequestSet set = new TimeQueryRequestSet(); - set.setRequests(baseRequests.toArray(new TimeQueryRequest[0])); - List> baseResults; - try { - baseResults = (List>) ThriftClient.sendRequest(set); - } catch (VizException e) { - throw new DataCubeException(e); - } - List> results = new ArrayList>( - requests.size()); - int baseIndex = 0; - for (TimeQueryRequest request : requests) { - if (derivedRequests.containsKey(request)) { - int size = derivedRequests.get(request); - List timeList = new ArrayList(); - for (int i = 0; i < size; i++) { - List derived = baseResults.get(baseIndex); - if (derived != null && !derived.isEmpty() - && timeList.size() == 0) { - timeList.addAll(derived); - } else if (derived != null && !derived.isEmpty() - && timeList.size() > 0) { - ArrayList newTimeList = new ArrayList(); - for (DataTime result : derived) { - for (DataTime check : timeList) { - if (check.equals(result)) { - newTimeList.add(result); - continue; - } - } - } - timeList = newTimeList; - } else if ((derived == null || derived.isEmpty()) - && timeList.size() > 0) { - timeList.clear(); - } - baseIndex += 1; - } - if (request.isMaxQuery() && !timeList.isEmpty()) { - Collections.sort(timeList); - results.add(Arrays.asList(timeList.get(timeList.size() - 1))); - } else { - results.add(timeList); - } - } else { - results.add(baseResults.get(baseIndex)); - baseIndex += 1; - } - - } - return results; - } - - private List getDerivedRequests(TimeQueryRequest request, - BinOffset binOffset) { - List result = new ArrayList(2); - Map queryParams = new HashMap( - request.getQueryTerms()); - String plugin = queryParams.get("pluginName").getConstraintValue(); - String param = queryParams.get(PE).getConstraintValue(); - if (plugin.matches("satellite") && derParLibrary.containsKey(param)) { - DerivParamDesc derParDesc = derParLibrary.get(param); - DerivParamMethod method = derParDesc.getMethods().get(0); - // We have a derived parameter for the requested grid - for (IDerivParamField ifield : method.getFields()) { - DerivParamField field = (DerivParamField) ifield; - TimeQueryRequest newRequest = new TimeQueryRequest(); - newRequest.setBinOffset(binOffset); - newRequest.setMaxQuery(false); - newRequest.setQueryTerms(modifyQuery(queryParams, field)); - newRequest.setPluginName("satellite"); - result.add(newRequest); - } - } - return result; - } - - private Map modifyQuery( - Map originalQuery, DerivParamField field) { - HashMap query = new HashMap( - originalQuery); - String paramAbb = getPhysicalElement(field); - query.put(PE, new RequestConstraint(paramAbb, - RequestConstraint.ConstraintType.EQUALS)); - query.remove(DERIVED); - - return query; - } -} diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/ComparableSatMapCoverage.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/ComparableSatMapCoverage.java new file mode 100644 index 0000000000..6a92d705dc --- /dev/null +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/ComparableSatMapCoverage.java @@ -0,0 +1,132 @@ +/** + * 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.satellite.inventory; + +import org.geotools.coverage.grid.GridEnvelope2D; +import org.geotools.coverage.grid.GridGeometry2D; +import org.geotools.geometry.Envelope2D; +import org.opengis.geometry.BoundingBox; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +import com.raytheon.uf.common.dataplugin.satellite.SatMapCoverage; +import com.raytheon.uf.common.geospatial.IGridGeometryProvider; +import com.raytheon.uf.common.inventory.IGridGeometryProviderComparable; + +/** + * A wrapper around {@link SatMapCoverage} that can be compared with other + * satellite coverages for derived parameters to be able to calculate between + * data at different resolution. It currently always chooses the higher + * resolutioon coverage when doing comparisons. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Apr 11, 2014  2947     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public class ComparableSatMapCoverage implements + IGridGeometryProviderComparable { + + private final SatMapCoverage coverage; + + + public ComparableSatMapCoverage(SatMapCoverage coverage) { + this.coverage = coverage; + } + + @Override + public GridGeometry2D getGridGeometry() { + return coverage.getGridGeometry(); + } + + @Override + public IGridGeometryProvider compare(IGridGeometryProvider other) { + if (other instanceof ComparableSatMapCoverage) { + ComparableSatMapCoverage otherCoverage = (ComparableSatMapCoverage) other; + if (otherCoverage.getCRS().equals(getCRS()) + && otherCoverage.getBoundingBox().intersects( + getBoundingBox())){ + if(getResolution() > otherCoverage.getResolution()){ + return this; + }else{ + return other; + } + } + } + return null; + } + + public SatMapCoverage getCoverage() { + return coverage; + } + + protected CoordinateReferenceSystem getCRS() { + return coverage.getGridGeometry().getCoordinateReferenceSystem(); + } + + protected BoundingBox getBoundingBox() { + return coverage.getGridGeometry().getEnvelope2D(); + } + + /** + * @return the resolution of the grid represented by this coverage in + * pixel/(m²). + */ + protected double getResolution() { + GridGeometry2D gg = coverage.getGridGeometry(); + Envelope2D e = gg.getEnvelope2D(); + GridEnvelope2D r = gg.getGridRange2D(); + return (r.width * r.height) / (e.width * e.height); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((coverage == null) ? 0 : coverage.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ComparableSatMapCoverage other = (ComparableSatMapCoverage) obj; + if (coverage == null) { + if (other.coverage != null) + return false; + } else if (!coverage.equals(other.coverage)) + return false; + return true; + } + +} diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/DerivedSatelliteRecord.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/DerivedSatelliteRecord.java new file mode 100644 index 0000000000..185de0e49b --- /dev/null +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/DerivedSatelliteRecord.java @@ -0,0 +1,164 @@ +/** + * 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.satellite.inventory; + +import java.awt.Rectangle; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import javax.measure.unit.UnitFormat; + +import org.geotools.coverage.grid.GridEnvelope2D; +import org.geotools.coverage.grid.GridGeometry2D; +import org.opengis.geometry.Envelope; +import org.opengis.referencing.operation.TransformException; + +import com.raytheon.uf.common.dataplugin.satellite.SatMapCoverage; +import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord; +import com.raytheon.uf.common.datastorage.DataStoreFactory; +import com.raytheon.uf.common.datastorage.Request; +import com.raytheon.uf.common.geospatial.interpolation.GridDownscaler; +import com.raytheon.uf.common.inventory.data.AbstractRequestableData; +import com.raytheon.uf.common.inventory.exception.DataCubeException; + +/** + * Satellite record which performs derived parameter calculations to get data + * instead of requesting directly from hdf5. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Apr 09, 2014  2947     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ + +public class DerivedSatelliteRecord extends SatelliteRecord { + + private static final long serialVersionUID = 1L; + + private final AbstractRequestableData requestableData; + + public DerivedSatelliteRecord(AbstractRequestableData requestableData) + throws DataCubeException { + this.requestableData = requestableData; + setDataTime(requestableData.getDataTime()); + setPhysicalElement(requestableData.getParameter()); + setSectorID(requestableData.getSource()); + setUnits(UnitFormat.getUCUMInstance().format(requestableData.getUnit())); + + Set base = findBaseRecords(requestableData); + Set creatingEntities = new HashSet(); + int interpolationLevels = 1; + for (SatelliteRecord record : base) { + creatingEntities.add(record.getCreatingEntity()); + interpolationLevels = Math.max(interpolationLevels, + record.getInterpolationLevels()); + } + setInterpolationLevels(interpolationLevels); + if (creatingEntities.size() == 1) { + setCreatingEntity(creatingEntities.iterator().next()); + } else { + throw new DataCubeException("Too many creating entities: " + + creatingEntities); + } + if (requestableData.getSpace() instanceof SatMapCoverage) { + setCoverage((SatMapCoverage) requestableData.getSpace()); + } else if (requestableData.getSpace() instanceof ComparableSatMapCoverage) { + setCoverage(((ComparableSatMapCoverage) requestableData.getSpace()) + .getCoverage()); + } + } + + /** + * Perform the necessary calculations to get data that matches the provided + * request and dataset and store the result in the messageData field. + * + * @param req + * a {@link Request} specifying the amount of data to return + * @param dataset + * indicates the interpolation level to deriv, uses the same + * naming convention as raw satellite data. + * @throws DataCubeException + */ + public void deriveMessageData(Request req, String dataset) + throws DataCubeException { + Rectangle[] levels = GridDownscaler + .getDownscaleSizes(getGridGeometry()); + int level; + for (level = 0; level < levels.length; ++level) { + if (DataStoreFactory.createDataSetName(null, + SatelliteRecord.SAT_DATASET_NAME, level).equals( + dataset)) { + break; + } + } + if (level >= levels.length) { + throw new DataCubeException("Unrecognized dataset: " + dataset); + } + GridGeometry2D gridGeometry = new GridGeometry2D(new GridEnvelope2D( + levels[level]), getGridGeometry().getEnvelope()); + if (req.getType() == Request.Type.SLAB) { + int[] min = req.getMinIndexForSlab(); + int[] max = req.getMaxIndexForSlab(); + GridEnvelope2D range = new GridEnvelope2D(min[0], min[1], max[0] + - min[0], max[1] - min[1]); + Envelope env; + try { + env = gridGeometry.gridToWorld(range); + } catch (TransformException e) { + throw new DataCubeException(e); + } + gridGeometry = new GridGeometry2D(range, env); + } else if (req.getType() != Request.Type.ALL) { + throw new DataCubeException( + "Unsupported request type for derived satellite data: " + + req.getType()); + } + Object dataValue = requestableData.getDataValue(gridGeometry); + setMessageData(dataValue); + } + + private static Set findBaseRecords( + AbstractRequestableData data) { + if (data instanceof SatelliteRequestableData) { + SatelliteRequestableData srd = (SatelliteRequestableData) data; + return Collections.singleton(srd.getRecord()); + } else { + Set entities = new HashSet(); + for (AbstractRequestableData dep : data.getDependencies()) { + entities.addAll(findBaseRecords(dep)); + } + return entities; + } + } + + public String getName() { + return requestableData.getParameterName(); + } + +} diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteCoverageCache.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteCoverageCache.java new file mode 100644 index 0000000000..2dd0828386 --- /dev/null +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteCoverageCache.java @@ -0,0 +1,100 @@ +/** + * 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.satellite.inventory; + +import java.util.HashMap; +import java.util.Map; + +import com.raytheon.uf.common.dataplugin.satellite.SatMapCoverage; +import com.raytheon.uf.common.dataquery.requests.DbQueryRequest; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.raytheon.uf.common.dataquery.responses.DbQueryResponse; +import com.raytheon.uf.common.inventory.exception.DataCubeException; +import com.raytheon.uf.common.serialization.comm.RequestRouter; + +/** + * A cache of {@link SatMapCoverage} based off the gid field. This cache can be + * used to some types of satellite queries that need the SatMapCoverage because + * the query can only request the gid field and then load the full coverage from + * cache. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Apr 09, 2014  2947     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ + +public class SatelliteCoverageCache { + + private static final String GID = "gid"; + + /** + * Map containing cached coverages, all access to this map must be + * syncronized. + */ + private final Map cache = new HashMap(); + + public SatelliteCoverageCache() throws DataCubeException { + /* Prepopulate the cache. */ + DbQueryRequest request = new DbQueryRequest(); + request.setEntityClass(SatMapCoverage.class); + handleRequest(request); + } + + public SatMapCoverage get(int gid) throws DataCubeException { + synchronized (cache) { + SatMapCoverage result = cache.get(gid); + if (result == null) { + DbQueryRequest request = new DbQueryRequest(); + request.setEntityClass(SatMapCoverage.class); + request.addConstraint(GID, + new RequestConstraint(Integer.toString(gid))); + handleRequest(request); + result = cache.get(gid); + } + return result; + } + } + + private void handleRequest(DbQueryRequest request) throws DataCubeException { + DbQueryResponse response; + try { + response = (DbQueryResponse) RequestRouter.route(request); + } catch (Exception e) { + throw new DataCubeException(e); + } + SatMapCoverage[] coverages = response + .getEntityObjects(SatMapCoverage.class); + synchronized (cache) { + for (SatMapCoverage coverage : coverages) { + cache.put(coverage.getGid(), coverage); + } + } + } + +} diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteDataCubeAdapter.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteDataCubeAdapter.java new file mode 100644 index 0000000000..70479bb37d --- /dev/null +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteDataCubeAdapter.java @@ -0,0 +1,178 @@ +/** + * 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.satellite.inventory; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.raytheon.uf.common.datastorage.Request; +import com.raytheon.uf.common.derivparam.library.DerivedParameterGenerator; +import com.raytheon.uf.common.derivparam.tree.AbstractDerivedDataNode; +import com.raytheon.uf.common.inventory.data.AbstractRequestableData; +import com.raytheon.uf.common.inventory.exception.DataCubeException; +import com.raytheon.uf.common.inventory.tree.AbstractRequestableNode; +import com.raytheon.uf.common.inventory.tree.AbstractRequestableNode.Dependency; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.viz.datacube.AbstractDataCubeAdapter; + +/** + * DataCubeAdapter for satellite + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Apr 09, 2014  2947     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ + +public class SatelliteDataCubeAdapter extends AbstractDataCubeAdapter { + + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(SatelliteDataCubeAdapter.class); + + /** + * @deprecated This used to be a required key in derived request constraints + * but is no longer necessary + */ + @Deprecated + public static final String DERIVED = "DERIVED"; + + private SatelliteInventory inventory; + + public SatelliteDataCubeAdapter() { + super(new String[] { SatelliteInventory.SATELLITE }); + } + + @Override + public void initInventory() { + if (inventory == null) { + try { + SatelliteInventory inventory = new SatelliteInventory(); + inventory + .initTree(DerivedParameterGenerator.getDerParLibrary()); + this.inventory = inventory; + } catch (Exception e) { + statusHandler.handle(Priority.PROBLEM, + e.getLocalizedMessage(), e); + } + } + } + + @Override + public Object getInventory() { + return inventory; + } + + @Override + protected List evaluateRequestConstraints( + Map constraints) { + return inventory.evaluateRequestConstraints(constraints); + } + + @Override + protected List timeAgnosticQuery( + Map queryTerms) throws DataCubeException { + return inventory.timeAgnosticQuery(queryTerms); + } + + @Override + protected List getData( + Map constraints, + DataTime[] selectedTimes, List requesters) + throws DataCubeException { + List results = new ArrayList( + requesters.size()); + for (AbstractRequestableData requester : requesters) { + if(requester instanceof SatelliteRequestableData){ + results.add(((SatelliteRequestableData) requester).getRecord()); + } else { + results.add(new DerivedSatelliteRecord(requester)); + } + } + return results; + } + + @Override + public void getRecords(List objs, Request req, + String dataset) throws DataCubeException { + List simpleRecords = new ArrayList( + objs.size()); + for (PluginDataObject obj : objs) { + if (obj instanceof DerivedSatelliteRecord) { + ((DerivedSatelliteRecord) obj).deriveMessageData(req, dataset); + } else if (obj instanceof SatelliteRecord) { + simpleRecords.add(obj); + } else if (obj != null) { + throw new DataCubeException(this.getClass().getSimpleName() + + " cannot get records for a " + + obj.getClass().getSimpleName()); + } + } + if (!simpleRecords.isEmpty()) { + super.getRecords(simpleRecords, req, dataset); + } + } + + @Override + public List> getBaseUpdateConstraints( + Map constraints) { + List nodes = evaluateRequestConstraints(constraints); + List> baseConstraints = new ArrayList>( + nodes.size() * 2); + for (AbstractRequestableNode node : nodes) { + baseConstraints.addAll(getBaseUpdateConstraints(node)); + } + return baseConstraints; + } + + protected List> getBaseUpdateConstraints( + AbstractRequestableNode node) { + if (node instanceof SatelliteRequestableLevelNode) { + SatelliteRequestableLevelNode satNode = (SatelliteRequestableLevelNode) node; + return Collections.singletonList(satNode.getRequestConstraintMap()); + } else if (node instanceof AbstractDerivedDataNode) { + AbstractDerivedDataNode derivedNode = (AbstractDerivedDataNode) node; + List> baseConstraints = new ArrayList>(); + for (Dependency d : derivedNode.getDependencies()) { + baseConstraints.addAll(getBaseUpdateConstraints(d.node)); + } + return baseConstraints; + } + return Collections.emptyList(); + } + + + +} diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteInventory.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteInventory.java new file mode 100644 index 0000000000..6bfda8f9f8 --- /dev/null +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteInventory.java @@ -0,0 +1,229 @@ +/** + * 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.satellite.inventory; + +import java.util.Collection; +import java.util.Collections; +import java.util.Deque; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.raytheon.uf.common.comm.CommunicationException; +import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.level.LevelFactory; +import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord; +import com.raytheon.uf.common.dataquery.requests.DbQueryRequest; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.raytheon.uf.common.dataquery.responses.DbQueryResponse; +import com.raytheon.uf.common.derivparam.inv.AbstractInventory; +import com.raytheon.uf.common.derivparam.library.DerivParamDesc; +import com.raytheon.uf.common.derivparam.library.DerivParamField; +import com.raytheon.uf.common.derivparam.library.DerivParamMethod; +import com.raytheon.uf.common.derivparam.tree.AbstractDerivedDataNode; +import com.raytheon.uf.common.inventory.data.AbstractRequestableData; +import com.raytheon.uf.common.inventory.exception.DataCubeException; +import com.raytheon.uf.common.inventory.tree.AbstractRequestableNode; +import com.raytheon.uf.common.inventory.tree.DataTree; +import com.raytheon.uf.common.inventory.tree.LevelNode; +import com.raytheon.uf.common.inventory.tree.ParameterNode; +import com.raytheon.uf.common.inventory.tree.SourceNode; +import com.raytheon.uf.common.serialization.comm.RequestRouter; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.DataTime; + +/** + * Inventory of available satellite data. sectorID is used for source and + * physicalElement for parameter, the level is always the entire atmosphere. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Apr 09, 2014  2947     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public class SatelliteInventory extends AbstractInventory { + + private static final IUFStatusHandler statusHandler = UFStatus + .getHandler(SatelliteInventory.class); + + public static final String SATELLITE = "satellite"; + + public static final String SECTOR_ID = "sectorID"; + + public static final String PHYSICALELEMENT = "physicalElement"; + + public static final String GID = "coverage.gid"; + + private SatelliteCoverageCache coverages; + + private Level level; + + @Override + public List timeAgnosticQuery(Map query) { + /* Returning null means no data will be time agnostic. */ + return null; + } + + @Override + public synchronized void initTree(Map derParLibrary) + throws DataCubeException { + try { + level = LevelFactory.getInstance().getLevel("EA", 0.0); + } catch (CommunicationException e) { + throw new DataCubeException(e); + } + coverages = new SatelliteCoverageCache(); + super.initTree(derParLibrary); + } + + @Override + protected DataTree createBaseTree() { + DbQueryRequest request = new DbQueryRequest(); + request.setEntityClass(SatelliteRecord.class); + request.setDistinct(true); + request.addRequestField(SECTOR_ID); + request.addRequestField(PHYSICALELEMENT); + + DbQueryResponse response; + try { + response = (DbQueryResponse) RequestRouter.route(request); + } catch (Exception e) { + // TODO Auto-generated catch block. Please revise as appropriate. + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); + return null; + } + + String levelId = Long.toString(level.getId()); + + DataTree tree = new DataTree(); + for (Map result : response.getResults()) { + String sectorID = (String) result.get(SECTOR_ID); + String physicalElement = (String) result.get(PHYSICALELEMENT); + SourceNode sourceNode = tree.getSourceNode(sectorID); + if (sourceNode == null) { + sourceNode = new SourceNode(); + sourceNode.setValue(sectorID); + tree.getSourceNodes().put(sectorID, sourceNode); + } + + ParameterNode paramNode = sourceNode.getChildNode(physicalElement); + if (paramNode == null) { + paramNode = new ParameterNode(); + paramNode.setValue(physicalElement); + paramNode.setParameterName(physicalElement); + sourceNode.addChildNode(paramNode); + } + + LevelNode levelNode = paramNode.getChildNode(levelId); + if (levelNode == null) { + Map requestConstraints = new HashMap(); + requestConstraints.put(SECTOR_ID, new RequestConstraint( + sectorID)); + requestConstraints.put(PHYSICALELEMENT, new RequestConstraint( + physicalElement)); + requestConstraints.put(PluginDataObject.PLUGIN_NAME_ID, + new RequestConstraint(SATELLITE)); + levelNode = new SatelliteRequestableLevelNode(coverages, + requestConstraints); + levelNode.setValue(levelId); + paramNode.addChildNode(levelNode); + } + } + return tree; + } + + @Override + protected LevelNode getCubeNode(SourceNode sNode, DerivParamField field, + Deque stack, Set nodata) { + /* Returning null means cubes is not supported. */ + return null; + } + + @Override + protected AbstractDerivedDataNode getImportNode( + AbstractRequestableData nodeToImport, SourceNode destSourceNode, + DerivParamDesc desc, DerivParamMethod method, Level level) { + /* Returning null means import is not supported. */ + return null; + } + + @Override + protected AbstractDerivedDataNode getImportNode( + AbstractRequestableNode nodeToImport, + String nodeToImportSourceName, SourceNode destSourceNode, + DerivParamDesc desc, DerivParamMethod method, Level level) { + /* Returning null means import is not supported. */ + return null; + } + + @Override + protected Object resolvePluginStaticData(SourceNode sNode, + DerivParamField field, Level level) { + /* Returning null means static data is not supported. */ + return null; + } + + protected List evaluateRequestConstraints( + Map constraints) { + Collection sources = getAllSources(); + RequestConstraint sectorLimiter = constraints.get(SECTOR_ID); + if (sectorLimiter != null) { + Iterator it = sources.iterator(); + while (it.hasNext()) { + if (!sectorLimiter.evaluate(it.next())) { + it.remove(); + } + } + } + Collection parameters = getAllParameters(); + RequestConstraint peLimiter = constraints.get(PHYSICALELEMENT); + if (peLimiter != null) { + Iterator it = parameters.iterator(); + while (it.hasNext()) { + if (!peLimiter.evaluate(it.next())) { + it.remove(); + } + } + } + Collection levels = Collections.singleton(level); + try { + List result = walkTree(null, sources, + parameters, levels, true, true, null); + return result; + } catch (InterruptedException e) { + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); + return Collections.emptyList(); + } + } + +} diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteRequestableData.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteRequestableData.java new file mode 100644 index 0000000000..bf1754d39d --- /dev/null +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteRequestableData.java @@ -0,0 +1,214 @@ +/** + * 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.satellite.inventory; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.Map; + +import javax.measure.unit.Unit; + +import org.geotools.coverage.grid.GridEnvelope2D; +import org.geotools.coverage.grid.GridGeometry2D; +import org.geotools.geometry.Envelope2D; +import org.opengis.coverage.grid.GridEnvelope; +import org.opengis.referencing.FactoryException; +import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.opengis.referencing.operation.TransformException; + +import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord; +import com.raytheon.uf.common.datastorage.DataStoreFactory; +import com.raytheon.uf.common.datastorage.Request; +import com.raytheon.uf.common.datastorage.records.IDataRecord; +import com.raytheon.uf.common.geospatial.interpolation.GridDownscaler; +import com.raytheon.uf.common.geospatial.interpolation.GridReprojection; +import com.raytheon.uf.common.geospatial.interpolation.NearestNeighborInterpolation; +import com.raytheon.uf.common.geospatial.interpolation.PrecomputedGridReprojection; +import com.raytheon.uf.common.geospatial.util.SubGridGeometryCalculator; +import com.raytheon.uf.common.inventory.data.AbstractRequestableData; +import com.raytheon.uf.common.inventory.exception.DataCubeException; +import com.raytheon.uf.common.numeric.buffer.BufferWrapper; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.viz.datacube.CubeUtil; +import com.raytheon.viz.satellite.tileset.SatDataRetriever; + +/** + * Object capable of requesting Satellite data for base or derived displays. Can + * also reproject into different coverages + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Apr 09, 2014  2947     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author mschenke + * @version 1.0 + */ + +public class SatelliteRequestableData extends AbstractRequestableData { + + private final SatelliteRecord record; + + public SatelliteRequestableData(SatelliteRecord record, Level level) { + this.record = record; + this.dataTime = record.getDataTime(); + this.level = level; + this.parameter = record.getPhysicalElement(); + this.parameterName = record.getPhysicalElement(); + this.source = record.getSectorID(); + this.space = new ComparableSatMapCoverage(record.getCoverage()); + } + + public SatelliteRecord getRecord() { + return record; + } + + @Override + public Object getDataValue(Object arg) throws DataCubeException { + if (arg instanceof GridGeometry2D) { + GridGeometry2D requestGeom = (GridGeometry2D) arg; + GridGeometry2D recordGeom = record.getGridGeometry(); + validateCRSMatch(requestGeom, recordGeom); + /* Figure out what level is needed */ + Envelope2D requestEnv = requestGeom.getEnvelope2D(); + GridEnvelope2D requestRange = requestGeom.getGridRange2D(); + double requestDx = requestEnv.width / requestRange.width; + double requestDy = requestEnv.height / requestRange.height; + Envelope2D recordEnv = recordGeom.getEnvelope2D(); + Rectangle[] levels = GridDownscaler.getDownscaleSizes(recordGeom); + int bestLevel = 0; + for (int level = levels.length - 1; level >= 0; level -= 1) { + double levelDx = recordEnv.width / levels[level].width; + double levelDy = recordEnv.height / levels[level].height; + if (levelDx <= requestDx || levelDy <= requestDy) { + bestLevel = Math.max(0, level); + break; + } + } + /* figure out what area of the level is needed. */ + GridGeometry2D levelGeom = new GridGeometry2D( + (GridEnvelope) new GridEnvelope2D(levels[bestLevel]), + recordEnv); + Request request; + SubGridGeometryCalculator subGrid; + try { + subGrid = new SubGridGeometryCalculator(requestEnv, levelGeom); + } catch (TransformException e) { + throw new DataCubeException(e); + } + if (subGrid.isEmpty()) { + /* The SpaceTimeMatcher should prevent this from ever happening */ + throw new DataCubeException( + "Request Area does not intersect data area."); + } else if (subGrid.isFull()) { + request = Request.ALL; + } else { + request = Request.buildSlab(subGrid.getGridRangeLow(true), + subGrid.getGridRangeHigh(false)); + } + String dataset = DataStoreFactory.createDataSetName(null, + SatelliteRecord.SAT_DATASET_NAME, bestLevel); + IDataRecord dataRecord = CubeUtil.retrieveData(record, + record.getPluginName(), request, dataset); + unit = SatDataRetriever.getDataUnit( + SatDataRetriever.getRecordUnit(record), dataRecord); + /* Reproject the data to match the request. */ + GridGeometry2D subGeom = subGrid.getSubGridGeometry2D(); + BufferWrapper source = BufferWrapper.wrapArray( + dataRecord.getDataObject(), subGeom.getGridRange2D().width, + subGeom.getGridRange2D().height); + BufferWrapper dest = BufferWrapper.create( + source.getPrimitiveType(), requestRange.width, + requestRange.height); + try { + GridReprojection reproj = PrecomputedGridReprojection + .getReprojection(subGeom, requestGeom); + reproj.reprojectedGrid(new NearestNeighborInterpolation(), + source, dest); + } catch (TransformException e) { + throw new DataCubeException(e); + } catch (FactoryException e) { + throw new DataCubeException(e); + } + Map attrs = dataRecord.getDataAttributes(); + dataRecord = DataStoreFactory.createStorageRecord( + dataRecord.getName(), dataRecord.getGroup(), + dest.getArray(), 2, new long[] { requestRange.width, + requestRange.height }); + dataRecord.setFillValue(0); + if (attrs != null) { + Number fill = (Number) attrs + .get(SatelliteRecord.SAT_FILL_VALUE); + + if (fill != null) { + dataRecord.setFillValue(fill); + } + } + return dataRecord; + } else { + return CubeUtil.retrieveData(record, record.getPluginName(), + Request.ALL, SatelliteRecord.SAT_DATASET_NAME); + } + } + + private static void validateCRSMatch(GridGeometry2D requestGeom, + GridGeometry2D recordGeom) throws DataCubeException { + CoordinateReferenceSystem requestCRS = requestGeom + .getCoordinateReferenceSystem(); + CoordinateReferenceSystem recordCRS = recordGeom + .getCoordinateReferenceSystem(); + + if (!requestCRS.equals(recordCRS)) { + /* The SpaceTimeMatcher should prevent this from ever happening */ + throw new DataCubeException("Incompatible CRSs\n" + + requestCRS.toWKT() + "\n" + recordCRS.toWKT()); + } + } + + @Override + public Unit getUnit() { + if (this.unit == null) { + /* + * Normally a data request occurs before anything needs the unit so + * this should never happen. + */ + try { + IDataRecord dataRecord = CubeUtil.retrieveData(record, + record.getPluginName(), + Request.buildPointRequest(new Point(0, 0)), + SatelliteRecord.SAT_DATASET_NAME); + unit = SatDataRetriever.getDataUnit( + SatDataRetriever.getRecordUnit(record), dataRecord); + } catch (DataCubeException e) { + UFStatus.getHandler(getClass()).error("Cannot find data unit.", + e); + + } + } + return super.getUnit(); + } + +} diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteRequestableLevelNode.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteRequestableLevelNode.java new file mode 100644 index 0000000000..4aec556449 --- /dev/null +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteRequestableLevelNode.java @@ -0,0 +1,173 @@ +/** + * 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.satellite.inventory; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.dataplugin.satellite.SatMapCoverage; +import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord; +import com.raytheon.uf.common.dataquery.requests.DbQueryRequest; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; +import com.raytheon.uf.common.dataquery.responses.DbQueryResponse; +import com.raytheon.uf.common.derivparam.tree.AbstractBaseDataNode; +import com.raytheon.uf.common.inventory.TimeAndSpace; +import com.raytheon.uf.common.inventory.data.AbstractRequestableData; +import com.raytheon.uf.common.inventory.exception.DataCubeException; +import com.raytheon.uf.common.time.DataTime; + +/** + * + * Satellite Requestable level node + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Apr 09, 2014  2947     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public class SatelliteRequestableLevelNode extends AbstractBaseDataNode { + + private final SatelliteCoverageCache coverages; + + private final Map requestConstraints; + + public SatelliteRequestableLevelNode(SatelliteCoverageCache coverages, + Map requestConstraints) { + this.coverages = coverages; + this.requestConstraints = requestConstraints; + } + + + public Map getRequestConstraintMap() { + return requestConstraints; + } + + protected DbQueryRequest getBaseRequest( + Map originalConstraints) { + Map constraints = new HashMap( + originalConstraints); + constraints.putAll(requestConstraints); + constraints.remove(SatelliteDataCubeAdapter.DERIVED); + DbQueryRequest request = new DbQueryRequest(); + request.setEntityClass(SatelliteRecord.class); + request.setDistinct(true); + request.setConstraints(constraints); + return request; + } + + @Override + public DbQueryRequest getAvailabilityRequest( + Map originalConstraints) { + DbQueryRequest request = getBaseRequest(originalConstraints); + request.addRequestField(PluginDataObject.DATATIME_ID); + request.addRequestField(SatelliteInventory.GID); + return request; + } + + @Override + public DbQueryRequest getDataRequest( + Map originalConstraints, + Set availability) { + DbQueryRequest request = getBaseRequest(originalConstraints); + RequestConstraint timeRc = new RequestConstraint(); + timeRc.setConstraintType(ConstraintType.IN); + for (TimeAndSpace time : availability) { + timeRc.addToConstraintValueList(time.getTime().toString()); + } + request.addConstraint(PluginDataObject.DATATIME_ID, timeRc); + return request; + } + + @Override + public Set getAvailability( + Map originalConstraints, Object response) + throws DataCubeException { + Set result = new HashSet(); + DbQueryResponse dbresponse = (DbQueryResponse) response; + for (Map map : dbresponse.getResults()) { + DataTime time = (DataTime) map.get(PluginDataObject.DATATIME_ID); + int gid = ((Number) map.get(SatelliteInventory.GID)).intValue(); + SatMapCoverage coverage = coverages.get(gid); + result.add(new TimeAndSpace(time, new ComparableSatMapCoverage( + coverage))); + } + return result; + } + + + @Override + public Set getData( + Map orignalConstraints, + Set availability, Object response) + throws DataCubeException { + DbQueryResponse queryResponse = (DbQueryResponse) response; + List> results = queryResponse.getResults(); + Set data = new HashSet( + results.size()); + SatelliteRecord[] records = queryResponse + .getEntityObjects(SatelliteRecord.class); + for (SatelliteRecord record : records) { + data.add(new SatelliteRequestableData(record, getLevel())); + } + return data; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime + * result + + ((requestConstraints == null) ? 0 : requestConstraints + .hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + SatelliteRequestableLevelNode other = (SatelliteRequestableLevelNode) obj; + if (requestConstraints == null) { + if (other.requestConstraints != null) + return false; + } else if (!requestConstraints.equals(other.requestConstraints)) + return false; + return true; + } + +} diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteUnitRegistrar.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteUnitRegistrar.java new file mode 100644 index 0000000000..e1a6287ec2 --- /dev/null +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/inventory/SatelliteUnitRegistrar.java @@ -0,0 +1,49 @@ +/** + * 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.satellite.inventory; + +import com.raytheon.uf.common.dataplugin.satellite.units.SatelliteUnits; +import com.raytheon.viz.core.units.IUnitRegistrar; + +/** + * Register the units used by satellite as part of cave startup. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Apr 15, 2014  2947     bsteffen    Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ +public class SatelliteUnitRegistrar implements IUnitRegistrar { + + @Override + public void register() { + SatelliteUnits.register(); + } + + +} diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBestResResourceData.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBestResResourceData.java index 270bec1fd0..15ee46a043 100644 --- a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBestResResourceData.java +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatBestResResourceData.java @@ -49,7 +49,7 @@ import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.ProgressiveDisclosureProperties; import com.raytheon.uf.viz.core.rsc.ResourceList; -import com.raytheon.viz.satellite.SatelliteDataCubeAdapter; +import com.raytheon.viz.satellite.inventory.SatelliteDataCubeAdapter; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryFactory; diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java index 66e2de9a71..c4eec82abf 100644 --- a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/rsc/SatResource.java @@ -66,8 +66,8 @@ import com.raytheon.uf.viz.core.rsc.AbstractPluginDataObjectResource; import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability; import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability; -import com.raytheon.uf.common.derivparam.library.DerivedParameterRequest; import com.raytheon.viz.satellite.SatelliteConstants; +import com.raytheon.viz.satellite.inventory.DerivedSatelliteRecord; import com.raytheon.viz.satellite.tileset.SatDataRetriever; import com.raytheon.viz.satellite.tileset.SatTileSetRenderable; import com.vividsolutions.jts.geom.Coordinate; @@ -97,6 +97,8 @@ import com.vividsolutions.jts.geom.Coordinate; * interrogation * Nov 20, 2013 2492 bsteffen Always get min/max values from style * rules. + * Apr 09, 2014 2947 bsteffen Improve flexibility of sat derived + * parameters. * * * @@ -283,14 +285,7 @@ public class SatResource extends } SingleLevel level = new SingleLevel(Level.LevelType.SURFACE); - String physicalElement = null; - DerivedParameterRequest request = (DerivedParameterRequest) record - .getMessageData(); - if (request == null) { - physicalElement = record.getPhysicalElement(); - } else { - physicalElement = request.getParameterAbbreviation(); - } + String physicalElement = record.getPhysicalElement(); // Grab the sampleRange from the preferences ParamLevelMatchCriteria match = new ParamLevelMatchCriteria(); @@ -459,17 +454,13 @@ public class SatResource extends return String.format("%.1f%s", measuredValue, unitString); } - private String getLegend(PluginDataObject record) { - String productName = null; - DerivedParameterRequest request = (DerivedParameterRequest) record - .getMessageData(); - if (request == null) { - productName = ((SatelliteRecord) record).getPhysicalElement(); - } else { - productName = request.getParameterAbbreviation(); + private String getLegend(SatelliteRecord record) { + String productName = record.getPhysicalElement(); + if (record instanceof DerivedSatelliteRecord) { + productName = ((DerivedSatelliteRecord) record).getName(); } return SatelliteConstants.getLegend(productName, - ((SatelliteRecord) record).getCreatingEntity()); + record.getCreatingEntity()); } public List getImages(IGraphicsTarget target, diff --git a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/tileset/SatDataRetriever.java b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/tileset/SatDataRetriever.java index 161c5e62d0..3b6d20dd7e 100644 --- a/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/tileset/SatDataRetriever.java +++ b/cave/com.raytheon.viz.satellite/src/com/raytheon/viz/satellite/tileset/SatDataRetriever.java @@ -22,6 +22,7 @@ package com.raytheon.viz.satellite.tileset; import java.awt.Rectangle; import java.nio.Buffer; import java.nio.ByteBuffer; +import java.nio.FloatBuffer; import java.nio.ShortBuffer; import java.text.ParseException; import java.text.ParsePosition; @@ -32,23 +33,22 @@ import javax.measure.unit.UnitFormat; import com.raytheon.uf.common.colormap.image.ColorMapData; import com.raytheon.uf.common.colormap.image.ColorMapData.ColorMapDataType; -import com.raytheon.uf.common.inventory.exception.DataCubeException; import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord; -import com.raytheon.uf.common.dataplugin.satellite.units.counts.DerivedWVPixel; import com.raytheon.uf.common.dataplugin.satellite.units.generic.GenericPixel; import com.raytheon.uf.common.dataplugin.satellite.units.goes.PolarPrecipWaterPixel; import com.raytheon.uf.common.dataplugin.satellite.units.water.BlendedTPWPixel; import com.raytheon.uf.common.datastorage.DataStoreFactory; import com.raytheon.uf.common.datastorage.Request; import com.raytheon.uf.common.datastorage.records.ByteDataRecord; +import com.raytheon.uf.common.datastorage.records.FloatDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.ShortDataRecord; +import com.raytheon.uf.common.inventory.exception.DataCubeException; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback; import com.raytheon.uf.viz.datacube.DataCubeContainer; -import com.raytheon.uf.common.derivparam.library.DerivedParameterRequest; import com.raytheon.viz.satellite.SatelliteConstants; /** @@ -59,11 +59,13 @@ import com.raytheon.viz.satellite.SatelliteConstants; * * SOFTWARE HISTORY * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Jun 20, 2013 2122 mschenke Initial creation - * Nov 13, 2013 2492 mschenke Added extraction of scale/offset from - * data record attributes for unit + * Date Ticket# Engineer Description + * ------------- -------- ----------- -------------------------- + * Jun 20, 2013 2122 mschenke Initial creation + * Nov 13, 2013 2492 mschenke Added extraction of scale/offset from + * data record attributes for unit + * Apr 09, 2014 2947 bsteffen Improve flexibility of sat derived + * parameters. * * * @@ -112,6 +114,8 @@ public class SatDataRetriever implements IColorMapDataRetrievalCallback { data = ByteBuffer.wrap((byte[]) record.getDataObject()); } else if (record instanceof ShortDataRecord) { data = ShortBuffer.wrap((short[]) record.getDataObject()); + } else if (record instanceof FloatDataRecord) { + data = FloatBuffer.wrap((float[]) record.getDataObject()); } Unit recordUnit = getRecordUnit(this.record); signed = recordUnit instanceof GenericPixel; @@ -148,14 +152,8 @@ public class SatDataRetriever implements IColorMapDataRetrievalCallback { public static Unit getRecordUnit(SatelliteRecord record) { Unit recordUnit = null; String physicalElement = record.getPhysicalElement(); - DerivedParameterRequest request = (DerivedParameterRequest) record - .getMessageData(); - if (request != null) { - physicalElement = request.getParameterAbbreviation(); - } - if (record.getUnits() != null && record.getUnits().isEmpty() == false - && request == null) { + if (record.getUnits() != null && record.getUnits().isEmpty() == false) { try { recordUnit = UnitFormat.getUCUMInstance().parseProductUnit( record.getUnits(), new ParsePosition(0)); @@ -165,12 +163,6 @@ public class SatDataRetriever implements IColorMapDataRetrievalCallback { "Unable to parse satellite units: " + record.getUnits(), e); } - } else if (request != null) { - if (physicalElement.equals("satDivWVIR")) { - recordUnit = new DerivedWVPixel(); - } else { - recordUnit = new GenericPixel(); - } } if (physicalElement.equals(SatelliteConstants.PRECIP)) { @@ -193,7 +185,7 @@ public class SatDataRetriever implements IColorMapDataRetrievalCallback { * @param dataRecord * @return */ - private static Unit getDataUnit(Unit recordUnit, + public static Unit getDataUnit(Unit recordUnit, IDataRecord dataRecord) { Unit units = recordUnit != null ? recordUnit : Unit.ONE; Map attrs = dataRecord.getDataAttributes(); diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/units/SatelliteUnits.java b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/units/SatelliteUnits.java index 07bc09ed35..4d0d7d8ef3 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/units/SatelliteUnits.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/units/SatelliteUnits.java @@ -28,6 +28,7 @@ import javax.measure.unit.SI; import javax.measure.unit.Unit; import javax.measure.unit.UnitFormat; +import com.raytheon.uf.common.dataplugin.satellite.units.counts.DerivedWVPixel; import com.raytheon.uf.common.dataplugin.satellite.units.generic.GenericPixel; import com.raytheon.uf.common.dataplugin.satellite.units.goes.PercentOfNormalTPWPixel; import com.raytheon.uf.common.dataplugin.satellite.units.goes.PolarPrecipWaterPixel; @@ -45,12 +46,14 @@ import com.raytheon.uf.common.dataplugin.satellite.units.water.RainfallRatePixel * *
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Sep 4, 2007             njensen     Initial creation
- * Mar 23, 2009     2086   jsanchez    Updated RainfallRatePixel to be velocity.
- *                                     Added PolarPrecipWaterPixel.
- * Jun 20, 2013     2122   mschenke    Added alias for degrees celsius to "C"
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * Sep 04, 2007           njensen     Initial creation
+ * Mar 23, 2009  2086     jsanchez    Updated RainfallRatePixel to be velocity.
+ *                                    Added PolarPrecipWaterPixel.
+ * Jun 20, 2013  2122     mschenke    Added alias for degrees celsius to "C"
+ * Apr 15, 2014  2947     bsteffen    Register units with both formats.
+ * 
  * 
  * 
* @@ -84,35 +87,35 @@ public class SatelliteUnits { public static final Unit GENERIC_PIXEL = new GenericPixel(); + public static final Unit DERIVED_WV = new DerivedWVPixel(); + public static void register() { - UnitFormat.getUCUMInstance().alias(SI.KELVIN, "kelvin"); - UnitFormat.getUCUMInstance().alias(SI.CELSIUS, "C"); - UnitFormat.getUCUMInstance().label(SatelliteUnits.IR_PIXEL, "IRPixel"); - UnitFormat.getUCUMInstance().label(SatelliteUnits.PRECIP_PIXEL, - "PrecipPixel"); - UnitFormat.getUCUMInstance().label(SatelliteUnits.RAINFALL_RATE_PIXEL, - "RainfallRatePixel"); - UnitFormat.getUCUMInstance().label( - SatelliteUnits.SOUNDER_CLOUD_AMOUNT_PIXEL, + register(UnitFormat.getUCUMInstance()); + register(UnitFormat.getInstance()); + + } + + public static void register(UnitFormat format) { + format.alias(SI.KELVIN, "kelvin"); + format.alias(SI.CELSIUS, "C"); + format.label(SatelliteUnits.IR_PIXEL, "IRPixel"); + format.label(SatelliteUnits.PRECIP_PIXEL, "PrecipPixel"); + format.label(SatelliteUnits.RAINFALL_RATE_PIXEL, "RainfallRatePixel"); + format.label(SatelliteUnits.SOUNDER_CLOUD_AMOUNT_PIXEL, "SounderCloudAmountPixel"); - UnitFormat.getUCUMInstance().label( - SatelliteUnits.SOUNDER_CLOUD_HEIGHT_PIXEL, + format.label(SatelliteUnits.SOUNDER_CLOUD_HEIGHT_PIXEL, "SounderCloudTopHeightPixel"); - UnitFormat.getUCUMInstance().label( - SatelliteUnits.SOUNDER_LIFTED_INDEX_PIXEL, + format.label(SatelliteUnits.SOUNDER_LIFTED_INDEX_PIXEL, "SounderLiftedIndexPixel"); - UnitFormat.getUCUMInstance().label( - SatelliteUnits.SOUNDER_PRECIP_WATER_PIXEL, + format.label(SatelliteUnits.SOUNDER_PRECIP_WATER_PIXEL, "SounderPrecipWaterPixel"); - UnitFormat.getUCUMInstance().label( - SatelliteUnits.POLAR_PRECIP_WATER_PIXEL, + format.label(SatelliteUnits.POLAR_PRECIP_WATER_PIXEL, "PolarPrecipWaterPixel"); - UnitFormat.getUCUMInstance().label( - SatelliteUnits.SOUNDER_SKIN_TEMP_PIXEL, "SounderSkinTempPixel"); - UnitFormat.getUCUMInstance().label(SatelliteUnits.GENERIC_PIXEL, - "GenericPixel"); - UnitFormat.getUCUMInstance().label(SatelliteUnits.PERCENT_PIXEL, - "PercentOfNormalTPWPixel"); + format.label(SatelliteUnits.SOUNDER_SKIN_TEMP_PIXEL, + "SounderSkinTempPixel"); + format.label(SatelliteUnits.GENERIC_PIXEL, "GenericPixel"); + format.label(SatelliteUnits.PERCENT_PIXEL, "PercentOfNormalTPWPixel"); + format.label(SatelliteUnits.DERIVED_WV, "DerivedWV"); } } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/units/goes/PercentOfNormalTPWPixel.java b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/units/goes/PercentOfNormalTPWPixel.java index 756d5d899d..feb3948edd 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/units/goes/PercentOfNormalTPWPixel.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/src/com/raytheon/uf/common/dataplugin/satellite/units/goes/PercentOfNormalTPWPixel.java @@ -25,19 +25,19 @@ import javax.measure.unit.Unit; import org.apache.commons.lang.builder.HashCodeBuilder; -import com.raytheon.uf.common.dataplugin.satellite.units.generic.GenericPixel; import com.raytheon.uf.common.dataplugin.satellite.units.goes.convert.PixelToPercentConverter; /** - * TODO Add Description + * A unit for the percent of normal total precipitable water pixels. * *
  * 
  * SOFTWARE HISTORY
  * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * May 12, 2010            jsanchez     Initial creation
+ * Date          Ticket#  Engineer    Description
+ * ------------- -------- ----------- --------------------------
+ * May 12, 2010           jsanchez    Initial creation
+ * Apr 15, 2014  2947     bsteffen    Fix equals.
  * 
  * 
* @@ -50,7 +50,7 @@ public class PercentOfNormalTPWPixel extends Unit { @Override public boolean equals(Object anObject) { - return (anObject instanceof GenericPixel); + return (anObject instanceof PercentOfNormalTPWPixel); } @Override diff --git a/edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/poesDif11u3_7uIR.xml b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/poesDif11u3_7uIR.xml similarity index 82% rename from edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/poesDif11u3_7uIR.xml rename to edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/poesDif11u3_7uIR.xml index fe5430b7c2..63d336de85 100644 --- a/edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/poesDif11u3_7uIR.xml +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/poesDif11u3_7uIR.xml @@ -18,9 +18,9 @@ See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for further_licensing_information. --> - + - - + + diff --git a/edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDif11u12uIR.xml b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDif11u12uIR.xml similarity index 80% rename from edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDif11u12uIR.xml rename to edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDif11u12uIR.xml index f200245d78..e2607addb8 100644 --- a/edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDif11u12uIR.xml +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDif11u12uIR.xml @@ -18,9 +18,9 @@ See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for further_licensing_information. --> - + - - + + diff --git a/edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDif11u13uIR.xml b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDif11u13uIR.xml similarity index 79% rename from edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDif11u13uIR.xml rename to edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDif11u13uIR.xml index cefc67320c..f31c3ef789 100644 --- a/edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDif11u13uIR.xml +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDif11u13uIR.xml @@ -18,9 +18,9 @@ See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for further_licensing_information. --> - + - - + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDif11u3_9uIR.xml b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDif11u3_9uIR.xml similarity index 79% rename from edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDif11u3_9uIR.xml rename to edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDif11u3_9uIR.xml index e5c254bf89..4ae657a5fd 100644 --- a/edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDif11u3_9uIR.xml +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDif11u3_9uIR.xml @@ -18,9 +18,9 @@ See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for further_licensing_information. --> - + - - + + diff --git a/edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDivWVIR.xml b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDivWVIR.xml similarity index 80% rename from edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDivWVIR.xml rename to edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDivWVIR.xml index 02131c35f1..7f9d5c9c1c 100644 --- a/edexOsgi/com.raytheon.uf.common.derivparam/utility/common_static/base/derivedParameters/definitions/satDivWVIR.xml +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/definitions/satDivWVIR.xml @@ -18,9 +18,9 @@ See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for further_licensing_information. --> - + - - + + diff --git a/edexOsgi/com.raytheon.uf.common.derivparam.python/utility/common_static/base/derivedParameters/functions/satDif11u3_9uIR.py b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/functions/satDif11u3_9uIR.py similarity index 100% rename from edexOsgi/com.raytheon.uf.common.derivparam.python/utility/common_static/base/derivedParameters/functions/satDif11u3_9uIR.py rename to edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/functions/satDif11u3_9uIR.py diff --git a/edexOsgi/com.raytheon.uf.common.derivparam.python/utility/common_static/base/derivedParameters/functions/satDifference.py b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/functions/satDifference.py similarity index 100% rename from edexOsgi/com.raytheon.uf.common.derivparam.python/utility/common_static/base/derivedParameters/functions/satDifference.py rename to edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/functions/satDifference.py diff --git a/edexOsgi/com.raytheon.uf.common.derivparam.python/utility/common_static/base/derivedParameters/functions/satDivWVIR.py b/edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/functions/satDivWVIR.py similarity index 100% rename from edexOsgi/com.raytheon.uf.common.derivparam.python/utility/common_static/base/derivedParameters/functions/satDivWVIR.py rename to edexOsgi/com.raytheon.uf.common.dataplugin.satellite/utility/common_static/base/derivedParameters/functions/satDivWVIR.py diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/PluginDataObject.java b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/PluginDataObject.java index 6d624ee83b..be6d7d5a72 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/PluginDataObject.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin/src/com/raytheon/uf/common/dataplugin/PluginDataObject.java @@ -104,6 +104,8 @@ import com.raytheon.uf.common.time.DataTime; * PluginDataObject. * May 16, 2013 1869 bsteffen Rewrite dataURI property mappings. * Aug 30, 2013 2298 rjpeter Make getPluginName abstract + * Apr 15, 2014 1869 bsteffen Remove unused transient record field. + * * * */ @@ -173,9 +175,6 @@ public abstract class PluginDataObject extends PersistableDataObject implements @Transient private transient int uriIndex = 2; - @Transient - private Object record = null; - /** * Default Constructor */ @@ -271,14 +270,6 @@ public abstract class PluginDataObject extends PersistableDataObject implements } } - public Object getRecord() { - return record; - } - - public void setRecord(Object record) { - this.record = record; - } - /** * TODO: Rework non-PointDataContainer plots and remove * diff --git a/ncep/gov.noaa.nws.ncep.viz.rsc.satellite/src/gov/noaa/nws/ncep/viz/rsc/satellite/area/McIdasAreaProviderFactory.java b/ncep/gov.noaa.nws.ncep.viz.rsc.satellite/src/gov/noaa/nws/ncep/viz/rsc/satellite/area/McIdasAreaProviderFactory.java index a294de8723..a1e7c55f14 100644 --- a/ncep/gov.noaa.nws.ncep.viz.rsc.satellite/src/gov/noaa/nws/ncep/viz/rsc/satellite/area/McIdasAreaProviderFactory.java +++ b/ncep/gov.noaa.nws.ncep.viz.rsc.satellite/src/gov/noaa/nws/ncep/viz/rsc/satellite/area/McIdasAreaProviderFactory.java @@ -30,7 +30,6 @@ import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.requests.ThriftClient; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.ResourceType; -import com.raytheon.viz.satellite.SatelliteDataCubeAdapter; import com.vividsolutions.jts.geom.Polygon; import gov.noaa.nws.ncep.common.dataplugin.mcidas.McidasMapCoverage;