Skip to content

TempFit does extrapolation on time and temperature data to estimate when your meat will reach your desired cooking temperature.

License

Notifications You must be signed in to change notification settings

DevinBerchtold/TempFit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TempFit

TempFit does extrapolation on time and temperature data to estimate when your meat will reach your desired cooking temperature.

  • Automatically estimate cooking time without fancy thermometers or apps.
  • Import spreadsheet or manually enter temperature data.
  • Understand more about the accuracy and reliability of the estimation.

Animation of temperature data and prediction

Illustrates the estimate() function with measured data in blue and the approximation functions in red, orange, and green (See more)


Installation

  1. Download the project from GitHub

  2. Install the required Python libraries:

    If you install SciPy, that should be all you need (scipy.org/install):

    python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
    

Usage

  1. Start cooking and save your temperature data with an electronic thermometer or using manual.py
  2. Import thermometer.py and create a Thermometer object from your CSV
  3. Run Thermometer.estimate() to predict future temperatures. (See test.ipynb for examples)

Temperature Data

Thermometer requires a list of temperatures and the times they were recorded. Some thermometers have the ability to export a spreadsheet or CSV file. If that's not available, you can manually measure and enter data points into a spreadsheet with the help of manual.py.

Depending on what you're cooking and how fast the temperature changes, you will probably need about an hour of data to get a good estimate.


Estimation Accuracy

Model Function

estimate() works by fitting a model function to measured temperature data and extrapolating to predict future values. A 3rd order polynomial usually fits well, but it's improved by adding an x⁻¹ term to the objective function:

def tx(x, a, b, c, d, e):
    return a*x**3+b*x**2+c*x+d*(1+x)**-1+e

The improvements can be easily seen when we plot the ETA at many points throughout the cook. The improved function is closer to correct eta (horizontal line) on average:

Plot of estimations of different functions at different times

Constraints

The result is improved by adding constraints to the fitting function. Some improvement can be obtained by constraining the value and slope of the model function to be what they were at the last measured point (y[-1]=f(x[-1]) and y'[-1]=f'(x[-1])). This is logical because the current temperature and rate of change of temperature will have the biggest effect on future values.

Plot of estimations of different functions at different times

The third constraint is designed specifically for barbecue. It accounts for the 'barbecue stall', a common observation that the temperature increase usually slows around 150-160 °F and speeds up after. This phenomenon represents an inflection point in the temperature vs time graph so it can be modeled by constraining the second derivative to be zero around 155 (f"(x)=0 when f(x)=155). A rough guess of 155 °F shows a big improvement in estimation, but this value can probably be further tuned.


Files

thermometer.py

Defines the Thermometer class which contains time and temperature data from an imported CSV file. Has the estimate() member function which predicts the time a Thermometer will reach a given temperature.

main.py

Find CSV files with today's date and import the most recent one. Do some common estimations quickly. This is the quickest way to import temperatures and estimate quickly white cooking.

manual.py

Manually enter temperature values for extrapolation. They will be automatically timestamped and saved in a CSV file for quick calculations while cooking.

test.ipynb

Contains demonstrations and analysis of different uses of the Thermometer class and estimate() function.


Example Cooks

Pork 🐷

Boneless pork shoulder with probe inserted into the center, estimated almost 2 hours before done time.

Pork temperature data and prediction

Turkey 🐔

Spatchcocked turkey with probe inserted into the breast, estimated about 1 hour before done time.

Turkey temperature data and prediction

Note: The FDA recommends poultry be cooked to at least 165° internal temperature, but it will probably be dry. See this article by J. Kenji López-Alt for more information.


Todo

  • Basic estimation
  • Improve fit function
    • Constrain curve_fit so f(x) and f'(x) have correct value at last sample
    • Detect and remove anomalies in input data
    • Use ambient temperature in calculations
  • More options for inputting temperature data (realtime mode)

Credits

Temperature data gathered with an Inkbird IBBQ-4T


License

This project is released under the MIT license:

MIT License

About

TempFit does extrapolation on time and temperature data to estimate when your meat will reach your desired cooking temperature.

Topics

Resources

License

Stars

Watchers

Forks