Source code for pycif.plugins.models.template.ini_mapper

import datetime
import numpy as np
from logging import info

from ....utils.classes.setup import Setup
from ....utils.classes.domains import Domain

from ....utils.check.errclass import PluginError


[docs] def ini_mapper(model, general_mapper={}, backup_comps={}, transforms_order=[], ref_transform="", transform_name="", all_transforms=None, **kwargs): if model.empty_mapper: mapper = {"inputs": {}, "outputs": {}} if model.only_outputs: output_intervals = { ddi: np.append( model.tstep_dates[ddi][:-1, np.newaxis], model.tstep_dates[ddi][1:, np.newaxis], axis=1) for ddi in model.tstep_dates} mapper = { "inputs": {}, "outputs": { ("concs", spec): { "force_loadout": True, "input_dates": output_intervals, "domain": model.domain, "sampled": True, "sparse_data": False, } for spec in model.chemistry.acspecies.attributes }} # Update the transform so it can start the pipeline getattr(all_transforms, transform_name).start_pipe = True if model.include_fluxes: input_intervals = { ddi: np.append( model.input_dates[ddi][:, np.newaxis], model.input_dates[ddi][:, np.newaxis] + datetime.timedelta(hours=1), axis=1) for ddi in model.input_dates} mapper["inputs"] = { ("flux", spec): { "input_dates": input_intervals, "force_dump": True, "sparse_data": False } for spec in model.chemistry.emis_species.attributes } # Update the transform so it can start the pipeline getattr(all_transforms, transform_name).start_pipe = True info("The model was initialized with the following mapper:") info(mapper) return mapper