home

Scientific Computing (Psychology 9040a)

Fall, 2020

Assignment 8

Due: Nov 24 by 11:55 pm (London ON time)


Right-click and Save As … these daily weather data from 2019 from London, ON and from Vancouver, BC:

  1. Import each file as a DataFrame, one called toronto and one called vancouver. Use the .info() function to view the contents. For example for the toronto DataFrame you should see:

    toronto.info()
    
    <class 'pandas.core.frame.DataFrame'>
    RangeIndex: 365 entries, 0 to 364
    Data columns (total 31 columns):
    #   Column                     Non-Null Count  Dtype  
    ---  ------                     --------------  -----  
    0   Longitude (x)              365 non-null    float64
    1   Latitude (y)               365 non-null    float64
    2   Station Name               365 non-null    object 
    3   Climate ID                 365 non-null    int64  
    4   Date/Time                  365 non-null    object 
    5   Year                       365 non-null    int64  
    6   Month                      365 non-null    int64  
    7   Day                        365 non-null    int64  
    8   Data Quality               0 non-null      float64
    9   Max Temp (°C)              364 non-null    float64
    10  Max Temp Flag              1 non-null      object 
    11  Min Temp (°C)              364 non-null    float64
    12  Min Temp Flag              1 non-null      object 
    13  Mean Temp (°C)             364 non-null    float64
    14  Mean Temp Flag             1 non-null      object 
    15  Heat Deg Days (°C)         364 non-null    float64
    16  Heat Deg Days Flag         1 non-null      object 
    17  Cool Deg Days (°C)         364 non-null    float64
    18  Cool Deg Days Flag         1 non-null      object 
    19  Total Rain (mm)            365 non-null    float64
    20  Total Rain Flag            25 non-null     object 
    21  Total Snow (cm)            365 non-null    float64
    22  Total Snow Flag            39 non-null     object 
    23  Total Precip (mm)          365 non-null    float64
    24  Total Precip Flag          55 non-null     object 
    25  Snow on Grnd (cm)          110 non-null    float64
    26  Snow on Grnd Flag          39 non-null     object 
    27  Dir of Max Gust (10s deg)  335 non-null    float64
    28  Dir of Max Gust Flag       26 non-null     object 
    29  Spd of Max Gust (km/h)     335 non-null    float64
    30  Spd of Max Gust Flag       30 non-null     object 
    dtypes: float64(14), int64(4), object(13)
    memory usage: 88.5+ KB
    
  2. For each city, calculate the maximum temperature range over the whole year: the difference between the highest maximum daily temperature and the lowest daily minimum temperature.

    Answer: 55.8 deg C for Toronto and 38.7 deg C for Vancouver

    1. How many days did Vancouver have a maximum temperature less than 0 degrees Celsius? What about Toronto? (b) What was the total rainfall over the year in Vancouver? What about Toronto? (c) What was the total snowfall over the year in Vancouver? In Toronto?

    Answer: (a) Vancouver: 3 days, Toronto: 55 days; (b) Vancouver: 934.1 mm, Toronto: 799.6 mm; (c) Vancouver: 32.2 cm, Toronto: 163.5 cm

    1. How many days over the course of the whole year did Vancouver have Total Rain (mm) greater than zero? What about Toronto? (b) How many days over the course of the whole year did Vancouver have Total Snow (cm) greater than zero? What about Toronto? (c) How many days did Vancouver have Snow on Grnd (cm) greater than zero? What about Toronto?

    Answer: (a) Vancouver: 144 days, Toronto: 130 days; (b) Vancouver: 9 days, Toronto: 52 days; (c) Vancouver: 11 days, Toronto: 76 days

    1. How many days did both Toronto and Vancouver have Total Rain (mm) greater than 1.0 mm? (b) What proportion of those days, in percent out of 100, using 2 decimal places (e.g. 12.34%) did Vancouver have greater Total Rain (mm) than Toronto? (c), (d) Repeat the analysis for Total Snow (cm) greater than 0.0 cm.

    Answer: (a) 21 days; (b) 38.10 %; (c) 5 days; (d) 40.00 %