Cal-Adapt Analytics Engine: Timeseries Transformations

Intended Application: As a user, I want to analyze climate timeseries data by:

  1. Computing trends of importance to my region of interest in a climatologically-appropriate manner

Runtime: With the default settings, this notebook takes approximately less than 1 minute to run from start to finish. Modifications to selections may increase the runtime.

Step 0: Setup

import climakitae as ck
import climakitaegui as ckg

Step 1: Select

In order to work with the timeseries tools, select Historical Climate and one of the SSP timeseries options. The historical data will be automatically appended to a SSP time series when both are selected, and select “yes” for area averaging.

To learn more about the data available on the Analytics Engine, see our data catalog.

selections = ckg.Select()
selections.show()

Step 2: Retrieve

my_data = selections.retrieve()
my_data

For the timeseries ‘explore’ function, we first need to load the dataset, so that the subsequent operations will be speedy. To do this, we’ll use the ck.load() function in climakitae.

The retrieve step above previews, but does not compute, the aggregation of all the selected data into timeseries. This may take a few minutes.

my_data = ck.load(my_data)

Steps 3 & 4: Visualize and Transform

import climakitaegui.explore.timeseries as tst
timeseries = tst.TimeSeries(my_data)

Preview various transforms on the data in real time. The below panel walks through several options for transforming your time series, such as:

  • Comparing the difference between the variable of interest and a 30-year historical baseline of January 1, 1981 to December 31, 2010. You can also select your own baseline range of interest out to 12/31/2021.
  • Removing the seasonal cycle (removing the mean monthly signal in each month) to view within-year patterns independent from the impact of seasonality.
  • Smooth your timeseries to remove noise with a running average, by specifying the number of timesteps to average over (for example you may want to average over 1, 3, 5, or 10 years). This option is only recommended if you want to examine changes in mean conditions.
  • Choose the disaggregate into four seasons option to examine patterns in a given season (data is grouped into December-January-February, March-April-May, June-July-August, or September-October-November, which can be toggled between in a dropdown menu at the bottom of the panel).

You may also choose to explore patterns in the minimum, maximum, or an extreme of your choice (defined by the percentile slider: e.g. temperatures above the 90th percentile)

  • If you choose to look at extremes, you can change the resampling window and period to assess how extreme a pattern is over a time period of your own choosing
    • For example, you may want to examine the annual minimum, in which we would recommend selecting “min”, 1 for the window, and “years” for the resample period.
    • Likewise, if you were interested in the decadal maximum, you would select “max”, 10 for the window, and “years” for the period

Examples of climatological interest:

  • Hourly: Consider 6, 12, or 24 hour events
  • Daily: Consider 3 day (heat wave length events), 7 day (week long), 14 day (biweekly), or 30 day events
  • Monthly: Consider sub-annual and seasonal scales, where 3, 6, 12 months could represent seasonal or dry/wet season interest periods
  • Yearly: Consider 5, 10 year intervals and beyond to assess long-term climatology trends

Please note, the figure may take a few minutes to update with your selections.

timeseries.explore()

And then output whatever the current state is to another variable:

transformed = timeseries.output_current()
transformed

Step 5: Export

To save data as a file, call export and input your desired

  1. data to export – an xarray DataArray or Dataset, as output by e.g. selections.retrieve()
  2. output file name (without file extension)
  3. file format (“NetCDF” or “CSV”)

To learn more about the file format options, see getting_started.ipynb.

ck.export(transformed, "my_filename", "NetCDF")