Commit d1d219b8 authored by SAPONE Alann's avatar SAPONE Alann

Cleaning + range text in results

parent bcb59244
......@@ -120,6 +120,7 @@ public class FlatEnergyFlux extends AbstractCalculator<
*/
@Override
protected Unit<UnivariateRealFunction> performCalculation(Tuple input) throws CalculationException {
System.out.println(fluxFunction);
return new Unit<UnivariateRealFunction>(fluxFunction);
}
......
......@@ -158,7 +158,6 @@ public class SignalFlux extends AbstractCalculator<
Calculator<Tuple, Unit<BoundedUnivariateFunction>>,
Calculator<Tuple, Unit<BoundedUnivariateFunction>>,
Calculator<Tuple, Unit<Double>>> configuration) throws ConfigurationException {
// Do nothing here
}
/**
......@@ -181,7 +180,8 @@ public class SignalFlux extends AbstractCalculator<
fluxCalculator = configuration.getValue1();
UnivariateRealFunction fluxFunction = null;
try {
fluxFunction = fluxCalculator.calculate(null).getValue0();
Unit<UnivariateRealFunction> calculator = fluxCalculator.calculate(null);
fluxFunction = calculator.getValue0();
} catch (CalculationException ex) {
logger.error("Failed to calculate the flux flunction", ex);
throw new InitializationException(ex.getMessage(), ex);
......
......@@ -92,15 +92,26 @@ public class SimulatedSignalFactory
// new ConvolutionKernelSizeFactory().getCalculator(configuration);
Calculator<Unit<Double>, Unit<BoundedUnivariateFunction>> convolutionKernelProducer = new SignalSpectralConvolutionKernelFactory()
.getCalculator(configuration);
Calculator<Tuple, Unit<UnivariateRealFunction>> flux = new FluxFactory().getCalculator(configuration);
Calculator<Tuple, Pair<UnivariateRealFunction, UnivariateRealFunction>> normalizationFactor = new NormalizationFactorFactory()
.getCalculator(configuration);
Calculator<Tuple, Unit<BoundedUnivariateFunction>> atmosphericTransmission = new AtmosphericTransmissionFactory()
.getCalculator(configuration);
Calculator<Tuple, Unit<BoundedUnivariateFunction>> systemEfficiency = new SystemEfficiencyFactory()
.getCalculator(configuration);
Calculator<Tuple, Unit<BoundedUnivariateFunction>> filterResponse = new FilterResponseFactory()
.getCalculator(configuration);
Calculator<Tuple, Unit<Double>> telescopeArea = new TelescopeAreaFactory().getCalculator(configuration);
Septet<Calculator<Unit<Double>, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<UnivariateRealFunction>>, Calculator<Tuple, Pair<UnivariateRealFunction, UnivariateRealFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<Double>>> signalFluxConfiguration = new Septet<Calculator<Unit<Double>, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<UnivariateRealFunction>>, Calculator<Tuple, Pair<UnivariateRealFunction, UnivariateRealFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<Double>>>(
convolutionKernelProducer, flux, normalizationFactor, atmosphericTransmission, systemEfficiency,
......@@ -109,7 +120,8 @@ public class SimulatedSignalFactory
// System.out.println(SignalFlux.class);
EtcCalculatorManager<Septet<Calculator<Unit<Double>, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<UnivariateRealFunction>>, Calculator<Tuple, Pair<UnivariateRealFunction, UnivariateRealFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<Double>>>, Pair<Double, Double>, Pair<UnivariateRealFunction, UnivariateRealFunction>, SignalFlux> manager;manager = EtcCalculatorManager.getManager(SignalFlux.class);
EtcCalculatorManager<Septet<Calculator<Unit<Double>, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<UnivariateRealFunction>>, Calculator<Tuple, Pair<UnivariateRealFunction, UnivariateRealFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<BoundedUnivariateFunction>>, Calculator<Tuple, Unit<Double>>>, Pair<Double, Double>, Pair<UnivariateRealFunction, UnivariateRealFunction>, SignalFlux> manager;
manager = EtcCalculatorManager.getManager(SignalFlux.class);
SignalFlux calculator = manager.getCalculator(signalFluxConfiguration);
return calculator;
}
......
......@@ -2,9 +2,9 @@ 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.calculator.ResultsHolder;
import org.cnrs.lam.dis.etc.datamodel.CalculationResults;
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;
......@@ -12,16 +12,18 @@ 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;
}
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;
......@@ -32,7 +34,8 @@ public class CommonRangeFactory {
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>>();
......@@ -81,7 +84,7 @@ public class CommonRangeFactory {
// Setting range
ArrayList<String> rangeErrors = new ArrayList<String>();
for (Triplet<Double, Double, String> range : ranges) {
Double newMin = Math.max(calculableRange.getValue0(), range.getValue0());
......@@ -89,37 +92,42 @@ public class CommonRangeFactory {
if (newMin > calculableRange.getValue0() || newMax < calculableRange.getValue1()) {
String errorSource = range.getValue2();
String errorMessage = errorSource + " : Calculable range is [" + range.getValue0() + " - "
+ range.getValue1() + "]";
String errorMessage = errorSource + " : [" + 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() + "] :";
if (rangeErrors.size() > 0) {
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("TRUNCATED_CALCULATION_RANGE", "[" + calculableRange.getValue0() + ", " + calculableRange.getValue1() + "]"),
CalculationResults.Level.FINAL
);
for (String rangeError : rangeErrors) {
fullErrorMessage += "\n " + rangeError;
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("TRUNCATED_CALCULATION_RANGE_CAUSE", rangeError),
CalculationResults.Level.FINAL
);
}
JOptionPane.showMessageDialog(null, fullErrorMessage);
CommonRangeFactory.setCanDisplayRangeError(false);
}
return calculableRange;
}
public static Triplet<Double, Double, String> getRange(Type type, DatasetInfo info, String option, String errorMessage) {
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)
if (option != null) {
dataSet = DatasetProviderHolder.getDatasetProvider().getDataset(type, info, option);
else
} 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],
......
......@@ -172,7 +172,7 @@ final class BuisnessListenerImpl implements BuisnessListener {
messenger.actionStoped(this);
// To reset warning about range
CommonRangeFactory.setCanDisplayRangeError(true);
// CommonRangeFactory.setCanDisplayRangeError(true);
}
return;
}
......
......@@ -95,6 +95,7 @@ public class OfficialRepositoryTreeView extends javax.swing.JPanel {
try {
if (isFolder) {
String cleanedName = text.substring(0, text.length() - 1);
System.out.println("VersionFilter" + versionFilter + " - cleanedName : " + cleanedName);
if (!isRoot || (isRoot && versionFilter.equals(cleanedName))) {
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(cleanedName);
node.add(newNode);
......
......@@ -373,6 +373,8 @@ RESULT_CONVOLUTION_KERNEL_X_LABEL=Wavelength
RESULT_CONVOLUTION_KERNEL_Y_LABEL=kernel size
RESULT_DIT=DIT
RESULT_EMISSION_LINE_FWHM=Emission line FWHM
RESULT_TRUNCATED_CALCULATION_RANGE=Truncated calculation range
RESULT_TRUNCATED_CALCULATION_RANGE_CAUSE=Truncated calculation cause
RESULT_WAVELENGTH_RANGE_METHOD=Wavelength range method
RESULT_WAVELENGTH_MIN=Wavelength range min
RESULT_WAVELENGTH_MAX=Wavelength range max
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment