/** * Look for Axis by Type and test against a predicate * @param ds look in this dataset's "Best" coordinate system. * @param atype look for this type of CoordinateAxis. * @param p match this predicate; may be null * @return the found CoordinateAxis, or null if none */ static public CoordinateAxis findCoordByType(NetcdfDataset ds, AxisType atype, Predicate p) { // try the "best" coordinate system CoordinateSystem use = findBestCoordinateSystem(ds); if (use == null) return null; CoordinateAxis result = findCoordByType(use.getCoordinateAxes(), atype, p); if (result != null) return result; // try all the axes return findCoordByType(ds.getCoordinateAxes(), atype, p); }
private TableConfig makeStructTableTestTraj(NetcdfDataset ds, FeatureType ftype, EncodingInfo info, Formatter errlog) throws IOException { Table.Type tableType = Table.Type.Structure; if (info.encoding == Encoding.single) tableType = Table.Type.Top; if (info.encoding == Encoding.flat) tableType = Table.Type.ParentId; String name = (info.parentDim == null) ? " single" : info.parentDim.getShortName(); TableConfig tableConfig = new TableConfig(tableType, name); tableConfig.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat); tableConfig.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon); tableConfig.elev = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Height); if (tableConfig.elev == null) tableConfig.elev = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Pressure); if (tableConfig.elev == null) tableConfig.elev = CoordSysEvaluator.findCoordNameByType(ds, AxisType.GeoZ); tableConfig.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time); tableConfig.featureType = ftype; if (info.encoding != Encoding.single) { tableConfig.dimName = name; makeStructureInfo(tableConfig, ds, null, info.parentDim); } return tableConfig; }
/** * Look for Axis by Type, assign to TableConfig if found. * Looks for Lat, Lon, Time, Height. * @param nt set coordinates short names in this table. * @param ds look in this dataset's "Best" coordinate system. If no CoordSystem, try list of coordinate axes */ static public void findCoords(TableConfig nt, NetcdfDataset ds, Predicate p) { nt.lat = findCoordShortNameByType(ds, AxisType.Lat, p); nt.lon = findCoordShortNameByType(ds, AxisType.Lon, p); nt.time = findCoordShortNameByType(ds, AxisType.Lat, p); nt.elev = findCoordShortNameByType(ds, AxisType.Height, p); if (nt.elev == null) nt.elev = findCoordShortNameByType(ds, AxisType.Pressure, p); }
/** * Look for Axis by Type, assign to TableConfig if found. * Looks for Lat, Lon, Time, Height. * @param nt assign coordinates to this table. * @param ds look in this dataset's "Best" coordinate system. If no CoordSystem, try list of coordinate axes */ static public void findCoords(TableConfig nt, NetcdfDataset ds) { CoordinateSystem use = findBestCoordinateSystem(ds); if (use == null) findCoords(nt, ds.getCoordinateAxes()); else findCoords(nt, use.getCoordinateAxes()); }
/** * Look for Axis by Type. * @param ds look in this dataset's "Best" coordinate system. * @param atype look for this type of CoordinateAxis. takes the first one it finds. * @return the found CoordinateAxis, or null if none */ static public CoordinateAxis findCoordByType(NetcdfDataset ds, AxisType atype) { return findCoordByType(ds, atype, null); }
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) { Dimension obsDim = ds.getUnlimitedDimension(); if (obsDim == null) { CoordinateAxis axis = CoordSysEvaluator.findCoordByType(ds, AxisType.Time); if ((axis != null) && axis.isScalar()) obsDim = axis.getDimension(0); nt.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure; nt.featureType = FeatureType.POINT; CoordSysEvaluator.findCoords(nt, ds); return nt; nt.featureType = FeatureType.STATION; nt.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat); nt.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon); obs.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure; obs.dimName = obsDim.getShortName(); obs.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time); nt.addChild(obs);
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) throws IOException { TableConfig topTable = new TableConfig(Table.Type.Top, "singleTrajectory"); CoordinateAxis coordAxis = CoordSysEvaluator.findCoordByType(ds, AxisType.Time); if (coordAxis == null) { errlog.format("Cant find a time coordinate"); return null; } final Dimension innerDim = coordAxis.getDimension(0); boolean obsIsStruct = Evaluator.hasNetcdf3RecordStructure(ds) && innerDim.isUnlimited(); TableConfig obsTable = new TableConfig(Table.Type.Structure, innerDim.getShortName()); obsTable.dimName = innerDim.getShortName(); obsTable.time = coordAxis.getFullName(); obsTable.structName = obsIsStruct ? "record" : innerDim.getShortName(); obsTable.structureType = obsIsStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure; CoordSysEvaluator.findCoords(obsTable, ds, new CoordSysEvaluator.Predicate() { public boolean match(CoordinateAxis axis) { return innerDim.equals(axis.getDimension(0)); } }); topTable.addChild(obsTable); return topTable; } }
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) { Dimension obsDim = ds.findDimension("time"); if (obsDim == null) { CoordinateAxis axis = CoordSysEvaluator.findCoordByType(ds, AxisType.Time); if ((axis != null) && axis.isScalar()) obsDim = axis.getDimension(0); nt.featureType = FeatureType.STATION; nt.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat); nt.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon); obs.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure; obs.dimName = obsDim.getShortName(); obs.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time); nt.addChild(obs);
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) { Dimension stationDim = CoordSysEvaluator.findDimensionByType(ds, AxisType.Lat); if (stationDim == null) { errlog.format("Must have a latitude coordinate"); Dimension obsDim = CoordSysEvaluator.findDimensionByType(ds, AxisType.Time); if (obsDim == null) { errlog.format("Must have a Time coordinate"); stationTable.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat); stationTable.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon); stationTable.stnAlt = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Height); obsTable.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time); obsTable.outerName = stationDim.getShortName(); obsTable.dimName = obsDim.getShortName();
protected TableConfig getStationConfig(NetcdfDataset ds, Formatter errlog) throws IOException { Variable lat = CoordSysEvaluator.findCoordByType(ds, AxisType.Lat); if (lat == null) { errlog.format("CdmDirect: Must have a Latitude coordinate%n"); Variable lon = CoordSysEvaluator.findCoordByType(ds, AxisType.Lon); if (lon == null) { errlog.format("CdmDirect: Must have a Longitude coordinate%n"); Variable alt = CoordSysEvaluator.findCoordByType(ds, AxisType.Height); if (alt != null) stnTable.stnAlt = alt.getShortName(); obs.time = CoordSysEvaluator.findCoordShortNameByType(ds, AxisType.Time); if (obs.time == null) { errlog.format("Must have a time coordinate%n");
if (v instanceof Structure) { // handles Sequences too TableConfig st = new TableConfig(Table.Type.Structure, v.getFullName()); CoordSysEvaluator.findCoords(st, ds); st.structName = v.getFullName(); st.nestedTableName = v.getShortName(); st.structName = obsDim.isUnlimited() ? "record" : obsDim.getShortName(); st.dimName = obsDim.getShortName(); CoordSysEvaluator.findCoordWithDimension(st, ds, obsDim); CoordinateAxis time = CoordSysEvaluator.findCoordByType(ds, AxisType.Time); if ((time != null) && (time.getRank() == 0)) { st.addJoin(new JoinArray(time, JoinArray.Type.scalar, 0)); st.structureType = TableConfig.StructureType.PsuedoStructure; st.dimName = obsDim.getShortName(); CoordSysEvaluator.findCoords(st, ds);
/** * Look for Axis by Type and test against a predicate * @param ds look in this dataset's "Best" coordinate system. * @param atype look for this type of CoordinateAxis. * @param p match this predicate * @return the found CoordinateAxis, or null if none */ static public CoordinateAxis findCoordByType(NetcdfDataset ds, AxisType atype, Predicate p) { CoordinateSystem use = findBestCoordinateSystem(ds); if (use == null) return null; // try the "best" cs for (CoordinateAxis axis : use.getCoordinateAxes()) { if (axis.getAxisType() == atype) if (p.match(axis)) return axis; } // try all the axes for (CoordinateAxis axis : ds.getCoordinateAxes()) { if (axis.getAxisType() == atype) if (p.match(axis)) return axis; } return null; }
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) throws IOException { TableConfig topTable = new TableConfig(Table.Type.Top, "singleTrajectory"); CoordinateAxis coordAxis = CoordSysEvaluator.findCoordByType(ds, AxisType.Time); if (coordAxis == null) { errlog.format("Cant find a time coordinate"); return null; } Dimension innerDim = coordAxis.getDimension(0); boolean obsIsStruct = Evaluator.hasRecordStructure(ds) && innerDim.isUnlimited(); TableConfig obsTable = new TableConfig(Table.Type.Structure, innerDim.getShortName()); obsTable.dimName = innerDim.getShortName(); obsTable.time = coordAxis.getFullName(); obsTable.structName = obsIsStruct ? "record" : innerDim.getShortName(); obsTable.structureType = obsIsStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure; CoordSysEvaluator.findCoordWithDimension(obsTable, ds, innerDim); topTable.addChild(obsTable); return topTable; } }
/** * Search for Axis by Type. * @param ds search in this dataset's "Best" coordinate system. * @param atype search for this type of CoordinateAxis. takes the first one it finds. * @return the found CoordinateAxis, or null if none */ static public CoordinateAxis findCoordByType(NetcdfDataset ds, AxisType atype) { return findCoordByType(ds, atype, null); }
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) { Dimension obsDim = ds.getUnlimitedDimension(); if (obsDim == null) { CoordinateAxis axis = CoordSysEvaluator.findCoordByType(ds, AxisType.Time); if ((axis != null) && axis.isScalar()) obsDim = axis.getDimension(0); nt.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure; nt.featureType = FeatureType.POINT; CoordSysEvaluator.findCoords(nt, ds, null); return nt; nt.featureType = FeatureType.STATION; nt.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat); nt.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon); obs.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure; obs.dimName = obsDim.getShortName(); obs.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time); nt.addChild(obs);
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) throws IOException { TableConfig topTable = new TableConfig(Table.Type.Top, "singleTrajectory"); CoordinateAxis coordAxis = CoordSysEvaluator.findCoordByType(ds, AxisType.Time); if (coordAxis == null) { errlog.format("Cant find a time coordinate"); return null; } final Dimension innerDim = coordAxis.getDimension(0); boolean obsIsStruct = Evaluator.hasNetcdf3RecordStructure(ds) && innerDim.isUnlimited(); TableConfig obsTable = new TableConfig(Table.Type.Structure, innerDim.getShortName()); obsTable.dimName = innerDim.getShortName(); obsTable.time = coordAxis.getFullName(); obsTable.structName = obsIsStruct ? "record" : innerDim.getShortName(); obsTable.structureType = obsIsStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure; CoordSysEvaluator.findCoords(obsTable, ds, new CoordSysEvaluator.Predicate() { public boolean match(CoordinateAxis axis) { return innerDim.equals(axis.getDimension(0)); } }); topTable.addChild(obsTable); return topTable; } }
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) { Dimension obsDim = ds.findDimension("time"); if (obsDim == null) { CoordinateAxis axis = CoordSysEvaluator.findCoordByType(ds, AxisType.Time); if ((axis != null) && axis.isScalar()) obsDim = axis.getDimension(0); nt.featureType = FeatureType.STATION; nt.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat); nt.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon); obs.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure; obs.dimName = obsDim.getShortName(); obs.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time); nt.addChild(obs);
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) { Dimension stationDim = CoordSysEvaluator.findDimensionByType(ds, AxisType.Lat); if (stationDim == null) { errlog.format("Must have a latitude coordinate"); Dimension obsDim = CoordSysEvaluator.findDimensionByType(ds, AxisType.Time); if (obsDim == null) { errlog.format("Must have a Time coordinate"); stationTable.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat); stationTable.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon); stationTable.stnAlt = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Height); obsTable.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time); obsTable.outerName = stationDim.getShortName(); obsTable.dimName = obsDim.getShortName();
protected TableConfig getStationConfig(NetcdfDataset ds, Formatter errlog) throws IOException { Variable lat = CoordSysEvaluator.findCoordByType(ds, AxisType.Lat); if (lat == null) { errlog.format("CdmDirect: Must have a Latitude coordinate%n"); Variable lon = CoordSysEvaluator.findCoordByType(ds, AxisType.Lon); if (lon == null) { errlog.format("CdmDirect: Must have a Longitude coordinate%n"); Variable alt = CoordSysEvaluator.findCoordByType(ds, AxisType.Height); if (alt != null) stnTable.stnAlt = alt.getShortName(); obs.time = CoordSysEvaluator.findCoordShortNameByType(ds, AxisType.Time); if (obs.time == null) { errlog.format("Must have a time coordinate%n");
/** * Look for Axis by Type. * @param ds look in this dataset's "Best" coordinate system. * @param atype look for this type of CoordinateAxis. takes the first one it finds. * @return the found CoordinateAxis, or null if none */ static public CoordinateAxis findCoordByType(NetcdfDataset ds, AxisType atype) { CoordinateSystem use = findBestCoordinateSystem(ds); if (use != null) { // first look for matching AxisType and "CF axis" attribute for (CoordinateAxis axis : use.getCoordinateAxes()) { if (axis.getAxisType() == atype) { Attribute att = axis.findAttribute(CF.AXIS); if (att != null && att.getStringValue().equals(atype.getCFAxisName())) return axis; } } // now match on just the AxisType for (CoordinateAxis axis : use.getCoordinateAxes()) { if (axis.getAxisType() == atype) return axis; } } // try all the axes for (CoordinateAxis axis : ds.getCoordinateAxes()) { if (axis.getAxisType() == atype) return axis; } return null; }