Source code for pycif.plugins.models.iconart.io.inputs.tracers

[docs] def change_tracers_xml_fluxes(self, emspec, is_ensemble=False): """Update the ICON-ART ``tracers.xml`` entry for one emitted species. Sets OEM temporal-scaling options (``oem_tscale``) for the reference emitted tracer and, in ensemble mode, for each perturbed sample. Args: self: ICON-ART model plugin instance. emspec (str): emitted species name (may include ``__sample#NNN``). is_ensemble (bool): whether running in ensemble mode. """ dtr = self.chemistry.dict_tracers acspecs = self.chemistry.mapping_emi2active[emspec] # Add information for the emitted reference tracer emspec_ref = emspec.split("__sample#")[0] dtr_es = dtr[emspec_ref] dtr_es['oem_tscale'] = '3' if self.use_hourofyear else '1' # Add information for the posterior emitted reference tracer if is_ensemble: emspec_ref_post = emspec_ref + '_POST' dtr_es_post = dtr[emspec_ref_post] dtr_es_post['oem_tscale'] = '3' if self.use_hourofyear else '1' # Each emitted species can be associated with multiple active species for acspec in acspecs: acspec_ref = acspec.split("__sample#")[0] dtr_s = dtr[acspec] dtr_s_ref = dtr[acspec_ref] dtr_s_ref['oem_tscale'] = '3' if self.use_hourofyear else '1' # Add ensemble attribute if is_ensemble: sample_id = acspec.split("__sample#")[1] new_sample_id = f"{int(sample_id) + 1:03d}" dtr_s['id'] = acspec_ref + '-' + new_sample_id dtr_s['oem_type'] = "ens" # For testing, switch to 0 if self.test_mode: dtr_s['iconv'] = '0' dtr_s['iturb'] = '0' return
[docs] def change_tracers_xml_inicond(self, spec, is_ensemble=False, is_perturbed_comp=False): """Update the ICON-ART ``tracers.xml`` entry for initial-condition tracer. Configures the tracer entry so ICON-ART reads initial conditions from the CIF-prepared ``meteo_inicond.nc`` file. Args: self: ICON-ART model plugin instance. spec (str): active species name. is_ensemble (bool): whether running in ensemble mode. is_perturbed_comp (bool): whether this is a perturbed ensemble member. """ dtr = self.chemistry.dict_tracers dtr_s = dtr[spec] spec_ref = spec.split("__sample#")[0] init_name = spec if is_perturbed_comp else spec_ref # Update the background tracer spec_bg = spec_ref + '_BG' dtr_bg = dtr[spec_bg] dtr_bg['init_mode'] = '1' if 'init_name' not in dtr_bg: dtr_bg['init_name'] = spec_bg # Update the posterior background tracer if is_ensemble: spec_bg_post = spec_ref + '_BG_POST' if spec_bg_post in dtr: dtr_bg_post = dtr[spec_bg_post] dtr_bg_post['init_mode'] = '1' if 'init_name' not in dtr_bg_post: dtr_bg_post['init_name'] = spec_bg_post # Update the current tracer dtr_s['init_mode'] = '1' dtr_s['init_name'] = init_name # For testing, switch to 0 if self.test_mode: dtr_s['init_mode'] = '0' return
[docs] def change_tracers_xml_lbc(self, spec, is_ensemble=False): """Update the ICON-ART ``tracers.xml`` entry for lateral boundary conditions. Configures the tracer entry to read LBC from the CIF-prepared ``ifs_YYYYMMDDHH_lbc.nc`` files. Args: self: ICON-ART model plugin instance. spec (str): active species name. is_ensemble (bool): whether running in ensemble mode. """ dtr = self.chemistry.dict_tracers dtr_s = dtr[spec] spec_ref = spec.split("__sample#")[0] # Update the background tracer spec_bg = spec_ref + '_BG' dtr_bg = dtr[spec_bg] dtr_bg['latbc'] = 'file' if is_ensemble: # Update the posterior background tracer spec_bg_post = spec_ref + '_BG_POST' if spec_bg_post in dtr: dtr_bg_post = dtr[spec_bg_post] dtr_bg_post['latbc'] = 'file' # Connect the background tracer to the sample... dtr_bg['oem_type'] = 'bg' dtr_bg_post['oem_type'] = 'bg' dtr_s['oem_bg_ens'] = spec_bg # ... or set a different lbc for each tracer else: dtr_s['latbc'] = 'file' return