Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cdm-test/src/test/java/ucar/nc2/dt/grid/TestGridSubset.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.dataset.CoordinateAxis1D;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.nc2.dt.GridCoordSystem;
import ucar.nc2.dt.GridDatatype;
import ucar.nc2.grib.collection.Grib;
Expand Down Expand Up @@ -426,7 +427,7 @@ public void testBBSubsetVP2() throws Exception {
@Test
public void testSubsetCoordEdges() throws Exception {
try (NetcdfDataset fooDataset =
NetcdfDataset.openDataset(TestDir.cdmLocalFromTestDataDir + "ncml/subsetCoordEdges.ncml")) {
NetcdfDatasets.openDataset(TestDir.cdmLocalFromTestDataDir + "ncml/subsetCoordEdges.ncml")) {
logger.debug("Open {}", fooDataset.getLocation());
CompareNetcdf2 compare = new CompareNetcdf2();
boolean ok = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import ucar.nc2.dataset.CoordinateAxis;
import ucar.nc2.dataset.CoordinateSystem;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.nc2.dataset.VariableDS;
import ucar.nc2.dt.GridCoordSystem;
import ucar.nc2.dt.GridDatatype;
Expand Down Expand Up @@ -111,7 +112,7 @@ public void testCoordinateSystemDomain() throws Exception {
System.err.printf("%nOpen %s grid='%s'%n", filename, gridName);
Grib.setDebugFlags(new DebugFlagsImpl("Grib/indexOnly"));

try (NetcdfDataset ncd = NetcdfDataset.openDataset(filename)) {
try (NetcdfDataset ncd = NetcdfDatasets.openDataset(filename)) {
Assert.assertNotNull(filename, ncd);
VariableDS vds = (VariableDS) ncd.findVariable(gridName);
Assert.assertNotNull(gridName, vds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import ucar.nc2.constants.FeatureType;
import ucar.nc2.dataset.CoordinateSystem;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.nc2.ft2.coverage.FeatureDatasetCoverage;
import ucar.nc2.ft2.coverage.CoverageCollection;
import ucar.nc2.ft2.coverage.CoverageDatasetFactory;
Expand Down Expand Up @@ -99,7 +100,7 @@ public void testAdapter() throws IOException {
}

// check DtCoverageCS
try (NetcdfDataset ds = NetcdfDataset.openDataset(endpoint)) {
try (NetcdfDataset ds = NetcdfDatasets.openDataset(endpoint)) {
Formatter errlog = new Formatter();
DtCoverageCSBuilder builder = DtCoverageCSBuilder.classify(ds, errlog); // uses cs with largest # axes
Assert.assertNotNull(errlog.toString(), builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import ucar.nc2.VariableSimpleIF;
import ucar.nc2.constants.FeatureType;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.nc2.ft.*;
import ucar.nc2.time.CalendarDate;
import ucar.nc2.time.CalendarDateRange;
Expand Down Expand Up @@ -303,12 +304,12 @@ public void testTryWith() throws IOException {
@Test
public void testTryWithWrap() throws IOException {
String location = TestDir.cdmLocalFromTestDataDir + "testWrite.nc";
NetcdfDataset ncd = NetcdfDataset.openDataset(location);
Formatter errlog = new Formatter();
try (FeatureDataset fdataset = FeatureDatasetFactoryManager.wrap(null, ncd, null, errlog)) {
assert (fdataset == null);
try (NetcdfDataset ncd = NetcdfDatasets.openDataset(location)) {
Formatter errlog = new Formatter();
try (FeatureDataset fdataset = FeatureDatasetFactoryManager.wrap(null, ncd, null, errlog)) {
assert (fdataset == null);
}
}
ncd.close();
}

// This is a regression test for TDS-513: https://bugtracking.unidata.ucar.edu/browse/TDS-513
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Formatter;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import ucar.nc2.NetcdfFile;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.unidata.util.test.TestDir;
import ucar.unidata.util.test.category.NeedsCdmUnitTest;
Expand All @@ -14,10 +15,12 @@ public class TestTableAnalyzer {
static void doit(String filename) throws IOException {
filename = TestDir.cdmUnitTestDir + filename;
System.out.println(filename);
NetcdfDataset ncd = ucar.nc2.dataset.NetcdfDataset.openDataset(filename);
TableAnalyzer csa = TableAnalyzer.factory(null, null, ncd);
csa.getDetailInfo(new Formatter(System.out));
System.out.println("%n-----------------");
try (NetcdfDataset ncd = ucar.nc2.dataset.NetcdfDatasets.openDataset(filename, true, -1, null,
NetcdfFile.IOSP_MESSAGE_ADD_RECORD_STRUCTURE)) {
TableAnalyzer csa = TableAnalyzer.factory(null, null, ncd);
csa.getDetailInfo(new Formatter(System.out));
System.out.println("%n-----------------");
}
}

@Test
Expand Down
3 changes: 1 addition & 2 deletions cdm-test/src/timing/java/ucar/nc2/TimeCdmRemote.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ static Section makeSubset(Variable v) throws InvalidRangeException {
return new Section(shape);
}


static void testRead(String filename, Stat stat, boolean readData) throws IOException, InvalidRangeException {
long bytes = 0;
long start = System.nanoTime();
if (show)
System.out.printf("%n------Reading filename %s (%s)%n", filename, stat.getName());

try (NetcdfFile ncfile = NetcdfDataset.openFile(filename, null)) {
try (NetcdfFile ncfile = NetcdfDatasets.openFile(filename, null)) {
if (readData)
bytes = readAllData(ncfile);
long end = System.nanoTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import ucar.nc2.constants.FeatureType;
import ucar.nc2.dataset.CoordinateSystem;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.nc2.ft2.coverage.CoverageCollection;
import ucar.nc2.ft2.coverage.CoverageDatasetFactory;
import ucar.nc2.ft2.coverage.FeatureDatasetCoverage;
Expand All @@ -24,7 +25,6 @@
/** Test Dsmp Coverage Classification */
@Category(NeedsCdmUnitTest.class)
public class TestDsmpCoverageClassification {

String endpoint = TestDir.cdmUnitTestDir + "formats/dmsp/F14200307192230.s.OIS";
FeatureType expectType = FeatureType.SWATH;
int domain = 2;
Expand All @@ -42,7 +42,7 @@ public void testAdapter() throws IOException {
}

// check DtCoverageCS
try (NetcdfDataset ds = NetcdfDataset.openDataset(endpoint)) {
try (NetcdfDataset ds = NetcdfDatasets.openDataset(endpoint)) {
Formatter errlog = new Formatter();
DtCoverageCSBuilder builder = DtCoverageCSBuilder.classify(ds, errlog); // uses cs with largest # axes
Assert.assertNotNull(errlog.toString(), builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import ucar.nc2.NetcdfFile;
import ucar.nc2.Variable;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.nc2.dataset.VariableDS;
import ucar.unidata.util.test.category.NeedsCdmUnitTest;
import ucar.unidata.util.test.TestDir;
Expand Down Expand Up @@ -52,7 +53,7 @@ public int doAct(String filename) throws IOException {
return 0;
}

try (NetcdfFile ncfile = NetcdfDataset.openFile(filename, null)) {
try (NetcdfFile ncfile = NetcdfDatasets.openFile(filename, null)) {
return testRead(ncfile);
}
}
Expand Down Expand Up @@ -129,10 +130,8 @@ static public boolean testCoordSystem(NetcdfFile nexrad2) throws IOException {

@Test
public void testCoordSys() throws IOException {
// NetcdfDataset ncd = NetcdfDataset.openDataset(
// "dods://localhost:8080/thredds/dodsC/testAll/Level2_KSOX_20051010_2322.ar2v", false, null);
String filename = TestDir.cdmUnitTestDir + "formats/nexrad/level2/Level2_KYUX_20060527_2335.ar2v";
try (NetcdfFile ncfile = NetcdfDataset.openFile(filename, null)) {
try (NetcdfFile ncfile = NetcdfDatasets.openFile(filename, null)) {
testCoordSystem(ncfile);
}
}
Expand All @@ -142,7 +141,7 @@ public void testBzipProblem() throws IOException, InvalidRangeException {
// file where there was an error unzipping the file
String filename =
TestDir.cdmUnitTestDir + "formats/nexrad/level2/Level2_KFTG_20060818_1814.ar2v.uncompress.missingradials";
try (NetcdfDataset ncd = NetcdfDataset.openDataset(filename)) {
try (NetcdfDataset ncd = NetcdfDatasets.openDataset(filename)) {

VariableDS azi = (VariableDS) ncd.findVariable("azimuthR");
assert azi != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import ucar.nc2.NetcdfFile;
import ucar.nc2.Variable;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.NetcdfDatasets;
import ucar.unidata.util.test.category.NeedsCdmUnitTest;
import ucar.unidata.util.test.TestDir;
import java.io.File;
Expand Down Expand Up @@ -51,15 +52,14 @@ public int doAct(String filename) throws IOException {
return 0;
}

try (NetcdfFile ncfile = NetcdfDataset.openFile(filename, null)) {
try (NetcdfFile ncfile = NetcdfDatasets.openFile(filename, null)) {
testRead(ncfile);
testCoordSystem(ncfile);
return 1;
}
}
}


private void testRead(NetcdfFile nexrad2) throws IOException {
Dimension scanR = nexrad2.findDimension("scanR");
assert null != scanR;
Expand Down
1 change: 0 additions & 1 deletion opendap/src/main/java/opendap/dap/HeaderInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
*
* @author jehamby
* @version $Revision: 15901 $
* @see DConnect
*/
public class HeaderInputStream extends FilterInputStream {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import ucar.nc2.write.Ncdump;

public abstract class UnitTestCommon {
//////////////////////////////////////////////////
Expand Down Expand Up @@ -554,8 +555,7 @@ protected static String ncdumpmetadata(NetcdfFile ncfile, String datasetname) th
}
// Print the meta-databuffer using these args to NcdumpW
try {
if (!ucar.nc2.NCdumpW.print(ncfile, args.toString(), sw, null))
throw new Exception("NcdumpW failed");
Ncdump.ncdump(ncfile, args.toString(), sw, null);
} catch (IOException ioe) {
throw new Exception("NcdumpW failed", ioe);
}
Expand All @@ -572,8 +572,7 @@ protected static String ncdumpdata(NetcdfFile ncfile, String datasetname) throws
// Dump the databuffer
StringWriter sw = new StringWriter();
try {
if (!ucar.nc2.NCdumpW.print(ncfile, args.toString(), sw, null))
throw new Exception("NCdumpW failed");
Ncdump.ncdump(ncfile, args.toString(), sw, null);
} catch (IOException ioe) {
ioe.printStackTrace();
throw new Exception("NCdumpW failed", ioe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package ucar.util.memory.memory;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ucar.nc2.*;
Expand All @@ -16,6 +15,7 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import ucar.nc2.dataset.NetcdfDatasets;

public class MemoryCounterAgentTest {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
Expand Down Expand Up @@ -140,33 +140,31 @@ static void showAll(NetcdfFile ncfile) {

static void testNcd() throws IOException {
String filename = "C:/data/test2.nc";
NetcdfDataset ncfile = NetcdfDataset.openDataset(filename);
measureSize("C:/data/test2.nc", ncfile, null, true);
try (NetcdfDataset ncfile = NetcdfDatasets.openDataset(filename)) {
measureSize("C:/data/test2.nc", ncfile, null, true);

NetcdfDatasetInfo info = new NetcdfDatasetInfo(filename);
measureSize("info", info, null, true);
String pifo = info.getParseInfo();
System.out.println("info= " + pifo);
ncfile.close();
NetcdfDatasetInfo info = new NetcdfDatasetInfo(filename);
measureSize("info", info, null, true);
String pifo = info.getParseInfo();
System.out.println("info= " + pifo);
}
}

static void testN3() throws IOException {
NetcdfFile ncfile = NetcdfDataset.openFile("C:/data/test2.nc", null);
measureSize("beforeRead", ncfile, null, true);

for (Variable v : ncfile.getVariables()) {
v.read();
try (NetcdfFile ncfile = NetcdfDatasets.openFile("C:/data/test2.nc", null)) {
measureSize("beforeRead", ncfile, null, true);
for (Variable v : ncfile.getVariables()) {
v.read();
}
measureSize("afterRead", ncfile, null, true);
}
measureSize("afterRead", ncfile, null, true);

ncfile.close();
}

static void testNcml() throws IOException {
String filename = "C:/dev/tds/thredds/cdm/src/test/data/ncml/aggUnionSimple.xml";
NetcdfDataset ncfile = NetcdfDataset.openDataset(filename, false, null);
measureSize("aggUnionSimple", ncfile, null, true);
ncfile.close();
try (NetcdfDataset ncfile = NetcdfDatasets.openDataset(filename, false, null)) {
measureSize("aggUnionSimple", ncfile, null, true);
}
}

}