Java Code Examples for ucar.nc2.constants.CF#FeatureType
The following examples show how to use
ucar.nc2.constants.CF#FeatureType .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CFpointObsExt.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected boolean identifyEncodingStation(NetcdfDataset ds, EncodingInfo info, CF.FeatureType ftype, Formatter errlog) { Structure obs = info.time.getParentStructure(); if (obs.getRank() == 0) { errlog.format("CFpointObs: must have a non-scalar Time coordinate%n"); return false; } Dimension obsDim = obs.getDimension(0); Structure station = info.lat.getParentStructure(); if (station.getRank() == 0) { // could be scalar info.set(Encoding.single, null, obsDim); } Dimension stnDim = station.getDimension(0); // the raggeds if (identifyRaggeds(ds, info, stnDim, obsDim, errlog)) return true; errlog.format("CFpointObsExt: %s Must have Lat/Lon coordinates of rank 0 or 1%n", ftype); return false; }
Example 2
Source File: GempakCdm.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public boolean isMine(FeatureType wantFeatureType, NetcdfDataset ds) { boolean ok = false; String conv = ds.getRootGroup().findAttributeString(CDM.CONVENTIONS, null); if (conv == null) return false; if (conv.equals(Convention)) ok = true; StringTokenizer stoke = new StringTokenizer(conv, ","); while (stoke.hasMoreTokens()) { String toke = stoke.nextToken().trim(); if (toke.equals(Convention)) ok = true; } if (!ok) return false; CF.FeatureType ftype = CF.FeatureType.getFeatureTypeFromGlobalAttribute(ds); if (ftype == null) ftype = CF.FeatureType.point; return (ftype == CF.FeatureType.timeSeries) || (ftype == CF.FeatureType.timeSeriesProfile); }
Example 3
Source File: GempakCdm.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) { CF.FeatureType ftype = CF.FeatureType.getFeatureTypeFromGlobalAttribute(ds); if (ftype == null) ftype = CF.FeatureType.point; switch (ftype) { case point: return null; // use default handler case timeSeries: if (wantFeatureType == FeatureType.POINT) return getStationAsPointConfig(ds, errlog); else return getStationConfig(ds, errlog); case timeSeriesProfile: return getStationProfileConfig(ds, errlog); default: throw new IllegalStateException("unimplemented feature ftype= " + ftype); } }
Example 4
Source File: CdmDirect.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public boolean isMine(FeatureType wantFeatureType, NetcdfDataset ds) { boolean ok = false; String conv = ds.getRootGroup().findAttributeString(CDM.CONVENTIONS, null); if (conv == null) return false; if (conv.equals(Convention)) ok = true; StringTokenizer stoke = new StringTokenizer(conv, ","); while (stoke.hasMoreTokens()) { String toke = stoke.nextToken().trim(); if (toke.equals(Convention)) ok = true; } if (!ok) return false; CF.FeatureType ftype = CF.FeatureType.getFeatureTypeFromGlobalAttribute(ds); if (ftype == null) ftype = CF.FeatureType.point; return (ftype == CF.FeatureType.timeSeries) || (ftype == CF.FeatureType.timeSeriesProfile); }
Example 5
Source File: CdmDirect.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) { CF.FeatureType ftype = CF.FeatureType.getFeatureTypeFromGlobalAttribute(ds); if (ftype == null) ftype = CF.FeatureType.point; switch (ftype) { case point: return null; // use default handler case timeSeries: /* * if (wantFeatureType == FeatureType.POINT) * return getStationAsPointConfig(ds, errlog); * else */ return getStationConfig(ds, errlog); case timeSeriesProfile: return getStationProfileConfig(ds, errlog); default: throw new IllegalStateException("unimplemented feature ftype= " + ftype); } }
Example 6
Source File: CFpointObs.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) { EncodingInfo info = new EncodingInfo(); // figure out the actual feature type of the dataset CF.FeatureType ftype = CF.FeatureType.getFeatureTypeFromGlobalAttribute(ds); if (ftype == null) ftype = CF.FeatureType.point; // make sure lat, lon, time coordinates exist if (!checkCoordinates(ds, info, errlog)) return null; // fail fast switch (ftype) { case point: return getPointConfig(ds, info, errlog); case timeSeries: return getStationConfig(ds, info, errlog); case profile: return getProfileConfig(ds, info, errlog); case trajectory: return getTrajectoryConfig(ds, info, errlog); case timeSeriesProfile: return getTimeSeriesProfileConfig(ds, info, errlog); case trajectoryProfile: return getSectionConfig(ds, info, errlog); } return null; }
Example 7
Source File: CFpointObs.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Variable identifyIdVariable(NetcdfDataset ds, CF.FeatureType ftype) { Variable result; switch (ftype) { case timeSeriesProfile: case timeSeries: result = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.TIMESERIES_ID); if (result != null) return result; return Evaluator.findVariableWithAttributeValue(ds, CF.STANDARD_NAME, CF.STATION_ID); // old way for backwards // compatibility case trajectory: case trajectoryProfile: result = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.TRAJECTORY_ID); if (result != null) return result; return Evaluator.findVariableWithAttributeValue(ds, CF.STANDARD_NAME, CF.TRAJECTORY_ID); // old way for // backwards // compatibility case profile: result = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.PROFILE_ID); if (result != null) return result; return Evaluator.findVariableWithAttributeValue(ds, CF.STANDARD_NAME, CF.PROFILE_ID); // old way for backwards // compatibility default: return null; } }
Example 8
Source File: FeatureDatasetFactoryManager.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Try to determine the feature type of the dataset, by examining its metadata. * * @param ncd the dataset * @return FeatureType if found, else null */ public static FeatureType findFeatureType(NetcdfFile ncd) { // search for explicit featureType global attribute String cdm_datatype = ncd.getRootGroup().findAttributeString(CF.FEATURE_TYPE, null); if (cdm_datatype == null) cdm_datatype = ncd.getRootGroup().findAttributeString("cdm_data_type", null); if (cdm_datatype == null) cdm_datatype = ncd.getRootGroup().findAttributeString("cdm_datatype", null); if (cdm_datatype == null) cdm_datatype = ncd.getRootGroup().findAttributeString("thredds_data_type", null); if (cdm_datatype != null) { for (FeatureType ft : FeatureType.values()) if (cdm_datatype.equalsIgnoreCase(ft.name())) { if (debug) System.out.println(" wrapUnknown found cdm_datatype " + cdm_datatype); return ft; } } CF.FeatureType cff = CF.FeatureType.getFeatureTypeFromGlobalAttribute(ncd); if (cff != null) return CF.FeatureType.convert(cff); return null; }
Example 9
Source File: CFpointObs.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected boolean identifyEncodingStation(NetcdfDataset ds, EncodingInfo info, CF.FeatureType ftype, Formatter errlog) { // find the obs dimension Dimension obsDim = null; if (info.time.getRank() > 0) obsDim = info.time.getDimension(info.time.getRank() - 1); // may be time(time) or time(stn, obs) else if (info.time.getParentStructure() != null) { Structure parent = info.time.getParentStructure(); // if time axis is a structure member, try pulling dimension // out of parent structure obsDim = parent.getDimension(parent.getRank() - 1); } if (obsDim == null) { errlog.format("CFpointObs: must have a non-scalar Time coordinate%n"); return false; } // find the station dimension if (info.lat.getRank() == 0) {// scalar means single info.set(Encoding.single, null, obsDim); return true; } Dimension stnDim = info.lat.getDimension(0); if (obsDim == stnDim) { info.set(Encoding.flat, null, obsDim); // not used ? return true; } // the raggeds if (identifyRaggeds(ds, info, stnDim, obsDim, errlog)) return true; // heres whats left if (info.lat.getRank() == 1) { // Encoding e = (info.time.getParentStructure() != null) ? Encoding.multiStructure : Encoding.multidim; info.set(Encoding.multidim, stnDim, obsDim); return true; } errlog.format("CFpointObs: %s Must have Lat/Lon coordinates of rank 0 or 1%n", ftype); return false; }
Example 10
Source File: CFpointObs.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected boolean identifyEncodingSection(NetcdfDataset ds, EncodingInfo info, CF.FeatureType ftype, Formatter errlog) { // find the non-station altitude VariableDS z = findZAxisNotStationAlt(ds); if (z == null) { errlog.format("CFpointObs: section must have a z coordinate%n"); return false; } if (z.getRank() == 0) { errlog.format("CFpointObs: section cannot have a scalar z coordinate%n"); return false; } info.alt = z; Dimension obsDim = null; if (z.getRank() > 0) obsDim = z.getDimension(z.getRank() - 1); // may be z(z) or alt(profile, z) else if (z.getParentStructure() != null) { Structure parent = z.getParentStructure(); // if time axis is a structure member, try pulling dimension out of // parent structure obsDim = parent.getDimension(parent.getRank() - 1); } if (obsDim == null) { errlog.format("CFpointObs: Must have a non-scalar Height coordinate%n"); return false; } info.grandChildDim = obsDim; // parent dimension Dimension trajDim; Dimension profileDim; if (z.getRank() > 2) { trajDim = z.getDimension(0); profileDim = z.getDimension(1); info.set(Encoding.multidim, trajDim, profileDim, obsDim); return true; } if (identifyDoubleRaggeds(ds, info, errlog)) return true; if (info.time.getRank() > 2) { trajDim = info.time.getDimension(0); profileDim = info.time.getDimension(1); info.set(Encoding.multidim, trajDim, profileDim, obsDim); return true; } if (info.lat.getRank() == 1) { profileDim = info.lat.getDimension(0); info.set(Encoding.single, null, profileDim, obsDim); return true; } if (info.lat.getRank() == 2) { trajDim = info.lat.getDimension(0); profileDim = info.lat.getDimension(0); info.set(Encoding.multidim, trajDim, profileDim, obsDim); return true; } // forget flat for now errlog.format("CFpointObs %s unrecognized form%n", ftype); return false; }
Example 11
Source File: CFpointObs.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
private String identifyIdVariableName(NetcdfDataset ds, CF.FeatureType ftype) { Variable v = identifyIdVariable(ds, ftype); return (v == null) ? null : v.getFullName(); }
Example 12
Source File: CFpointObsExt.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected boolean identifyEncodingTimeSeriesProfile(NetcdfDataset ds, EncodingInfo info, CF.FeatureType ftype, Formatter errlog) { // find the obs structure Evaluator.VarAtt varatt = Evaluator.findVariableWithAttribute(ds, CF.SAMPLE_DIMENSION); if (varatt == null) return false; String dimName = varatt.att.getStringValue(); info.grandChildDim = ds.findDimension(dimName); info.grandChildStruct = Evaluator.findStructureWithDimensions(ds, info.grandChildDim, null); // find the station structure Variable stdId = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.TIMESERIES_ID); Structure stn = stdId.getParentStructure(); if (stn.getRank() == 0) { // could be scalar info.set(Encoding.single, null, info.grandChildDim); } info.parentDim = stn.getDimension(0); info.parentStruct = stn; // find the profile structure Variable profileId = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.PROFILE_ID); Structure profile = profileId.getParentStructure(); info.childDim = profile.getDimension(0); info.childStruct = profile; // find the non-station altitude VariableDS z = findZAxisNotStationAlt(ds); if (z == null) { errlog.format("CFpointObs: timeSeriesProfile must have a z coordinate, not the station altitude%n"); return false; } info.alt = z; // raggeds if (identifyDoubleRaggeds(ds, info, errlog)) return true; errlog.format("CFpointObsExt: %s only supports ragged array representation%n", CF.FeatureType.timeSeriesProfile); return false; }
Example 13
Source File: CFpointObsExt.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected boolean identifyEncodingSection(NetcdfDataset ds, EncodingInfo info, CF.FeatureType ftype, Formatter errlog) { // find the obs structure Evaluator.VarAtt varatt = Evaluator.findVariableWithAttribute(ds, CF.SAMPLE_DIMENSION); if (varatt == null) return false; String dimName = varatt.att.getStringValue(); info.grandChildDim = ds.findDimension(dimName); info.grandChildStruct = Evaluator.findStructureWithDimensions(ds, info.grandChildDim, null); // find the traj structure Variable trajId = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.TRAJECTORY_ID); Structure traj = trajId.getParentStructure(); if (traj.getRank() == 0) { // could be scalar info.set(Encoding.single, null, info.grandChildDim); } info.parentDim = traj.getDimension(0); info.parentStruct = traj; // find the profile structure Variable profileId = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.PROFILE_ID); Structure profile = profileId.getParentStructure(); info.childDim = profile.getDimension(0); info.childStruct = profile; // find the non-station altitude VariableDS z = findZAxisNotStationAlt(ds); if (z == null) { errlog.format("CFpointObs: section must have a z coordinate%n"); return false; } if (z.getRank() == 0 && z.getParentStructure() == null) { errlog.format("CFpointObs: section cannot have a scalar z coordinate%n"); return false; } info.alt = z; // raggeds if (identifyDoubleRaggeds(ds, info, errlog)) return true; errlog.format("CFpointObsExt: %s only supports ragged array representation%n", CF.FeatureType.trajectoryProfile); return false; }