Source code for pycif.plugins.models.wrfchem.perturb_model

import copy
from logging import warn


[docs] def perturb_model(self, nsamples, transf_mapper): warn(nsamples, transf_mapper) # Perturb active species in the chemical scheme list_acspecies = copy.deepcopy(self.chemistry.acspecies.attributes[:]) warn(f"list_acspecies = {list_acspecies}") for spec in list_acspecies: for i in range(nsamples): spec_sample = "{}__sample#{:03d}".format(spec, i) spec_plg = getattr(self.chemistry.acspecies, spec) setattr(self.chemistry.acspecies, spec_sample, spec_plg) self.chemistry.acspecies.attributes.append(spec_sample) delattr(self.chemistry.acspecies, spec) self.chemistry.acspecies.attributes.remove(spec) # Perturb emis species in the chemical scheme list_emispecies = copy.deepcopy(self.chemistry.emis_species.attributes[:]) warn(f"list_emispecies = {list_emispecies}") for spec in list_emispecies: for i in range(nsamples): spec_sample = "{}__sample#{:03d}".format(spec, i) spec_plg = getattr(self.chemistry.emis_species, spec) setattr(self.chemistry.emis_species, spec_sample, spec_plg) self.chemistry.emis_species.attributes.append(spec_sample) delattr(self.chemistry.emis_species, spec) self.chemistry.emis_species.attributes.remove(spec)
# Dump updated chemical scheme # self.chemistry.create_chemicalscheme()