We will now analyze the output of the command:
./scripts/run_fwd.py --emis -s 2000,1,1 -e 2000,1,2 rc/nam1x1-dummy_tr.rc > run_output
Since we have the --emis option, the run script will start creating emissions. It first read the name of the emission class from the .rc file.
emis_module = r.rcf.get('my.emission.class')
Now the key my.emission.class is located in __include/dummy_tr_emission_parameters.rc:
my.emission.class : dummy_Emissions
Now what does r.SetupEmissions(Emission) do? This is a crucial part of the setup. First remember that we extended the python search part. So the tracer emission of dummy_tr is constructed by the routine Emissions.py located in proj/tracer/dummy_tr/py. If you look into the header of Emission.py you will see that is loads general emission routines (the base functionality):
1 2 3 4 5 6 7 8 9 | #!/usr/bin/env python # -*- coding: utf-8 -*- import sys sys.dont_write_bytecode = True import re, os.path, shutil, tempfile, hashlib, rc .... from Emissions_base import Emissions |
The Emissions_base functionality is found in the base code branch, in my case in
/home/krol/HG/tm5-code-0/base/branches/var4d/py/Emissions_base.py
Now we also can trace where the RunTM5 object is coming from. In proj/tracer/dummy_tr/py we will find the file RunTM5.py that includes the functionality from RunTM5_base.py (and nothing else in this case!):
1 2 3 4 5 6 7 | #!/usr/bin/env python # -*- coding: utf-8 -*- import sys sys.dont_write_bytecode = True from RunTM5_base import RunTM5 |
So, finally we can trace what the r.SetupEmissions(Emission) is doing:
1 2 3 4 5 6 7 8 9 | #!/usr/bin/env python # -*- coding: utf-8 -*- def SetupEmissions(self, emis_class, read_optim_emis=False, optim_emis_filename=None): .... # First, process the emissions and write the emissions file StartTuple = (self.StartTime.year, self.StartTime.month, self.StartTime.day, self.StartTime.hour, self.StartTime.minute) EndTuple = (self.EndTime.year, self.EndTime.month, self.EndTime.day, self.EndTime.hour, self.EndTime.minute) em = emis_class(StartTuple, EndTuple) self.Emission = em(read_optim_emis, optim_emis_filename) # Write emissions and keep them in memory |
The em = emis_class(StartTuple,EndTuple) constructs an emission object by calling emis_class (class dummy_Emissions in this case) by executing the initialization routine of that module:
1 2 3 4 5 6 7 | #!/usr/bin/env python # -*- coding: utf-8 -*- def __init__(self, start_time, end_time): Emissions.__init__(self, start_time, end_time) # Load a land sea mask topo_file = self.rcf.get('dummy_tr.topo_file') .... |
Now, some homework. Find out what the statement self.Emission = em(read_optim_emis, optim_emis_filename) is doing.
[Answer to Homework]