Assignment 6

If you have installed Python locally, launch JupyterLab by running:

conda activate sds

and

jupyter lab

Plotting weather station data

In this activity, we will use Pandas and Matplotlib to make some visually-appealing plots of meteorological data which was collected by a weather station installed at Hayden Glacier in the Oregon Cascades. The data can be downloaded here. This dataset is similar to the one we used back in Week 3. Although this time, all the data have been provided as a .csv file. The dataset includes the following variables: pressure (mbar), solar radiation (W/m2), air temperature (C), relative humidity (%), wind speed (m/s), gust speed (m/s), wind direction (degrees), and rainfall (mm).

aws

Note

We will be giving bonus points to students that go beyond the instructions and format their plots especially nicely.


Task 1 (10 points)

Read the data and answer the following questions:

  • a) What time period does the data represent?

  • b) Plot one variable using pyplot style (i.e. plt.plot()), including axis labels, a gridded background, and customized linestyle, linewidth, and color.

  • c) Plot another variable, this time using the object-oriented style (i.e. ax.plot()), including axis labels, a gridded background, and customized linestyle, linewidth, and color.

  • d) Make a multi-panel figure with two rows and one column that plots two different variables (one variable in each). Customize these plots again to include axis labels, a gridded background, and customized linestyle, linewidth, and color. This time, also add a legend.

  • Bonus point:


Task 2 (10 points)

  • a) Read the data again but, this time, parse the dates and make Datetime the index column. Print the first five rows to show your new DataFrame.

  • b) Make a plot showing air temperature with a figure size 10 x 4 inches.

  • c) Format the x-axis labels as month day (i.e. Aug 10).

  • d) Add a horizontal line to the figure that represents the mean air temperature

  • e) Add a label to the horizontal line that says “mean = X F” where X is the mean air temperature in Fahrenheit.

  • f) Add an arrow that points to the lowest air temperature value that says “lowest value”

  • g) Add an arrow that points to the highest air temperature value that says “highest value”

  • h) Limit the x-axis from Jul 02 to Sep 30.


Task 3 (5 points)

  • a) Make a four panelled figure with two columns and two rows. In each panel, show the relationship between two variables (i.e. a scatterplot).

  • b) Annotate the figure so that each panel is labelled (a), (b), (c), and (d).

  • c) Label the x- and y-axes of each panel.

  • d) Customize the size and facecolors of the dots in the plots.

  • e) Add a grid to each panel.


Important

Save your notebook to your local course folder and submit assignment (in .pdf format) to Canvas by the deadline.