Cumulative Mass Residual Rainfall Calculation

Background: Mass Residual Rainfall is a useful calculation of the cumulative difference from the mean rainfall.

Before you run this notebook:

You need access to r78 to use the load_rainfall function. You can get accesss by signing into your NCI account and requesting r78 access:

You need to run the following commands from the command line prior to launching jupyter notebook from the same terminal so that the required libraries and paths are set.

module use /g/data/v10/public/modules/modulefiles

module load dea

What does this notebook do?: Calculates mass residual rainfall for an area of interest

Date: Oct 2018

Authors: Bex Dunn, Vanessa Newey, Neil Symington, Claire Krause, Leo Lymburner

Tags: rainfall, dc.load, query, statistics,

load modules

[ ]:
%load_ext autoreload
%autoreload 2

#get modules from standard libraries

import os.path
import numpy as np
import sys
import xarray as xr

from datetime import datetime
import matplotlib.pyplot as plt

#modules for datacube
import datacube
from datacube.utils import geometry
from import write_dataset_to_netcdf
from datacube.helpers import write_geotiff

# Import external functions from dea-notebooks
from RainfallTools import load_rainfall

Choose a time period and location to calculate residual mass curve.

  • Note: please select whole months here, not days, as a month with only two days may negatively affect your mass residual curve

[ ]:
## Choose a query area and time
##note: datacube is inclusive of both ends of the interval.

query = {
        'lat': (-35.25, -35.35),
        'lon': (149.05, 149.17),
        'time':('2010-01-01', '2013-03-31')

load rainfall data

[ ]:
dc = datacube.Datacube(app='dc-BOMrainfall')
#use our function to load the rainfall grids
rainfall = load_rainfall(query)

calculate rainfall mass residual

[ ]:
#group rainfall data by day of year
rainfall_bydayofyear = rainfall.groupby('time.dayofyear')
[ ]:
# get the mean rainfall by day over this time period
rainfall_dayofyear_mean = rainfall.groupby('time.dayofyear').mean(dim='time')
[ ]:
#calculate the cumulative mean rainfall by day of year
cumulative_mean_rainfall = rainfall_dayofyear_mean.rainfall[cumulative_rainfall.time.dt.dayofyear-1].cumsum(dim='time',keep_attrs=True)

Calculate the cumulative mass residual by subtracting the cumulative mean rainfall from the cumulative rainfall

[ ]:
mass_residual= cumulative_rainfall.rainfall-cumulative_mean_rainfall

The spatially-averaged cumulative mass residual rainfall for our area of interest

[ ]:

The cumulative mass residual rainfall for one timestep

[ ]:

Future additions:

calculate metrics based on residual rainfall - increasing and decreasing periods - wet year after dry years - dry year after wet years

calculate seasonality - Koppen climate region (use notebook to follow decision tree - requires climate data) - Summer dominant, Summer, Uniform, Winter, Winter dominant # - TROP SOI value - IOD /SAM indices

“During El Niño, rainfall in eastern Australian is typically below average during winter and spring. A neutral ENSO phase has little effect on Australian climate.”Bureau of meteorology

Calculate failed wet seasons - calculate total wet season + dry season rainfalls - end of wet season rainfalls?

[ ]: