Question: 2 3 . 1 Project 1 : Filtered temperature data Requirements Summary Create a C + + program that first reads the time stamp and

23.1 Project1: Filtered temperature data
Requirements Summary
Create a C++ program that first reads the time stamp and temperature data from the input testfile
(testilexx) and produces a smoothed curve of timestamped temperature data. The result should be
placed in the output files called outputfilexx.
Input Temperature Log Format
The input temperature log format provides a log of recorded times and temperature readings, in which
one reading will be specified per line, using the following format:
HH:MM, TT.T
where
HH:MM represents the time at which the temperature was recorded and is specified in 24 hour format.
The time format used in the file is 00:00 through 23:59.
TT.T represents the recorded temperature reported in Fahrenheit
The time and temperature will be separated by one or more whitespace characters. Each input file
contains several hours worth of temperature readings.
Note: The temperature log may be missing data and may not contain a complete log of temperature
for every minute.
The following is a simple example of the input file format:
Data structure
The following data structure MUST be used for storing data.
struct time_temp {
string Eimestamp;
double temperature;
};
You may modify or add other data in the given struct as you see fit.
Temperature Filtering Part 1: Removing Erroneous Data
Your program should first remove any erroneous temperature readings.
An erroneous temperature reading is defined as a temperature reading that is either more than 5
degrees above or less than 5 degrees below the temperature recorded in the previous minute.
All erroneous temperature readings should be removed.
For example, given the data above, after Filtering Part 1, it should look as follows (observe that 00:15
76.3 is removed since 76.3 is more than 5 degrees of 67.3 at 00:14)
Temperature Filtering Part 2: Simple Low-Pass Filter of Consecutive
Samples
As temperature sensor readings may be noisy, we would like to apply a simple low-pass filter to filter
any sequences of consecutive temperature readings. The following defines a simple low-pass filter
that can be used for these purposes:
filteredoutput (0)=unfilteredinput (0)
filteredoutput (n)=0.9375**filteredoutput (n-1)+0.0625***
unfilteredinput (n)
Note: After removing the erroneous data, your program should apply a low-pass filter to sequences
of temperature readings for consecutive times. The filter should restart if any gaps (in timestamp)
are found within the recorded data.
Filtered Output File Format
The filtered output log should be formatted with one entry per line using the following format:
:MM TT.TTTTTT
where
HH:MM represents the time at which the temperature was recorded and is specified in 24 hour format.
The time format used in the file is 00:00 through 23:59.
TT.TTTTTT represents the filtered temperature value in Fahrenheit as a floating-point value with 6
decimal digits of precision. Each entry should be separate by a single tab character ( t t ).
For example, consider the data given in Filtering Part 1, the output is
00:1067.598517
00:1167.579860
00:1267.556119
00:1367.533861
00:1467.519245
00:1667.200000
00:1767.206250
00:1867.212109
00:1967.236353
00:2067.227831
Explanation:
data at 00:11 is from 0.9375** filteredoutput (n-1)+0.0625* unfilteredinput (n)=0.9375**67.598517+
0.0625*67.3=67.579860
data at 00:16 is an original data since there is a time gap between 00:14 and 00:16. No filter occurs.
data at 00:17 is from 0.9375* filteredoutput (n-1)+0.0625* unfilteredinput(n)=0.9375*67.2+0.0625
67.3=67.206250
The result should be written in the output file called outputfilexx where can be 1-4.
Files
main.cpp
testfile1, test/file2, testfile3, testfile4. When open it, use the statement
yourvariablename.open("testfile1"); Observe that no file extension is needed. You can use any
text editor to open these files.
2 3 . 1 Project 1 : Filtered temperature data

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!