use of org.eclipse.scanning.api.points.models.InterpolatedMultiScanModel in project gda-core by openGDA.
the class ScanRequestFactory method createInterpolatedCompoundModel.
/**
* Implementation based on {@code org.eclipse.scanning.test.scan.nexus.MalcolmMultiScanTest}
*
* @param acquisitionTemplate
* @return
*/
private CompoundModel createInterpolatedCompoundModel(AcquisitionTemplate acquisitionTemplate) {
final var multiScanModel = new InterpolatedMultiScanModel();
// --- Preparation ---
// Each new multiscanModel must set this start position and image type
// --- Positions List ---
final List<IPosition> interpolationPositions = new ArrayList<>();
// --- Images Type ---
final List<ImageType> imageTypes = new ArrayList<>();
// --- Flat Positions ---
// Note - The shutter "close" position is added by the ScanningAcquisitionController
final IPosition flatPos = createPositionMap(getFlatCalibration().getPosition());
// --- Dark Positions ---
// Note - The shutter "close" position is added by the ScanningAcquisitionController
final IPosition darkPos = createPositionMap(getDarkCalibration().getPosition());
// --- Steps estimation
ScannableTrackDocument trackDocument = getScanpathDocument().getScannableTrackDocuments().get(0);
// darks and flats should be (step / 2) before the start of the main scan, and the same after
final double posBeforeMainScan = trackDocument.getStart() - trackDocument.calculatedStep() / 2;
final double posAfterMainScan = trackDocument.getStop() + trackDocument.calculatedStep() / 2;
// Flat Before Acquisition
if (getFlatCalibration().isBeforeAcquisition() && getFlatCalibration().getNumberExposures() > 0) {
var preScanFlats = getCalibrationModel(trackDocument.getScannable(), posBeforeMainScan, getFlatCalibration().getNumberExposures());
multiScanModel.addModel(preScanFlats);
addPosition(flatPos, interpolationPositions::add);
imageTypes.add(ImageType.FLAT);
}
// Dark Before Acquisition
if (getDarkCalibration().isBeforeAcquisition() && getDarkCalibration().getNumberExposures() > 0) {
var preScanDarks = getCalibrationModel(trackDocument.getScannable(), posBeforeMainScan, getDarkCalibration().getNumberExposures());
multiScanModel.addModel(preScanDarks);
addPosition(darkPos, interpolationPositions::add);
imageTypes.add(ImageType.DARK);
}
// Acquisition
addPosition(createStartPosition(), interpolationPositions::add);
multiScanModel.addModel(acquisitionTemplate.getIScanPointGeneratorModel());
imageTypes.add(ImageType.NORMAL);
// Flat After Acquisition
if (getFlatCalibration().isAfterAcquisition() && getFlatCalibration().getNumberExposures() > 0) {
var postScanFlats = getCalibrationModel(trackDocument.getScannable(), posAfterMainScan, getFlatCalibration().getNumberExposures());
multiScanModel.addModel(postScanFlats);
addPosition(flatPos, interpolationPositions::add);
imageTypes.add(ImageType.FLAT);
}
// Dark After Acquisition
if (getDarkCalibration().isAfterAcquisition() && getDarkCalibration().getNumberExposures() > 0) {
var posScanDarks = getCalibrationModel(trackDocument.getScannable(), posAfterMainScan, getDarkCalibration().getNumberExposures());
multiScanModel.addModel(posScanDarks);
addPosition(darkPos, interpolationPositions::add);
imageTypes.add(ImageType.DARK);
}
multiScanModel.setContinuous(Optional.ofNullable(getScanpathDocument().getMutators().containsKey(Mutator.CONTINUOUS)).orElse(false));
multiScanModel.setInterpolatedPositions(interpolationPositions);
multiScanModel.setImageTypes(imageTypes);
return new CompoundModel(multiScanModel);
}
Aggregations