This document outlines the scripts used in my project thesis for the course TMA4500 at NTNU.
DescriptivePlots.R- This file contains code for generating the plots shown in Chapter 2 of the thesis. Data is loaded and presented. Plots generated by this file is shown in Figures 2.1, 2.2 and 2.3.
ReanalysisTreatment.R- This file combines the reanalysis into a single object and crops it for the considered domain.
MergeElevationMaps.R- This file reads all elevation maps and merges these into a single field with some simplification. This field is then stored as one file.
normaliseData.R- This file normalises the covariates and stores the resulting parameters that are used in the other files.
GenerateMesh.R- This file generates and stores the triangulation used to fit the candidate models.
Triangulation.R- Calculates and shows the mesh used for calculating the statistical models. Plot from this file are in Figure 4.1.
FitHeightModel.R- Sets up the covariates and model specification for the model referred to as Model 1 in the project thesis. The model is calculated for all years in the timespan. Plot of the parameter estimates for each year is generated and is shown in Figure 4.2.
FitTimeModel.R- Sets up the covariates and model specification for the model referred to as Model 2 in the project thesis.
AlternativeModels.R- Sets up the covariates and model specification for the model referred to as Model 3 in the project thesis. Normalisation of the latitude and longitude covariates is also done here.
ModelRealisation.R- This file is used to generate realisations of a candidate model. The model is loaded along with necessary covariate data and generates samples. These samples are then plotted in a plot of \mu(s,t) and a plot of the standard deviation of the model. These plots are shown for all candidate models in Figures 4.3 and 4.4.
timeEffectPlot.R- This file creates a plot of the combined time effect for the models that have such an effect. The plots generated by this file is found in Figure 4.5
crossValidation.R- Performs model selection procedures for the candidate models. Calculates the DIC, WAIC, LS, and DSS for all the candidate models and reports these.
CompareModels.R- Calculates bias and error between the statistical model and the numerical weather prediction. Plots generated are shown in Figures 5.1 and 5.2.
DiffTimeseries.R- Calculates spatial means for the difference between the statistical model and the numerical weather prediction with uncertainties. The resulting plots are shown in Figures 5.3 and 5.5 in the project thesis.
DiffHistograms.R- This file creates simulated densities of temperatures for each year over the entire domain and plots these together. The plot generated is shown in Figure 5.4.
DiffSpatial.R- Calculates temporal means for the difference between the statistical model and the numerical weather prediction with uncertainties. The resulting plots are shown in Figure 5.6.
ModelVReanalysis.R- This is a working file used to create procedures used in other files.
All the python code is within a single file but separates into different functions. Most of these functions are toy examples working with spatial weather data. These are not described here.
data.pygetRelevantStations()- Get a list of all stations within the bounds of the domain to be studied.
downloadYearlyReanalysis()- Downloads all reanalysis from
thredds.met.no. This data is then merged and used in the analysis.
- Downloads all reanalysis from
degToFloat()- Converts latitudes and longitudes on the form DEGREE:MINUTE:SECOND to a float representing the same latitude and longitude.
cleanObservationsECAD()- Reads the ECA dataset and processes them for easier analysis later. The steps taken are (in order)
- Removeing stations outside bounding box
- Calculating yearly average for each station if enough data
- Store filtered data in
.csvfile