Welcome to the exercises of module 2! Please try to solve the following exercises, and if you do not remember how to write the code for certain things, have a look again at the previous scripts. Programming is about learning by doing! So, do not hesitate to look for help in the internet, too. Remember that there is almost always more than just one way to solve a problem in R!

Part A: Weather station measurements

Exercise 01 (5 points)

Import the file of the weather measurements that corresponds to the station assigned to your group from the folder “Weather_by_station”. You can find the list of stations for each group in the file “M02_Overview.pptx”. Process the station measurements according to the workflow in script 01, lines 83 to 115.

Exercise 02 (5 points)

Plot the mean and standard deviation of snow cover measured at your station during each day of the year (1-366), across all years for which data is available. Export your plot as PNG.

Exercise 03 (15 points)

For each year available, calculate the average of the daily maximum temperature measurements in May. Plot these averages as points connected by a line, and add to the plot the regression line of a linear model with “average daily maximum temperature in May” as dependent and “year” as explanatory variable. Export your plot as PNG. Report the in- or decrease in average daily maximum temperature in May per decade and whether the trend is significant according to the Mann-Kendall test.

Exercise 04 (15 points)

For all parameters available at your station, and for all months, calculate whether there has been a significant in- or decrease in monthly sums (precipitation and sunshine duration) or monthly means (all other parameters) for the entire period that is covered by your dataset. Visualize your results in a bubble plot (see last figure in script 01) and export it as PNG.

Part B: CHIRPS

Exercise 05 (30 points)

Download all available CHIRPS layers from 1981 to 2020 for the month assigned to your group to the folder “download”. You can find the list of months for each group in the file “M02_Overview.pptx”. In each raster, change the value “-9999” to “NA”. Use the functions crop() and mask() to reduce the data to the extent of Armenia. For each year, calculate the sum of the daily precipitation measurements during the month assigned to your group. Save the resulting 40 rasters of monthly sums as TIFFs. Plot the 40 monthly sum rasters as maps and save your plot(s) as PNG.

Exercise 06 (15 points)

Import all 40 monthly precipitation sum rasters as a raster stack. Use the function exact_extract() to calculate marz-level averages of the monthly precipitation sums for all 40 years. Add the result to the attribute table of the marzes shapefile. Use spplot() to create a multipart map of the marz-level monthly precipitation for the years 1990, 2000, 2010 and 2020.

Exercise 07 (10 points)

Use ggplot() and facet_wrap() to create line plots that show the yearly precipitation sums during the selected month, from 1981 to 2020. Each facet should represent one marz. Add a regression line to each plot.

Exercise 08 (5 points)

In a table, report the significance of the Mann-Kendall test for the precipitation time series of each marz.