首页 > > 详细

AirNow website辅导、讲解Python程序语言、辅导AQI forecasts、Python讲解 调试C/C++编程|辅导R语言

Summary
The Air Quality Index (AQI) is a simple, unitless index used to communicate air pollution to the general public. EPA's AirNow website shows interactive maps with the current AQI, as well as AQI forecasts.


To calculate the AQI, the US EPA draws from various environmental monitors that each record a pollutant. Six pollutant types are used to calculate the AQI:
Part of this project is an exercise in having control over functions and patterns to produce target outputs. It is not a creative exercise, but rather the opportunity for you to demonstrate precision, control and being detail-oriented. You are asked to demonstrate the requested behavior and output, matching the sample output exactly. In all samples below, user input is shown in italics and underlined.

Checkpoint 1A
For Checkpoint A, you will need to demonstrate a program that does the following:
1.Prompts the user to enter the number of locations for which AQI will be calculated. For Checkpoint A, you can assume that the user always enters a positive integer (greater than zero).
2.Prompts the user to enter the name of each location.
3.Prompts the user, per location, to enter the pollutant concentrations for PM2.5, PM10?and NO2?monitors. You can assume that the user always enters a valid float value for these.
4.Calculates and prints the quality index for each pollutant and, for each location, prints the final AQI and the category label for the AQI.
5.Follows the EPA guidance on truncating the sensor readings (see the AQI Equation), and rounds the final calculated AQI to the nearest integer.
6.Matches the sample input/output below.
The spacing will be checked. You can highlight over the sample to see the spacing. For example, there are four spaces in front of the first?->.
We will use additional sample inputs to test your demo and your final program, and so should you. You can test your program using the?AQI calculator?to check answers; however, there may be discrepancies with out-of-range concentrations.
Sample 1
=== Air Quality Index (AQI) Calculator ===
Select the number of locations for the report: 1

Enter name of ** Location 1 **: Rohnert Park
-> PM-2.5 [ug/m3, 24-hr avg] Monitor: 3.2
PM-2.5 concentration 3.2 yields 13 index
-> PM-10 [ug/m3, 24-hr avg] Monitor: 0
PM-10 concentration 0 yields 0 index
-> NO2 [ppb, 1-hr avg] Monitor: 2.5
NO2 concentration 2 yields 2 index
AQI for Rohnert Park is 13
Condition: Good
Sample 2
=== Air Quality Index (AQI) Calculator ===
Select the number of locations for the report: 2

Enter name of ** Location 1 **: San Bernadino
-> PM-2.5 [ug/m3, 24-hr avg] Monitor: 35.82
PM-2.5 concentration 35.8 yields 102 index
-> PM-10 [ug/m3, 24-hr avg] Monitor: 70.7
PM-10 concentration 70 yields 58 index
-> NO2 [ppb, 1-hr avg] Monitor: 205.2
NO2 concentration 205 yields 121 index
AQI for San Bernadino is 121
Condition: Unhealthy for Sensitive Groups

Enter name of ** Location 2 **: Newport Beach
-> PM-2.5 [ug/m3, 24-hr avg] Monitor: 10.59
PM-2.5 concentration 10.5 yields 44 index
-> PM-10 [ug/m3, 24-hr avg] Monitor: 40.1
PM-10 concentration 40 yields 37 index
-> NO2 [ppb, 1-hr avg] Monitor: 25
NO2 concentration 25 yields 24 index
AQI for Newport Beach is 44
Condition: Good
Advice and Hints
Hint:?There is some syntactic sugar in Python to assign values to multiple variables with a single line of code:
x, y, z = 1, 2, 3 # assigns x the value 1, y the value 2 and z the value 3
Hint:There is some syntactic sugar in Python to chain conditionals:
if (1 <= x <= 10):
# this is the same as if (1 <= x) and (x <= 10):
print("Hi!")
Hint:?float('inf')?is larger than every other float, and?float('-inf')?is smaller than every other float. You may find these useful as variable initializers, when you are tracking minima and maxima
Checkpoint 1B
For Checkpoint B, you will extend your code from Checkpoint A by supporting all pollutants and printing summary statistics:
1.Extend your program to support the pollutant concentration from SO2, CO and O3?monitors.
2.When calculating the ozone AQI, ignore 1-hr ozone readings less than 125 ppb and 8-hr ozone readings greater than 200 ppb; otherwise, the ozone AQI between 100 and 300 is computed by selecting the larger of the AQI calculated using the 1-hour ozone reading and the AQI calculated using the 8-hour ozone reading.
3.After the AQI of each location has been reported, print a summary report that features: the location with the maximum AQI, the location with the minimum AQI, and the average PM2.5?concentration (average of those locations that had monitor readings for that pollutant).

Sample 3
=== Air Quality Index (AQI) Calculator ===
Select the number of locations for the report: 1

Enter name of ** Location 1 **: Cupertino
-> PM-2.5 [ug/m3, 24-hr avg] Monitor: 12.3
PM-2.5 concentration 12.3 yields 51 index
-> PM-10 [ug/m3, 24-hr avg] Monitor: 0.1
PM-10 concentration 0 yields 0 index
-> NO2 [ppb, 1-hr avg] Monitor: 0.5
NO2 concentration 0 yields 0 index
-> SO2 [ppb, 1-hr avg] Monitor: 11
SO2 concentration 11 yields 16 index
-> CO [ppm, 8-hr avg] Monitor: 12
CO concentration 12.0 yields 143 index
-> O3 [ppb, 8-hr avg] Monitor: 110
-> O3 [ppb, 1-hr avg] Monitor: 170
O3 concentration 110 yields 205 index
AQI for Cupertino is 205
Condition: Very Unhealthy

Summary Report
Location with max AQI is Cupertino (205)
Location with min AQI is Cupertino (205)
Avg PM-2.5 concentration reading: 12.3
Sample 4
=== Air Quality Index (AQI) Calculator ===
Select the number of locations for the report: 3

Enter name of ** Location 1 **: Davis
-> PM-2.5 [ug/m3, 24-hr avg] Monitor: 130
PM-2.5 concentration 130.0 yields 189 index
-> PM-10 [ug/m3, 24-hr avg] Monitor: 25.33
PM-10 concentration 25 yields 23 index
-> NO2 [ppb, 1-hr avg] Monitor: 5.4
NO2 concentration 5 yields 5 index
-> SO2 [ppb, 1-hr avg] Monitor: 0
SO2 concentration 0 yields 0 index
-> CO [ppm, 8-hr avg] Monitor: 1.4
CO concentration 1.4 yields 16 index
-> O3 [ppb, 8-hr avg] Monitor: 69
-> O3 [ppb, 1-hr avg] Monitor: 100
O3 concentration 69 yields 97 index
AQI for Davis is 189
Condition: Unhealthy

Enter name of ** Location 2 **: Woodland
-> PM-2.5 [ug/m3, 24-hr avg] Monitor: 20
PM-2.5 concentration 20.0 yields 68 index
-> PM-10 [ug/m3, 24-hr avg] Monitor: 10
PM-10 concentration 10 yields 9 index
-> NO2 [ppb, 1-hr avg] Monitor: 40
NO2 concentration 40 yields 38 index
-> SO2 [ppb, 1-hr avg] Monitor: 15
SO2 concentration 15 yields 21 index
-> CO [ppm, 8-hr avg] Monitor: 1.4
CO concentration 1.4 yields 16 index
-> O3 [ppb, 8-hr avg] Monitor: 10.5
-> O3 [ppb, 1-hr avg] Monitor: 123
O3 concentration 10 yields 9 index
AQI for Woodland is 68
Condition: Moderate

Enter name of ** Location 3 **: Vacaville
-> PM-2.5 [ug/m3, 24-hr avg] Monitor: 10
PM-2.5 concentration 10.0 yields 42 index
-> PM-10 [ug/m3, 24-hr avg] Monitor: 2
PM-10 concentration 2 yields 2 index
-> NO2 [ppb, 1-hr avg] Monitor: 10
NO2 concentration 10 yields 9 index
-> SO2 [ppb, 1-hr avg] Monitor: 5
SO2 concentration 5 yields 7 index
-> CO [ppm, 8-hr avg] Monitor: 2.4
CO concentration 2.4 yields 27 index
-> O3 [ppb, 8-hr avg] Monitor: 8
-> O3 [ppb, 1-hr avg] Monitor: 165
O3 concentration 165.0 yields 151 index
AQI for Vacaville is 151
Condition: Unhealthy

Summary Report
Location with max AQI is Davis (189)
Location with min AQI is Woodland (68)
Avg PM-2.5 concentration reading: 53.3

Final Code
In your final code, you will extend the above code to handle two special user-input scenarios:
If a user inputs a zero or a negative value for 'number of locations' then print an error message and exit (see samples 5 and 6 below).
If a user inputs a negative pollutant concentration, interpret this as meaning there is no monitor for that pollutant at that location and, subsequently, ignore that pollutant during relevant calculations (see sample 7 below).
There is no demo for your final code.
Advice and Hints
Hint:The exit() function in the sys library can be used to halt the program running and report an exit code back to the operating system. Please use?exit(-1), which will report it as an error.?Here is a little code demonstrating this, but note that it will not run in PythonTutor (which does not let you use the sys library). You will need to copy-paste the code and run it in a different environment.
Hint: Be careful about computing the average PM-2.5 concentations across locations, in the scenario that the user did not have a PM-2.5 reading at some locations. For example, in Sample 7, the average PM-2.5 value is 8.5 ug/m3, which is just the average of Santa Cruz's and Watsonville's two readings.
Sample Input/Output
Sample 5
=== Air Quality Index (AQI) Calculator ===
Select the number of locations for the report: 0
Error: 0 is not a valid input.
Sample 6
=== Air Quality Index (AQI) Calculator ===
Select the number of locations for the report: -20
Error: -20 is not a valid input.
Sample 7
=== Air Quality Index (AQI) Calculator ===
Select the number of locations for the report: 3

Enter name of ** Location 1 **: Santa Cruz
-> PM-2.5 [ug/m3, 24-hr avg] Monitor: 5
PM-2.5 concentration 5.0 yields 21 index
-> PM-10 [ug/m3, 24-hr avg] Monitor: 12.5
PM-10 concentration 12 yields 11 index
-> NO2 [ppb, 1-hr avg] Monitor: 20.8
NO2 concentration 20 yields 19 index
-> SO2 [ppb, 1-hr avg] Monitor: 4
SO2 concentration 4 yields 6 index
-> CO [ppm, 8-hr avg] Monitor: 1.1
CO concentration 1.1 yields 12 index
-> O3 [ppb, 8-hr avg] Monitor: -1
-> O3 [ppb, 1-hr avg] Monitor: -1
AQI for Santa Cruz is 21
Condition: Good

Enter name of ** Location 2 **: Watsonville
-> PM-2.5 [ug/m3, 24-hr avg] Monitor: 12
PM-2.5 concentration 12.0 yields 50 index
-> PM-10 [ug/m3, 24-hr avg] Monitor: -1
-> NO2 [ppb, 1-hr avg] Monitor: -1
-> SO2 [ppb, 1-hr avg] Monitor: -1
-> CO [ppm, 8-hr avg] Monitor: -1
-> O3 [ppb, 8-hr avg] Monitor: -1
-> O3 [ppb, 1-hr avg] Monitor: -1
AQI for Watsonville is 50
Condition: Good

Enter name of ** Location 3 **: Salinas
-> PM-2.5 [ug/m3, 24-hr avg] Monitor: -1
-> PM-10 [ug/m3, 24-hr avg] Monitor: -1
-> NO2 [ppb, 1-hr avg] Monitor: 55
NO2 concentration 55 yields 52 index
-> SO2 [ppb, 1-hr avg] Monitor: -1
-> CO [ppm, 8-hr avg] Monitor: 3.0
CO concentration 3.0 yields 34 index
-> O3 [ppb, 8-hr avg] Monitor: 56
-> O3 [ppb, 1-hr avg] Monitor: -1
O3 concentration 56 yields 54 index
AQI for Salinas is 54
Condition: Moderate

Summary Report
Location with max AQI is Salinas (54)
Location with min AQI is Santa Cruz (21)
Avg PM-2.5 concentration reading: 8.5

Extra Credit
You can get extra credit by checking for more error conditions. For example, you could reject NO2?concentrations that fall outside the range from the AQI Breakpoint Table. In each case, the program should display a user-friendly message before exiting. You will get max +1 points for each boundary condition you check.
You can get extra credit by checking that, when no sensor data is input to the program for a location, it should not print the AQI for that location (+3), since none can be calculated.
You will get no more than 10 points total for extra credit. Be sure you describe any extra-credit work in your docstring, explaining the judgements you made and you must include references justifying these judgements. If you do not describe your extra credit work, it will get ignored.
Correctness: functional features (50 points -- 5 points each)
Feature 1: For each AQI, a correct and matching "Condition:" message is reported (Ex: Samples 1, 2, 3, 4 and 7). There are six possible condition messages (see the AQI Breakpoint Table for the Category labels).
Feature 2: When the user inputs an invalid number for the number of locations, the program produces an appropriate error message and exit code (Ex: Samples 5 and 6).
Feature 3: The locations with the max and min AQI are correctly reported in the Summary Report (Ex: Samples 3, 4 and 7).
Feature 4: The average PM-2.5 concentration is correctly reported in the Summary Report. This should work for these scenarios: for 1 location (Ex: Sample 3); for multiple locations (Ex: Sample 4); when some locations are missing PM-2.5 measurements (Ex: Sample 7). User input handling should reflect the standard guidance on how to truncate PM-2.5 concentration readings.
Feature 5: Given a concentration for PM-2.5, the per-pollutant (IPM-2.5) index is correctly computed, including: the truncation of the concentration data is performed correctly, all boundary break-points are correctly reasoned, and the index formula is correctly computed.
Feature 6: Given a concentration for PM-10, the per-pollutant (IPM-10) index is correctly computed, including: the truncation of the concentration data is performed correctly, all boundary break-points are correctly reasoned, and the index formula is correctly computed.
Feature 7: Given concentrations for NO2, SO2 and CO, their per-pollutant indices are correctly computed, including: the truncation of the concentration data is performed correctly, all boundary break-points are correctly reasoned, and the index formula is correctly computed.
Feature 8: Given a concentration for O3, the per-pollutant (IO3) index is correctly computed, including: the truncation of the concentration data is performed correctly, all boundary break-points are correctly reasoned, and the index formula is correctly computed.
Feature 9: Given all per-pollutant indices (PM-2.5, PM-10, NO2, SO2, CO, and O3), the location's AQI is correctly computed (Ex: Samples 3 and 4).
Feature 10: Given some per-pollutant indices (PM-2.5, PM-10, NO2, SO2, CO, and O3, where one or more readings are missing from the user's input), the location's AQI is correctly computed (Ex: Sample 7).
Correctness: spacing, spelling, grammar, punctuation (5 points)
Your spelling, punctuation, etc. get a separate score: each minor error in spacing, punctuation, or spelling gets a score of 2.5, and each major error gets a score of 5. Here is how the score translates to points on the assignment:
[5] Score = 0
-1 0 < Score <= 2.5
-2 2.5 < Score <= 5
-3 5 < Score <= 7.5
-4 7.5 < Score <= 10
-5 Score > 10
Programming Design and Style (25 points)
Docstring (5 points)
There should be a docstring at the top of your submitted file with the following information:
1 pt. Your name (first and last)
1 pt. The course (IT 11 Flower)
1 pt. The assignment (e.g., AQI Calculator)
2 pts. A brief description of what the program does
Documentation (6 points)
Not counting the docstring, your program should contain at least three comments explaining aspects of your code that are potentially tricky for a person reading it to understand. You should assume that the person understands what Python syntax means but may not understand?why?you are doing what you are doing.
6 pts. You have at least 3 useful comments (2 points each)
Variables (5 points)
5 pts. Variables have helpful names that indicate what kind of information they contain.
Algorithm (4 points)

2 pts. Your algorithm is straightforward and easy to follow.
2 pts. Your algorithm is reasonably efficient, with no wasted computation or unused variables.
Program structure (5 points)
All or nothing: your code should define a main function and then call that function, just like our programs do in the lab. Other than library imports, the docstring, and the final call to?main(), you should not have any stray code outside a function definition.
Catchall
For students using language features that were not covered in class, up to 5 points may be taken off if the principles of programming style are not adhered to when using these features. If you have any questions about what this means, then ask.
Checkpoints [20%]
Checkpoint demos are each worth 10 points; each is all or nothing.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!