Projects‎ > ‎

Project 9: Data Calibration

You can solve this project using either python or PowerShell - your choice:
  • You must implement the calibration calculation in a function (which takes two arguments, the data type and the value, and returns the calibrated value).
    • For PowerShell you should use chapters 5, 6, and 9 in the "Windows PowerShell Cookbook" to figure out to pieces you need for your script.
  • In python you must load the function from a separate file using the "import" statement.
Your script will process a data file with sensor readings.  (For the IT folks, a different example might be a list of IP networks to be processed into firewall rules. For this project, lets go with the sensor data.) The content of the file looks like this:
A copy of the data file is attached so you can download it. Each line starts with a one-character "data type", followed by a comma, then the "data value".

The premise here is that the sensor readings need to be calibrated, the details are at the end of the project description.
Your script will:
  • Read the file one line at a time.  You can hard-code the name of the file, do not hard-code the path (too hard for me to test). Place the file into the working directory. For each line:
    • Apply the correct calibration
      • You must use a function to implement the calibration
      • You should use a list and/or dictionary to hold the calibration parameters for the different data types
    • Print the original and the calibrated value
    • Ignore data of unknown type
The calibration process:
  • If D is the data value in the file, compute the calibrated data as F = x*D+y
    • If the data type is 'A', x=0.95 and y=.2
    • If the data type is 'X', x=1.01 and y=-.3
    • If the data type is 'R', no calibration is needed (which is equivalent to x=1, y=0)
    • Lines with any other data type should be silently ignored, meaning you do not signal an error, but skip the data and do not produce output for that line

Hans Kruse,
Mar 5, 2018, 10:25 AM