Commit bcb59244 authored by SAPONE Alann's avatar SAPONE Alann

New range corrector class

parent 91fc011a
......@@ -102,5 +102,4 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>org.cnrs.lam.dis</groupId>
</project>
</project>
......@@ -33,8 +33,6 @@
*/
package org.cnrs.lam.dis.etc.calculator;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.cnrs.lam.cesam.util.calculator.CalculationException;
import org.cnrs.lam.cesam.util.calculator.ConfigurationException;
......@@ -42,15 +40,14 @@ import org.cnrs.lam.cesam.util.calculator.InitializationException;
import org.cnrs.lam.dis.etc.calculator.exposuretime.ExposureTimeFactory;
import org.cnrs.lam.dis.etc.calculator.signaltonoise.SignalToNoiseFactory;
import org.cnrs.lam.dis.etc.calculator.util.FunctionToDatasetResultConverter;
import org.cnrs.lam.dis.etc.calculator.wavelengthrange.CommonRangeFactory;
import org.cnrs.lam.dis.etc.calculator.wavelengthrange.Imaging;
import org.cnrs.lam.dis.etc.calculator.wavelengthrange.WavelengthRangeFactory;
import org.cnrs.lam.dis.etc.configuration.ConfigFactory;
import org.cnrs.lam.dis.etc.datamodel.CalculationResults;
import org.cnrs.lam.dis.etc.datamodel.Dataset;
import org.cnrs.lam.dis.etc.datamodel.Dataset.Type;
import org.cnrs.lam.dis.etc.datamodel.DatasetProvider;
import org.cnrs.lam.dis.etc.datamodel.ObsParam.FixedParameter;
import org.cnrs.lam.dis.etc.datamodel.Session;
import org.cnrs.lam.dis.etc.datamodel.Instrument.InstrumentType;
import org.javatuples.Pair;
import org.javatuples.Unit;
/**
......@@ -80,7 +77,8 @@ final class CalculatorImpl implements Calculator {
}
@Override
public CalculationResults performCalculation(Session session, DatasetProvider datasetProvider) throws CalculationError, ValidationError {
public CalculationResults performCalculation(Session session, DatasetProvider datasetProvider) throws CalculationError, ValidationError {
CommonRangeFactory.setSession(session);
PreviousResultsHolder.setResults(ResultsHolder.getResults());
ResultsHolder.resetResults();
DatasetProviderHolder.setDatasetProvider(datasetProvider);
......@@ -94,7 +92,7 @@ final class CalculatorImpl implements Calculator {
logger.error(ex.getMessage(), ex);
throw new CalculationError("Failed to calculate the wavelength range of the simulation. Reason:\n" + ex.getMessage());
}
double oldExposureTime = session.getObsParam().getExposureTime();
if (session.getObsParam().getFixedParameter() == FixedParameter.SNR) {
double time;
......
......@@ -183,7 +183,6 @@ public class EtcCalculatorManager <C extends Tuple, I extends Tuple, O extends T
for (CalculationResults.Level level : CalculationResults.Level.values()) {
for (String name : resultNameMap.get(level)) {
Result result = PreviousResultsHolder.getResults().getResultByName(name);
//System.out.println("result : " + result + " - input : " + input + " - output : " + output + " - name : " + name + " - level : " + level);
if (result != null) {
ResultsHolder.getResults().addResult(result, level);
}
......
......@@ -68,8 +68,11 @@ public class FilterResponseFactory implements Factory<Unit<Session>, Tuple, Unit
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("FILTER_RESPONSE_METHOD", "Filter Transmission Profile"), CalculationResults.Level.DEBUG);
DatasetInfo filterTransmissionInfo = instrument.getFilterTransmission();
Unit<DatasetInfo> calculatorConfiguration = new Unit<DatasetInfo>(filterTransmissionInfo);
return EtcCalculatorManager.getManager(org.cnrs.lam.dis.etc.calculator.filterresponse.FilterTransmissionProfile.class).getCalculator(calculatorConfiguration);
EtcCalculatorManager<Unit<DatasetInfo>, Tuple, Unit<BoundedUnivariateFunction>, FilterTransmissionProfile> manager = EtcCalculatorManager.getManager(org.cnrs.lam.dis.etc.calculator.filterresponse.FilterTransmissionProfile.class);
FilterTransmissionProfile calculator = manager.getCalculator(calculatorConfiguration);
return calculator;
} else {
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("FILTER_RESPONSE_METHOD", "No Filter"), CalculationResults.Level.DEBUG);
......
......@@ -117,13 +117,6 @@ public class SignalToNoiseFactory implements
return EtcCalculatorManager.getManager(SpectroscopyDit.class)
.getCalculator(spectroscopyDitConfiguration);
case NO_EXPO:
System.out.println("Contenu des éléments");
System.out.println("signalPairSp - value à 0 : " + signalPairSp.getValue0().getClass());
System.out.println("signalPairSp - value à 1 : " + signalPairSp.getValue1().getClass());
System.out.println("backgroundPairSp - value à 0 : " + backgroundPairSp.getValue0().getClass());
System.out.println("backgroundPairSp - value à 1 : " + backgroundPairSp.getValue1().getClass());
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("SNR_METHOD", "Spectroscopy / Exposures Number"),
......@@ -131,6 +124,7 @@ public class SignalToNoiseFactory implements
Ennead<Calculator<Unit<Double>, Unit<Double>>, Pair<Calculator<Pair<Double, Double>, Pair<UnivariateRealFunction, UnivariateRealFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>>, Pair<Calculator<Pair<Double, Double>, Pair<UnivariateRealFunction, UnivariateRealFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>>, Calculator<Unit<Double>, Unit<Double>>, Pair<Double, String>, Pair<Double, String>, Integer, Pair<Double, String>, Calculator<Tuple, Pair<Double, Double>>> spectroscopyNExpoConfiguration = new Ennead<Calculator<Unit<Double>, Unit<Double>>, Pair<Calculator<Pair<Double, Double>, Pair<UnivariateRealFunction, UnivariateRealFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>>, Pair<Calculator<Pair<Double, Double>, Pair<UnivariateRealFunction, UnivariateRealFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>>, Calculator<Unit<Double>, Unit<Double>>, Pair<Double, String>, Pair<Double, String>, Integer, Pair<Double, String>, Calculator<Tuple, Pair<Double, Double>>>(
deltaLambda, signalPairSp, backgroundPairSp, numberOfPixels, dark, readout, nExpo, exposureTime,
wavelengthRange);
return EtcCalculatorManager.getManager(SpectroscopyExposuresNumber.class)
.getCalculator(spectroscopyNExpoConfiguration);
}
......
......@@ -238,6 +238,8 @@ public class SpectroscopyExposuresNumber extends AbstractCalculator<
noExpo = configuration.getValue6();
exposureTime = configuration.getValue7().getValue0();
wavelengthRange = configuration.getValue8();
// Calculate the minimum and maximum of the wavelength range
Pair<Double, Double> minMax = null;
......
......@@ -53,6 +53,13 @@ public class Dataset {
private final double minZeroRange;
private final double maxZeroRange;
private static double globalMinRange = Double.NEGATIVE_INFINITY;
private static double globalMaxRange = Double.POSITIVE_INFINITY;
public static Pair<Double, Double> getGlobalBounds() {
return new Pair<Double, Double>(globalMinRange, globalMaxRange);
}
/**
* Constructs a new {@code Dataset} object, representing the given data. Note
* that the order of the given data will be ignored and the data will be stored
......@@ -78,6 +85,16 @@ public class Dataset {
}
minRange = min;
maxRange = max;
// global update
if (minRange > globalMinRange)
globalMinRange = minRange;
if (maxRange < globalMaxRange)
globalMaxRange = maxRange;
//System.out.println("Datalength: " + data.size() + " - minRange : " + minRange + " - maxRange : " + maxRange + " - globalMinRange : " + globalMinRange + " - globalMaxRange : " + globalMaxRange);
// Find the nodes for the zero range. We use the local map which is sorted.
double minZero = min;
double maxZero = max;
......@@ -135,7 +152,8 @@ public class Dataset {
* or null if there is no such key
*/
public Entry<Double, Double> getFloorDataNode(double key) {
return data.floorEntry(key);
Entry<Double, Double> floorEntry = data.floorEntry(key);
return floorEntry;
}
/**
......@@ -146,7 +164,8 @@ public class Dataset {
* or null if there is no such key
*/
public Entry<Double, Double> getCeilingDataNode(double key) {
return data.ceilingEntry(key);
Entry<Double, Double> ceilingEntry = data.ceilingEntry(key);
return ceilingEntry;
}
/**
......@@ -157,7 +176,8 @@ public class Dataset {
* or null if there is no such key
*/
public Entry<Double, Double> getLowerDataNode(double key) {
return data.lowerEntry(key);
Entry<Double, Double> lowerEntry = data.lowerEntry(key);
return lowerEntry;
}
/**
......@@ -168,7 +188,8 @@ public class Dataset {
* or null if there is no such key
*/
public Entry<Double, Double> getHigherDataNode(double key) {
return data.higherEntry(key);
Entry<Double, Double> higherEntry = data.higherEntry(key);
return higherEntry;
}
/**
......
......@@ -72,8 +72,9 @@ public class LinearFunctionDataset extends Dataset implements
// First make a check that we are inside the bounds
Pair<Double, Double> bounds = getBounds();
if (x < bounds.getValue0() || x > bounds.getValue1()) {
throw new FunctionEvaluationException(x);
throw new FunctionEvaluationException(x);
}
// We get the floor entry from the data. Note that if there is a node
// with the exact same key we return its value directly
Map.Entry<Double, Double> floorDataNode = getFloorDataNode(x);
......
......@@ -43,6 +43,8 @@ import org.apache.commons.math.FunctionEvaluationException;
import org.cnrs.lam.dis.etc.calculator.util.CautionMessage;
import org.cnrs.lam.dis.etc.calculator.util.functions.BoundedUnivariateFunction;
import org.cnrs.lam.dis.etc.calculator.util.functions.IntegrableUnivariateFunction;
import org.cnrs.lam.dis.etc.calculator.wavelengthrange.CommonRangeFactory;
import org.cnrs.lam.dis.etc.calculator.wavelengthrange.WavelengthRangeFactory;
import org.javatuples.Pair;
/**
......@@ -162,12 +164,15 @@ public class TemplateFunctionDataset extends Dataset implements
if (x1 == x2) {
return 0;
}
/*
// Check that the integration range is inside the bounds of the function
Pair<Double, Double> bounds = getBounds();
if (x2 > bounds.getValue1() || x1 < bounds.getValue0()) {
//CautionMessage.getInstance().addMessage("INTEGRAL_OUT_OF_BOUNDS", bundle.getString("INTEGRAL_OUT_OF_BOUNDS"));
if (CommonRangeFactory.getCanDisplayRangeError())
CautionMessage.getInstance().addMessage("INTEGRAL_OUT_OF_BOUNDS", bundle.getString("INTEGRAL_OUT_OF_BOUNDS"));
//throw new FunctionEvaluationException(x2);
}
*/
double integral = 0;
// We get all the nodes which are between the x1 and x2.
......@@ -268,4 +273,4 @@ public class TemplateFunctionDataset extends Dataset implements
return super.getNonZeroBounds();
}
}
}
\ No newline at end of file
......@@ -333,9 +333,6 @@ public class FunctionMultiplicationTool {
LinearFunctionDataset mainFunction, UnivariateRealFunction ... functionList)
throws FunctionEvaluationException {
System.out.println(mainFunction.getClass().getName());
System.out.println(mainFunction.getData().entrySet().size());
Map<Double, Double> productData = new TreeMap<Double, Double>();
for (Map.Entry<Double, Double> entry : mainFunction.getData().entrySet()) {
double key = entry.getKey();
......
package org.cnrs.lam.dis.etc.calculator.wavelengthrange;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import org.cnrs.lam.dis.etc.calculator.DatasetProviderHolder;
import org.cnrs.lam.dis.etc.datamodel.DatasetInfo;
import org.cnrs.lam.dis.etc.datamodel.Session;
import org.cnrs.lam.dis.etc.datamodel.Dataset.Type;
import org.javatuples.Pair;
import org.javatuples.Triplet;
public class CommonRangeFactory {
private static Session session;
private static int i = 0;
public static void setSession(Session _session) {
CommonRangeFactory.session = _session;
}
public static Session getSession() {
return CommonRangeFactory.session;
}
// To avoid multiple error on calculation range
private static boolean canDisplayRangeError = true;
public static void setCanDisplayRangeError(boolean canDisplayRangeError) {
CommonRangeFactory.canDisplayRangeError = canDisplayRangeError;
}
public static boolean getCanDisplayRangeError() {
return canDisplayRangeError;
}
public static Pair<Double, Double> getCalculableRange(Session session, Pair<Double, Double> calculableRange) {
ArrayList<Triplet<Double, Double, String>> ranges = new ArrayList<Triplet<Double, Double, String>>();
/* Instrumental limitations */
// Transmision
Triplet<Double, Double, String> instrumentTransmissionRange = getRange(Type.TRANSMISSION,
session.getInstrument().getTransmission(), null, "Instrument > Transmission");
if (instrumentTransmissionRange != null)
ranges.add(instrumentTransmissionRange);
// Resolving power
Triplet<Double, Double, String> spectralResolutionRange = getRange(Type.SPECTRAL_RESOLUTION,
session.getInstrument().getSpectralResolution(), null, "Instrument > Resolving power");
if (spectralResolutionRange != null)
ranges.add(spectralResolutionRange);
/* Sites limitations */
// Sky brightness
Triplet<Double, Double, String> skyBrightnessRange = getRange(Type.SKY_EMISSION,
session.getSite().getSkyEmission(), session.getSite().getSkyEmissionSelectedOption(),
"Site > Sky brightness");
if (skyBrightnessRange != null)
ranges.add(skyBrightnessRange);
// Sky absorption
Triplet<Double, Double, String> skyAbsorptionRange = getRange(Type.SKY_ABSORPTION,
session.getSite().getSkyAbsorption(), null, "Site > Sky absorption");
if (skyAbsorptionRange != null)
ranges.add(skyAbsorptionRange);
// Sky extinction
Triplet<Double, Double, String> skyExtinctionRange = getRange(Type.SKY_EXTINCTION,
session.getSite().getSkyExtinction(), null, "Site > Sky extinction");
if (skyExtinctionRange != null)
ranges.add(skyExtinctionRange);
/* Sources limitations */
// Spectral distribution
Triplet<Double, Double, String> spectralDistributionRange = getRange(Type.SPECTRAL_DIST_TEMPLATE,
session.getSource().getSpectralDistributionTemplate(), null, "Source > Spectral distribution");
if (spectralDistributionRange != null)
ranges.add(spectralDistributionRange);
// Setting range
ArrayList<String> rangeErrors = new ArrayList<String>();
for (Triplet<Double, Double, String> range : ranges) {
Double newMin = Math.max(calculableRange.getValue0(), range.getValue0());
Double newMax = Math.min(calculableRange.getValue1(), range.getValue1());
if (newMin > calculableRange.getValue0() || newMax < calculableRange.getValue1()) {
String errorSource = range.getValue2();
String errorMessage = errorSource + " : Calculable range is [" + range.getValue0() + " - "
+ range.getValue1() + "]";
rangeErrors.add(errorMessage);
}
calculableRange = new Pair<Double, Double>(newMin, newMax);
}
if (rangeErrors.size() > 0 && canDisplayRangeError) {
String fullErrorMessage = "The spectrograph range must be truncated in order to perform the calculation."
+ "\nThe closest calculation range is : [" + calculableRange.getValue0() + " - " + calculableRange.getValue1() + "] :";
for (String rangeError : rangeErrors) {
fullErrorMessage += "\n " + rangeError;
}
JOptionPane.showMessageDialog(null, fullErrorMessage);
CommonRangeFactory.setCanDisplayRangeError(false);
}
return calculableRange;
}
public static Triplet<Double, Double, String> getRange(Type type, DatasetInfo info, String option, String errorMessage) {
Triplet<Double, Double, String> lowHigh = null;
if (info != null) {
org.cnrs.lam.dis.etc.datamodel.Dataset dataSet = null;
if (option != null)
dataSet = DatasetProviderHolder.getDatasetProvider().getDataset(type, info, option);
else
dataSet = DatasetProviderHolder.getDatasetProvider().getDataset(type, info);
if (dataSet != null) {
Object[] keys = dataSet.getData().keySet().toArray();
lowHigh = new Triplet<Double, Double, String>((Double) keys[0], (Double) keys[keys.length - 1],
errorMessage);
}
}
return lowHigh;
}
}
......@@ -33,15 +33,19 @@
*/
package org.cnrs.lam.dis.etc.calculator.wavelengthrange;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javax.swing.JOptionPane;
import lombok.EqualsAndHashCode;
import org.apache.log4j.Logger;
import org.cnrs.lam.cesam.util.calculator.*;
import org.cnrs.lam.dis.etc.calculator.ResultsHolder;
import org.cnrs.lam.dis.etc.calculator.util.FunctionToDatasetResultConverter;
import org.cnrs.lam.dis.etc.calculator.util.Units;
import org.cnrs.lam.dis.etc.calculator.util.functions.BoundedUnivariateFunction;
import org.cnrs.lam.dis.etc.datamodel.CalculationResults;
import org.cnrs.lam.dis.etc.datamodel.Session;
import org.javatuples.Pair;
import org.javatuples.Tuple;
import org.javatuples.Unit;
......@@ -84,7 +88,7 @@ public class Imaging extends AbstractCalculator<
private static final ResourceBundle validationErrorsBundle = ResourceBundle.getBundle("org/cnrs/lam/dis/etc/calculator/ValidationErrors");
private double minLambda;
private double maxLambda;
/**
* It validates the configuration of the calculator. It checks that the filter
* transmission and the total system efficiency have overlapping non-zero ranges.
......@@ -163,7 +167,12 @@ public class Imaging extends AbstractCalculator<
*/
@Override
protected Pair<Double, Double> performCalculation(Tuple input) throws CalculationException {
return new Pair<Double, Double>(minLambda, maxLambda);
Pair<Double, Double> calculableRange = CommonRangeFactory.getCalculableRange(
CommonRangeFactory.getSession(),
new Pair<Double, Double>(minLambda, maxLambda)
);
return new Pair<Double, Double>(calculableRange.getValue0(), calculableRange.getValue1());
}
/**
......
......@@ -34,7 +34,11 @@
package org.cnrs.lam.dis.etc.calculator.wavelengthrange;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javax.swing.JOptionPane;
import lombok.EqualsAndHashCode;
import org.cnrs.lam.cesam.util.calculator.AbstractCalculator;
import org.cnrs.lam.cesam.util.calculator.Cacheable;
......@@ -43,7 +47,6 @@ import org.cnrs.lam.cesam.util.calculator.CalculationException;
import org.cnrs.lam.cesam.util.calculator.ConfigurationException;
import org.cnrs.lam.cesam.util.calculator.InitializationException;
import org.cnrs.lam.dis.etc.calculator.ResultsHolder;
import org.cnrs.lam.dis.etc.calculator.util.FunctionToDatasetResultConverter;
import org.cnrs.lam.dis.etc.calculator.util.Units;
import org.cnrs.lam.dis.etc.datamodel.CalculationResults;
import org.javatuples.Pair;
......@@ -152,7 +155,12 @@ public class Spectroscopy extends AbstractCalculator<Quartet<Double, String, Dou
*/
@Override
protected Pair<Double, Double> performCalculation(Tuple input) throws CalculationException {
return new Pair<Double, Double>(minLambda, maxLambda);
Pair<Double, Double> calculableRange = CommonRangeFactory.getCalculableRange(
CommonRangeFactory.getSession(),
new Pair<Double, Double>(minLambda, maxLambda)
);
return new Pair<Double, Double>(calculableRange.getValue0(), calculableRange.getValue1());
}
/**
......
......@@ -34,6 +34,7 @@
package org.cnrs.lam.dis.etc.calculator.wavelengthrange;
import java.util.ResourceBundle;
import org.cnrs.lam.cesam.util.calculator.*;
import org.cnrs.lam.dis.etc.calculator.EtcCalculatorManager;
import org.cnrs.lam.dis.etc.calculator.ResultsHolder;
......@@ -49,49 +50,68 @@ import org.javatuples.Tuple;
import org.javatuples.Unit;
/**
* The class {@code WavelengthRangeFactory} is a factory for creating calculators
* for performing the wavelength range calculation.
* The class {@code WavelengthRangeFactory} is a factory for creating
* calculators for performing the wavelength range calculation.
*/
public class WavelengthRangeFactory implements Factory<Unit<Session>, Tuple, Pair<Double, Double>> {
// The bundle with all the error translations
private static final ResourceBundle validationErrorsBundle = ResourceBundle.getBundle("org/cnrs/lam/dis/etc/calculator/ValidationErrors");
/**
* Provides a calculator for performing wavelength range calculations. The
* type of the calculator returned is added in the debug results with the
* code WAVELENGTH_RANGE_METHOD.
* @param configuration The session for which the simulation is executed
* @return A calculator for performing wavelength range calculations
* @throws InitializationException If the initialization of the calculator fails
* @throws ConfigurationException If the configuration session is invalid
*/
@Override
public Calculator<Tuple, Pair<Double, Double>> getCalculator(Unit<Session> configuration) throws InitializationException, ConfigurationException {
Session session = configuration.getValue0();
Instrument instrument = session.getInstrument();
switch (instrument.getInstrumentType()) {
case IMAGING:
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("WAVELENGTH_RANGE_METHOD", "Imaging"), CalculationResults.Level.DEBUG);
Calculator<Tuple, Unit<BoundedUnivariateFunction>> filterCalculator = new FilterResponseFactory().getCalculator(configuration);
Calculator<Tuple, Unit<BoundedUnivariateFunction>> systemCalculator = new SystemEfficiencyFactory().getCalculator(configuration);
Pair<Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>> imagingConfiguration
= new Pair<Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>>(filterCalculator, systemCalculator);
return EtcCalculatorManager.getManager(Imaging.class).getCalculator(imagingConfiguration);
case SPECTROGRAPH:
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("WAVELENGTH_RANGE_METHOD", "Spectroscopy"), CalculationResults.Level.DEBUG);
Double rangeMin = instrument.getRangeMin();
String rangeMinUnit = instrument.getRangeMinUnit();
Double rangeMax = instrument.getRangeMax();
String rangeMaxUnit = instrument.getRangeMaxUnit();
Quartet<Double, String, Double, String> spectroscopyConfiguration
= new Quartet<Double, String, Double, String>(rangeMin, rangeMinUnit, rangeMax, rangeMaxUnit);
return EtcCalculatorManager.getManager(Spectroscopy.class).getCalculator(spectroscopyConfiguration);
}
String message = validationErrorsBundle.getString("UNKNOWN_WAVELENGTH_RANGE_METHOD");
throw new ConfigurationException(message);
}
// The bundle with all the error translations
private static final ResourceBundle validationErrorsBundle = ResourceBundle
.getBundle("org/cnrs/lam/dis/etc/calculator/ValidationErrors");
/**
* Provides a calculator for performing wavelength range calculations. The
* type of the calculator returned is added in the debug results with the
* code WAVELENGTH_RANGE_METHOD.
*
* @param configuration
* The session for which the simulation is executed
* @return A calculator for performing wavelength range calculations
* @throws InitializationException
* If the initialization of the calculator fails
* @throws ConfigurationException
* If the configuration session is invalid
*/
@Override
public Calculator<Tuple, Pair<Double, Double>> getCalculator(Unit<Session> configuration)
throws InitializationException, ConfigurationException {
Session session = configuration.getValue0();
Instrument instrument = session.getInstrument();
switch (instrument.getInstrumentType()) {
case IMAGING:
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("WAVELENGTH_RANGE_METHOD", "Imaging"),
CalculationResults.Level.DEBUG);
Calculator<Tuple, Unit<BoundedUnivariateFunction>> filterCalculator = new FilterResponseFactory()
.getCalculator(configuration);
Calculator<Tuple, Unit<BoundedUnivariateFunction>> systemCalculator = new SystemEfficiencyFactory()
.getCalculator(configuration);
return EtcCalculatorManager.getManager(Imaging.class).getCalculator(
new Pair<Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>>(
filterCalculator, systemCalculator));
case SPECTROGRAPH:
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("WAVELENGTH_RANGE_METHOD", "Spectroscopy"),
CalculationResults.Level.DEBUG);
String rangeMinUnit = instrument.getRangeMinUnit();
Double rangeMin = instrument.getRangeMin();
String rangeMaxUnit = instrument.getRangeMaxUnit();
Double rangeMax = instrument.getRangeMax();
Quartet<Double, String, Double, String> spectroscopyConfiguration = new Quartet<Double, String, Double, String>(
rangeMin, rangeMinUnit, rangeMax, rangeMaxUnit);
Spectroscopy calculator = EtcCalculatorManager.getManager(Spectroscopy.class)
.getCalculator(spectroscopyConfiguration);
return calculator;
}
String message = validationErrorsBundle.getString("UNKNOWN_WAVELENGTH_RANGE_METHOD");
throw new ConfigurationException(message);
}
}
......@@ -7,7 +7,6 @@
<groupId>org.cnrs.lam.dis</groupId>
<version>1.0.0</version>
</parent>
<groupId>org.cnrs.lam.dis</groupId>
<artifactId>ETC-Configuration</artifactId>
<name>ETC-Configuration</name>
<build>
......
......@@ -134,5 +134,4 @@
<url>http://xladmin.oamp.lan/maven/</url>
</repository>
</repositories>
<groupId>org.cnrs.lam.dis</groupId>
</project>
......@@ -42,9 +42,13 @@ import org.cnrs.lam.dis.etc.calculator.Calculator;
import org.cnrs.lam.dis.etc.calculator.ValidationError;
import org.cnrs.lam.dis.etc.calculator.Validator;
import org.cnrs.lam.dis.etc.calculator.util.CautionMessage;
import org.cnrs.lam.dis.etc.calculator.wavelengthrange.CommonRangeFactory;
import org.cnrs.lam.dis.etc.calculator.wavelengthrange.Imaging;
import org.cnrs.lam.dis.etc.calculator.wavelengthrange.WavelengthRangeFactory;
import org.cnrs.lam.dis.etc.configuration.ConfigFactory;
import org.cnrs.lam.dis.etc.datamodel.CalculationResults;
import org.cnrs.lam.dis.etc.datamodel.DatasetProvider;
import org.cnrs.lam.dis.etc.datamodel.Session;
import org.cnrs.lam.dis.etc.plugins.PluginException;
import org.cnrs.lam.dis.etc.plugins.PluginManager;
import org.cnrs.lam.dis.etc.ui.BuisnessListener;
......@@ -139,7 +143,8 @@ final class BuisnessListenerImpl implements BuisnessListener {
// Perform the calculation
CalculationResults result = null;
try {
result = calculator.performCalculation(CurrentSessionContainer.getCurrentSession(), datasetProvider);
Session session = CurrentSessionContainer.getCurrentSession();
result = calculator.performCalculation(session, datasetProvider);
if(CautionMessage.getInstance().getMessages().size() > 0) {
for(String key : CautionMessage.getInstance().getMessages().keySet()) {
messenger.info(CautionMessage.getInstance().getMessages().get(key).toString());
......@@ -165,6 +170,9 @@ final class BuisnessListenerImpl implements BuisnessListener {
// We do not want to present any results, so we return here
} finally {
messenger.actionStoped(this);
// To reset warning about range
CommonRangeFactory.setCanDisplayRangeError(true);
}
return;
}
......
......@@ -123,5 +123,4 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>org.cnrs.lam.dis</groupId>
</project>
......@@ -43,6 +43,5 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>org.cnrs.lam.dis</groupId>
</project>
......@@ -25,5 +25,4 @@
</plugin>
</plugins>
</build>
<groupId>org.cnrs.lam.dis</groupId>
</project>
......@@ -59,5 +59,4 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>org.cnrs.lam.dis</groupId>
</project>
......@@ -99,5 +99,4 @@
</repository>
</repositories>
<groupId>org.cnrs.lam.dis</groupId>
</project>