diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/res/spring/radar-request.xml b/edexOsgi/com.raytheon.edex.plugin.radar/res/spring/radar-request.xml index fa8c7bb5a4..75a36c1153 100644 --- a/edexOsgi/com.raytheon.edex.plugin.radar/res/spring/radar-request.xml +++ b/edexOsgi/com.raytheon.edex.plugin.radar/res/spring/radar-request.xml @@ -14,6 +14,12 @@ + + + + + + diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/dao/RadarDao.java b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/dao/RadarDao.java index cf7c22c7d5..70ec621eb9 100644 --- a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/dao/RadarDao.java +++ b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/dao/RadarDao.java @@ -1,19 +1,19 @@ /** * 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. **/ @@ -22,7 +22,7 @@ package com.raytheon.edex.plugin.radar.dao; /** * Data Access Object implementation for accessing radar data - * + * *
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
@@ -30,14 +30,15 @@ package com.raytheon.edex.plugin.radar.dao;
  * Feb 06, 2009 1990       bphillip    Initial creation
  * Mar 18, 2013 1804       bsteffen    Reduce useless data stored in radar hdf5
  * Aug 30, 2013 2298       rjpeter     Make getPluginName abstract
- * 
+ * Aug 14, 2014 3393       nabowle     Remove broken getFullRecord override.
+ * Aug 19, 2014 3393       nabowle     Default constructor.
+ *
  * 
- * + * * @author bphillip * @version 1.0 */ import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,10 +49,6 @@ import com.raytheon.uf.common.dataplugin.radar.RadarDataKey; import com.raytheon.uf.common.dataplugin.radar.RadarDataPoint; import com.raytheon.uf.common.dataplugin.radar.RadarRecord; import com.raytheon.uf.common.dataplugin.radar.RadarStoredData; -import com.raytheon.uf.common.dataplugin.radar.level3.GSMBlock.GSMMessage; -import com.raytheon.uf.common.dataplugin.radar.level3.GraphicBlock; -import com.raytheon.uf.common.dataplugin.radar.level3.SymbologyBlock; -import com.raytheon.uf.common.dataplugin.radar.util.RadarConstants; import com.raytheon.uf.common.dataplugin.radar.util.RadarConstants.MapValues; import com.raytheon.uf.common.dataplugin.radar.util.RadarDataRetriever; import com.raytheon.uf.common.datastorage.IDataStore; @@ -62,17 +59,24 @@ import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.ShortDataRecord; import com.raytheon.uf.common.serialization.DynamicSerializationManager; import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationType; -import com.raytheon.uf.common.serialization.SerializationException; -import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.edex.core.dataplugin.PluginRegistry; import com.raytheon.uf.edex.database.plugin.PluginDao; -import com.raytheon.uf.edex.database.query.DatabaseQuery; public class RadarDao extends PluginDao { + /** + * Creates a new radar dao. Equivalent to RadarDao("radar"). + * + * @throws PluginException + * If the dao cannot be initialized + */ + public RadarDao() throws PluginException { + super("radar"); + } + /** * Creates a new radar dao - * + * * @param pluginName * "radar" * @throws PluginException @@ -270,38 +274,6 @@ public class RadarDao extends PluginDao { return retVal; } - @Override - public PluginDataObject[] getFullRecord(DatabaseQuery query, int tile) - throws PluginException { - PluginDataObject[] queryResults = getMetadata(query); - for (PluginDataObject obj : queryResults) { - RadarRecord record = (RadarRecord) obj; - IDataRecord[] hdf5Data = getHDF5Data(record, tile); - record.setMessageData(hdf5Data[0].getDataObject()); - record.setAngleData((float[]) hdf5Data[1].getDataObject()); - record.setThresholds((short[]) hdf5Data[2].getDataObject()); - record.setProductDependentValues((short[]) hdf5Data[8] - .getDataObject()); - - record.setProductVals((HashMap>>) hdf5Data[5] - .getDataObject()); - record.setMapRecordVals((HashMap>) hdf5Data[6]); - record.setGsmMessage((GSMMessage) hdf5Data[7].getDataObject()); - try { - record.setSymbologyBlock((SymbologyBlock) SerializationUtil - .transformFromThrift((byte[]) hdf5Data[3] - .getDataObject())); - record.setGraphicBlock((GraphicBlock) SerializationUtil - .transformFromThrift((byte[]) hdf5Data[4] - .getDataObject())); - - } catch (SerializationException e) { - throw new PluginException( - "Error deserializing symbology block", e); - } - } - return queryResults; - } public void populateData(RadarRecord record) throws Exception { RadarDataRetriever.populateRadarRecord(getDataStore(record), record); diff --git a/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/handler/GetRadarDataRecordHandler.java b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/handler/GetRadarDataRecordHandler.java new file mode 100644 index 0000000000..df058f94fa --- /dev/null +++ b/edexOsgi/com.raytheon.edex.plugin.radar/src/com/raytheon/edex/plugin/radar/handler/GetRadarDataRecordHandler.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.edex.plugin.radar.handler; + +import java.util.List; + +import com.raytheon.edex.plugin.radar.dao.RadarDao; +import com.raytheon.uf.common.dataplugin.PluginDataObject; +import com.raytheon.uf.common.dataplugin.radar.RadarRecord; +import com.raytheon.uf.common.dataplugin.radar.request.GetRadarDataRecordRequest; +import com.raytheon.uf.common.dataplugin.radar.response.GetRadarDataRecordResponse; +import com.raytheon.uf.common.dataplugin.radar.response.RadarDataRecord; +import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand; +import com.raytheon.uf.common.datastorage.records.IDataRecord; +import com.raytheon.uf.common.serialization.comm.IRequestHandler; +import com.raytheon.uf.edex.database.query.DatabaseQuery; + +/** + * Request handler for {@link GetRadarDataRecordRequest}s. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 7, 2014  3393       nabowle     Initial creation
+ *
+ * 
+ * + * @author nabowle + * @version 1.0 + */ +public class GetRadarDataRecordHandler implements + IRequestHandler { + public static final String ENTITY = RadarRecord.class.getName().toString(); + + /** + * Constructor. + */ + public GetRadarDataRecordHandler() { + super(); + } + + /* + * (non-Javadoc) + * + * @see + * IRequestHandler#handleRequest(com.raytheon.uf.common.serialization.comm + * .IServerRequest) + */ + @Override + public GetRadarDataRecordResponse handleRequest(GetRadarDataRecordRequest request) + throws Exception { + GetRadarDataRecordResponse response = new GetRadarDataRecordResponse(); + DatabaseQuery query = buildQuery(request); + + RadarDao dao = new RadarDao(); + List objects = (List) dao + .queryByCriteria(query); + + if (objects != null && objects.size() > 0) { + List hdf5Records = dao.getHDF5Data(objects, -1); + + RadarRecord record; + RadarDataRecord data; + RadarDataRecord[] responseData = new RadarDataRecord[objects.size()]; + for (int i = 0; i < objects.size(); i++) { + data = new RadarDataRecord(); + data.setHdf5Data(hdf5Records.get(i)); + + record = (RadarRecord) objects.get(i); + // Strings are used to match MSAS/LAPS uEngine precision for + // side by side comparison + data.setDataTime(record.getDataTime()); + data.setLatitude(record.getLatitude().toString()); + data.setLongitude(record.getLongitude().toString()); + data.setElevation(record.getElevation().toString()); + data.setElevationNumber(record.getElevationNumber().toString()); + data.setTrueElevationAngle(record.getTrueElevationAngle() + .toString()); + data.setVolumeCoveragePattern(record.getVolumeCoveragePattern() + .toString()); + + responseData[i] = data; + } + response.setData(responseData); + } + + return response; + } + + /** + * Build the database query. + * + * @param request + * The request. + * @return A database query using the fields of the request. + */ + private DatabaseQuery buildQuery(GetRadarDataRecordRequest request) { + DatabaseQuery query = new DatabaseQuery(ENTITY); + + query.addQueryParam("icao", request.getRadarId()); + query.addQueryParam("productCode", request.getProductCode()); + query.addQueryParam("primaryElevationAngle", + request.getPrimaryElevationAngle()); + query.addQueryParam("dataTime.refTime", request.getTimeRange() + .getStart(), QueryOperand.GREATERTHANEQUALS); + query.addQueryParam("dataTime.refTime", + request.getTimeRange().getEnd(), QueryOperand.LESSTHANEQUALS); + + return query; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/META-INF/MANIFEST.MF index 1833adf26f..2202b7f607 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Radar Bundle-SymbolicName: com.raytheon.uf.common.dataplugin.radar -Bundle-Version: 1.14.0.qualifier +Bundle-Version: 1.14.1.qualifier Eclipse-RegisterBuddy: com.raytheon.uf.common.geospatial Bundle-Vendor: RAYTHEON Require-Bundle: com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", @@ -19,12 +19,13 @@ Require-Bundle: com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174", javax.persistence;bundle-version="1.0.0", org.hibernate;bundle-version="1.0.0", com.raytheon.uf.common.numeric;bundle-version="1.14.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Export-Package: com.raytheon.uf.common.dataplugin.radar, com.raytheon.uf.common.dataplugin.radar.level3, com.raytheon.uf.common.dataplugin.radar.level3.generic, com.raytheon.uf.common.dataplugin.radar.projection, com.raytheon.uf.common.dataplugin.radar.request, + com.raytheon.uf.common.dataplugin.radar.response, com.raytheon.uf.common.dataplugin.radar.units, com.raytheon.uf.common.dataplugin.radar.util diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/request/GetRadarDataRecordRequest.java b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/request/GetRadarDataRecordRequest.java new file mode 100644 index 0000000000..c10510a92b --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/request/GetRadarDataRecordRequest.java @@ -0,0 +1,129 @@ +/** + * 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.request; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.common.serialization.comm.IServerRequest; +import com.raytheon.uf.common.time.TimeRange; + +/** + * A request for radar hdf5 data. Requires a radar id, product code, primary + * elevation angle, and a time range in order to search. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 7, 2014  3393       nabowle     Initial creation
+ *
+ * 
+ * + * @author nabowle + * @version 1.0 + */ +@DynamicSerialize +public class GetRadarDataRecordRequest implements IServerRequest { + + /** The ICAO id of the radar. */ + @DynamicSerializeElement + private String radarId; + + /** The product code. */ + @DynamicSerializeElement + private int productCode; + + /** The primary elevation angle. */ + @DynamicSerializeElement + private double primaryElevationAngle; + + /** The datetime range. */ + @DynamicSerializeElement + private TimeRange timeRange; + + /** + * Constructor. + */ + public GetRadarDataRecordRequest() { + super(); + } + + /** + * @return the radarId + */ + public String getRadarId() { + return radarId; + } + + /** + * @param radarId + * the radarId to set + */ + public void setRadarId(String radarId) { + this.radarId = radarId; + } + + /** + * @return the productCode + */ + public int getProductCode() { + return productCode; + } + + /** + * @param productCode + * the productCode to set + */ + public void setProductCode(int productCode) { + this.productCode = productCode; + } + + /** + * @return the primaryElevationAngle + */ + public double getPrimaryElevationAngle() { + return primaryElevationAngle; + } + + /** + * @param primaryElevationAngle + * the primaryElevationAngle to set + */ + public void setPrimaryElevationAngle(double primaryElevationAngle) { + this.primaryElevationAngle = primaryElevationAngle; + } + + /** + * @return the timeRange + */ + public TimeRange getTimeRange() { + return timeRange; + } + + /** + * @param timeRange + * the timeRange to set + */ + public void setTimeRange(TimeRange timeRange) { + this.timeRange = timeRange; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/response/GetRadarDataRecordResponse.java b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/response/GetRadarDataRecordResponse.java new file mode 100644 index 0000000000..94377babb8 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/response/GetRadarDataRecordResponse.java @@ -0,0 +1,80 @@ +/** + * 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.response; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * Response object to a GetRadarHDF5Request. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 7, 2014  3393       nabowle     Initial creation
+ *
+ * 
+ * + * @author nabowle + * @version 1.0 + */ +@DynamicSerialize +public class GetRadarDataRecordResponse { + + @DynamicSerializeElement + private RadarDataRecord[] data; + + /** + * Constructor. + */ + public GetRadarDataRecordResponse() { + super(); + } + + /** + * Constructor. + * + * @param datas + * The response data. + */ + public GetRadarDataRecordResponse(RadarDataRecord... datas) { + super(); + this.data = datas; + } + + /** + * @return the data + */ + public RadarDataRecord[] getData() { + return data; + } + + /** + * @param data + * the data to set + */ + public void setData(RadarDataRecord[] data) { + this.data = data; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/response/RadarDataRecord.java b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/response/RadarDataRecord.java new file mode 100644 index 0000000000..adeab21cbb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.radar/src/com/raytheon/uf/common/dataplugin/radar/response/RadarDataRecord.java @@ -0,0 +1,200 @@ +/** + * 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.response; + +import com.raytheon.uf.common.datastorage.records.IDataRecord; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; +import com.raytheon.uf.common.time.DataTime; + +/** + * A data object for a single radar record. The IDataRecords and a subset of the + * radar fields are available. + * + * String fields are used to match MSAS/LAPS uEngine precision for side by side + * comparison. + * + *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 7, 2014  3393       nabowle     Initial creation
+ *
+ * 
+ * + * @author nabowle + * @version 1.0 + */ +@DynamicSerialize +public class RadarDataRecord { + + @DynamicSerializeElement + private IDataRecord[] hdf5Data; + + @DynamicSerializeElement + private DataTime dataTime; + + @DynamicSerializeElement + private String latitude; + + @DynamicSerializeElement + private String longitude; + + @DynamicSerializeElement + private String elevation; + + @DynamicSerializeElement + private String elevationNumber; + + @DynamicSerializeElement + private String trueElevationAngle; + + @DynamicSerializeElement + private String volumeCoveragePattern; + + /** + * Constructor. + */ + public RadarDataRecord() { + super(); + } + + /** + * @return the hdf5Data + */ + public IDataRecord[] getHdf5Data() { + return hdf5Data; + } + + /** + * @param hdf5Data + * the hdf5Data to set + */ + public void setHdf5Data(IDataRecord[] hdf5Data) { + this.hdf5Data = hdf5Data; + } + + /** + * @return the dataTime + */ + public DataTime getDataTime() { + return dataTime; + } + + /** + * @param dataTime + * the dataTime to set + */ + public void setDataTime(DataTime dataTime) { + this.dataTime = dataTime; + } + + /** + * @return the latitude + */ + public String getLatitude() { + return latitude; + } + + /** + * @param latitude + * the latitude to set + */ + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + /** + * @return the longitude + */ + public String getLongitude() { + return longitude; + } + + /** + * @param longitude + * the longitude to set + */ + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + /** + * @return the elevation + */ + public String getElevation() { + return elevation; + } + + /** + * @param elevation + * the elevation to set + */ + public void setElevation(String elevation) { + this.elevation = elevation; + } + + /** + * @return the elevationNumber + */ + public String getElevationNumber() { + return elevationNumber; + } + + /** + * @param elevationNumber + * the elevationNumber to set + */ + public void setElevationNumber(String elevationNumber) { + this.elevationNumber = elevationNumber; + } + + /** + * @return the trueElevationAngle + */ + public String getTrueElevationAngle() { + return trueElevationAngle; + } + + /** + * @param trueElevationAngle + * the trueElevationAngle to set + */ + public void setTrueElevationAngle(String trueElevationAngle) { + this.trueElevationAngle = trueElevationAngle; + } + + /** + * @return the volumeCoveragePattern + */ + public String getVolumeCoveragePattern() { + return volumeCoveragePattern; + } + + /** + * @param volumeCoveragePattern + * the volumeCoveragePattern to set + */ + public void setVolumeCoveragePattern(String volumeCoveragePattern) { + this.volumeCoveragePattern = volumeCoveragePattern; + } +} diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/__init__.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/__init__.py index 3effe594ce..2c3b901e78 100644 --- a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/__init__.py +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/__init__.py @@ -25,7 +25,8 @@ __all__ = [ 'grib', 'grid', 'level', - 'message' + 'message', + 'radar' ] diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/__init__.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/__init__.py new file mode 100644 index 0000000000..daea64e073 --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/__init__.py @@ -0,0 +1,28 @@ +## +# 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. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'request', + 'response' + ] + + diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/GetRadarDataRecordRequest.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/GetRadarDataRecordRequest.py new file mode 100644 index 0000000000..97d5ba6397 --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/GetRadarDataRecordRequest.py @@ -0,0 +1,62 @@ +## +# 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. +## + +# File auto-generated against equivalent DynamicSerialize Java class +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# Aug 19, 2014 nabowle Generated + +import numpy + +class GetRadarDataRecordRequest(object): + + def __init__(self): + self.timeRange = None + self.productCode = None + self.radarId = None + self.primaryElevationAngle = None + + def getTimeRange(self): + return self.timeRange + + def setTimeRange(self, timeRange): + self.timeRange = timeRange + + def getProductCode(self): + return self.productCode + + def setProductCode(self, productCode): + self.productCode = productCode + + def getRadarId(self): + return self.radarId + + def setRadarId(self, radarId): + self.radarId = radarId + + def getPrimaryElevationAngle(self): + return self.primaryElevationAngle + + def setPrimaryElevationAngle(self, primaryElevationAngle): + self.primaryElevationAngle = numpy.float64(primaryElevationAngle) + diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py new file mode 100644 index 0000000000..b86afc0c3b --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py @@ -0,0 +1,28 @@ +## +# 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. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'GetRadarDataRecordRequest' + ] + +from GetRadarDataRecordRequest import GetRadarDataRecordRequest + diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/GetRadarDataRecordResponse.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/GetRadarDataRecordResponse.py new file mode 100644 index 0000000000..c5bfd9a6d9 --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/GetRadarDataRecordResponse.py @@ -0,0 +1,39 @@ +## +# 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. +## + +# File auto-generated against equivalent DynamicSerialize Java class +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# Aug 19, 2014 nabowle Generated + +class GetRadarDataRecordResponse(object): + + def __init__(self): + self.data = None + + def getData(self): + return self.data + + def setData(self, data): + self.data = data + diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/RadarDataRecord.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/RadarDataRecord.py new file mode 100644 index 0000000000..c9901f665b --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/RadarDataRecord.py @@ -0,0 +1,88 @@ +## +# 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. +## + +# File auto-generated against equivalent DynamicSerialize Java class +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# Aug 19, 2014 nabowle Generated + +class RadarDataRecord(object): + + def __init__(self): + self.hdf5Data = None + self.trueElevationAngle = None + self.elevationNumber = None + self.elevation = None + self.longitude = None + self.latitude = None + self.dataTime = None + self.volumeCoveragePattern = None + + def getHdf5Data(self): + return self.hdf5Data + + def setHdf5Data(self, hdf5Data): + self.hdf5Data = hdf5Data + + def getTrueElevationAngle(self): + return self.trueElevationAngle + + def setTrueElevationAngle(self, trueElevationAngle): + self.trueElevationAngle = trueElevationAngle + + def getElevationNumber(self): + return self.elevationNumber + + def setElevationNumber(self, elevationNumber): + self.elevationNumber = elevationNumber + + def getElevation(self): + return self.elevation + + def setElevation(self, elevation): + self.elevation = elevation + + def getLongitude(self): + return self.longitude + + def setLongitude(self, longitude): + self.longitude = longitude + + def getLatitude(self): + return self.latitude + + def setLatitude(self, latitude): + self.latitude = latitude + + def getDataTime(self): + return self.dataTime + + def setDataTime(self, dataTime): + self.dataTime = dataTime + + def getVolumeCoveragePattern(self): + return self.volumeCoveragePattern + + def setVolumeCoveragePattern(self, volumeCoveragePattern): + self.volumeCoveragePattern = volumeCoveragePattern + diff --git a/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py new file mode 100644 index 0000000000..69a045eb8c --- /dev/null +++ b/pythonPackages/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py @@ -0,0 +1,30 @@ +## +# 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. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'GetRadarDataRecordResponse', + 'RadarDataRecord' + ] + +from GetRadarDataRecordResponse import GetRadarDataRecordResponse +from RadarDataRecord import RadarDataRecord + diff --git a/pythonPackages/msaslaps/radar/a2advrad.csh b/pythonPackages/msaslaps/radar/a2advrad.csh index 00abd6b947..f9f0bfc93d 100644 --- a/pythonPackages/msaslaps/radar/a2advrad.csh +++ b/pythonPackages/msaslaps/radar/a2advrad.csh @@ -1,4 +1,24 @@ #!/bin/csh +## +# 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. +## + # # A script wrapper that is meant to get data for a single radar product # from the A-II database. The result is output to stdout as ASCII. @@ -22,7 +42,7 @@ # # Usage: # -# a2gtrad.csh {p} {x} radar msgcode {elev} date time {slop} +# a2advrad.csh {p} {x} radar msgcode {elev} date time {slop} # # p - A literal p. (optional) # x - A literal x. (optional) Expanded set of header information. @@ -37,8 +57,16 @@ # # The literal p option means preserve the final version of the python # submitted to the UEngine instead of cleaning it up. The path to the -# finalized python is /tmp/a2gtradNNNNN.py where NNNNN is a unix process id. +# finalized python is /tmp/a2advradNNNNN.py where NNNNN is a unix process id. # +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 08/07/2014 3393 nabowle Initial modification. Passes parameters straight to +# non-uengine script instead of sed. Remove use of gtasUtil +# if not using the uengine stub. +# # set rmpy = yes set fff = "" @@ -71,37 +99,49 @@ set fxa_home = $FXA_HOME if ( $?STAGING ) then set fxa_home = $STAGING/D-2D endif -# -# Set up the environment we need to run the UEngine. -# -if ( -e ./UEngine.cshsrc ) then - set ueenv = ./UEngine.cshsrc -else if ( -e $mydir/UEngine.cshsrc ) then - set ueenv = $mydir/UEngine.cshsrc -else if ( -e $fxa_home/src/dm/point/UEngine.cshsrc ) then - set ueenv = $fxa_home/src/dm/point/UEngine.cshsrc -else if ( -e $FXA_HOME/bin/UEngine.cshsrc ) then - set ueenv = $FXA_HOME/bin/UEngine.cshsrc -else - bash -c "echo could not find UEngine.cshsrc 1>&2" - exit -endif -source $ueenv + # # Locate python stub that we will modify to create the final UEngine script # -if ( -e ./a2gtradStub.py ) then - set stubpy = ./a2gtradStub.py -else if ( -e $mydir/a2gtradStub.py ) then - set stubpy = $mydir/a2gtradStub.py -else if ( -e $fxa_home/src/dm/radar/a2gtradStub.py ) then - set stubpy = $fxa_home/src/dm/radar/a2gtradStub.py -else if ( -e $FXA_HOME/bin/a2gtradStub.py ) then - set stubpy = $FXA_HOME/bin/a2gtradStub.py +if ( -e ./a2advradStub.py ) then + set stubpy = ./a2advradStub.py +else if ( -e $mydir/a2advradStub.py ) then + set stubpy = $mydir/a2advradStub.py +else if ( -e $fxa_home/src/dm/radar/a2advradStub.py ) then + set stubpy = $fxa_home/src/dm/radar/a2advradStub.py +else if ( -e $FXA_HOME/bin/a2advradStub.py ) then + set stubpy = $FXA_HOME/bin/a2advradStub.py else - bash -c "echo could not find a2gtradStub.py 1>&2" + bash -c "echo could not find a2advradStub.py 1>&2" exit endif + +# +# Determine if we are using the data access framework or the uEngine. +# +grep DataAccessLayer $stubpy >& /dev/null +if ( $status == 0 ) then + set method = "daf" +else + # + # Set up the environment we need to run the UEngine. + # + set method = "uengine" + if ( -e ./UEngine.cshsrc ) then + set ueenv = ./UEngine.cshsrc + else if ( -e $mydir/UEngine.cshsrc ) then + set ueenv = $mydir/UEngine.cshsrc + else if ( -e $FXA_HOME/src/dm/point/UEngine.cshsrc ) then + set ueenv = $FXA_HOME/src/dm/point/UEngine.cshsrc + else if ( -e $FXA_HOME/bin/UEngine.cshsrc ) then + set ueenv = $FXA_HOME/bin/UEngine.cshsrc + else + bash -c "echo could not find UEngine.cshsrc 1>&2" + exit + endif + source $ueenv +endif + # # Locate file that lets us provide a description of the data set. # @@ -124,49 +164,69 @@ set mmm = $2 shift shift set ddd = `echo $mmm | sed -f $mctrans | cut '-d|' -f2 ` -# -# Get program that can do math with ascii time string, then use this to -# properly encode range of times for which we look for data. -# -if ( -x ./gtasUtil ) then - set gtasUtil = ./gtasUtil -else if ( -x $mydir/gtasUtil ) then - set gtasUtil = $mydir/gtasUtil -else if ( -x $fxa_home/src/dm/point/gtasUtil ) then - set gtasUtil = $fxa_home/src/dm/point/gtasUtil -else if ( -x $FXA_HOME/bin/gtasUtil ) then - set gtasUtil = $FXA_HOME/bin/gtasUtil -else - bash -c "echo could not find gtasUtil executable 1>&2" - exit -endif + set eee = `echo $1 | grep -v '.*-'` if ( "$eee" != "" ) shift set slop = `echo $3 | grep '[0-9]'` if ( "$slop" == "" ) set slop = 60 -set aaa = `$gtasUtil = $1 $2 -$slop` -set bbb = `$gtasUtil = $1 $2 $slop` -# -# Modify the text of special tags in stub to create finalized script. -# -set specpy = /tmp/a2gtrad${$}.py -rm -rf $specpy >& /dev/null -touch $specpy -chmod 775 $specpy -if ( "$eee" == "" ) then - cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \ - sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \ - sed "s/DDDDD/$ddd/g" | sed 's/^.*EEEE.*$//g' >> $specpy + + +if ( "$method" == "daf" ) then + set datetime = $1' '$2 + set opts = "" + + if ( "$eee" != "" ) then + set opts = "$opts --angle $eee" + endif + + if ( "$fff" == "x" ) then + set opts = "$opts --extended" + endif + + /awips2/python/bin/python $stubpy --radar $rrr --code $mmm --datetime="${datetime}" --slop $slop --description="${ddd}" $opts else - cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \ - sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \ - sed "s/DDDDD/$ddd/g" | sed "s/EEEE/$eee/g" >> $specpy + # + # Get program that can do math with ascii time string, then use this to + # properly encode range of times for which we look for data. + # + if ( -x ./gtasUtil ) then + set gtasUtil = ./gtasUtil + else if ( -x $mydir/gtasUtil ) then + set gtasUtil = $mydir/gtasUtil + else if ( -x $fxa_home/src/dm/point/gtasUtil ) then + set gtasUtil = $fxa_home/src/dm/point/gtasUtil + else if ( -x $FXA_HOME/bin/gtasUtil ) then + set gtasUtil = $FXA_HOME/bin/gtasUtil + else + bash -c "echo could not find gtasUtil executable 1>&2" + exit + endif + + set aaa = `$gtasUtil = $1 $2 -$slop` + set bbb = `$gtasUtil = $1 $2 $slop` + + # + # Modify the text of special tags in stub to create finalized script. + # + set specpy = /tmp/a2advrad${$}.py + rm -rf $specpy >& /dev/null + touch $specpy + chmod 775 $specpy + if ( "$eee" == "" ) then + cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \ + sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \ + sed "s/DDDDD/$ddd/g" | sed 's/^.*EEEE.*$//g' >> $specpy + else + cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \ + sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \ + sed "s/DDDDD/$ddd/g" | sed "s/EEEE/$eee/g" >> $specpy + endif + # + # Submit the temporary python script stripping xml stuff, then remove it + # + cd $UE_BIN_PATH + ( uengine -r python < $specpy ) | grep -v '<' | sed 's/>/>/g' | \ + sed 's/</& /dev/null endif # -# Submit the temporary python script stripping xml stuff, then remove it -# -cd $UE_BIN_PATH -( uengine -r python < $specpy ) | grep -v '<' | sed 's/>/>/g' | \ - sed 's/</& /dev/null -# diff --git a/pythonPackages/msaslaps/radar/a2advradStub.py b/pythonPackages/msaslaps/radar/a2advradStub.py index fd29c875f0..06dda8fb6a 100644 --- a/pythonPackages/msaslaps/radar/a2advradStub.py +++ b/pythonPackages/msaslaps/radar/a2advradStub.py @@ -1,177 +1,128 @@ -import BaseRequest -from com.raytheon.uf.common.message.response import ResponseMessageGeneric -from com.raytheon.edex.plugin.radar.dao import RadarDao - -# Perform a radar request for data of interest -rr = BaseRequest.BaseRequest("radar") -rr.addParameter("icao","KKKK","=") -rr.addParameter("productCode","MMMM","=") -rr.addParameter("primaryElevationAngle","EEEE","=") -rr.addParameter("dataTime","AAAAA",">=") -rr.addParameter("dataTime","BBBBB","<=") -hedfmt = "FFF" - -result = rr.execute() -size = result.size() -if size == 0: - return ResponseMessageGeneric("Data not available") - -# ResponseMessageGeneric. Payload is RadarRecord -rmg = result.get(0) -# return rmg - -# RadarRecord -rrec = rmg.getContents() +## +# 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. +## # -# From here to the end is the part we know how to do for radar but not -# for radar. +# Gets data for a single radar product from the A-II database. The result is +# output to stdout as ASCII. This uses a data-specific Request/Response instead +# of the DataAccessLayer in order to preserve data-genericness of the interface. +# +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 08/13/2014 3393 nabowle Initial modification. Replaces UEngine +# with a custom Request/Response. +# # -mytime = rrec.getDataURI().split('/',4)[2] -# RadarDao. Inherits from PluginDao, which has a getHDF5Data method, -# which takes a PluginDataObject as an arg. -raddao = RadarDao("radar") +import argparse +import a2radcommon -# returns IDataRecord[]. IDataRecord is implemented by only one class -- -# AbstractStorageRecord. ASR is extended by a few *DataRecord classes; one -# of them is ByteDataRecord -idra = raddao.getHDF5Data(rrec,-1) +def get_args(): + parser = a2radcommon.get_args_parser() + parser.add_argument("--extended", action='store_true', default=False, + dest="extended", help="Output the extended header.") + return parser.parse_args() -msg = "No data." -if len(idra) > 0: - # pick radar Data record - # record 0 contains Angles getFloatData - # record 1 contains Data getByteData - # record 2 contains DependentValues getShortData - # record 3 contains ProductVals getByteData - # record 4 contains RecordVals getByteData - # record 5 contains StormIds getByteData - # record 6 contains Symbology getByteData - # record 7 contains SymbologyData getByteData - # record 8 contains Thresholds getShortData - dattyp = "raster" - for ii in range(len(idra)): - if idra[ii].getName() == "Data": - rdat = idra[ii] - elif idra[ii].getName() == "Angles": - azdat = idra[ii] - dattyp = "radial" - elif idra[ii].getName() == "DependentValues": - depVals = idra[ii].getShortData() -# elif idra[ii].getName() == "ProductVals": -# prodVals = idra[ii].getByteData() -# elif idra[ii].getName() == "RecordVals": -# recVals = idra[ii].getByteData() -# elif idra[ii].getName() == "StormIds": -# stormVals = idra[ii].getByteData() -# elif idra[ii].getName() == "Symbology": -# symVals = idra[ii].getByteData() -# elif idra[ii].getName() == "SymbologyData": -# symData = idra[ii].getByteData() - elif idra[ii].getName() == "Thresholds": - threshVals = idra[ii].getShortData() - # this hints at the IDR's concrete class: ByteDataRecord - #print "true type of IDataRecord:", idr.getDataObject().toString() +def main(): + user_args = get_args() - dim = rdat.getDimension() - if dim != 2: - return ResponseMessageGeneric(msg) + records = a2radcommon.send_request(user_args) - yLen = rdat.getSizes()[0] - xLen = rdat.getSizes()[1] + if not records: + # print "Data not available" + return - # byte[] -- the raw data - array = rdat.getByteData() - arraySize = len(array) - if xLen * yLen != arraySize: - return ResponseMessageGeneric(msg) + description = user_args.description + if not description: + print >> sys.stderr, "Description not provided" + return - # get data for azimuth angles if we have them. - if dattyp == "radial" : - azVals = azdat.getFloatData() - azValsLen = len(azVals) - if yLen != azValsLen: - return ResponseMessageGeneric(msg) - description = "DDDDD" + format = user_args.extended - # Encode dimensions, time, mapping, description, tilt, and VCP - if hedfmt == "x" : - msg = "\n"+ str(xLen) + " " + str(yLen) + " " + mytime + " " + \ - dattyp + " " + str(rrec.getLatitude()) + " " + \ - str(rrec.getLongitude()) + " " + \ - str(rrec.getElevation()) + " " + \ - str(rrec.getElevationNumber()) + " " + \ - description + " " + str(rrec.getTrueElevationAngle()) + " " + \ - str(rrec.getVolumeCoveragePattern()) + "\n" - else : - msg = "\n"+ str(xLen) + " " + str(yLen) + " " + mytime + " " + \ - dattyp + " " + description + " " + \ - str(rrec.getTrueElevationAngle()) + " " + \ - str(rrec.getVolumeCoveragePattern()) + "\n" - - # Encode level labels - spec = [".", "TH", "ND", "RF", "BI", "GC", "IC", "GR", "WS", "DS", - "RA", "HR", "BD", "HA", "UK"] - nnn = len(threshVals) - j = 0 - while j 14 : - msg += "." - else : - msg += spec[lo] - continue - if hi % 16 >= 8 : - msg += ">" - elif hi % 8 >= 4 : - msg += "<" - if hi % 4 >= 2 : - msg += "+" - elif hi % 2 >= 1 : - msg += "-" - if hi >= 64 : - msg += "%.2f"%(lo*0.01) - elif hi % 64 >= 32 : - msg += "%.2f"%(lo*0.05) - elif hi % 32 >= 16 : - msg += "%.1f"%(lo*0.1) - else : - msg += str(lo) - msg += "\n" + print_record(records[0], format, description) - # Encode product dependent parameters 17 through 26 - nnn = len(depVals) - j = 0 - while j&2" - exit -endif + set eee = `echo $1 | grep -v '.*-'` if ( "$eee" != "" ) shift set slop = `echo $3 | grep '[0-9]'` if ( "$slop" == "" ) set slop = 60 -set aaa = `$gtasUtil = $1 $2 -$slop` -set bbb = `$gtasUtil = $1 $2 $slop` -# -# Modify the text of special tags in stub to create finalized script. -# -set specpy = /tmp/a2gtrad${$}.py -rm -rf $specpy >& /dev/null -touch $specpy -chmod 775 $specpy -if ( "$eee" == "" ) then - cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \ - sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \ - sed "s/DDDDD/$ddd/g" | sed 's/^.*EEEE.*$//g' | \ - sed "s/XXXXX/$encoding/g" >> $specpy -else - cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \ - sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \ - sed "s/DDDDD/$ddd/g" | sed "s/EEEE/$eee/g" | \ - sed "s/XXXXX/$encoding/g" >> $specpy -endif -# -# Submit the temporary python script stripping xml stuff, then remove it -# + if ( "$method" == "daf" ) then - /awips2/python/bin/python $specpy + set datetime = $1' '$2 + set opts = "" + + if ( "$eee" != "" ) then + set opts = "$opts --angle $eee" + endif + + if ( "$fff" == "x" ) then + set opts = "$opts --extended" + endif + if ( "$encoding" == "1" ) then + set opts = "$opts --hex" + else if ( "$encoding" == "0" ) then + set opts = "$opts --int" + endif + + /awips2/python/bin/python $stubpy --radar $rrr --code $mmm --datetime="${datetime}" --slop $slop --description="${ddd}" $opts else + # + # Get program that can do math with ascii time string, then use this to + # properly encode range of times for which we look for data. + # + if ( -x ./gtasUtil ) then + set gtasUtil = ./gtasUtil + else if ( -x $mydir/gtasUtil ) then + set gtasUtil = $mydir/gtasUtil + else if ( -x $fxa_home/src/dm/point/gtasUtil ) then + set gtasUtil = $fxa_home/src/dm/point/gtasUtil + else if ( -x $FXA_HOME/bin/gtasUtil ) then + set gtasUtil = $FXA_HOME/bin/gtasUtil + else + bash -c "echo could not find gtasUtil executable 1>&2" + exit + endif + + set aaa = `$gtasUtil = $1 $2 -$slop` + set bbb = `$gtasUtil = $1 $2 $slop` + # + # Modify the text of special tags in stub to create finalized script. + # + set specpy = /tmp/a2gtrad${$}.py + rm -rf $specpy >& /dev/null + touch $specpy + chmod 775 $specpy + if ( "$eee" == "" ) then + cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \ + sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \ + sed "s/DDDDD/$ddd/g" | sed 's/^.*EEEE.*$//g' | \ + sed "s/XXXXX/$encoding/g" >> $specpy + else + cat $stubpy | sed "s/KKKK/$rrr/g" | sed "s/MMMM/$mmm/g" | \ + sed "s/AAAAA/$aaa/g" | sed "s/BBBBB/$bbb/g" | sed "s/FFF/$fff/g" | \ + sed "s/DDDDD/$ddd/g" | sed "s/EEEE/$eee/g" | \ + sed "s/XXXXX/$encoding/g" >> $specpy + endif + # + # Submit the temporary python script stripping xml stuff, then remove it + # + cd $UE_BIN_PATH ( uengine -r python < $specpy ) | grep -v '<' | sed 's/>/>/g' | \ sed 's/</& /dev/null endif -if ( "$rmpy" == "yes" ) rm -rf $specpy >& /dev/null + # diff --git a/pythonPackages/msaslaps/radar/a2gtradStub.py b/pythonPackages/msaslaps/radar/a2gtradStub.py index c25c5c1a7b..fd73171213 100644 --- a/pythonPackages/msaslaps/radar/a2gtradStub.py +++ b/pythonPackages/msaslaps/radar/a2gtradStub.py @@ -1,208 +1,166 @@ -import BaseRequest -from com.raytheon.uf.common.message.response import ResponseMessageGeneric -from com.raytheon.edex.plugin.radar.dao import RadarDao - -# Perform a radar request for data of interest -rr = BaseRequest.BaseRequest("radar") -rr.addParameter("icao","KKKK","=") -rr.addParameter("productCode","MMMM","=") -rr.addParameter("primaryElevationAngle","EEEE","=") -rr.addParameter("dataTime","AAAAA",">=") -rr.addParameter("dataTime","BBBBB","<=") -hedfmt = "FFF" -encoding = XXXXX - -result = rr.execute() -size = result.size() -if size == 0: - return ResponseMessageGeneric("Data not available") - -# ResponseMessageGeneric. Payload is RadarRecord -rmg = result.get(0) -# return rmg - -# RadarRecord -rrec = rmg.getContents() +## +# 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. +## # -# From here to the end is the part we know how to do for radar but not -# for radar. +# Gets data for a single radar product from the A-II database. The result is +# output to stdout as ASCII. This uses a data-specific Request/Response instead +# of the DataAccessLayer in order to preserve data-genericness of the interface. +# +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 08/11/2014 3393 nabowle Initial modification. Replaces UEngine +# with a custom Request/Response. +# # -mytime = rrec.getDataURI().split('/',4)[2] -# RadarDao. Inherits from PluginDao, which has a getHDF5Data method, -# which takes a PluginDataObject as an arg. -raddao = RadarDao("radar") +import argparse +import a2radcommon -# returns IDataRecord[]. IDataRecord is implemented by only one class -- -# AbstractStorageRecord. ASR is extended by a few *DataRecord classes; one -# of them is ByteDataRecord -idra = raddao.getHDF5Data(rrec,-1) +def get_args(): + parser = a2radcommon.get_args_parser() + parser.add_argument("--hex", action='store_const', dest="encoding", + const=1, help="Hex encoding.", metavar="encoding") + parser.add_argument("--int", action='store_const', dest="encoding", + const=0, help="Delimited integer encoding.", + metavar="encoding") + parser.add_argument("--extended", action='store_true', default=False, + dest="extended", help="Output the extended header.") + return parser.parse_args() -msg = "No data." -if len(idra) > 0: - # pick radar Data record - # record 0 contains Angles getFloatData - # record 1 contains Data getByteData - # record 2 contains DependentValues getShortData - # record 3 contains ProductVals getByteData - # record 4 contains RecordVals getByteData - # record 5 contains StormIds getByteData - # record 6 contains Symbology getByteData - # record 7 contains SymbologyData getByteData - # record 8 contains Thresholds getShortData - dattyp = "raster" - for ii in range(len(idra)): - if idra[ii].getName() == "Data": - rdat = idra[ii] - elif idra[ii].getName() == "Angles": - azdat = idra[ii] - dattyp = "radial" - elif idra[ii].getName() == "DependentValues": - depVals = idra[ii].getShortData() -# elif idra[ii].getName() == "ProductVals": -# prodVals = idra[ii].getByteData() -# elif idra[ii].getName() == "RecordVals": -# recVals = idra[ii].getByteData() -# elif idra[ii].getName() == "StormIds": -# stormVals = idra[ii].getByteData() -# elif idra[ii].getName() == "Symbology": -# symVals = idra[ii].getByteData() -# elif idra[ii].getName() == "SymbologyData": -# symData = idra[ii].getByteData() - elif idra[ii].getName() == "Thresholds": - threshVals = idra[ii].getShortData() - # this hints at the IDR's concrete class: ByteDataRecord - #print "true type of IDataRecord:", idr.getDataObject().toString() +def main(): + user_args = get_args() - dim = rdat.getDimension() - if dim != 2: - return ResponseMessageGeneric(msg) + records = a2radcommon.send_request(user_args) - yLen = rdat.getSizes()[0] - xLen = rdat.getSizes()[1] + if not records: + # print "Data not available" + return - # byte[] -- the raw data - array = rdat.getByteData() - arraySize = len(array) - if xLen * yLen != arraySize: - return ResponseMessageGeneric(msg) + description = user_args.description + if not description: + print >> sys.stderr, "Description not provided" + return - # get data for azimuth angles if we have them. - if dattyp == "radial" : - azVals = azdat.getFloatData() - azValsLen = len(azVals) - if yLen != azValsLen: - return ResponseMessageGeneric(msg) - description = "DDDDD" + format = user_args.extended + encoding = user_args.encoding - # Encode dimensions, time, mapping, description, tilt, and VCP - if hedfmt == "x" : - msg = "\n"+ str(xLen) + " " + str(yLen) + " " + mytime + " " + \ - dattyp + " " + str(rrec.getLatitude()) + " " + \ - str(rrec.getLongitude()) + " " + \ - str(rrec.getElevation()) + " " + \ - str(rrec.getElevationNumber()) + " " + \ - description + " " + str(rrec.getTrueElevationAngle()) + " " + \ - str(rrec.getVolumeCoveragePattern()) + "\n" - else : - msg = "\n"+ str(xLen) + " " + str(yLen) + " " + mytime + " " + \ - dattyp + " " + description + " " + \ - str(rrec.getTrueElevationAngle()) + " " + \ - str(rrec.getVolumeCoveragePattern()) + "\n" - - # Encode level labels - spec = [".", "TH", "ND", "RF", "BI", "GC", "IC", "GR", "WS", "DS", - "RA", "HR", "BD", "HA", "UK"] - nnn = len(threshVals) - j = 0 - while j 14 : - msg += "." - else : - msg += spec[lo] - continue - if hi % 16 >= 8 : - msg += ">" - elif hi % 8 >= 4 : - msg += "<" - if hi % 4 >= 2 : - msg += "+" - elif hi % 2 >= 1 : - msg += "-" - if hi >= 64 : - msg += "%.2f"%(lo*0.01) - elif hi % 64 >= 32 : - msg += "%.2f"%(lo*0.05) - elif hi % 32 >= 16 : - msg += "%.1f"%(lo*0.1) - else : - msg += str(lo) - msg += "\n" + print_record(records[0], format, description, encoding) - # Encode product dependent parameters 17 through 26 - nnn = len(depVals) - j = 0 - while jkk+20 or kkk : - msg += plus[k-kk] - else : - msg += minus[kk-k] - kk = k - i += 1 - msg += "\n" - j += xLen + idra = record.getHdf5Data() -return ResponseMessageGeneric(msg) + rdat,azdat,depVals,threshVals = a2radcommon.get_hdf5_data(idra) + + if not rdat: + # Graphic, XY + # print "Unsupported radar format" + return + + dim = rdat.getDimension() + if dim != 2: + # print "Data not available" + return + + yLen = rdat.getSizes()[0] + xLen = rdat.getSizes()[1] + + # byte[] -- the raw data + array = rdat.getByteData() + arraySize = len(array) + if xLen * yLen != arraySize: + # print "Data not available" + return + + # get data for azimuth angles if we have them. + if azdat : + azVals = azdat.getFloatData() + azValsLen = len(azVals) + if yLen != azValsLen: + # print "Data not available" + return + + msg = a2radcommon.get_header(record, format, xLen, yLen, azdat, description) + + msg += a2radcommon.encode_thresh_vals(threshVals) + msg += a2radcommon.encode_dep_vals(depVals) + if azdat : + msg += a2radcommon.encode_radial(azVals) + msg += encode_data(yLen, xLen, array, encoding) + + print msg.strip() + + +def encode_data(yLen, xLen, array, encoding): + plus = " ghijklmnopqrstuvwxyz" + minus = " GHIJKLMNOPQRSTUVWXYZ" + nxy = yLen*xLen + j = 0 + msg = "" + while jkk+20 or kkk : + msg += plus[k-kk] + else : + msg += minus[kk-k] + kk = k + i += 1 + msg += "\n" + j += xLen + return msg + + +if __name__ == '__main__': + main() diff --git a/pythonPackages/msaslaps/radar/a2gtradStubAll.py b/pythonPackages/msaslaps/radar/a2gtradStubAll.py index ff285fc912..34dc4a5c36 100644 --- a/pythonPackages/msaslaps/radar/a2gtradStubAll.py +++ b/pythonPackages/msaslaps/radar/a2gtradStubAll.py @@ -1,109 +1,165 @@ -import BaseRequest -import RadarRequest -from com.raytheon.uf.common.message.response import ResponseMessageGeneric -from com.raytheon.edex.plugin.radar.dao import RadarDao -import numpy - -# Perform a radar request for data of interest -rr = BaseRequest.BaseRequest("radar") -rr.addParameter("icao","KKKK","=") -rr.addParameter("productCode","MMMM","=") -rr.addParameter("primaryElevationAngle","EEEE","=") -rr.addParameter("dataTime","AAAAA",">=") -rr.addParameter("dataTime","BBBBB","<=") - -result = rr.execute() -size = result.size() -if size == 0: - return ResponseMessageGeneric("Data not available") - -# ResponseMessageGeneric. Payload is RadarRecord -rmg = result.get(0) -# return rmg - -# RadarRecord -rrec = rmg.getContents() +## +# 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. +## # -# From here to the end is the part we know how to do for radar but not -# for radar. +# Gets data for a single radar product from the A-II database. The result is +# output to stdout as ASCII. This uses a data-specific Request/Response instead +# of the DataAccessLayer in order to preserve data-genericness of the interface. +# +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 08/11/2014 3393 nabowle Initial modification. Replaces UEngine +# with a custom Request/Response. +# # -mytime = rrec.getDataURI().split('/',4)[2] -# RadarDao. Inherits from PluginDao, which has a getHDF5Data method, -# which takes a PluginDataObject as an arg. -raddao = RadarDao("radar") +import argparse +import a2radcommon -# returns IDataRecord[]. IDataRecord is implemented by only one class -- -# AbstractStorageRecord. ASR is extended by a few *DataRecord classes; one -# of them is ByteDataRecord -idra = raddao.getHDF5Data(rrec,-1) +def get_args(): + parser = a2radcommon.get_args_parser() + return parser.parse_args() -msg = "No data." -if len(idra) > 0: - # pick radar Data record - # record 0 contains Angles getFloatData - # record 1 contains Data getByteData - # record 2 contains DependentValues getShortData - # record 3 contains ProductVals getByteData - # record 4 contains RecordVals getByteData - # record 5 contains StormIds getByteData - # record 6 contains Symbology getByteData - # record 7 contains SymbologyData getByteData - # record 8 contains Thresholds getShortData - dattyp = "raster" - for ii in range(len(idra)): - if idra[ii].getName() == "Data": - rdat = idra[ii] - elif idra[ii].getName() == "Angles": - azdat = idra[ii] - dattyp = "radial" - elif idra[ii].getName() == "DependentValues": - depVals = idra[ii].getShortData() - elif idra[ii].getName() == "ProductVals": - prodVals = idra[ii].getByteData() - elif idra[ii].getName() == "RecordVals": - recVals = idra[ii].getByteData() - elif idra[ii].getName() == "StormIds": - stormVals = idra[ii].getByteData() - elif idra[ii].getName() == "Symbology": - symVals = idra[ii].getByteData() - elif idra[ii].getName() == "SymbologyData": - symData = idra[ii].getByteData() - elif idra[ii].getName() == "Thresholds": - threshVals = idra[ii].getShortData() - # this hints at the IDR's concrete class: ByteDataRecord - #print "true type of IDataRecord:", idr.getDataObject().toString() +def main(): + user_args = get_args() - dim = rdat.getDimension() - if dim != 2: - return ResponseMessageGeneric(msg) + records = a2radcommon.send_request(user_args) - yLen = rdat.getSizes()[0] - xLen = rdat.getSizes()[1] + if not records: + # print "Data not available" + return - # byte[] -- the raw data - array = rdat.getByteData() - arraySize = len(array) - if xLen * yLen != arraySize: - return ResponseMessageGeneric(msg) + description = user_args.description + if not description: + print >> sys.stderr, "Description not provided" + return - # get data for azimuth angles if we have them. - if dattyp == "radial" : - azVals = azdat.getFloatData() - azValsLen = len(azVals) - if yLen != azValsLen: - return ResponseMessageGeneric(msg) - description = "DDDDD" + print_record(records[0], description) - msg = "\n"+ str(xLen) + " " + str(yLen) + " " + mytime + " " + dattyp + \ - " " + description + "\n" - msg += str(rrec.getTrueElevationAngle()) + " " + \ - str(rrec.getVolumeCoveragePattern()) + "\n" +def print_record(record, description): + + idra = record.getHdf5Data() + + rdat,azdat,depVals,prodVals,recVals,stormVals,symVals,symData,threshVals = get_hdf5_data(idra) + + if not rdat: + # Graphic, XY + # print "Unsupported radar format" + return + + dim = rdat.getDimension() + if dim != 2: + # print "Data not available" + return + + yLen = rdat.getSizes()[0] + xLen = rdat.getSizes()[1] + + # byte[] -- the raw data + array = rdat.getByteData() + arraySize = len(array) + if xLen * yLen != arraySize: + # print "Data not available" + return + + # get data for azimuth angles if we have them. + if azdat : + azVals = azdat.getFloatData() + azValsLen = len(azVals) + if yLen != azValsLen: + # print "Data not available" + return + + msg = get_header(record, xLen, yLen, azdat, description) + msg += encode_dep_vals(depVals) + msg += encode_prod_vals(prodVals) + msg += encode_rec_vals(recVals) + msg += encode_storm_vals(stormVals) + msg += encode_sym_vals(symVals) + msg += encode_sym_data(symData) + msg += encode_thresh_vals(threshVals) + + if azdat : + msg += a2radcommon.encode_radial(azVals) + + msg += encode_data(yLen, xLen, array) + + print msg + + +def get_hdf5_data(idra): + rdat = [] + azdat = [] + depVals = [] + prodVals = [] + recVals = [] + stormVals = [] + symVals = [] + symData = [] + threshVals = [] + if len(idra) > 0: + for ii in range(len(idra)): + if idra[ii].getName() == "Data": + rdat = idra[ii] + elif idra[ii].getName() == "Angles": + azdat = idra[ii] + dattyp = "radial" + elif idra[ii].getName() == "DependentValues": + depVals = idra[ii].getShortData() + elif idra[ii].getName() == "ProductVals": + prodVals = idra[ii].getByteData() + elif idra[ii].getName() == "RecordVals": + recVals = idra[ii].getByteData() + elif idra[ii].getName() == "StormIds": + stormVals = idra[ii].getByteData() + elif idra[ii].getName() == "Symbology": + symVals = idra[ii].getByteData() + elif idra[ii].getName() == "SymbologyData": + symData = idra[ii].getByteData() + elif idra[ii].getName() == "Thresholds": + threshVals = idra[ii].getShortData() + + return rdat,azdat,depVals,prodVals,recVals,stormVals,symVals,symData,threshVals + + +def get_header(record, xLen, yLen, azdat, description): + # Encode dimensions, time, mapping, description, tilt, and VCP + mytime = a2radcommon.get_datetime_str(record) + dattyp = a2radcommon.get_data_type(azdat) + + msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + dattyp + \ + " " + description + "\n" + \ + str(record.getTrueElevationAngle()) + " " + \ + str(record.getVolumeCoveragePattern()) + "\n" + return msg + + +def encode_dep_vals(depVals): nnn = len(depVals) - msg += str(nnn) + msg = str(nnn) j = 0 while j 0: msg += " " + "%4.4X"%depVals[j] j += 1 msg += "\n" + return msg + +def encode_prod_vals(prodVals): nnn = len(prodVals) - msg += str(nnn) + msg = str(nnn) j = 0 while j 0: msg += " " + "%2.2X"%prodVals[j] j += 1 msg += "\n" + return msg + +def encode_rec_vals(recVals): nnn = len(recVals) - msg += str(nnn) + msg = str(nnn) j = 0 while j 0: msg += " " + "%2.2X"%recVals[j] j += 1 msg += "\n" + return msg + +def encode_storm_vals(stormVals): nnn = len(stormVals) - msg += str(nnn) + msg = str(nnn) j = 0 while j 0: msg += " " + "%2.2X"%stormVals[j] j += 1 msg += "\n" + return msg + +def encode_sym_vals(symVals): nnn = len(symVals) - msg += str(nnn) + msg = str(nnn) j = 0 while j 0: msg += " " + "%2.2X"%symVals[j] j += 1 msg += "\n" + return msg + +def encode_sym_data(symData): nnn = len(symData) - msg += str(nnn) + msg = str(nnn) j = 0 while j 0: msg += " " + "%2.2X"%symData[j] j += 1 msg += "\n" + return msg - spec = [".", "TH", "ND", "RF", "BI", "GC", "IC", "GR", "WS", "DS", - "RA", "HR", "BD", "HA", "UK"] - nnn = len(threshVals) - msg += str(nnn) - j = 0 - while j 14 : - msg += "." - else : - msg += spec[lo] - continue - if hi % 16 >= 8 : - msg += ">" - elif hi % 8 >= 4 : - msg += "<" - if hi % 4 >= 2 : - msg += "+" - elif hi % 2 >= 1 : - msg += "-" - if hi >= 64 : - msg += "%.2f"%(lo*0.01) - elif hi % 64 >= 32 : - msg += "%.2f"%(lo*0.05) - elif hi % 32 >= 16 : - msg += "%.1f"%(lo*0.1) - else : - msg += str(lo) - msg += "\n" - if dattyp == "radial" : - j = 0 - while j> sys.stderr, "DateTime not provided" + return + dateTime = datetime.strptime(dateTimeStr, "%Y-%m-%d %H:%M") + beginRange = dateTime - timedelta(0, slop) + endRange = dateTime + timedelta(0, slop) + + timerange = TimeRange(beginRange, endRange) + + radar = user_args.radar + if not radar: + print >> sys.stderr, "Radar code not provided" + return + + code = user_args.code + if not code: + print >> sys.stderr, "Product code not provided" + return + + angle = user_args.angle + + slop = int(user_args.slop) + + host = user_args.host + if not host: + host = get_default_host() + + client = ThriftClient.ThriftClient(host) + + # Perform a GetRadarHDF5Request + req = GetRadarDataRecordRequest() + req.setRadarId(radar) + req.setPrimaryElevationAngle(float(angle)) + req.setTimeRange(timerange) + req.setProductCode(int(code)) + + response = client.sendRequest(req) + + if response is None: + # print "Data not available" + return + + records = response.getData() + return records + + +def get_datetime_str(record): + #2014-07-16 00:00:00 (0) => 2014-07-16_00:03:00.0 + return str(record.getDataTime())[0:19].replace(" ","_") + ".0" + + +def get_data_type(azdat): + if azdat: + dattyp = "radial" + else : + dattyp = "raster" + return dattyp + + +def get_hdf5_data(idra): + rdat = [] + azdat = [] + depVals = [] + threshVals = [] + if len(idra) > 0: + for ii in range(len(idra)): + if idra[ii].getName() == "Data": + rdat = idra[ii] + elif idra[ii].getName() == "Angles": + azdat = idra[ii] + dattyp = "radial" + elif idra[ii].getName() == "DependentValues": + depVals = idra[ii].getShortData() +## Commented out from the original. May not be available. +# elif idra[ii].getName() == "ProductVals": +# prodVals = idra[ii].getByteData() +# elif idra[ii].getName() == "RecordVals": +# recVals = idra[ii].getByteData() +# elif idra[ii].getName() == "StormIds": +# stormVals = idra[ii].getByteData() +# elif idra[ii].getName() == "Symbology": +# symVals = idra[ii].getByteData() +# elif idra[ii].getName() == "SymbologyData": +# symData = idra[ii].getByteData() +## + elif idra[ii].getName() == "Thresholds": + threshVals = idra[ii].getShortData() + + return rdat,azdat,depVals,threshVals + + +def get_header(record, format, xLen, yLen, azdat, description): + # Encode dimensions, time, mapping, description, tilt, and VCP + mytime = get_datetime_str(record) + dattyp = get_data_type(azdat) + + if format : + msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + \ + dattyp + " " + str(record.getLatitude()) + " " + \ + str(record.getLongitude()) + " " + \ + str(record.getElevation()) + " " + \ + str(record.getElevationNumber()) + " " + \ + description + " " + str(record.getTrueElevationAngle()) + " " + \ + str(record.getVolumeCoveragePattern()) + "\n" +#"%.1f"% + else : + msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + \ + dattyp + " " + description + " " + \ + str(record.getTrueElevationAngle()) + " " + \ + str(record.getVolumeCoveragePattern()) + "\n" + + return msg + + +def encode_thresh_vals(threshVals): + spec = [".", "TH", "ND", "RF", "BI", "GC", "IC", "GR", "WS", "DS", + "RA", "HR", "BD", "HA", "UK"] + nnn = len(threshVals) + j = 0 + msg = "" + while j 14 : + msg += "." + else : + msg += spec[lo] + continue + if hi % 16 >= 8 : + msg += ">" + elif hi % 8 >= 4 : + msg += "<" + if hi % 4 >= 2 : + msg += "+" + elif hi % 2 >= 1 : + msg += "-" + if hi >= 64 : + msg += "%.2f"%(lo*0.01) + elif hi % 64 >= 32 : + msg += "%.2f"%(lo*0.05) + elif hi % 32 >= 16 : + msg += "%.1f"%(lo*0.1) + else : + msg += str(lo) + msg += "\n" + return msg + + +def encode_dep_vals(depVals): + nnn = len(depVals) + j = 0 + msg = "" + while j