Overview This project will combine all of your previous projects. You will manually display data using a raw drawing mod

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Overview This project will combine all of your previous projects. You will manually display data using a raw drawing mod

Post by answerhappygod »

Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 1
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 1 (28.35 KiB) Viewed 34 times
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 2
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 2 (161.32 KiB) Viewed 34 times
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 3
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 3 (85.76 KiB) Viewed 34 times
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 4
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 4 (91.88 KiB) Viewed 34 times
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 5
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 5 (50.82 KiB) Viewed 34 times
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 6
Overview This Project Will Combine All Of Your Previous Projects You Will Manually Display Data Using A Raw Drawing Mod 6 (97.32 KiB) Viewed 34 times
Codes from the screenshot:
Overview This project will combine all of your previous projects. You will manually display data using a raw drawing module called tkinter. Visualizing data is an important tool to data science. This project is challenging, but you will see that essentially you can do anything you want provided you know how to draw it! Assignment You will be parsing a data file and drawing a visualization of the data. The data file is a list of Meterological Aerodrome Reports (METARs for short). These give pilots the current conditions over an airport, such as McGhee-Tyson Airport in Knoxville (KTYS).

METAR and Data File Format KMOR 311435Z AUTO 27887G14KT 18SM 23/17 A2995 RMK A81 KTYS 3113532 28889KT 18SM 23/17 A2995 RMK A02 SLP132 T02338167 KLSV 3113552 29802KT 18SM 21/e7 A2992 RMK A02A SLPC93 WND DATA ESTMD Te2148871 KLAS 3113562 81006KT 4SM 22/08 A2990 RMK A02 SLP102 T02228878 KVGT 311353Z 22083KT 1SM 21/08 22991 RMK A02 SLP125 T02868883 PHNL 3181532 07887KT 3SM 26/19 A3881 RMK 402 SLP162 T82568189 KBNA POS 3123532 68BBBKT 1/25M 28/01 A2997 RMK A02 SLP140 T82509144 m You will notice that the METAR always begins with a four letter identifier. This identifies the airport (KMOR is Morristown, KTYS is McGhee-Tyson, KLSV is Nellis AFB, Nevada, etc). For purposes of simplifing this project, I removed all ceilings (such as SCT040, BKN100, etc.) in case you're familiar with METARS. A6 digit timecode followed by a 'Z' (for Zulu time) comes next. The first two digits are the day of the month. In the examples below, 31 is the 31st day. Notice that the month and year are not given. The rest of the four digits are the 24-hour zulu time of the report. 1435Z means 2:35pm in Zulu time zone. Currently, our time zone is -4 from Zulu, so this would be a report from 10:35am. The field that ends in KT (knots for wind speed) is the wind direction and speed. Notice that KMOR has AUTO listed, you must be able to detect the wind speed (notice that the wind speed always ends in KT [knots]). The first three digits are the compass direction (clockwise from 000 (Magnetic North) to 090 (Magnetic East) to 180 (Magnetic South) to 270 (Magnetic West) and back to 000). The last two digits are the speed in knots. So 09 is 9 knots of wind speed. The entire field 01006KT would be wind speed of 6 knots from the north-north-east direction. A value of 000OOKT would mean "calm" winds. You will notice that one field (for KMOR) has a G14. This means that the winds are steady at 7 knots but gust up to 14 knots. Your program must be able to decode the G (gust) field if one exists. The field that ends in SM is the visibility. SM means "statute miles" (rather than nautical miles). So 10SM means 10 miles of visibility. No visibility can go above 10; however, some may be fractional, such as 1/2SM, which means 0.5 miles of visibility. Visibility can be modified with a Por M for "more than" or "less than", respectively. For example, P5SM would mean more than 5 miles of runway visibility, but not enough for 6 SM of visibility. The next field contains the temperature over the dew point in celsius. For example, 21/07 means 21 degrees with a dew point of 7 degrees (all in celsius). The field can be modified with an M which means minus for negative values. For example M01/M10 would mean -1C temperature with a -10C dewpoint. The next field starts with an A, which stands for "altimeter" for altitude meter. This is the value that pilots must set their altimeter. This value is in inches of mercury (inHg). There is an implied decimal after the first two digits. For example, A2984 means that the altimeter must be set to 29.84 inHg. Everything starting with and after RMK (remark) must be ignored. Any other field not mentioned must also be ignored, such as AUTO You must NOT detect the fields based on their position, except the airport identifier. The only field guaranteed to be in position is the airport identifier (the first 4 letters). You will notice that each field either ends with a suffix, such as KT, SM, or Zor a prefix, such as A, or it has a well defined format, such as TT/DD for temperature over dewpoint. METARs can contain several special symbols, such as vre for variable wind directions. Using judgment we can see that winds of variable direction means we cannot put an azimuth indicator on the wind direction, but we can put down wind speed. I will not test your code with erroneous data, however you should have error checking in your code! By no means should your program report incorrect data or crash if it cannot understand a given symbol. For more information about reading a METAR, please see: How to Decode METAR. TAF. and pilot reports (nps.edu) e This site contains much more information about a METAR than we are going to test, but since you will be retrieving real-world weather reports, you might encounter information we haven't covered. So, the website above might help you discern what the METAR actually means.

Getting Data You will be getting data from aviationweather.gov. However, this gives you data in a nice, graphical representation of the data. So, there is some stuff to sift through. However, they make it easy by placing a comment where the data starts. So, you can use your string utilities to parse out the data and grab just the METAR information. AWC - METeorological Aerodrome Reports (METARS) (aviationweather.gov) So, the data we need is stuffed between two comments in the file. import requests as ng data = r.get("https://aviationweather.gov/metar/data? ... e=&hours=8") needle = "<!-- Data starts here -->\n<code>" needle_position - data.text.find(needle) + len(needle) data = data.text[needle_position:] needle = "</code> needle_position = data.find(needle) data = data[: needle_position] The code above grabs the entire file from aviationweather.gov. However, as I mentioned before, it comes with all the stuff to make it look good on a web page. Luckily, this website puts a comment in there right before the data. This is <!- - Data starts here --> So, when we find this position in the text, it will give us the string index where this starts. This is why we have to add len(needle), because we want to skip it all. That will give us the start of the data. The data ends when the code tag is closed, which is </code>. After all of this above, we get the METAR data, which when I wrote this looks as follows: KTYS 1301532 eeeeeKT 9SM CLR 61/81 A3e21 RMK A02 SLP236 Tee118006 So, you can use this code to download data using the requests module. You can see that I'm downloading this data directly from aviationweather.gov and parsing it! Multiple airports can be requested. In this case, the data still starts with the "data starts here", however, each unique airport is wrapped in <code> </code>, which you will need to find and remove. Notice that you will keep finding <code> and then </code> until you hit <!-- Data ends here --> for multiple airports.

Starter Code You may use the following code to get started. This code creates the dropdown box for you and a canvas so you can draw: import tkinter as tk def run(metar): # Create the root Tko root = tk.Tk) # Set the title root.title("COSC585 - Weather") # Create two frames, the list is on top of the Canvas list_frame = tk. Frame (root) draw_frame = tk. Frame (root) # Set the list grid in c, r = 0,8 list_frame.grid(column=w, row=8) # Set the draw grid in c,r = 0,1 draw_frame.grid(column=w, row=1) # Create the canvas on the draw frame, set the width to see and height to 680 canvas = tk.Canvas (draw_frame, width=8ee, height=680) # Reset the size of the grid canvas.pack() # THESE ARE EXAMPLES! You need to populate this list with the available airports in the METAR # which is given by metar parameter passed into this function. choices = ["KONE", "KTWO", "KTHRE"] # Create a variable that will store the currently selected choice. listvar - tk. Stringvar(root) # Immediately set the choice to the first element. Double check to make sure choices[@] is valid! listvar.set(choices[@]) # Create the dropdown menu with the given choices and the update variable. This is stored on the # list frame. You must make sure that choices is already fully populated. dropdown = tk.OptionMenu(list_frame, listvar, *choices) # The dropdown menu is on the top of the screen. This will make sure it is in the middle. dropdown.grid(row=0, column=1) # This function is called whenever the user selects another. Change this as you see fit. def drop_changed(*args) : canvas.delete("airport_text") canvas.create_text(100, 100, text-listvar.get(), fill="black", tags="airport_text") # Listen for the dropdown to change. When it does, the function drop_changed is called. listvar.trace('w', drop_changed) # You need to draw the text manually with the first choice. drop_changed() # mainloop() is necessary for handling events tk.mainloop() # Entry point for running programs if _name == "_main_": data = requests.get("https://aviationweather.gov/metar/data? ... e=&hours=9") # Parse data here run(data) Notice that no file handling has been added. This is your job. When you run the program, you should provide it with a metar file that contains the list of airports. The choices needs to be populated with the available airports. Whenever the user selects an airport, the canvas should reset and display the values of the selected airport. Do not change the location of the canvas and dropdown box, but for everything else, you are free to change it.

Data Structures Using a dictionary to store each airport and a nested dictionary for the information is probably the best way to store the information for easy recall. For example, the data file given above would be parsed into the following: KMOR': {'date': 31, 'utc': 1435, 'wind_dir': 270, 'wind_speed': 7, 'wind_gust': 14, 'vis': 10, 'degrees': 23, 'dewpoint': 17, 'altimeter': 29.95}, "KTYS': {'date': 31, 'utc': 1353, 'wind_dir': 280, 'wind_speed': 9, 'wind_gust': , 'vis': 10, 'degrees': 23, 'dewpoint': 1 7, 'altimeter': 29.95}, "KLSV': {'date': 31, 'utc': 1355, 'wind_dir': 290, 'wind_speed': 2, "wind_gust': @, 'vis': 19, 'degrees': 21, 'dewpoint': 7, 'altimeter': 29.92), "KLAS': {'date': 31, 'utc': 1356, 'wind_dir': 1e, 'wind_speed': 6, 'wind_gust': , 'vis': 4, 'degrees': 22, 'dewpoint': 8, 'altimeter': 29.9}, "KUGT': {'date': 31, 'utc': 1353, 'wind_dir': 220, 'wind_speed': 3, 'wind_gust': , 'vis': 1, 'degrees': 21, 'dewpoint': 8, 'altimeter': 29.91), PHNL': 'date': 31, 'utc': 153, 'wind_dir': 70, 'wind_speed': 7, 'wind_gust': , 'vis': 3, 'degrees': 26, 'dewpoint': 19, 'altimeter': 30.01), "KBNA': {'date': 31, 'utc': 2353, 'wind_dir': 0, 'wind_speed': , 'wind_gust': 0, "vis': 8.5, 'degrees': 8, 'dewpoint': 1, 'altimeter': 29.97} } Notice that when parsed, the date, utc, wind_dir, etc are valid data types (integers or floats). You are free to store the information as you see fit as long as it can be recalled correctly.

Presentation Oval You will present the data by drawing "widgets" manually, including the altimeter, wind data, visibility, and temperature. You will need to draw the following "widgets". Try to make these look close to the example shown below, but as long as they're close, you will receive credit. Widget X,y width, height Type Wind gauge 300, 100 100, 100 Oval Temp gauge 500, 100 100, 200 Rectangle Altimeter gauge 300, 250 100, 100 Visibility gauge 300, 400 400, 100 Rectangle Airport name 100, 100 n/a Text Date 100, 140 n/a Text The wind gauge has a small red dot in the center. The wind direction can be created using a line with an arrow, or using an arc. However, the magnetic north direction (straight up) is 0, whereas with graphs O would be the east direction (straight to the right). You will have to convert the windspeed from knots to miles per hour. Do this by multiplying knots by 1.15 . Remember, when you multiply, you'll get a float. However, for the windspeed, we want whole numbers only. If the winds are calm (0), then only print "CALM". Output the gust speed ONLY if a gust exists. You will have to convert the time from a 24-hour clock to a 12-hour clock. Remember, 0000 is 12:00am, 1200 is 12:00pm. In other words, subtract 1200 from the time. If it's negative, you're in "am", otherwise, you're in "pm". You will have to convert both the temperature and dewpoint into Fahrenheit. Remember, it is given in a METAR as Celsius. The temperature gauge has a range from 0 to 90 degrees. Notice that the dewpoint (blue part of gauge) is overlaid over the temperature (red part of the gauge). The visibility gauge increases to the right from OSM visibility to 10SM visibility. Therefore, if an airport has 10SM of visibility, the gauge should be fully orange. Otherwise, it should be some ratio of orange and gray depending on the amount of visibility. When the user selects another airport, the entire screen will erase .delete("all") and all widgets will be redrawn with the new data.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply