Java Code Examples for ucar.nc2.Variable#getParentStructure()
The following examples show how to use
ucar.nc2.Variable#getParentStructure() .
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: ConvertD2N.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Convert a DataDDS into an Array for a Structure member variable. * * @param v must be a member of a structure * @param section the requested variable section, as a List of type Range * @param dataV the dataDDS has been parsed into this dodsV, this is the top variable containing v * @param flatten if true, remove the StructureData "wrapper". * @return the data as as Array * @throws IOException on io error * @throws DAP2Exception on bad things happening */ public Array convertNestedVariable(ucar.nc2.Variable v, List<Range> section, DodsV dataV, boolean flatten) throws IOException, DAP2Exception { Array data = convertTopVariable(v, section, dataV); if (flatten) { ArrayStructure as = (ArrayStructure) data; // make list of names List<String> names = new ArrayList<>(); Variable nested = v; while (nested.isMemberOfStructure()) { names.add(0, nested.getShortName()); nested = nested.getParentStructure(); } StructureMembers.Member m = findNested(as, names, v.getShortName()); Array mdata = m.getDataArray(); if (mdata instanceof ArraySequenceNested) { // gotta unroll ArraySequenceNested arraySeq = (ArraySequenceNested) mdata; return arraySeq.flatten(); } return mdata; } return data; }
Example 2
Source File: CFpointObsExt.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected boolean identifyEncodingTraj(NetcdfDataset ds, EncodingInfo info, Formatter errlog) { // find the obs structure info.childStruct = info.lat.getParentStructure(); Dimension obsDim = info.childStruct.getDimension(0); // find the traj structure Variable varatt = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.TRAJECTORY_ID); Structure traj = varatt.getParentStructure(); if (traj.getRank() == 0) { // could be scalar info.set(Encoding.single, null, obsDim); } Dimension trajDim = traj.getDimension(0); if (identifyRaggeds(ds, info, trajDim, obsDim, errlog)) return true; errlog.format("CFpointObsExt: %s only supports ragged array representation%n", CF.FeatureType.trajectory); return false; }
Example 3
Source File: DatasetWriter.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void setSelected(Variable v) { List<Variable> vchain = new ArrayList<>(); vchain.add(v); Variable vp = v; while (vp.isMemberOfStructure()) { vp = vp.getParentStructure(); vchain.add(0, vp); // reverse } for (int i = 0; i < vchain.size(); i++) { vp = vchain.get(i); NestedTable ntable = setNestedTable(i, vp.getParentStructure()); ntable.setSelected(vp); } }
Example 4
Source File: DatasetViewer.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void setSelected(Variable v) { eventsOK = false; List<Variable> vchain = new ArrayList<>(); vchain.add(v); Variable vp = v; while (vp.isMemberOfStructure()) { vp = vp.getParentStructure(); vchain.add(0, vp); // reverse } for (int i = 0; i < vchain.size(); i++) { vp = vchain.get(i); NestedTable ntable = setNestedTable(i, vp.getParentStructure()); ntable.setSelected(vp); } eventsOK = true; }
Example 5
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 6
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; }