Skip to content
Snippets Groups Projects
Commit 3d16ffeb authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

- No more use of region: a detector region is a detector

- Simplified external tools : HarvestSignalAttributes is useless and removed. Use HarvestEquipmentAttributes instead.
parent 90cf604a
Branches
Tags
No related merge requests found
...@@ -18,7 +18,6 @@ import org.apache.commons.lang.ArrayUtils; ...@@ -18,7 +18,6 @@ import org.apache.commons.lang.ArrayUtils;
import fr.soleil.cdma.box.data.SoftData; import fr.soleil.cdma.box.data.SoftData;
import fr.soleil.cdma.box.data.scan.ScanData; import fr.soleil.cdma.box.data.scan.ScanData;
import fr.soleil.cdma.box.data.scan.ScanData.Dimension; import fr.soleil.cdma.box.data.scan.ScanData.Dimension;
import fr.soleil.cdma.box.data.sensor.PhotoElectronAnalyzerConfig;
import fr.soleil.cdma.box.data.sensor.SensorConfig; import fr.soleil.cdma.box.data.sensor.SensorConfig;
import fr.soleil.lib.project.math.MathConst; import fr.soleil.lib.project.math.MathConst;
...@@ -31,26 +30,24 @@ public class Acquisition { ...@@ -31,26 +30,24 @@ public class Acquisition {
private final String sourceURI; private final String sourceURI;
private final String uriSimpleName; private final String uriSimpleName;
private final SensorConfig sensorConfig; private final String detector;
private final List<ScanData> scanList; private final List<ScanData> scanList;
private double[] spectrumX; private double[] spectrumX;
private boolean energyAcquisition; private boolean energyAcquisition;
/** /**
* Constructs this {@link Acquisition} and associates a source URI and a {@link SensorConfig} to * Constructs this {@link Acquisition} and associates a source URI and a detector to it.
* it
* *
* @param sourceURI The path of the URI * @param sourceURI The path of the URI
* @param uriSimpleName The path of the URI, or a simple name for the URI, that can be understood by human beings. * @param uriSimpleName The path of the URI, or a simple name for the URI, that can be understood by human beings.
* @param sensorConfig The {@link SensorConfig} * @param detector The detector
*/ */
public Acquisition(String sourceURI, String uriSimpleName, SensorConfig sensorConfig) { public Acquisition(String sourceURI, String uriSimpleName, String detector) {
scanList = new ArrayList<ScanData>(); scanList = new ArrayList<ScanData>();
this.sourceURI = sourceURI; this.sourceURI = sourceURI;
this.uriSimpleName = uriSimpleName; this.uriSimpleName = uriSimpleName;
this.sensorConfig = sensorConfig; this.detector = detector;
spectrumX = (sensorConfig instanceof PhotoElectronAnalyzerConfig spectrumX = null;
? ((PhotoElectronAnalyzerConfig) sensorConfig).getPixelToEnergy() : null);
energyAcquisition = false; energyAcquisition = false;
} }
...@@ -64,12 +61,12 @@ public class Acquisition { ...@@ -64,12 +61,12 @@ public class Acquisition {
} }
/** /**
* Returns the {@link SensorConfig} of this {@link Acquisition} * Returns this {@link Acquisition}'s detector.
* *
* @return A {@link SensorConfig} * @return A {@link String}.
*/ */
public SensorConfig getSensorConfig() { public String getDetector() {
return sensorConfig; return detector;
} }
/** /**
......
...@@ -309,8 +309,10 @@ public class ScanData { ...@@ -309,8 +309,10 @@ public class ScanData {
*/ */
public double[] getMeanSpectrum() { public double[] getMeanSpectrum() {
double[] result = getSumSpectrum(); double[] result = getSumSpectrum();
int[] stack = spectrumStack.getStackFullShape(); if (spectrumStack != null) {
int[] reducedShape = Arrays.copyOf(stack, stack.length - 1); int[] stackFullShape = spectrumStack.getStackFullShape();
if (stackFullShape != null) {
int[] reducedShape = Arrays.copyOf(stackFullShape, stackFullShape.length - 1);
int size = 1; int size = 1;
for (int i = 0; i < reducedShape.length; i++) { for (int i = 0; i < reducedShape.length; i++) {
...@@ -320,6 +322,8 @@ public class ScanData { ...@@ -320,6 +322,8 @@ public class ScanData {
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
result[i] /= size; result[i] /= size;
} }
} // end if (stackFullShape != null)
} // end if (spectrumStack != null)
return result; return result;
} }
...@@ -330,9 +334,11 @@ public class ScanData { ...@@ -330,9 +334,11 @@ public class ScanData {
*/ */
public double[] getSumSpectrum() { public double[] getSumSpectrum() {
double[] sumSpectrum = new double[0]; double[] sumSpectrum = new double[0];
int[] stack = spectrumStack.getStackFullShape(); if (spectrumStack != null) {
int[] stackFullShape = spectrumStack.getStackFullShape();
if (stackFullShape != null) {
int index = 0; int index = 0;
int[] reducedShape = Arrays.copyOf(stack, stack.length - 1); int[] reducedShape = Arrays.copyOf(stackFullShape, stackFullShape.length - 1);
int[] position = new int[stackShape.length]; int[] position = new int[stackShape.length];
// TODO CREATE TASK FOR READING SPECTRUM BY BLOCK // TODO CREATE TASK FOR READING SPECTRUM BY BLOCK
...@@ -354,6 +360,8 @@ public class ScanData { ...@@ -354,6 +360,8 @@ public class ScanData {
index++; index++;
} }
} }
} // end if (stackFullShape != null)
} // end if (spectrumStack != null)
return sumSpectrum; return sumSpectrum;
} }
......
...@@ -7,13 +7,9 @@ ...@@ -7,13 +7,9 @@
******************************************************************************/ ******************************************************************************/
package fr.soleil.cdma.box.data.sensor; package fr.soleil.cdma.box.data.sensor;
import java.text.Collator;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
/** /**
* *
...@@ -21,46 +17,24 @@ import java.util.TreeSet; ...@@ -21,46 +17,24 @@ import java.util.TreeSet;
*/ */
public class ExperimentConfig { public class ExperimentConfig {
private final Map<String, SensorConfig> acquisitionConfigCache; private Collection<String> detectors;
private final Map<Sensor, Set<SensorConfig>> detectorMap;
public ExperimentConfig() { public ExperimentConfig() {
detectorMap = new LinkedHashMap<Sensor, Set<SensorConfig>>(); detectors = new LinkedHashSet<>();
acquisitionConfigCache = new LinkedHashMap<String, SensorConfig>();
} }
public void addConfig(Sensor detector, SensorConfig acquisitionConfig) { public void addDetector(String detector) {
if (detector != null && acquisitionConfig != null) { if (detector != null) {
// Test if config already exists in cache detectors.add(detector);
String configName = detector + acquisitionConfig.getName();
SensorConfig cachedAcquisitionConfig = acquisitionConfigCache.get(configName);
if (cachedAcquisitionConfig == null) {
acquisitionConfigCache.put(configName, acquisitionConfig);
cachedAcquisitionConfig = acquisitionConfig;
}
Set<SensorConfig> regions = detectorMap.get(detector);
if (regions == null) {
regions = new TreeSet<SensorConfig>(new Comparator<SensorConfig>() {
Collator collator = Collator.getInstance();
@Override
public int compare(SensorConfig o1, SensorConfig o2) {
return collator.compare(o1.getName(), o2.getName());
}
});
}
if (acquisitionConfig != null) {
regions.add(cachedAcquisitionConfig);
}
detectorMap.put(detector, regions);
} }
} }
public Collection<Sensor> getDetectorList() { public boolean hasDetector(String detector) {
return detectorMap.keySet(); return ((detector != null) && detectors.contains(detector));
} }
public Collection<SensorConfig> getAcquisitionConfigListForDetector(Sensor detector) { public Collection<String> getDetectorList() {
return detectorMap.get(detector); return Collections.unmodifiableCollection(detectors);
} }
} }
...@@ -11,7 +11,6 @@ import java.util.HashSet; ...@@ -11,7 +11,6 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import fr.soleil.cdma.box.data.LoadableData; import fr.soleil.cdma.box.data.LoadableData;
import fr.soleil.cdma.box.data.sensor.SensorConfig;
import fr.soleil.cdma.box.exception.CDMAAccessException; import fr.soleil.cdma.box.exception.CDMAAccessException;
import fr.soleil.cdma.box.reader.ICDMAReader; import fr.soleil.cdma.box.reader.ICDMAReader;
...@@ -23,7 +22,7 @@ import fr.soleil.cdma.box.reader.ICDMAReader; ...@@ -23,7 +22,7 @@ import fr.soleil.cdma.box.reader.ICDMAReader;
public class AcquisitionManager { public class AcquisitionManager {
protected final ICDMAReader cdmaReader; protected final ICDMAReader cdmaReader;
private SensorConfig sensorConfig; private String detector;
private final Set<LoadableData> dataToLoad; private final Set<LoadableData> dataToLoad;
/** /**
...@@ -33,7 +32,7 @@ public class AcquisitionManager { ...@@ -33,7 +32,7 @@ public class AcquisitionManager {
*/ */
public AcquisitionManager(ICDMAReader cdmaReader) { public AcquisitionManager(ICDMAReader cdmaReader) {
this.cdmaReader = cdmaReader; this.cdmaReader = cdmaReader;
sensorConfig = null; detector = null;
dataToLoad = new HashSet<LoadableData>(); dataToLoad = new HashSet<LoadableData>();
} }
...@@ -48,26 +47,26 @@ public class AcquisitionManager { ...@@ -48,26 +47,26 @@ public class AcquisitionManager {
synchronized (dataToLoad) { synchronized (dataToLoad) {
toLoad = dataToLoad.toArray(new LoadableData[dataToLoad.size()]); toLoad = dataToLoad.toArray(new LoadableData[dataToLoad.size()]);
} }
cdmaReader.loadAcquisition(sensorConfig, toLoad); cdmaReader.loadAcquisition(detector, toLoad);
} }
} }
/** /**
* Returns the previously set {@link SensorConfig} * Returns the previously set detector.
* *
* @return A {@link SensorConfig} * @return A {@link String}.
*/ */
public SensorConfig getSensorConfig() { public String getDetector() {
return sensorConfig; return detector;
} }
/** /**
* Sets the {@link SensorConfig} to use for acquisition loading * Sets the detector to use for acquisition loading.
* *
* @param sensorConfig The {@link SensorConfig} to use * @param detector The detector to use.
*/ */
public void setSensorConfig(SensorConfig sensorConfig) { public void setDetector(String detector) {
this.sensorConfig = sensorConfig; this.detector = detector;
} }
/** /**
......
...@@ -16,7 +16,6 @@ import fr.soleil.cdma.box.data.ContextDataItem; ...@@ -16,7 +16,6 @@ import fr.soleil.cdma.box.data.ContextDataItem;
import fr.soleil.cdma.box.data.LoadableData; import fr.soleil.cdma.box.data.LoadableData;
import fr.soleil.cdma.box.data.acquisition.Acquisition; import fr.soleil.cdma.box.data.acquisition.Acquisition;
import fr.soleil.cdma.box.data.sensor.ExperimentConfig; import fr.soleil.cdma.box.data.sensor.ExperimentConfig;
import fr.soleil.cdma.box.data.sensor.SensorConfig;
import fr.soleil.cdma.box.exception.CDMAAccessException; import fr.soleil.cdma.box.exception.CDMAAccessException;
import fr.soleil.data.source.AbstractDataSource; import fr.soleil.data.source.AbstractDataSource;
import fr.soleil.lib.project.ICancelable; import fr.soleil.lib.project.ICancelable;
...@@ -42,7 +41,6 @@ public interface ICDMAReader extends ICancelable { ...@@ -42,7 +41,6 @@ public interface ICDMAReader extends ICancelable {
public static final String STACK_NAME_KEY = "stack_name"; public static final String STACK_NAME_KEY = "stack_name";
public static final String ATTR_EQUIPMENT_NAME = "equipment"; public static final String ATTR_EQUIPMENT_NAME = "equipment";
public static final String ATTR_EQUIPMENT_REGION = "region";
public static final String ATTR_LONG_NAME = "long_name"; public static final String ATTR_LONG_NAME = "long_name";
public static final String ATTR_UNIT = "unit"; public static final String ATTR_UNIT = "unit";
public static final String ATTR_FORMAT = "format"; public static final String ATTR_FORMAT = "format";
...@@ -59,7 +57,7 @@ public interface ICDMAReader extends ICancelable { ...@@ -59,7 +57,7 @@ public interface ICDMAReader extends ICancelable {
public static final String SCIENTA_DETECTOR = "Scienta"; public static final String SCIENTA_DETECTOR = "Scienta";
public static final String KEITHLEY_DETECTOR = "Keithley"; public static final String KEITHLEY_DETECTOR = "Keithley";
public static final String XIA_DETECTOR = "Xia"; public static final String XIA_DETECTOR = "Xia";
// public static final String MBS_DETECTOR_PATTERN = "MBSAcquisition[_]*\\d*"; public static final String XIA_DETECTOR_PATTERN = "Xia.*";
public static final String MBS_DETECTOR_PATTERN = "MBS.*"; public static final String MBS_DETECTOR_PATTERN = "MBS.*";
public static final String LIVE_TIME_KEY = "liveTime"; public static final String LIVE_TIME_KEY = "liveTime";
public static final String CHANNEL_SCALE_KEY = "channelScale"; public static final String CHANNEL_SCALE_KEY = "channelScale";
...@@ -80,6 +78,7 @@ public interface ICDMAReader extends ICancelable { ...@@ -80,6 +78,7 @@ public interface ICDMAReader extends ICancelable {
public static final String SLICES_KEY = "slices"; public static final String SLICES_KEY = "slices";
public static final String IMAGES_KEY = "images"; public static final String IMAGES_KEY = "images";
public static final String SPECTRA_KEY = "spectra";
public static final String SPECTRA_XIA_KEY = "spectra_xia"; public static final String SPECTRA_XIA_KEY = "spectra_xia";
public static final String SPECTRA_SCIENTA_KEY = "spectra_scienta"; public static final String SPECTRA_SCIENTA_KEY = "spectra_scienta";
public static final String SPECTRA_MBS_KEY = "spectra_mbs"; public static final String SPECTRA_MBS_KEY = "spectra_mbs";
...@@ -91,6 +90,15 @@ public interface ICDMAReader extends ICancelable { ...@@ -91,6 +90,15 @@ public interface ICDMAReader extends ICancelable {
public static final String SAMPLE_THETA_KEY = "sampleTheta"; public static final String SAMPLE_THETA_KEY = "sampleTheta";
public static final String APERTURE_ANGLE_KEY = "apertureAngle"; public static final String APERTURE_ANGLE_KEY = "apertureAngle";
public static final String SCALARS_DISPLAY_NAME = SCALARS_KEY;
public static final String SPECTRA_DISPLAY_NAME = SPECTRA_KEY;
public static final String IMAGES_DISPLAY_NAME = IMAGES_KEY;
public static final String TOTAL_SPECTRUM_DISPLAY_NAME = "total spectrum";
public static final String BEAM_ENERGY_DISPLAY_NAME = "beam energy";
public static final String SAMPLE_PHI_DISPLAY_NAME = "sample phi";
public static final String SAMPLE_THETA_DISPLAY_NAME = "theta";
public static final String APERTURE_ANGLE_DISPLAY_NAME = "aperture angle";
public static final String MOTORS_GROUP = "motors"; public static final String MOTORS_GROUP = "motors";
public static final String MOTOR_PARAMETER = "motor"; public static final String MOTOR_PARAMETER = "motor";
public static final String MOTOR_POSITION_KEY = "motor_position"; public static final String MOTOR_POSITION_KEY = "motor_position";
...@@ -419,13 +427,13 @@ public interface ICDMAReader extends ICancelable { ...@@ -419,13 +427,13 @@ public interface ICDMAReader extends ICancelable {
public double getBias(String im, LogicalGroup monitorGroup); public double getBias(String im, LogicalGroup monitorGroup);
/** /**
* Recovers an {@link Acquisition} from a {@link SensorConfig} * Recovers an {@link Acquisition} from a detector
* *
* @param sensorConfig The concerned {@link SensorConfig} * @param detector The concerned detector
* @param dataToLoad The optional data to load * @param dataToLoad The optional data to load
* @throws CDMAAccessException If a problem occurred during acquisition loading * @throws CDMAAccessException If a problem occurred during acquisition loading
*/ */
public void loadAcquisition(SensorConfig sensorConfig, LoadableData... dataToLoad) throws CDMAAccessException; public void loadAcquisition(String detector, LoadableData... dataToLoad) throws CDMAAccessException;
/** /**
* Returns the {@link AbstractDataSource} that contains the loaded {@link ExperimentConfig} * Returns the {@link AbstractDataSource} that contains the loaded {@link ExperimentConfig}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment