Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help writing code to import sensor.py and amp_filter.py Notes Come back to these after you have read through the problems . You should write
Need help writing code to import sensor.py and amp_filter.py
Notes Come back to these after you have read through the problems . You should write tests for all of the functions you write for this lab. Write the tests before you write the code, and put them after the if --name-- == '-_main__': line. We're going to import the functions from your files for testing and, if you don't put your tests after this line and indented to the if block), then it might confuse our testing code. Also, this if good programming practice. Yes, we (more or less) wrote the sum functions in class last week. There are a number of ways to write the recursive functions. Any of them will do. There are likely to be built-in functions for a number of the things we're asking you to do for this lab. Please don't use them. If you do, you'll get zero points for that part of the assignment, since we want you to write them from scratch (this time). The amplitude filter only affects sensor readings beyond a certain threshold. These sensor readings get clipped to the maximum allowed amplitude. When you write the variable-width mean filter, you might find array slicing useful. Also, the filtered arrays will be shorter than the input arrays. For a filter with width 3, the filtered lists will be 2 elements shorter than the original list. For a width of 5, it will be 4 shorter, and so on. Make sure you write testing code for all of the functions that you write. Download sensor.py and amp_filter.py from Canvas. Read the code in these files, and make sure you understand what they're doing. Do not modify these files; all of your code should go in test filter.py. Write some code in test_filter.py to generate a single CSV file, where the first column has 1000 points of (simulated) sensor data generated using the function in sensor.py), and the second column has the same data after you pass it through the amplitude filter (from amp_filter.py). Note that there are many modules in Python that work with CSVs. You can use any standard library modules you wish (but no Numpy/Pandas/etc.), but for this assignment, you may also find that writing each line manually is the easiest. Each line should look something like 1.2411,0.8921, with a comma separating each number (hence the name comma separated values)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started