Skip to content

Commit

Permalink
Next development version, refactoring to netcdf 5 and other updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshoffmann committed Apr 6, 2024
1 parent a6c088f commit 52ae364
Show file tree
Hide file tree
Showing 31 changed files with 119 additions and 86 deletions.
2 changes: 1 addition & 1 deletion cross-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>cross</artifactId>
<groupId>io.github.nilshoffmann</groupId>
<version>2.0.1</version>
<version>2.0.2-SNAPSHOT</version>
</parent>
<artifactId>cross-annotations</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cross-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>cross</artifactId>
<groupId>io.github.nilshoffmann</groupId>
<version>2.0.1</version>
<version>2.0.2-SNAPSHOT</version>
</parent>
<artifactId>cross-cache</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cross-event/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>cross</artifactId>
<groupId>io.github.nilshoffmann</groupId>
<version>2.0.1</version>
<version>2.0.2-SNAPSHOT</version>
</parent>
<artifactId>cross-event</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cross-exception/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>cross</artifactId>
<groupId>io.github.nilshoffmann</groupId>
<version>2.0.1</version>
<version>2.0.2-SNAPSHOT</version>
</parent>
<artifactId>cross-exception</artifactId>
<packaging>jar</packaging>
Expand Down
4 changes: 2 additions & 2 deletions cross-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>cross</artifactId>
<groupId>io.github.nilshoffmann</groupId>
<version>2.0.1</version>
<version>2.0.2-SNAPSHOT</version>
</parent>
<artifactId>cross-main</artifactId>
<packaging>jar</packaging>
Expand Down Expand Up @@ -84,7 +84,7 @@
</dependency>
<dependency>
<groupId>edu.ucar</groupId>
<artifactId>netcdfAll</artifactId>
<artifactId>cdm-core</artifactId>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
Expand Down
4 changes: 2 additions & 2 deletions cross-main/src/main/java/cross/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ public void dumpConfig(final String filename, final Date d) {
File configLocationNew = new File(location.getParentFile(), configLocation.getName());
FileUtils.copyFile(configLocation, configLocationNew);
}
LoggerFactory.getLogger(Factory.class).error("Saving configuration to: ");
LoggerFactory.getLogger(Factory.class).error("{}", location.getAbsolutePath());
LoggerFactory.getLogger(Factory.class).info("Saving configuration to: ");
LoggerFactory.getLogger(Factory.class).info("{}", location.getAbsolutePath());
saveConfiguration(cfg, location);
} catch (IOException | ConfigurationException ex) {
LoggerFactory.getLogger(Factory.class).error("{}", ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public SerializableArray(Array array) {
@Override
public void writeExternal(ObjectOutput oo) throws IOException {
if (array != null) {
oo.writeObject(DataType.getType(array.getElementType()));
oo.writeObject(DataType.getType(array));
oo.writeObject(array.getShape());
oo.writeObject(array.getStorage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public void setArray(final Array a1) {
ArrayList<Array> list = new ArrayList<>(1);
list.add(a1);
parent.getCache().put(this, list);
setDataType(DataType.getType(a1.getElementType()));
setDataType(DataType.getType(a1));
if (getDimensions() == null) {
setDimensions(cross.datastructures.tools.ArrayTools.getDefaultDimensions(a1));
}
Expand Down Expand Up @@ -437,7 +437,7 @@ protected void setIndexedArrayInternal(final List<Array> al1) {
if (al1 != null && !al1.isEmpty()) {
this.isModified = true;
parent.getCache().put(this, al1);
setDataType(DataType.getType(al1.get(0).getElementType()));
setDataType(DataType.getType(al1.get(0)));
} else {
clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public static IVariableFragment createIntArrayD1(
} else {
vf = new VariableFragment(parent, varname);
}
final ArrayInt.D1 a = new ArrayInt.D1(size);
final ArrayInt.D1 a = new ArrayInt.D1(size, false);
vf.setArray(a);
return vf;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public ArrayList<Array> readIndexed(final IVariableFragment f)
// read in the full index_array
log.debug("Reading index array {}", index);
Array index_array = readSingle(index);
switch (DataType.getType(index_array.getElementType())) {
switch (DataType.getType(index_array)) {
case LONG:
log.warn("Index array contains long values, this is currently only supported up to Integer.MAX_VALUE");
break;
Expand Down Expand Up @@ -588,7 +588,7 @@ public ArrayList<Array> readIndexed(final IVariableFragment f)
data_end = Math.min(data_dim.getLength() - 1, data_end);
if (data_start > data_end) {
log.warn("scan_index contains an invalid last scan offset. Inserting terminating array with length 0!");
al.add(Array.factory(DataType.getType(data_array.getElementType()), new int[0]));
al.add(Array.factory(DataType.getType(data_array), new int[0]));
} else {
try {
log.debug("Reading array {}, from {} to {}", new Object[]{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void cachedVariableFragment() throws IOException {
VariableFragment vf1 = new VariableFragment(ff, "a" + j);
vf1.setArray(new ArrayDouble.D2(10, 39));
VariableFragment vfIndex = new VariableFragment(ff, "index" + j);
vfIndex.setArray(new ArrayInt.D1(20));
vfIndex.setArray(new ArrayInt.D1(20, false));
VariableFragment vf2 = new VariableFragment(ff, "b" + j, vfIndex);
List<Array> l = new ArrayList<>();
Array indexArray = vfIndex.getArray();
Expand Down Expand Up @@ -175,7 +175,7 @@ public void customCachedVariableFragment() throws IOException {
VariableFragment vf1 = new VariableFragment(ff, "a" + j);
vf1.setArray(new ArrayDouble.D2(10, 39));
VariableFragment vfIndex = new VariableFragment(ff, "index" + j);
vfIndex.setArray(new ArrayInt.D1(20));
vfIndex.setArray(new ArrayInt.D1(20, false));
VariableFragment vf2 = new VariableFragment(ff, "b" + j, vfIndex);
List<Array> l = new ArrayList<>();
Array indexArray = vfIndex.getArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ public void testBreadthFirstSearch() {
//create two Filefragments at the same level with equally named variables
File pathLocal1 = new File(outBaseDir, "local1.cdf");
FileFragment local1 = new FileFragment(pathLocal1);
local1.addChild("testVar1").setArray(Array.factory(new double[]{876, 986123.8, 21986.856, 79006.8613, 897123.123}));
local1.addChild("testVar1").setArray(Array.makeFromJavaArray(new double[]{876, 986123.8, 21986.856, 79006.8613, 897123.123}));

File pathLocal2 = new File(outBaseDir, "local2.cdf");
FileFragment local2 = new FileFragment(pathLocal2);
local2.addChild("testVar1").setArray(Array.factory(new double[]{7889, 986123.8, 21986.856, 79006.8613, 897123.123}));
local2.addChild("testVar1").setArray(Array.makeFromJavaArray(new double[]{7889, 986123.8, 21986.856, 79006.8613, 897123.123}));

File pathLocal3 = new File(new File(outBaseDir, "subdir"), "local3.cdf");
FileFragment local3 = new FileFragment(pathLocal3);
Expand All @@ -290,7 +290,7 @@ public void testBreadthFirstDifferentDepthSearch() {

File pathLocal0 = new File(outBaseDir, "local0.cdf");
FileFragment local0 = new FileFragment(pathLocal0);
local0.addChild("testVar1").setArray(Array.factory(new double[]{876, 986123.8, 21986.856, 79006.8613, 897123.123}));
local0.addChild("testVar1").setArray(Array.makeFromJavaArray(new double[]{876, 986123.8, 21986.856, 79006.8613, 897123.123}));

//create two Filefragments at the same level with equally named variables
File pathLocal1 = new File(outBaseDir, "local1.cdf");
Expand All @@ -299,7 +299,7 @@ public void testBreadthFirstDifferentDepthSearch() {

File pathLocal2 = new File(outBaseDir, "local2.cdf");
FileFragment local2 = new FileFragment(pathLocal2);
local2.addChild("testVar1").setArray(Array.factory(new double[]{7889, 986123.8, 21986.856, 79006.8613, 897123.123}));
local2.addChild("testVar1").setArray(Array.makeFromJavaArray(new double[]{7889, 986123.8, 21986.856, 79006.8613, 897123.123}));

File pathLocal3 = new File(new File(outBaseDir, "subdir"), "local3.cdf");
FileFragment local3 = new FileFragment(pathLocal3);
Expand All @@ -326,7 +326,7 @@ public void testBreadthFirstSameDepthSearch() {

File pathLocal0 = new File(outBaseDir, "local0.cdf");
FileFragment local0 = new FileFragment(pathLocal0);
local0.addChild("testVar1").setArray(Array.factory(new double[]{876, 986123.8, 21986.856, 79006.8613, 897123.123}));
local0.addChild("testVar1").setArray(Array.makeFromJavaArray(new double[]{876, 986123.8, 21986.856, 79006.8613, 897123.123}));

//create two Filefragments at the same level with equally named variables
File pathLocal1 = new File(outBaseDir, "local1.cdf");
Expand All @@ -336,7 +336,7 @@ public void testBreadthFirstSameDepthSearch() {
File pathLocal2 = new File(outBaseDir, "local2.cdf");
FileFragment local2 = new FileFragment(pathLocal2);
local2.addSourceFile(local1);
local2.addChild("testVar1").setArray(Array.factory(new double[]{7889, 986123.8, 21986.856, 79006.8613, 897123.123}));
local2.addChild("testVar1").setArray(Array.makeFromJavaArray(new double[]{7889, 986123.8, 21986.856, 79006.8613, 897123.123}));

File pathLocal3 = new File(new File(outBaseDir, "subdir"), "local3.cdf");
FileFragment local3 = new FileFragment(pathLocal3);
Expand Down Expand Up @@ -403,18 +403,18 @@ public IFileFragment createTestFragment(File folder) {
IFileFragment f = new FileFragment(folder, "testFragment.cdf");
f.addChild("variable1").setIndex(f.addChild("indexVar1"));
List<Array> l1 = new ArrayList<>();
l1.add(Array.factory(new double[]{1.2, 1.5}));
l1.add(Array.factory(new double[]{2.2, 2.6, 2.87}));
l1.add(Array.factory(new double[]{3.67}));
l1.add(Array.makeFromJavaArray(new double[]{1.2, 1.5}));
l1.add(Array.makeFromJavaArray(new double[]{2.2, 2.6, 2.87}));
l1.add(Array.makeFromJavaArray(new double[]{3.67}));
f.getChild("variable1").setIndexedArray(l1);
f.addChild("variable2").setIndex(f.getChild("indexVar1"));
List<Array> l2 = new ArrayList<>();
l2.add(Array.factory(new int[]{1, 1}));
l2.add(Array.factory(new int[]{2, 2, 2}));
l2.add(Array.factory(new int[]{3}));
l2.add(Array.makeFromJavaArray(new int[]{1, 1}));
l2.add(Array.makeFromJavaArray(new int[]{2, 2, 2}));
l2.add(Array.makeFromJavaArray(new int[]{3}));
f.getChild("variable2").setIndexedArray(l2);
f.addChild("variable3").setArray(Array.factory(new double[]{2, 3.3, 235.32, 352.3}));
f.getChild("indexVar1").setArray(Array.factory(new int[]{2, 3, 1}));
f.addChild("variable3").setArray(Array.makeFromJavaArray(new double[]{2, 3.3, 235.32, 352.3}));
f.getChild("indexVar1").setArray(Array.makeFromJavaArray(new int[]{2, 3, 1}));
return f;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void testChunkIterator(int length, int chunksize) {
testVar.setArray(ref);
ArrayChunkIterator aci = new ArrayChunkIterator(Factory.getInstance(), testVar, chunksize);//21 chunks, 20 of size 10 and one of size 5
int idx = 0;
Array reconstructedRef = Array.factory(DataType.getType(ref.getElementType()), ref.getShape());
Array reconstructedRef = Array.factory(ref.getDataType(), ref.getShape());
List<Array> arrayChunks = new ArrayList<>();
while (aci.hasNext()) {
Array chunk = aci.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,18 @@ public File[] getFiles() {
IFileFragment f = new FileFragment(tf.newFolder(), "testFragment.maltcms.xml");
f.addChild("variable1").setIndex(f.addChild("indexVar1"));
List<Array> l1 = new ArrayList<>();
l1.add(Array.factory(new double[]{1.2, 1.5}));
l1.add(Array.factory(new double[]{2.2, 2.6, 2.87}));
l1.add(Array.factory(new double[]{3.67}));
l1.add(Array.makeFromJavaArray(new double[]{1.2, 1.5}));
l1.add(Array.makeFromJavaArray(new double[]{2.2, 2.6, 2.87}));
l1.add(Array.makeFromJavaArray(new double[]{3.67}));
f.getChild("variable1").setIndexedArray(l1);
f.addChild("variable2").setIndex(f.getChild("indexVar1"));
List<Array> l2 = new ArrayList<>();
l2.add(Array.factory(new int[]{1, 1}));
l2.add(Array.factory(new int[]{2, 2, 2}));
l2.add(Array.factory(new int[]{3}));
l2.add(Array.makeFromJavaArray(new int[]{1, 1}));
l2.add(Array.makeFromJavaArray(new int[]{2, 2, 2}));
l2.add(Array.makeFromJavaArray(new int[]{3}));
f.getChild("variable2").setIndexedArray(l2);
f.addChild("variable3").setArray(Array.factory(new double[]{2, 3.3, 235.32, 352.3}));
f.getChild("indexVar1").setArray(Array.factory(new int[]{2, 3, 1}));
f.addChild("variable3").setArray(Array.makeFromJavaArray(new double[]{2, 3.3, 235.32, 352.3}));
f.getChild("indexVar1").setArray(Array.makeFromJavaArray(new int[]{2, 3, 1}));

final Element maltcms = new Element("maltcms");
final Document doc = new Document(maltcms);
Expand Down Expand Up @@ -360,7 +360,7 @@ public IFileFragment createTestFragment(URI uri, List<String> variableNames, Map
//variable2
VariableFragment ivf2 = new VariableFragment(ff, "variable2");
ivf2.setDimensions(new Dimension[]{dim3});
ArrayInt.D1 arr2 = new ArrayInt.D1(dim3.getLength());
ArrayInt.D1 arr2 = new ArrayInt.D1(dim3.getLength(), false);
ivf2.setArray(arr2);
usedDimensions.put("variable2", copyDims(dim3));
variableNames.add("variable2");
Expand All @@ -372,15 +372,15 @@ public IFileFragment createTestFragment(URI uri, List<String> variableNames, Map

//variable3 - no explicit dimension
VariableFragment ivf3 = new VariableFragment(ff, "variable3");
ArrayInt.D2 arr3 = new ArrayInt.D2(25, 17);
ArrayInt.D2 arr3 = new ArrayInt.D2(25, 17, false);
ivf3.setArray(arr3);
variableNames.add("variable3");

//variable4 - index variable
VariableFragment ivf4 = new VariableFragment(ff, "variable4");
ivf4.setDimensions(new Dimension[]{dim5});
List<Array> arrays = new ArrayList<>();
ArrayInt.D1 index = new ArrayInt.D1(24);
ArrayInt.D1 index = new ArrayInt.D1(24, false);
int offset = 0;
for (int i = 0; i < 24; i++) {
index.set(i, offset);
Expand Down Expand Up @@ -701,11 +701,11 @@ public void testMultiChainedReadWrite() {
//create a shadowing variable
IVariableFragment shadow = new VariableFragment(work,
"shadow-" + i);
shadow.setArray(Array.factory(new int[]{j}));
shadow.setArray(Array.makeFromJavaArray(new int[]{j}));
//create unique variable
IVariableFragment unique = new VariableFragment(work,
"unique-" + j);
unique.setArray(Array.factory(new int[]{i, j}));
unique.setArray(Array.makeFromJavaArray(new int[]{i, j}));
System.out.println(work.toString());
getDataSource().write(work);
work.clearArrays();
Expand Down Expand Up @@ -837,19 +837,19 @@ public IFileFragment createInvalidIndexTestFragment() {
IFileFragment f = new FileFragment(new File(folder, "invalidIndexTestFrag.maltcms.xml"));
f.addChild("variable1").setIndex(f.addChild("indexVar1"));
List<Array> l1 = new ArrayList<>();
l1.add(Array.factory(new double[]{1.2, 1.5}));
l1.add(Array.factory(new double[]{2.2, 2.6, 2.87}));
l1.add(Array.factory(new double[]{3.67}));
l1.add(Array.makeFromJavaArray(new double[]{1.2, 1.5}));
l1.add(Array.makeFromJavaArray(new double[]{2.2, 2.6, 2.87}));
l1.add(Array.makeFromJavaArray(new double[]{3.67}));
f.getChild("variable1").setIndexedArray(l1);
f.addChild("variable2").setIndex(f.addChild("indexVar2"));
List<Array> l2 = new ArrayList<>();
l2.add(Array.factory(new int[]{1, 1}));
l2.add(Array.factory(new int[]{2, 2, 2}));
l2.add(Array.factory(new int[]{3}));
l2.add(Array.makeFromJavaArray(new int[]{1, 1}));
l2.add(Array.makeFromJavaArray(new int[]{2, 2, 2}));
l2.add(Array.makeFromJavaArray(new int[]{3}));
f.getChild("variable2").setIndexedArray(l2);
f.addChild("variable3").setArray(Array.factory(new double[]{2, 3.3, 235.32, 352.3}));
f.getChild("indexVar1").setArray(Array.factory(new int[]{2, 3, 1, 4}));
f.getChild("indexVar2").setArray(Array.factory(new int[]{2, 3}));
f.addChild("variable3").setArray(Array.makeFromJavaArray(new double[]{2, 3.3, 235.32, 352.3}));
f.getChild("indexVar1").setArray(Array.makeFromJavaArray(new int[]{2, 3, 1, 4}));
f.getChild("indexVar2").setArray(Array.makeFromJavaArray(new int[]{2, 3}));
return f;
} catch (IOException ioex) {
throw new RuntimeException(ioex);
Expand Down Expand Up @@ -884,18 +884,18 @@ public IFileFragment createTestFragment() {
IFileFragment f = new FileFragment(new File(folder, "testFrag.maltcms.xml"));
f.addChild("variable1").setIndex(f.addChild("indexVar1"));
List<Array> l1 = new ArrayList<>();
l1.add(Array.factory(new double[]{1.2, 1.5}));
l1.add(Array.factory(new double[]{2.2, 2.6, 2.87}));
l1.add(Array.factory(new double[]{3.67}));
l1.add(Array.makeFromJavaArray(new double[]{1.2, 1.5}));
l1.add(Array.makeFromJavaArray(new double[]{2.2, 2.6, 2.87}));
l1.add(Array.makeFromJavaArray(new double[]{3.67}));
f.getChild("variable1").setIndexedArray(l1);
f.addChild("variable2").setIndex(f.getChild("indexVar1"));
List<Array> l2 = new ArrayList<>();
l2.add(Array.factory(new int[]{1, 1}));
l2.add(Array.factory(new int[]{2, 2, 2}));
l2.add(Array.factory(new int[]{3}));
l2.add(Array.makeFromJavaArray(new int[]{1, 1}));
l2.add(Array.makeFromJavaArray(new int[]{2, 2, 2}));
l2.add(Array.makeFromJavaArray(new int[]{3}));
f.getChild("variable2").setIndexedArray(l2);
f.addChild("variable3").setArray(Array.factory(new double[]{2, 3.3, 235.32, 352.3}));
f.getChild("indexVar1").setArray(Array.factory(new int[]{2, 3, 1}));
f.addChild("variable3").setArray(Array.makeFromJavaArray(new double[]{2, 3.3, 235.32, 352.3}));
f.getChild("indexVar1").setArray(Array.makeFromJavaArray(new int[]{2, 3, 1}));
return f;
} catch (IOException ioex) {
throw new RuntimeException(ioex);
Expand Down
2 changes: 1 addition & 1 deletion cross-math/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>cross</artifactId>
<groupId>io.github.nilshoffmann</groupId>
<version>2.0.1</version>
<version>2.0.2-SNAPSHOT</version>
</parent>
<artifactId>cross-math</artifactId>
<name>Cross Math</name>
Expand Down
Loading

0 comments on commit 52ae364

Please sign in to comment.