Ejemplo n.º 1
0
    def get_tasks(config, prior_tasks, base_output_dir, stage_number, prefix,
                  global_config):
        tasks = []

        all_deps = Task.match_tasks_of_type(None, prior_tasks, DataPrep,
                                            SNANASimulation)
        for fit_name in config.get("LCFIT", []):
            num_matches = 0
            fit_config = config["LCFIT"][fit_name]
            mask = fit_config.get("MASK", "")

            sim_tasks = Task.match_tasks_of_type(mask, prior_tasks, DataPrep,
                                                 SNANASimulation)
            for sim in sim_tasks:
                num_matches += 1
                fit_output_dir = f"{base_output_dir}/{stage_number}_LCFIT/{fit_name}_{sim.name}"
                f = SNANALightCurveFit(f"{fit_name}_{sim.name}",
                                       fit_output_dir, sim, fit_config,
                                       global_config)
                Task.logger.info(
                    f"Creating fitting task {fit_name} with {f.num_jobs} jobs, for simulation {sim.name}"
                )
                tasks.append(f)
            if num_matches == 0:
                Task.fail_config(
                    f"LCFIT task {fit_name} with mask '{mask}' matched no sim_names: {[sim.name for sim in all_deps]}"
                )
        return tasks
Ejemplo n.º 2
0
    def get_tasks(configs, prior_tasks, base_output_dir, stage_number, prefix,
                  global_config):
        def _get_analyse_dir(base_output_dir, stage_number, name):
            return f"{base_output_dir}/{stage_number}_ANALYSE/{name}"

        tasks = []
        key = "ANALYSE"
        for cname in configs.get(key, []):
            config = configs[key].get(cname, {})
            if config is None:
                config = {}
            options = config.get("OPTS", {})

            mask_cosmofit = config.get("MASK_COSMOFIT")
            mask_biascor = config.get("MASK_BIASCOR")
            if config.get("HISTOGRAM") is not None:
                Task.fail_config(
                    "Sorry to do this, but please change HISTOGRAM into MASK_LCFIT to bring it into line with others."
                )
            mask_lcfit = config.get("MASK_LCFIT")
            # TODO: Add aggregation to compile all the plots here

            deps_cosmofit = Task.match_tasks_of_type(mask_cosmofit,
                                                     prior_tasks,
                                                     CosmoFit,
                                                     match_none=False,
                                                     allowed_failure=True)
            Task.logger.debug(f"deps_cosmofit: {deps_cosmofit}")
            deps_biascor = Task.match_tasks_of_type(mask_biascor,
                                                    prior_tasks,
                                                    BiasCor,
                                                    match_none=False)
            Task.logger.debug(f"deps_biascor: {deps_biascor}")
            deps_lcfit = Task.match_tasks_of_type(mask_lcfit,
                                                  prior_tasks,
                                                  SNANALightCurveFit,
                                                  match_none=False)
            Task.logger.debug(f"deps_lcfit: {deps_lcfit}")

            deps = deps_cosmofit + deps_biascor + deps_lcfit
            if len(deps) == 0:
                Task.fail_config(f"Analyse task {cname} has no dependencies!")

            a = AnalyseChains(
                cname, _get_analyse_dir(base_output_dir, stage_number, cname),
                config, options, deps)
            Task.logger.info(
                f"Creating Analyse task {cname} for {[c.name for c in deps]} with {a.num_jobs} jobs"
            )
            tasks.append(a)

        return tasks