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.9.tar.gz (25.8 MB view details)

Uploaded Source

Built Distribution

rascal_ties-1.0.9-py3-none-any.whl (33.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rascal_ties-1.0.9.tar.gz
  • Upload date:
  • Size: 25.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for rascal_ties-1.0.9.tar.gz
Algorithm Hash digest
SHA256 0585b4326cb40d11388f026b51737637336b90befa0cc080ca568d2d428e2975
MD5 96ad048e256e4c97db44a17621bd14f1
BLAKE2b-256 0cd3a6161034689e18c923f72b324d1736f06520410ea8a92ec00f8ccbf9ab34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rascal_ties-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 33.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for rascal_ties-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 e6615298fa05d7053bb119e4e2ea413e40487235c0dd365649ae145369a2d095
MD5 7d3b7c465a6f179e74718a9a7268a0e2
BLAKE2b-256 47eabf5cec09742659ac401351cc907e70316379f38d1f39a5a89fc4a25fcedc

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