Search in sources :

Example 1 with TaskInterface

use of org.cirdles.squid.tasks.TaskInterface in project Squid by CIRDLES.

the class SquidProject method makeTaskFromSquid25Task.

public TaskInterface makeTaskFromSquid25Task(TaskSquid25 taskSquid25) throws SquidException {
    TaskInterface taskFromSquid25 = new Task(taskSquid25.getTaskName());
    taskFromSquid25.setTaskType(taskSquid25.getTaskType());
    taskFromSquid25.setDescription(taskSquid25.getTaskDescription());
    taskFromSquid25.setProvenance(taskSquid25.getSquidTaskFileName());
    taskFromSquid25.setAuthorName(taskSquid25.getAuthorName());
    taskFromSquid25.setLabName(taskSquid25.getLabName());
    taskFromSquid25.setNominalMasses(taskSquid25.getNominalMasses());
    taskFromSquid25.setRatioNames(taskSquid25.getRatioNames());
    taskFromSquid25.setFilterForRefMatSpotNames(filterForRefMatSpotNames);
    taskFromSquid25.setFilterForConcRefMatSpotNames(filterForConcRefMatSpotNames);
    taskFromSquid25.setFiltersForUnknownNames(filtersForUnknownNames);
    taskFromSquid25.setParentNuclide(taskSquid25.getParentNuclide());
    taskFromSquid25.setDirectAltPD(taskSquid25.isDirectAltPD());
    taskFromSquid25.setExtPErrTh(extPErrTh);
    taskFromSquid25.setExtPErrU(extPErrU);
    taskFromSquid25.setSelectedIndexIsotope(selectedIndexIsotope);
    taskFromSquid25.setSquidAllowsAutoExclusionOfSpots(squidAllowsAutoExclusionOfSpots);
    taskFromSquid25.setUseSBM(useSBM);
    taskFromSquid25.setUserLinFits(userLinFits);
    taskFromSquid25.setReferenceMaterialModel(referenceMaterialModel);
    taskFromSquid25.setConcentrationReferenceMaterialModel(concentrationReferenceMaterialModel);
    // determine index of background mass as specified in task
    for (int i = 0; i < taskSquid25.getNominalMasses().size(); i++) {
        if (taskSquid25.getNominalMasses().get(i).compareToIgnoreCase(taskSquid25.getBackgroundMass()) == 0) {
            taskFromSquid25.setIndexOfTaskBackgroundMass(i);
            taskFromSquid25.setIndexOfBackgroundSpecies(i);
            break;
        }
    }
    List<TaskSquid25Equation> task25Equations = taskSquid25.getTask25Equations();
    for (TaskSquid25Equation task25Eqn : task25Equations) {
        ((Task) taskFromSquid25).makeCustomExpression(task25Eqn);
    }
    List<String> constantNames = taskSquid25.getConstantNames();
    List<String> constantValues = taskSquid25.getConstantValues();
    for (int i = 0; i < constantNames.size(); i++) {
        // March 2019 moved imported constants to be custom expressions
        ExpressionSpecInterface constantSpec = specifyConstantExpression(constantNames.get(i), constantValues.get(i), "Custom constant imported from Squid2 task " + taskSquid25.getTaskName() + " .");
        ((Task) taskFromSquid25).makeCustomExpression(constantSpec);
    }
    taskFromSquid25.setSpecialSquidFourExpressionsMap(taskSquid25.getSpecialSquidFourExpressionsMap());
    return taskFromSquid25;
}
Also used : Task(org.cirdles.squid.tasks.Task) TaskInterface(org.cirdles.squid.tasks.TaskInterface) TaskSquid25Equation(org.cirdles.squid.tasks.squidTask25.TaskSquid25Equation) ExpressionSpecInterface(org.cirdles.squid.tasks.expressions.ExpressionSpecInterface)

Example 2 with TaskInterface

use of org.cirdles.squid.tasks.TaskInterface in project Squid by CIRDLES.

the class SquidUIController method synchronizeTaskLabDataAndSquidVersion.

private void synchronizeTaskLabDataAndSquidVersion() throws SquidException {
    if (squidProject != null && squidProject.getTask() != null) {
        TaskInterface task = squidProject.getTask();
        SquidProject.setProjectChanged(((Task) task).synchronizeTaskVersion());
        (((Task) task).verifySquidLabDataParameters()).forEach(model -> {
            if (model instanceof PhysicalConstantsModel) {
                squidLabData.addPhysicalConstantsModel(model);
                squidLabData.getPhysicalConstantsModels().sort(new ParametersModelComparator());
            } else if (model instanceof CommonPbModel) {
                squidLabData.addcommonPbModel(model);
                squidLabData.getCommonPbModels().sort(new ParametersModelComparator());
            } else if (model instanceof ReferenceMaterialModel) {
                squidLabData.addReferenceMaterial(model);
                squidLabData.getReferenceMaterials().sort(new ParametersModelComparator());
            }
        });
        squidProject.setReferenceMaterialModel(task.getReferenceMaterialModel());
        squidProject.setConcentrationReferenceMaterialModel(task.getConcentrationReferenceMaterialModel());
        if (SquidProject.isProjectChanged()) {
            // dec 2021 for issue #674
            task.setExtPErrU(squidProject.getExtPErrU());
            task.setExtPErrTh(squidProject.getExtPErrTh());
            // next two lines make sure 15-digit rounding is used by reprocessing data
            task.setChanged(true);
            task.setupSquidSessionSpecsAndReduceAndReport(true);
            ((Task) task).initTaskDefaultSquidReportTables(true);
            ProjectFileUtilities.serializeSquidProject(squidProject, projectFileName);
            SquidMessageDialog.showInfoDialog("The project file has been updated for this version of Squid3.\n", primaryStageWindow);
        }
    }
}
Also used : ReferenceMaterialModel(org.cirdles.squid.parameters.parameterModels.referenceMaterialModels.ReferenceMaterialModel) Task(org.cirdles.squid.tasks.Task) PhysicalConstantsModel(org.cirdles.squid.parameters.parameterModels.physicalConstantsModels.PhysicalConstantsModel) TaskInterface(org.cirdles.squid.tasks.TaskInterface) ParametersModelComparator(org.cirdles.squid.parameters.ParametersModelComparator) CommonPbModel(org.cirdles.squid.parameters.parameterModels.commonPbModels.CommonPbModel)

Example 3 with TaskInterface

use of org.cirdles.squid.tasks.TaskInterface in project Squid by CIRDLES.

the class TaskFolderBrowserController method updateCurrentTaskWithThisTaskAction.

@FXML
private void updateCurrentTaskWithThisTaskAction(ActionEvent event) throws SquidException {
    TaskInterface chosenTask = listViewOfTasksInFolder.getSelectionModel().selectedItemProperty().getValue();
    TaskDesign taskEditor = SquidPersistentState.getExistingPersistentState().getTaskDesign();
    if (squidProject.getTask().getTaskType().equals(chosenTask.getTaskType())) {
        // check the mass count
        boolean valid = (squidProject.getTask().getSquidSpeciesModelList().size() == (chosenTask.getNominalMasses().size()));
        if (valid) {
            // due to associating commonPb and Physical Constants with Project, need to update design
            // this issue was overlooked and noticed in issue #655
            chosenTask.setCommonPbModel(squidProject.getCommonPbModel());
            chosenTask.setPhysicalConstantsModel(squidProject.getPhysicalConstantsModel());
            chosenTask.updateTaskDesignFromTask(taskEditor, true);
            try {
                squidProject.createNewTask();
                squidProject.getTask().updateTaskFromTaskDesign(taskEditor, false);
            } catch (SquidException squidException) {
                SquidMessageDialog.showWarningDialog(squidException.getMessage(), primaryStageWindow);
            }
            MenuItem menuItemTaskManager = ((MenuBar) SquidUI.primaryStage.getScene().getRoot().getChildrenUnmodifiable().get(0)).getMenus().get(2).getItems().get(0);
            menuItemTaskManager.fire();
        } else {
            SquidMessageDialog.showInfoDialog("The data file has " + squidProject.getTask().getSquidSpeciesModelList().size() + " masses, but this task has " + chosenTask.getNominalMasses().size() + ".", primaryStageWindow);
        }
    } else {
        SquidMessageDialog.showInfoDialog("The Project is type  " + squidProject.getTask().getTaskType() + ", but this task is type " + chosenTask.getTaskType() + ".", primaryStageWindow);
    }
}
Also used : SquidException(org.cirdles.squid.exceptions.SquidException) TaskDesign(org.cirdles.squid.tasks.taskDesign.TaskDesign) TaskInterface(org.cirdles.squid.tasks.TaskInterface) FXML(javafx.fxml.FXML)

Example 4 with TaskInterface

use of org.cirdles.squid.tasks.TaskInterface in project Squid by CIRDLES.

the class Squid3Ink method setUseLinearRegression.

@Override
public void setUseLinearRegression(boolean doUse) throws SquidException {
    squid3Project.setUserLinFits(doUse);
    SquidProject.setProjectChanged(true);
    TaskInterface task = squid3Project.getTask();
    task.setUserLinFits(doUse);
    task.setChanged(true);
    task.setupSquidSessionSpecsAndReduceAndReport(true);
}
Also used : TaskInterface(org.cirdles.squid.tasks.TaskInterface)

Example 5 with TaskInterface

use of org.cirdles.squid.tasks.TaskInterface in project Squid by CIRDLES.

the class PrawnFileHandlerIT method setUp.

/**
 * @throws java.lang.Exception
 */
// provides to run setup once
@BeforeClass
public static void setUp() throws Exception {
    // april 2022 to preserve tests due to change in issue #698
    CommonLeadSpecsForSpot.DEFAULT_METHOD = CommonLeadSpecsForSpot.METHOD_COMMON_LEAD_MODEL;
    prawnFileHandler = (new SquidProject(GEOCHRON)).getPrawnFileHandler();
    reportsFolder = temporaryFolder.getRoot();
    prawnFileZ6266 = RESOURCE_EXTRACTOR.extractResourceAsFile(PRAWN_FILE_RESOURCE_Z6266);
    CalamariFileUtilities.initSampleParametersModels();
    squidProjectZ6266 = new SquidProject(GEOCHRON);
    prawnFileDataZ6266 = prawnFileHandler.unmarshallPrawnFileXML(prawnFileZ6266.getAbsolutePath(), true);
    squidProjectZ6266.setPrawnFile(prawnFileDataZ6266);
    // March 2019 remove dependency on Squid25 task for testing of built-ins
    SquidProject.setProjectChanged(true);
    TaskInterface task = new Task("test", prawnFileDataZ6266, prawnFileHandler.getReportsEngine());
    task.updateTaskFromTaskDesign(new TaskDesign11Mass(), false);
    squidProjectZ6266.setTask(task);
    squidProjectZ6266.setDelimiterForUnknownNames("-");
    squidProjectZ6266.getTask().setFilterForRefMatSpotNames("6266");
    squidProjectZ6266.getTask().setFilterForConcRefMatSpotNames("6266");
    squidProjectZ6266.getTask().setTaskType(Squid3Constants.TaskTypeEnum.GEOCHRON);
    squidProjectZ6266.getTask().setUseSBM(true);
    squidProjectZ6266.setUseSBM(true);
    squidProjectZ6266.getTask().setUserLinFits(false);
    squidProjectZ6266.setUserLinFits(false);
    squidProjectZ6266.getTask().setSquidAllowsAutoExclusionOfSpots(true);
    squidProjectZ6266.setSquidAllowsAutoExclusionOfSpots(true);
    squidProjectZ6266.getTask().setExtPErrU(0.75);
    squidProjectZ6266.setExtPErrU(0.75);
    squidProjectZ6266.getTask().setExtPErrTh(0.75);
    squidProjectZ6266.setExtPErrTh(0.75);
    squidProjectZ6266.getTask().setPhysicalConstantsModel(PhysicalConstantsModel.getDefaultModel(SQUID2_DEFAULT_PHYSICAL_CONSTANTS_MODEL_V1, "1.0"));
    squidProjectZ6266.setPhysicalConstantsModel(PhysicalConstantsModel.getDefaultModel(SQUID2_DEFAULT_PHYSICAL_CONSTANTS_MODEL_V1, "1.0"));
    squidProjectZ6266.getTask().setCommonPbModel(CommonPbModel.getDefaultModel("Stacey-Kramers@559.0Ma (z6266)", "1.0"));
    squidProjectZ6266.setCommonPbModel(CommonPbModel.getDefaultModel("Stacey-Kramers@559.0Ma (z6266)", "1.0"));
    // modified sept 202 to accommodate old tests and new models
    ResourceExtractor extractor = new ResourceExtractor(ReferenceMaterialModel.class);
    File testingModelFile = extractor.extractResourceAsFile("GA Accepted BR266 v.1.0.xml");
    ReferenceMaterialModel testingModel = new ReferenceMaterialModel();
    testingModel = (ReferenceMaterialModel) testingModel.readXMLObject(testingModelFile.getAbsolutePath(), false);
    squidProjectZ6266.getTask().setReferenceMaterialModel(testingModel);
    squidProjectZ6266.setReferenceMaterialModel(testingModel);
    squidProjectZ6266.getTask().setConcentrationReferenceMaterialModel(testingModel);
    squidProjectZ6266.setConcentrationReferenceMaterialModel(testingModel);
    squidProjectZ6266.setSelectedIndexIsotope(Squid3Constants.IndexIsoptopesEnum.PB_204);
    squidProjectZ6266.setSelectedIndexIsotope(Squid3Constants.IndexIsoptopesEnum.PB_204);
    // force defaults for testing of builtins
    squidProjectZ6266.getTask().getSpecialSquidFourExpressionsMap().put(PARENT_ELEMENT_CONC_CONST, "[\"238/195.8\"]/[\"254/238\"]^0.66");
    squidProjectZ6266.getTask().getSpecialSquidFourExpressionsMap().put(UNCOR206PB238U_CALIB_CONST, UNCOR206PB238U_CALIB_CONST_DEFAULT_EXPRESSION);
    squidProjectZ6266.getTask().getSpecialSquidFourExpressionsMap().put(UNCOR208PB232TH_CALIB_CONST, UNCOR208PB232TH_CALIB_CONST_DEFAULT_EXPRESSION);
    squidProjectZ6266.getTask().getSpecialSquidFourExpressionsMap().put(TH_U_EXP_DEFAULT, TH_U_EXP_DEFAULT_EXPRESSION);
    squidProjectZ6266.getTask().setSquidAllowsAutoExclusionOfSpots(true);
    squidProjectZ6266.getTask().applyTaskIsotopeLabelsToMassStations();
}
Also used : ReferenceMaterialModel(org.cirdles.squid.parameters.parameterModels.referenceMaterialModels.ReferenceMaterialModel) Task(org.cirdles.squid.tasks.Task) TaskInterface(org.cirdles.squid.tasks.TaskInterface) SquidProject(org.cirdles.squid.projects.SquidProject) TaskDesign11Mass(org.cirdles.squid.tasks.taskDesign.TaskDesign11Mass) File(java.io.File) ResourceExtractor(org.cirdles.commons.util.ResourceExtractor)

Aggregations

TaskInterface (org.cirdles.squid.tasks.TaskInterface)17 Task (org.cirdles.squid.tasks.Task)7 SquidException (org.cirdles.squid.exceptions.SquidException)5 File (java.io.File)4 IOException (java.io.IOException)4 ReferenceMaterialModel (org.cirdles.squid.parameters.parameterModels.referenceMaterialModels.ReferenceMaterialModel)4 CommonPbModel (org.cirdles.squid.parameters.parameterModels.commonPbModels.CommonPbModel)3 PhysicalConstantsModel (org.cirdles.squid.parameters.parameterModels.physicalConstantsModels.PhysicalConstantsModel)3 Squid3ProjectParametersAPI (org.cirdles.squid.projects.Squid3ProjectParametersAPI)3 SAXException (org.xml.sax.SAXException)3 Path (java.nio.file.Path)2 FXML (javafx.fxml.FXML)2 JAXBException (javax.xml.bind.JAXBException)2 ResourceExtractor (org.cirdles.commons.util.ResourceExtractor)2 ParametersModelComparator (org.cirdles.squid.parameters.ParametersModelComparator)2 SquidProject (org.cirdles.squid.projects.SquidProject)2 ZipUtility.extractZippedFile (org.cirdles.squid.utilities.fileUtilities.ZipUtility.extractZippedFile)2 BufferedWriter (java.io.BufferedWriter)1 FilenameFilter (java.io.FilenameFilter)1 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)1