Max Temperatures

We have a number of temperatures mesured at various times for a set of ovens that belong to an industrial process. For example:


>>> ovenL = ['fNK021', 'fMM042', 'fMF023', 'fMM004', 'fLP085']

>>> tempL = [
... ('01:15:00', [30.1, 31.5, 31.9, 28.0, 31.0]),
... ('02:30:00', [30.0, 32.5, 30.0, 38.0, 32.5]),
... ('03:45:00', [29.1, 38.5, 29.9, 25.5, 34.5]),
... ('04:30:00', [28.1, 37.5, 31.0, 31.5, 38.2]),
... ('05:00:00', [27.5, 36.5, 32.1, 29.5, 38.2])
... ]

where we have:

  • ovenL is a list of oven identifiers (str)

  • tempL is a list of tuple each with the measures taken at a specific time. The tuple has two components: the first is a str with the time of measure, and the second is a list with the temperature measures taken at that time in the same order of the ovens in ovenL.

You are required to implement the following functions in the module tmax.py (file tmax.py):


Maximum for each Time

The first function is

tmax_time_oven(ovenL, tempL)

such that

given ovenL and tempL as described above,

returns a list where, for each time of measure, it includes the maximum temperature of all the ovens. Specifically, for each time of mesure of tempL, and in the same order, this list must include a tuple with three components: the time (str), the max temperature (float) of all the temperatures taken at that time for the different ovens, and the oven identifier (str) of that max temperature. In case that there is more than one oven with the max temperature, the first one is taken.

For example, given the input lists above:


>>> tmt = tmax_time_oven(ovenL, tempL)
>>> tmt_corr = [
... ('01:15:00', 31.9, 'fMF023'),
... ('02:30:00', 38.0, 'fMM004'),
... ('03:45:00', 38.5, 'fMM042'),
... ('04:30:00', 38.2, 'fLP085'),
... ('05:00:00', 38.2, 'fLP085'),
... ]

Doctests are available at més tests al fitxer tmax_time_oven-test.txt.


Maximum for each Oven

tmax_oven(ovenL, tempL)

such that

given ovenL and tempL as described above,

returns a list where, for each oven, it includes the maximum temperature of all times of measure. Specificly, for each oven ovenL, and in the same order, this list must include a tuple with two components: the oven id (str), and the max temperature (float). In case that there is no temperatrue measure for that oven the value will be 0.0.

For example, given the input lists above:


>>> tmo = tmax_oven(ovenL, tempL)
>>> tmo_corr = [
... ('fNK021', 30.1),
... ('fMM042', 38.5),
... ('fMF023', 32.1),
... ('fMM004', 38.0),
... ('fLP085', 38.2),
... ]
>>> if tmo == tmo_corr:
...     True
... else:
...     print(tmo)
...     print(tmo_corr)
True

Doctests are available at més tests al fitxer tmax_oven-test.txt.