OD_Reader parameter questions

I want to start the OD reader through a class.

MyClass(BackgroundJobContrib):
    def __init__(self)
        self.od_reader = ODReader(channel_angle_map, interval)

I’m not sure what the value of interval should be. When I normally start my OD reader, I do it through the pioreactor.local/pioreactors UI, and I have never had to input any of the parameters myself.

I think that I should probably set channel_angel_map = { ‘1’ : ‘90’} because I am currently only using a single photodiode at 90 degrees (plus reference, but I don’t think that is relevant here). I don’t know what to put for interval. This says that " Initializing this class will start reading in the background, if interval is not None."

What is the default value of interval if I were to start it through the web UI? I tried looking in the .yaml but didn’t see any values for it there either. I don’t want to do anything special with my OD reader (yet…), I just want to start this job through another job.

If I had to guess, I would say interval=5 because samples_per_second=0.2 in config.ini, but I don’t really know how the OD reader job is finding that value.

This is a good question. Most parameters, like interval, are from the config.ini file. However, we encoded it as samples_per_second (the inverse of interval). In the od_reading.py file, we can see that we pass in there parameter directly from the config file, inverted. When you start from the UI, you are actually running this start_od_reading function, which is just a wrapper around ODReader.

Using start_od_reading might work well for your application, too. It wraps up ADC reader, and other utility classes that produce a good OD signal. Note that this function returns an ODReader class, too.

Thanks. So then, can I just instantiate my OD reader object via:

from pioreactor.background_jobs.od_reading import ODReader
MyClass(BackgroundJobContrib):
    def __init__(self)
        self.od_reader = ODReader()

and then this will pull the values from the config? (currently 1=REF, 2=90, and samples_per_second=0.2)

If I wanted to try your way, would that look like this?

from pioreactor.background_jobs.od_reading import ODReader
MyClass(BackgroundJobContrib):
    def __init__(self)
        self.od_reader = ODReader.start_od_reading()

and then this will pull the values from the config? (currently 1=REF, 2=90, and samples_per_second=0.2)

No, you’ll need to provide the values. ODReader is a “lower-level” API. If you use the second snippet, with start_od_reading, this will provide more default values, though you still need to provide “90” and “REF”:

Note: there was an import problem that i’ve fixed below, too.

from pioreactor.background_jobs.od_reading import start_od_reading
MyClass(BackgroundJobContrib):
    def __init__(self)
        self.od_reader = start_od_reading("90", "REF")

Ahhh, I see. Thanks for catching that. I had thought start_od_reading was a method of ODReader, but looking at it again I realize I misread its indentation.

I’m looking at the parameters for start_od_reading and these are the first two:

    od_angle_channel1: Optional[pt.PdAngleOrREF] = None,
    od_angle_channel2: Optional[pt.PdAngleOrREF] = None,

Does it matter which od_angle_channel is assigned to REF and which is assigned to “90”? In my config (below), I have channel 1 set to REF and channel 2 set to “90”.

[od_config.photodiode_channel]
1=REF
2=90

Should it be start_od_reading("90", "REF") or start_od_reading("REF", "90")?

start_od_reading("REF", "90") is correct for your config. I’ll make some documentation around this