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

import copy


[docs]def perturb_model(self, nsamples, transf_mapper): if hasattr(self, "reactions"): raise Exception("There are reactions in your chemical scheme. " "This is not yet implemented!!") # Perturb active species in the chemical scheme list_acspecies = copy.deepcopy(self.chemistry.acspecies.attributes[:]) for spec in list_acspecies: for i in range(nsamples): spec_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 output species in the chemical scheme list_outspecies = copy.deepcopy(self.chemistry.outspecies.attributes[:]) for spec in list_outspecies: for i in range(nsamples): spec_sample = "{}{:03d}".format(spec, i) spec_plg = getattr(self.chemistry.outspecies, spec) setattr(self.chemistry.outspecies, spec_sample, spec_plg) self.chemistry.outspecies.attributes.append(spec_sample) delattr(self.chemistry.outspecies, spec) self.chemistry.outspecies.attributes.remove(spec) # Perturb emis species in the chemical scheme list_emispecies = copy.deepcopy(self.chemistry.emis_species.attributes[:]) for spec in list_emispecies: for i in range(nsamples): spec_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) # Perturb bio species in the chemical scheme list_biospecies = copy.deepcopy(self.chemistry.bio_species.attributes[:]) for spec in list_biospecies: for i in range(nsamples): spec_sample = "{}{:03d}".format(spec, i) spec_plg = getattr(self.chemistry.bio_species, spec) setattr(self.chemistry.bio_species, spec_sample, spec_plg) self.chemistry.bio_species.attributes.append(spec_sample) delattr(self.chemistry.bio_species, spec) self.chemistry.bio_species.attributes.remove(spec) # Dump updated chemical scheme as text files for CHIMERE executable self.chemistry.create_chemicalscheme()