xhtml.newline(); for (Variable var : ncFile.getVariables()){ xhtml.element("p", String.valueOf(var.getDataType()) + var.getNameAndDimensions() + ";"); for(Attribute element : var.getAttributes()){
public static NcVariableMap create(final NetcdfFile file) { return new NcVariableMap(file.getVariables()); }
private String debugMissingVar(NetcdfFile proto, NetcdfFile result) { Formatter f = new Formatter(); f.format("%nresult dataset %s%n", result.getLocation()); for (Variable v: result.getVariables()) f.format(" %s%n", v.getNameAndDimensions()); f.format("%n"); f.format("proto dataset %s%n", proto.getLocation()); for (Variable v: proto.getVariables()) f.format(" %s%n", v.getNameAndDimensions()); return f.toString(); }
private String debugMissingVar(NetcdfFile proto, NetcdfFile result) { Formatter f = new Formatter(); f.format("%nresult dataset %s%n", result.getLocation()); for (Variable v: result.getVariables()) f.format(" %s%n", v.getNameAndDimensions()); f.format("%n"); f.format("proto dataset %s%n", proto.getLocation()); for (Variable v: proto.getVariables()) f.format(" %s%n", v.getNameAndDimensions()); return f.toString(); }
private String debugMissingVar(NetcdfFile proto, NetcdfFile result) { Formatter f = new Formatter(); f.format("%nresult dataset %s%n", result.getLocation()); for (Variable v: result.getVariables()) f.format(" %s%n", v.getNameAndDimensions()); f.format("%n"); f.format("proto dataset %s%n", proto.getLocation()); for (Variable v: proto.getVariables()) f.format(" %s%n", v.getNameAndDimensions()); return f.toString(); }
public boolean checkSeadasMapped() { try { List<Variable> seadasMappedVariables = ncfile.getVariables(); return seadasMappedVariables.get(0).findAttribute("Projection_Category").isString(); } catch (Exception e) { return false; } }
xhtml.startElement("ul"); xhtml.newline(); for (Variable var : ncFile.getVariables()) { xhtml.startElement("li"); xhtml.characters(var.getDataType() + " " + var.getNameAndDimensions());
@Test public void testEnums() throws IOException { //H5header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H5header/header")); String filename = testDir+"tst/tst_enums.nc"; try (NetcdfFile ncfile = NetcdfFile.open(filename)) { logger.debug("**** testReadNetcdf4 done\n{}", ncfile); List<Variable> vars = ncfile.getVariables(); Collections.sort(vars); for (Variable v : vars) logger.debug(" {}", v.getFullName()); logger.debug("nvars = {}", ncfile.getVariables().size()); } }
@Test public void testGlobalHeapOverun() throws IOException { // Global Heap 1t 13059 runs out with no heap id = 0 String filename = testDir+"globalHeapOverrun.nc4"; try (NetcdfFile ncfile = NetcdfFile.open(filename)) { logger.debug("**** testGlobalHeapOverun done\n{}", ncfile); List<Variable> vars = ncfile.getVariables(); Collections.sort(vars); for (Variable v : vars) logger.debug(" {}", v.getFullName()); logger.debug("nvars = {}", ncfile.getVariables().size()); } }
/** read all data, make sure variable metadata matches the array */ static public void testReadData( NetcdfFile ncfile, boolean showStatus) { try { for (Variable v : ncfile.getVariables()) { testVarMatchesData(v, showStatus); } } catch (IOException ioe) { ioe.printStackTrace(); assert (false); } if (showStatus) logger.debug( "**** testReadData done on {}", ncfile.getLocation()); }
protected void fillNonRecordVariables() throws IOException { // run through each variable for (Variable v : ncfile.getVariables()) { if (v.isUnlimited()) continue; try { writeData(v, v.getShapeAsSection(), makeConstantArray(v)); } catch (InvalidRangeException e) { e.printStackTrace(); // shouldnt happen } } }
protected void fillNonRecordVariables() throws IOException { // run through each variable for (Variable v : ncfile.getVariables()) { if (v.isUnlimited()) continue; try { writeData(v, v.getShapeAsSection(), makeConstantArray(v)); } catch (InvalidRangeException e) { e.printStackTrace(); // shouldnt happen } } }
protected void fillNonRecordVariables() throws IOException { // run through each variable for (Variable v : ncfile.getVariables()) { if (v.isUnlimited()) continue; try { writeData(v, v.getShapeAsSection(), makeConstantArray(v)); } catch (InvalidRangeException e) { e.printStackTrace(); // shouldnt happen } } }
public static void readNetcdfMetadata(NetcdfFile netcdfFile, MetadataElement root, int maxNumValuesRead) { root.addElement(readAttributeList(netcdfFile.getGlobalAttributes(), GLOBAL_ATTRIBUTES)); root.addElement(readVariableDescriptions(netcdfFile.getVariables(), VARIABLE_ATTRIBUTES, maxNumValuesRead)); }
protected void fillRecordVariables(int recStart, int recEnd) throws IOException, InvalidRangeException { // do each record completely, should be a bit more efficient for (int i = recStart; i < recEnd; i++) { // do one record at a time Range r = new Range(i, i); // run through each variable for (Variable v : ncfile.getVariables()) { if (!v.isUnlimited() || (v instanceof Structure)) continue; Section recordSection = new Section( v.getRanges()); recordSection.setRange(0, r); writeData(v, recordSection, makeConstantArray(v)); } } }
protected void fillRecordVariables(int recStart, int recEnd) throws IOException, InvalidRangeException { // do each record completely, should be a bit more efficient for (int i = recStart; i < recEnd; i++) { // do one record at a time Range r = new Range(i, i); // run through each variable for (Variable v : ncfile.getVariables()) { if (!v.isUnlimited() || (v instanceof Structure)) continue; Section recordSection = new Section( v.getRanges()); recordSection.setRange(0, r); writeData(v, recordSection, makeConstantArray(v)); } } }
protected void fillRecordVariables(int recStart, int recEnd) throws IOException, InvalidRangeException { // do each record completely, should be a bit more efficient for (int i = recStart; i < recEnd; i++) { // do one record at a time Range r = new Range(i, i); // run through each variable for (Variable v : ncfile.getVariables()) { if (!v.isUnlimited() || (v instanceof Structure)) continue; Section recordSection = new Section( v.getRanges()); recordSection.setRange(0, r); writeData(v, recordSection, makeConstantArray(v)); } } }
private void testReadStrides(String filename) throws IOException, InvalidRangeException { NetcdfFile ncfile = TestDir.open(filename); List vars = ncfile.getVariables(); for (int i = 0; i < vars.size(); i++) { Variable v = (Variable) vars.get(i); if (v.getRank() == 0 ) continue; if (!v.hasCachedData()) v.setCaching(false); //if (v.getRank() == 1 ) testVariableReadStrides(v); } ncfile.close(); }
private void readGlobalMetaData(File inFile) throws IOException { netCDFAttributes = new NetCDFAttributes(); netCDFAttributes.add(netcdfFile.getGlobalAttributes()); netCDFVariables = new NetCDFVariables(); netCDFVariables.add(netcdfFile.getVariables()); // check wheter daac or imapp if (isImappFormat()) { globalAttributes = new ImappAttributes(inFile, netCDFVariables, netCDFAttributes); } else { globalAttributes = new DaacAttributes(netCDFVariables); } }
private long readAllData(NetcdfFile ncfile) throws IOException { System.out.println("------Open "+ncfile.getLocation()); long total = 0; for (Variable v : ncfile.getVariables()) { long nbytes = v.getSize() * v.getElementSize(); System.out.println(" Try to read variable " + v.getFullName() + " " + nbytes); v.read(); total += v.getSize() * v.getElementSize(); } ncfile.close(); return total; } }