Skip to main content

Open-source tool for climatological time series reconstruction and extension

Project description

Reconstruction by AnalogS of ClimatologicAL time series (RASCAL)

docs GMD GMD

RASCAL is a python library desinged to reconstruct time series of climatological data, based on the Analog Method (AM), to use them for climate studies. The AM is a statistical downscalling method, based on the assumption that large-scale atmospheric conditions tend to produce similar local weather patterns, and therefore is possible to predict local conditions finding analog days, with similar large-scale patterns, in the historical record. The objective of RASCAL is to generate complete time series, based on limited observational data, that can reproduce the climatic characteristics of the region to study better than the reanalysis products.

Requirements

To run this library renalaysis and observational data is required. the reanalysis data should cover the whole period to be reconstructed, and should have at least one predictor variable.The observational data temporal cover must overlap with the reanalysis data.

The choice of the predictor variable is flexible. However, if you want to reconstruct a long time series, it's important to consider that the connection between the predictor and the predicted variable should be very robust. This is because certain relationships may change in a changing climate scenario.

RASCAL is based in python 3.10. To run RASCAL, these other python libraries are required:

  • numpy 1.26.4
  • pandas 2.2.1
  • dask 2024.4.1
  • xarray 2024.3.0
  • scipy 1.13.0
  • tqdm 4.65.0
  • scikit-learn 1.4.1.post1
  • seaborn 0.13.2
  • eofs 1.4.1

Documentation

For a more detalied documentation you can check RASCAL ReadTheDocs.

Getting Started

RASCAL can be installed through PyPi

pip install rascal-ties

or using the files in rascal/ directory inside this repository

How to use

RASCAL is based in four main clases: Station, Predictor, Analogs and Rskill

import rascal

1) Get observational data

To load the observational data (in daily or sub-daily resolution) and the station metadata, the data is loaded from a CSV file with the same name as the desired variable, and a meta.csv file containing the name, code, altitude, longitude and latitude of the station

station = rascal.analogs.Station(path='./data/observations/station/')
station_data = station.get_data(variable='PCP')

2) Load and process predictor fields from large-scale models

To load the reanalysis or large-scale model data we use the Predictor class. This example shows how to use the Total Column of Water Vapor Flux from the ERA20C reanalysis. In this reanalysis the components U and V of the TCWVF are named '71.162' and '72.162'. The predictor is set or the years 1900-1910, for each day only the 12:00 is selected through the grouping argument, the domain is 80ºN-20ºN, 60ºW-20ºE. The mosaic argument set to True concatenates both components U and V in the longitude axis to obtain a single compound variable of size (time x 2*longitude x latitude):

# Get file paths
predictor_files = rascal.utils.get_files(
    nwp_path='./data/reanalysis/era20c/',
    variables=['71.162', '72.162'],
    dates=[1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910],
    file_format=".grib"
)

# Generate Predictor
predictors = rascal.analogs.Predictor(
    paths=predictor_files,
    grouping='12h_1D_mean',
    lat_min=20,
    lat_max=80,
    lon_min=-60,
    lon_max=20,
    mosaic=True
)

3) Perform Principal Component Analysis on the predictor fields

The Principal Component Analysis (PCA) of the compund variable standardized anomalies, with 4 principal components and for the conventionan seasons DJF, MAM, JJA, and SON, is conducted as follows:

predictor_pcs = predictors.pcs(
    npcs=n_components,
    seasons=[[12, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]],
    standardize=True,
    path="./tmp/"
)

4) Look at the PC space to find analog days in the historical data

After performing the PCA, the obtained values of the principal componets act as the predictor used to perform the reconstructions. First the analog days, in order of euclidean distance, are found.

analogs = rascal.analogs.Analogs(pcs=predictor_pcs, observations=station_data, dates=test_dates)

5) Reconstruct or extend missing observational data

Later, the reconstuctions are made using one of the following similarity methods: closest, average, or quantilemap.

reconstruction = analogs.reconstruct(
    pool_size=30,
    method='closest',
)

6) Evaluate the reconstructions based on your scientific goals

The evaluation of the reconstructions is made with the RSkill class. The Jupyter Notebook 'RASCAL_evaluation' contains examples of applications

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rascal_ties-1.0.7.tar.gz (24.6 MB view details)

Uploaded Source

Built Distribution

rascal_ties-1.0.7-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file rascal_ties-1.0.7.tar.gz.

File metadata

  • Download URL: rascal_ties-1.0.7.tar.gz
  • Upload date:
  • Size: 24.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.12

File hashes

Hashes for rascal_ties-1.0.7.tar.gz
Algorithm Hash digest
SHA256 c3b5edffad53bf04b392e191e5a2344af9854f7796acd98d814cd06fbf31e555
MD5 0254b41ee8321d2f272574238d31fdf6
BLAKE2b-256 c5115010f79dad282bafb37eea5507a7d6fd6d73ecac0e520e7bf7938673858b

See more details on using hashes here.

File details

Details for the file rascal_ties-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: rascal_ties-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.12

File hashes

Hashes for rascal_ties-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3aaebc37eec3dd7df84223e7cdf62cf7f9b071fc7be193b047f0d11a455256be
MD5 664a4515df911c4fad9784910c1d2e47
BLAKE2b-256 c7eca5552fb20c3f32701ea8e4e091ca258c14cffaeccb52cee4a14b7d858f9b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page