CSR Output service

Revision as of 09:53, 13 May 2013 by WikiSysop (Talk | contribs) (store a value for display in the Output pool)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

At present, the model engin that is running CSR does not have a fully elaborated output mechanism, since the requirements of such a service have not yet been defined. Instead, a simple mechanism is available to transport values to be shown in the output from the units where they are calculated to a central output formating unit.

store a value for display in the Output pool

The intent is to burden the model classes as little as possible with the mechanics of the output system. However, it is inevitable that certain variables are marked for output at the place in code where they exist. Thus for local variables this must be within the procedure where they are used.

Marking a variable for output does not mean it will be shown in output; just that it is available to output.

marking a variable
def calculateRates(self, NewTime):
  super(Patch, self).calculateRates(NewTime)
  rabsorbed = 0.
  for plant in self.plants:
      rabsorbed += plant.AR.can[PAR] + plant.AR.can[NIR]
  Output.set(self, "absorbed", rabsorbed)

In the last line, the variable rabsorbed is stored in the output pool by the lable "absorbed". Note that selc is stored too so multiple objects can store a variable by the same name, but in the present implementation of Output this parameter is still ignored, however, a warning is issued when different objects used the same variable tag.

using variables stored in the Output pool

Output does not account for changing values due to progress of Time. Values in the ouptput pool stay there until overwritten by a new value.

Thus, with this mechanism, the output processor must collect the values every integratin step. A place to do this is in the Runner object:

retrieving output
def doBeforeIntegration(self, system, newTime):
  value = Output.get("rad_term")
  self._plotter.addValue("rad_term", value)
def doEndRun(self, system):
  self._plotter.plot(1, ["absorbed"], unit = "W/m2", positive = True)