/** * Get a set of sounding obs based on the choice * * @param dataChoice DataChoice for data * @param subset subselection criteria * @return corresponding sounding observations * @throws RemoteException Java RMI problem * @throws VisADException VisAD problem */ private Data getSoundingObs(DataChoice dataChoice, DataSelection subset) throws VisADException, RemoteException { Vector v = new Vector(); List choices = (dataChoice instanceof CompositeDataChoice) ? ((CompositeDataChoice) dataChoice).getDataChoices() : Arrays.asList(new DataChoice[] {dataChoice}); Object t = subset.getProperty(DataSelection.PROP_USESTIMEDRIVER); if ((t instanceof Boolean) && (useDriverTime == false)) { useDriverTime = ((Boolean) t).booleanValue(); } if (useDriverTime) { // getAllTimesForTimeDriver(dataChoice, subset, // subset.getTimeDriverTimes()); if (initTimes == null) { initTimes = subset.getTimeDriverTimes(); } if (initTimes != null) { // reset the time for data choice if useDriverTime List<SoundingOb> soundingObs = getTimeMatchingSoundingObs(initTimes); choices = getTimeMatchingDataChoices(soundingObs); } } for (Iterator iter = choices.iterator(); iter.hasNext(); ) { DataChoice dc = (DataChoice) iter.next(); Data ob = makeSoundingOb(dc, subset); if (ob != null) { v.add(ob); } } return (v.isEmpty()) ? null : new Tuple((Data[]) v.toArray(new Data[v.size()]), false); }
/** * Get the data represented by this class. Calls makeObs, real work needs to be implemented there. * * @param dataChoice choice for data * @param category category of data * @param dataSelection subselection properties * @param requestProperties additional selection properties (not used here) * @return Data object representative of the choice * @throws RemoteException Java RMI error * @throws VisADException VisAD Error */ protected Data getDataInner( DataChoice dataChoice, DataCategory category, DataSelection dataSelection, Hashtable requestProperties) throws VisADException, RemoteException { Object id = dataChoice.getId(); // CompositeDataChoice // If it is a list then we are doing a grid field boolean doGriddedData = false; if (id instanceof List) { if (((List) id).get(0) instanceof Integer) { doGriddedData = true; } } if (doGriddedData) { List idList = (List) id; // Integer i = (Integer) idList.get(0); RealType type = (RealType) idList.get(1); Hashtable properties = dataChoice.getProperties(); if (properties == null) { properties = new Hashtable(); } Data firstGuessData = null; boolean doFirstGuessField = false; if (idList.size() > 2) { doFirstGuessField = ((Boolean) idList.get(2)).booleanValue(); } if (doFirstGuessField) { DataChoice firstGuessDataChoice = (DataChoice) dataChoice.getProperty(PROP_FIRSTGUESS); if (firstGuessDataChoice == null) { List operands = new ArrayList(); List categories = DataCategory.parseCategories("GRID-2D-TIME;GRID-3D-TIME", false); operands.add( new DataOperand("First Guess Field", "First Guess Field", categories, false)); List userValues = getDataContext().selectDataChoices(operands); if (userValues == null) { return null; } firstGuessDataChoice = (DataChoice) userValues.get(0); dataChoice.setObjectProperty(PROP_FIRSTGUESS, firstGuessDataChoice); } if (firstGuessDataChoice != null) { firstGuessData = firstGuessDataChoice.getData(null); if (firstGuessData == null) { return null; } } } // Merge the point obs properties.put(PROP_GRID_PARAM, type); FieldImpl pointObs = null; List datas = new ArrayList(); for (int i = 0; i < sources.size(); i++) { DataChoice choice = new DirectDataChoice( this, new Integer(i), "", "", dataChoice.getCategories(), properties); pointObs = (FieldImpl) getDataInner(choice, category, dataSelection, requestProperties); if (pointObs != null) { datas.add(pointObs); } } if (datas.size() == 0) { return null; } pointObs = PointObFactory.mergeData(datas); if (pointObs == null) { return null; } // { minY, minX, maxY, maxX }; float spacingX = this.gridX; float spacingY = this.gridY; int passes = this.numGridPasses; float gain = this.gridGain; float searchRadius = this.gridSearchRadius; Number tmp; tmp = (Float) dataSelection.getProperty(PROP_GRID_X); if (tmp != null) { spacingX = tmp.floatValue(); } tmp = (Float) dataSelection.getProperty(PROP_GRID_Y); if (tmp != null) { spacingY = tmp.floatValue(); } tmp = (Integer) dataSelection.getProperty(PROP_GRID_NUMPASSES); if (tmp != null) { passes = tmp.intValue(); } String theUnit = (String) dataSelection.getProperty(PROP_GRID_UNIT); if (theUnit == null) { theUnit = this.gridUnit; } tmp = (Float) dataSelection.getProperty(PROP_GRID_GAIN); if (tmp != null) { gain = tmp.floatValue(); } tmp = (Float) dataSelection.getProperty(PROP_GRID_SEARCH_RADIUS); if (tmp != null) { searchRadius = tmp.floatValue(); } float degreesX = 0, degreesY = 0; pointObs = PointObFactory.makeTimeSequenceOfPointObs(pointObs); if (theUnit.equals(SPACING_COMPUTE) || (spacingX <= 0) || (spacingY <= 0)) { degreesX = PointObFactory.OA_GRID_DEFAULT; degreesY = PointObFactory.OA_GRID_DEFAULT; if ((searchRadius == DEFAULT_RADIUS) && (firstGuessData == null)) { searchRadius = PointObFactory.OA_GRID_DEFAULT; } } else if (theUnit.equals(SPACING_POINTS)) { double[] bbox = PointObFactory.getBoundingBox(pointObs); float spanX = (float) Math.abs(bbox[1] - bbox[3]); float spanY = (float) Math.abs(bbox[0] - bbox[2]); degreesX = spanX / (int) spacingX; degreesY = spanY / (int) spacingY; } else if (theUnit.equals(SPACING_DEGREES)) { degreesX = spacingX; degreesY = spacingY; } Barnes.AnalysisParameters ap = new Barnes.AnalysisParameters(degreesX, degreesY, searchRadius, 0.0d); log_.debug( "X = " + degreesX + " Y = " + degreesY + " unit = " + theUnit + " gain = " + gain + " search = " + searchRadius); LogUtil.message("Doing Barnes Analysis"); FieldImpl fi = PointObFactory.barnes( pointObs, type, degreesX, degreesY, passes, gain, searchRadius, ap, (FieldImpl) firstGuessData); if (ap.getGridXArray() != null) { log_.debug( "Analysis params: X = " + ap.getGridXArray().length + " Y = " + ap.getGridYArray().length + " search = " + ap.getScaleLengthGU() + " random = " + ap.getRandomDataSpacing()); } return fi; } GeoSelection geoSelection = ((dataSelection != null) ? dataSelection.getGeoSelection() : null); GeoLocationInfo bbox = ((geoSelection == null) ? null : geoSelection.getBoundingBox()); LatLonRect llr = ((bbox != null) ? bbox.getLatLonRect() : null); FieldImpl retField = null; try { // List choices = (List) dataChoice.getId(); List choices = (dataChoice instanceof CompositeDataChoice) ? ((CompositeDataChoice) dataChoice).getDataChoices() : Misc.toList(new DataChoice[] {dataChoice}); List datas = new ArrayList(choices.size()); for (int i = 0; i < choices.size(); i++) { DataChoice subDataChoice = (DataChoice) choices.get(i); FieldImpl obs = makeObs(subDataChoice, dataSelection, llr); if (obs == null) { continue; } // if (true) { // return obs; // } datas.add(obs); if (fieldsDescription == null) { makeFieldDescription(obs); } } if (datas.isEmpty()) { return null; } retField = PointObFactory.mergeData(datas); } catch (Exception exc) { logException("Creating obs", exc); } return retField; }