Skip to content
Snippets Groups Projects
Commit 9f55edcc authored by Sahbi Thairi's avatar Sahbi Thairi
Browse files

added spectrum block reading

parent 1e978300
No related branches found
No related tags found
No related merge requests found
...@@ -125,6 +125,31 @@ public class SpectrumStack extends StackedData { ...@@ -125,6 +125,31 @@ public class SpectrumStack extends StackedData {
return spectrum; return spectrum;
} }
public FlatData[] getSpectrumBlockAt(int sizeBlock, int... position) {
FlatData[] spectrum = null;
if (useMap) {
SoftIndexedData<double[]> data = spectra.get(new PositionKey(position));
if (data != null) {
spectrum = new FlatData[1];
spectrum[0] = new FlatData(data.getShape(), data.getData());
}
} else {
ICDMAReader cdmaReader = getReader();
if ((cdmaReader != null) && (stackFullShape != null) && (position != null)) {
if (position.length != stackFullShape.length) {
position = Arrays.copyOf(position, stackFullShape.length);
}
// For spectra, we don't need FlatData, as resulting data is already a single dimension array
spectrum = cdmaReader.readCDMFlatComplexArrayBlockWithCtx(contextDataItem, position, dataFullShape,
sizeBlock);
// spectrum = cdmaReader.readCDMSimpleArrayWithCtx(contextDataItem, position, dataFullShape);
}
}
return spectrum;
}
@Override @Override
public Object getCompleteStack() { public Object getCompleteStack() {
Object result; Object result;
......
...@@ -53,6 +53,7 @@ public class ScanData { ...@@ -53,6 +53,7 @@ public class ScanData {
private final String scanOrigin; private final String scanOrigin;
private String comments; private String comments;
private IAcquisitionDataManager acquisitionDataManager; private IAcquisitionDataManager acquisitionDataManager;
// private long durationRead = 0;
/** /**
* Constructs this {@link ScanData} * Constructs this {@link ScanData}
...@@ -334,6 +335,7 @@ public class ScanData { ...@@ -334,6 +335,7 @@ public class ScanData {
int[] reducedShape = Arrays.copyOf(stack, stack.length - 1); int[] reducedShape = Arrays.copyOf(stack, stack.length - 1);
int[] position = new int[stackShape.length]; int[] position = new int[stackShape.length];
// TODO CREATE TASK FOR READING SPECTRUM BY BLOCK
while (ArrayUtils.isPosition(reducedShape, position)) { while (ArrayUtils.isPosition(reducedShape, position)) {
Object spectrum = spectrumStack.getSpectrumAt(position); Object spectrum = spectrumStack.getSpectrumAt(position);
...@@ -522,6 +524,28 @@ public class ScanData { ...@@ -522,6 +524,28 @@ public class ScanData {
spectrum = spectrumStack.getSpectrumAt(position); spectrum = spectrumStack.getSpectrumAt(position);
} }
// if ((index != null) && (spectra != null)) {
// if ((stackShape != null) && (index.length != stackShape.length)) {
// index = Arrays.copyOf(index, stackShape.length);
// }
// result = spectra.get(new PositionKey(index));
// }
// return result;
return spectrum;
}
public FlatData[] getSpectrumBlockAt(int sizeBlock, int... position) {
FlatData[] spectrum = null;
// TODO clean code!
// long startReadingBlock = System.nanoTime();
if (spectrumStack != null) {
spectrum = spectrumStack.getSpectrumBlockAt(sizeBlock, position);
}
// long duration = System.nanoTime() - startReadingBlock;
// durationRead += duration;
// System.out.println("current total duration read is " + durationRead);
// if ((index != null) && (spectra != null)) { // if ((index != null) && (spectra != null)) {
// if ((stackShape != null) && (index.length != stackShape.length)) { // if ((stackShape != null) && (index.length != stackShape.length)) {
// index = Arrays.copyOf(index, stackShape.length); // index = Arrays.copyOf(index, stackShape.length);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment