Issue #2947 Minor satellite and derived parameter improvements.
Former-commit-id: d5fe527ff45e02cbbba3a92f2031d500db879839
This commit is contained in:
parent
8a682a5e23
commit
dd794a3c12
5 changed files with 136 additions and 92 deletions
|
@ -28,10 +28,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.inventory.data.AbstractRequestableData;
|
||||
import com.raytheon.uf.common.inventory.exception.DataCubeException;
|
||||
import com.raytheon.uf.common.inventory.TimeAndSpace;
|
||||
import com.raytheon.uf.common.inventory.tree.AbstractRequestableNode;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequestSet;
|
||||
|
@ -43,7 +39,12 @@ import com.raytheon.uf.common.datastorage.Request;
|
|||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.derivparam.inv.AvailabilityContainer;
|
||||
import com.raytheon.uf.common.derivparam.inv.MetadataContainer;
|
||||
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.inventory.tree.AbstractRequestableNode;
|
||||
import com.raytheon.uf.common.serialization.comm.RequestRouter;
|
||||
import com.raytheon.uf.common.time.BinOffset;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
||||
/**
|
||||
|
@ -54,12 +55,14 @@ import com.raytheon.uf.common.time.DataTime;
|
|||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 30, 2012 mschenke Initial creation
|
||||
* Feb 25, 2013 1659 bsteffen Stop derived parameters from sending
|
||||
* empty requests for cached times
|
||||
* Jan 30, 2014 #2725 ekladstrup Remove usage of ThriftClient
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 30, 2012 mschenke Initial creation
|
||||
* Feb 25, 2013 1659 bsteffen Stop derived parameters from sending
|
||||
* empty requests for cached times
|
||||
* Jan 30, 2014 2725 ekladstrup Remove usage of ThriftClient
|
||||
* Apr 11, 2014 2947 bsteffen Fix binoffset time queries and getRecord.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -169,6 +172,11 @@ public abstract class AbstractDataCubeAdapter extends DefaultDataCubeAdapter {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (request.getBinOffset() != null) {
|
||||
BinOffset bin = request.getBinOffset();
|
||||
results = bin.getNormalizedTimes(results
|
||||
.toArray(new DataTime[0]));
|
||||
}
|
||||
if (!request.isMaxQuery() || results.isEmpty()) {
|
||||
finalResponse.add(new ArrayList<DataTime>(results));
|
||||
} else {
|
||||
|
@ -255,7 +263,13 @@ public abstract class AbstractDataCubeAdapter extends DefaultDataCubeAdapter {
|
|||
public IDataRecord[] getRecord(PluginDataObject obj, Request req,
|
||||
String dataset) throws DataCubeException {
|
||||
getRecords(Arrays.asList(obj), req, dataset);
|
||||
IDataRecord[] result = (IDataRecord[]) obj.getMessageData();
|
||||
IDataRecord[] result = null;
|
||||
Object message = obj.getMessageData();
|
||||
if (message instanceof IDataRecord[]) {
|
||||
result = (IDataRecord[]) message;
|
||||
} else if (message instanceof IDataRecord) {
|
||||
result = new IDataRecord[] { (IDataRecord) message };
|
||||
}
|
||||
obj.setMessageData(null);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -65,13 +65,16 @@ import com.vividsolutions.jts.geom.Polygon;
|
|||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 24, 2007 353 bphillip Initial Checkin
|
||||
* Jul 12, 2012 798 jkorman Changed projection "magic" numbers
|
||||
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
|
||||
* spatial
|
||||
* Sep 30, 2013 2333 mschenke Refactored to store coordinates in CRS space
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 24, 2007 353 bphillip Initial Checkin
|
||||
* Jul 12, 2012 798 jkorman Changed projection "magic" numbers
|
||||
* Jul 16, 2013 2181 bsteffen Convert geometry types to use hibernate-
|
||||
* spatial
|
||||
* Sep 30, 2013 2333 mschenke Refactored to store coordinates in CRS
|
||||
* space
|
||||
* Apr 11, 2014 2947 bsteffen Fix equals
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
|
@ -417,9 +420,15 @@ public class SatMapCoverage extends PersistableDataObject<Object> implements
|
|||
if (Double.doubleToLongBits(minY) != Double
|
||||
.doubleToLongBits(other.minY))
|
||||
return false;
|
||||
if (nx != other.nx)
|
||||
if (nx == null) {
|
||||
if (other.nx != null)
|
||||
return false;
|
||||
} else if (!nx.equals(other.nx))
|
||||
return false;
|
||||
if (ny != other.ny)
|
||||
if (ny == null) {
|
||||
if (other.ny != null)
|
||||
return false;
|
||||
} else if (!ny.equals(other.ny))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Map;
|
|||
|
||||
import jep.JepException;
|
||||
|
||||
import com.raytheon.uf.common.inventory.tree.CubeLevel;
|
||||
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
|
@ -35,8 +34,9 @@ import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
|
|||
import com.raytheon.uf.common.datastorage.records.LongDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.ShortDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.StringDataRecord;
|
||||
import com.raytheon.uf.common.python.PythonInterpreter;
|
||||
import com.raytheon.uf.common.derivparam.library.DerivedParameterRequest;
|
||||
import com.raytheon.uf.common.inventory.tree.CubeLevel;
|
||||
import com.raytheon.uf.common.python.PythonInterpreter;
|
||||
|
||||
/**
|
||||
* A script for running the master derived parameter script, which can run any
|
||||
|
@ -44,12 +44,14 @@ import com.raytheon.uf.common.derivparam.library.DerivedParameterRequest;
|
|||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 8, 2008 njensen Initial creation
|
||||
* Nov 20, 2009 #3387 jelkins Use derived script's variableId instead of filename
|
||||
* Nov 21, 2009 #3576 rjpeter Refactored to populate DerivParamDesc.
|
||||
* Oct 29, 2013 2476 njensen Renamed numeric methods to numpy
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 08, 2008 njensen Initial creation
|
||||
* Nov 20, 2009 3387 jelkins Use derived script's variableId instead of filename
|
||||
* Nov 21, 2009 3576 rjpeter Refactored to populate DerivParamDesc.
|
||||
* Oct 29, 2013 2476 njensen Renamed numeric methods to numpy
|
||||
* Apr 11, 2014 2947 bsteffen Allow returning NaN
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
|
@ -351,20 +353,9 @@ public class MasterDerivScript extends PythonInterpreter {
|
|||
}
|
||||
|
||||
private void filterResult() throws JepException {
|
||||
StringBuilder script = new StringBuilder();
|
||||
jep.eval("import numpy");
|
||||
// Float NaN filtering
|
||||
script.append("if isinstance(" + RESULT + ", numpy.ndarray) and "
|
||||
+ RESULT + ".dtype == numpy.float32:\n");
|
||||
script.append(" " + RESULT + "[" + RESULT + " <= -9999] = -999999\n");
|
||||
script.append(" " + RESULT + "[" + RESULT + " >= 999999] = -999999\n");
|
||||
script.append(" " + RESULT + "[ numpy.isnan(" + RESULT
|
||||
+ ") ] = -999999\n");
|
||||
script.append(" " + RESULT + "[ numpy.isinf(" + RESULT
|
||||
+ ") ] = -999999\n");
|
||||
jep.eval(script.toString());
|
||||
script = new StringBuilder();
|
||||
// String conversion
|
||||
jep.eval("import numpy");
|
||||
StringBuilder script = new StringBuilder();
|
||||
script.append("if isinstance(" + RESULT + ", numpy.ndarray) and "
|
||||
+ RESULT + ".dtype.kind == \"S\":\n");
|
||||
script.append(" " + RESULT + "=" + RESULT + ".flatten().tolist()\n");
|
||||
|
|
|
@ -32,13 +32,6 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.inventory.data.AbstractRequestableData;
|
||||
import com.raytheon.uf.common.inventory.data.AliasRequestableData;
|
||||
import com.raytheon.uf.common.inventory.exception.DataCubeException;
|
||||
import com.raytheon.uf.common.inventory.TimeAndSpace;
|
||||
import com.raytheon.uf.common.inventory.TimeAndSpaceMatcher;
|
||||
import com.raytheon.uf.common.inventory.TimeAndSpaceMatcher.MatchResult;
|
||||
import com.raytheon.uf.common.inventory.tree.AbstractRequestableNode;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.derivparam.data.DerivedRequestableData;
|
||||
import com.raytheon.uf.common.derivparam.inv.AvailabilityContainer;
|
||||
|
@ -47,6 +40,13 @@ import com.raytheon.uf.common.derivparam.library.DerivParamField;
|
|||
import com.raytheon.uf.common.derivparam.library.DerivParamMethod;
|
||||
import com.raytheon.uf.common.derivparam.library.DerivedParameterRequest;
|
||||
import com.raytheon.uf.common.derivparam.library.IDerivParamField;
|
||||
import com.raytheon.uf.common.inventory.TimeAndSpace;
|
||||
import com.raytheon.uf.common.inventory.TimeAndSpaceMatcher;
|
||||
import com.raytheon.uf.common.inventory.TimeAndSpaceMatcher.MatchResult;
|
||||
import com.raytheon.uf.common.inventory.data.AbstractRequestableData;
|
||||
import com.raytheon.uf.common.inventory.data.AliasRequestableData;
|
||||
import com.raytheon.uf.common.inventory.exception.DataCubeException;
|
||||
import com.raytheon.uf.common.inventory.tree.AbstractRequestableNode;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
||||
/**
|
||||
|
@ -57,9 +57,10 @@ import com.raytheon.uf.common.time.DataTime;
|
|||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 14, 2009 rjpeter Initial creation
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Dec 14, 2009 rjpeter Initial creation
|
||||
* Apr 11, 2014 2947 bsteffen Don't check units until data is requested.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -400,15 +401,11 @@ public class DerivedLevelNode extends AbstractDerivedDataNode {
|
|||
Set<AbstractRequestableData> newRecs = new HashSet<AbstractRequestableData>(
|
||||
records.size());
|
||||
for (AbstractRequestableData record : records) {
|
||||
if (record.getUnit() != null
|
||||
&& !record.getUnit().equals(field.getUnit())
|
||||
&& record.getUnit().isCompatible(field.getUnit())) {
|
||||
AbstractRequestableData alias = new AliasRequestableData(record);
|
||||
alias.setUnit(field.getUnit());
|
||||
newRecs.add(alias);
|
||||
} else {
|
||||
newRecs.add(record);
|
||||
}
|
||||
/* Wrap in an alias to perform unit conversion when necessary. */
|
||||
AbstractRequestableData alias = new AliasRequestableData(record);
|
||||
alias.setUnit(field.getUnit());
|
||||
newRecs.add(alias);
|
||||
|
||||
}
|
||||
return newRecs;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,12 @@ import javax.measure.converter.UnitConverter;
|
|||
import javax.measure.unit.NonSI;
|
||||
import javax.measure.unit.Unit;
|
||||
|
||||
import com.raytheon.uf.common.inventory.exception.DataCubeException;
|
||||
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.IntegerDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.ShortDataRecord;
|
||||
import com.raytheon.uf.common.inventory.exception.DataCubeException;
|
||||
|
||||
/**
|
||||
* Represents a simple alias, where a parameter represents the same data as
|
||||
|
@ -42,6 +45,8 @@ import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
|||
* ------------- -------- ----------- --------------------------
|
||||
* Jan 15, 2010 3965 rjpeter Initial creation
|
||||
* Jan 14, 2014 2661 bsteffen Make vectors u,v only
|
||||
* Apr 11, 2014 2947 bsteffen Perform unit conversion on more types of
|
||||
* records.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -59,6 +64,7 @@ public class AliasRequestableData extends AbstractRequestableData {
|
|||
this.space = sourceRecord.space;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDataValue(Object arg) throws DataCubeException {
|
||||
return getDataAndConvert(sourceRecord, arg);
|
||||
}
|
||||
|
@ -102,41 +108,14 @@ public class AliasRequestableData extends AbstractRequestableData {
|
|||
if ((Float) rval > -9999) {
|
||||
rval = converter.convert((Float) rval);
|
||||
}
|
||||
} else if (rval instanceof FloatDataRecord) {
|
||||
float[] data = ((FloatDataRecord) rval).getFloatData();
|
||||
for (int c = 0; c < data.length; c++) {
|
||||
if (data[c] > -9999) {
|
||||
|
||||
data[c] = (float) converter.convert(data[c]);
|
||||
}
|
||||
}
|
||||
} else if (rval instanceof FloatDataRecord[]) {
|
||||
FloatDataRecord[] recs = (FloatDataRecord[]) rval;
|
||||
if (recs.length != 1 || !unit.equals(NonSI.DEGREE_ANGLE)) {
|
||||
for (int i = 0; i < recs.length; i++) {
|
||||
float[] data = recs[i].getFloatData();
|
||||
for (int c = 0; c < data.length; c++) {
|
||||
if (data[c] > -9999) {
|
||||
data[c] = (float) converter
|
||||
.convert(data[c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (rval instanceof IDataRecord) {
|
||||
rval = convertDataRecord(converter, (IDataRecord) rval);
|
||||
} else if (rval instanceof IDataRecord[]) {
|
||||
IDataRecord[] recs = (IDataRecord[]) rval;
|
||||
if (recs.length != 1 || !unit.equals(NonSI.DEGREE_ANGLE)) {
|
||||
rval = recs = Arrays.copyOf(recs, recs.length);
|
||||
for (int i = 0; i < recs.length; i++) {
|
||||
if (recs[i] instanceof FloatDataRecord) {
|
||||
float[] data = ((FloatDataRecord) recs[i])
|
||||
.getFloatData();
|
||||
for (int c = 0; c < data.length; c++) {
|
||||
if (data[c] > -9999) {
|
||||
data[c] = (float) converter
|
||||
.convert(data[c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
recs[i] = convertDataRecord(converter, recs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,6 +124,60 @@ public class AliasRequestableData extends AbstractRequestableData {
|
|||
return rval;
|
||||
}
|
||||
|
||||
private static IDataRecord convertDataRecord(UnitConverter converter,
|
||||
IDataRecord record) {
|
||||
float[] newData = null;
|
||||
double fillValue = Double.NaN;
|
||||
if (record.getFillValue() != null) {
|
||||
fillValue = record.getFillValue().doubleValue();
|
||||
}
|
||||
if (record instanceof FloatDataRecord) {
|
||||
float[] data = ((FloatDataRecord) record).getFloatData();
|
||||
newData = new float[data.length];
|
||||
for (int c = 0; c < data.length; c++) {
|
||||
if (data[c] == fillValue) {
|
||||
newData[c] = Float.NaN;
|
||||
} else {
|
||||
newData[c] = (float) converter.convert(data[c]);
|
||||
}
|
||||
}
|
||||
} else if (record instanceof ByteDataRecord) {
|
||||
byte[] data = ((ByteDataRecord) record).getByteData();
|
||||
newData = new float[data.length];
|
||||
for (int c = 0; c < data.length; c++) {
|
||||
if (data[c] == fillValue) {
|
||||
newData[c] = Float.NaN;
|
||||
} else {
|
||||
newData[c] = (float) converter.convert(data[c]);
|
||||
}
|
||||
}
|
||||
} else if (record instanceof ShortDataRecord) {
|
||||
short[] data = ((ShortDataRecord) record).getShortData();
|
||||
newData = new float[data.length];
|
||||
for (int c = 0; c < data.length; c++) {
|
||||
if (data[c] == fillValue) {
|
||||
newData[c] = Float.NaN;
|
||||
} else {
|
||||
newData[c] = (float) converter.convert(data[c]);
|
||||
}
|
||||
}
|
||||
} else if (record instanceof IntegerDataRecord) {
|
||||
int[] data = ((IntegerDataRecord) record).getIntData();
|
||||
newData = new float[data.length];
|
||||
for (int c = 0; c < data.length; c++) {
|
||||
if (data[c] == fillValue) {
|
||||
newData[c] = Float.NaN;
|
||||
} else {
|
||||
newData[c] = (float) converter.convert(data[c]);
|
||||
}
|
||||
}
|
||||
} else{
|
||||
return record;
|
||||
}
|
||||
return new FloatDataRecord(record.getName(), record.getGroup(),
|
||||
newData, record.getDimension(), record.getSizes());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue