Question
Python 3 help! Thank you! You have a data set: http://foehn.colorado.edu/weather/atoc8/ and this code: def read_boulder(date): url = 'http://foehn.colorado.edu/weather/atoc8/' # get julian day (requested date)
Python 3 help! Thank you!
You have a data set: http://foehn.colorado.edu/weather/atoc8/ and this code:
def read_boulder(date): url = 'http://foehn.colorado.edu/weather/atoc8/' # get julian day (requested date) y0=int(date[0:4]); m0=int(date[4:6]); d0= int(date[6:8]) jday0= (datetime.datetime(y0,m0,d0)-datetime.datetime(y0,1,1)).total_seconds()/86400.0 + 1.0 jul = [] # initialize julian day loc = [] # initialize local times t2m = [] # 2m temperatures wind = [] #wind speed url=url+'wxobs'+date+'.txt' print('Reading: ',url) try: lines = urllib.request.urlopen(url).readlines() for line in lines[3:]: # go through all lines, ignoring first three (header) entries = line.decode("utf-8").split(" ") columns = [] # will contain columns for entry in entries: if len(entry) > 1: columns.append(entry) mmddyy= columns[0].zfill(8) # assigns date, filling in leading '0' mm=int(mmddyy[0:2]); dd=int(mmddyy[3:5]); yyyy=int('20'+mmddyy[6:8]) # get julian day (acquired date) jday = (datetime.datetime(yyyy,mm,dd)-datetime.datetime(y0,1,1)).total_seconds()/86400.0 + 1.0 # get time and convert from am/pm format to military time hhmmX = columns[1].zfill(6) # assigns time, filling in leading '0' hh = float(hhmmX[0:2]) if (hhmmX[5] == 'p') & (hh < 12): hh=hh+12. if (hhmmX[5] == 'a') & (hh > 11): hh=hh-12. mm = float(hhmmX[3:5]) if jday == jday0: loc.append(hh+mm/60.) jul.append(jday) t2m.append((float(columns[2])-32)*5./9.) wind.append((float(columns[7])))
Rewrite the code for the data as a python class where the temperature and wind data for each day are stored in as objects. Then loop through all of the days of 2017 and combine the objects(days) in a list. Then write a function that calculates the daily mean, min, max and plots them.
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