Esempio n. 1
0
def root( ):
    if request.method=="POST":
        city=request.form["city"]
        while " " in city:
            city=city[:city.find(" ")]+"_"+city[city.find(" ")+1:]
    else:
        city="New_York_City"
    temp = util.get_weather(city)
    temp = (temp-273.15)*1.8+32
    while "_" in city:
            city=city[:city.find("_")]+" "+city[city.find("_")+1:]
    if temp <=0:
        planet = "Pluto"
    elif temp >0 and temp <= 20:
        planet = "Uranus"
    elif temp >20 and temp <= 40:
        planet = "Neptune"
    elif temp >40 and temp <= 50:
        planet = "Saturn"
    elif temp >50 and temp <= 60:
        planet = "Mars"
    elif temp >60 and temp <= 70:
        planet = "Earth"
    elif temp >70 and temp <= 80:
        planet = "Mercury"
    elif temp > 80 and temp <= 90:
        planet = "Venus"
    elif temp > 90 and temp <= 100:
        planet = "Jupiter"
    elif temp >100:
        planet = "Sun"
    d = { 'city':city, 'temp':temp }
    return render_template( 'index.html', d = d, planet = planet)
Esempio n. 2
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In GoOutIntentHandler")
        local_time, current_temp, current_condition = util.get_weather(
            data.CITY_DATA, data.MY_API)

        speech = "It is {} and the weather in {} is {} and {}.".format(
            local_time, data.CITY_DATA["city"], current_temp,
            current_condition)

        handler_input.response_builder.speak(speech)
        return handler_input.response_builder.response
Esempio n. 3
0
def index(city="nyc"):
    temp = util.get_weather(city)
    photos = util.get_turtles()[0:10];
    d={'city':city,'temp':temp,'photos':photos}
    return render_template("index.html",d=d)
Esempio n. 4
0
# import list of locations
df_stations = pd.read_csv(station_path)
stations = df_stations.StationID
print('Fetching the following stations...')
print(df_stations)

# Station ID for the locations of interest
stationid = 'GHCND:MXM00076680'
datasetid = 'GHCND'

# urls
base_url_data = 'https://www.ncdc.noaa.gov/cdo-web/api/v2/data'
df_weather = pd.DataFrame()

# fetch data from NOAA and store in csv
for s in stations:
    for i in np.arange(0, 12):
        start = begin_date + datetime.timedelta(weeks=int(i * 4))
        end = start + datetime.timedelta(weeks=4)
        d = get_weather(stationid=s,
                        datasetid=datasetid,
                        datatype='PRCP',
                        start_date=start.strftime('%Y-%m-%d'),
                        end_date=end.strftime('%Y-%m-%d'),
                        token=myToken,
                        base_url=base_url_data)
        df_weather = df_weather.append(d, ignore_index=True)

# Write to CSV
df_weather.to_csv('out/2017_raw_weather_data.csv')