Skip to main content

SynthDataGen

Usage

This app is designed to be use in the following way:

  1. Load the data either from ESIOS or from a local CSV file which contains a pandas.DataFrame-like table.
  2. Apply the needed adjustments by
    • Applying a multiplication factor by year to all the rows
    • Upsampling or downsampling the data by means of different techniques
  3. Get samples from the DataFrame, following the available probability distributions, for each row.

Workflow and usage

  1. Depending on the used loader (ESIOSLoader, LocalDFLoader, etc.), the corresponding attributes are expected to be specified in the corresponding nested dictionary in the input parameters file:

    • "ESIOS": the fields for the access token, the particular indicator and the granularity for the data to be requested.
    • "LocalDF": the directory and name of the CSV file containing the DataFrame to be loaded, the variable name to get (indicator), whether to skip the first column or not, and the datetime format of the index column.
  2. The Loader.getDataFromSource(...) method receive a number of parameters, which are used as filters against the loaded DataFrame. So, the resulting DataFrame will start from an

    • initial year, and consider
    • from an initial datetime (default value: 'now')
    • a number of hours ahead.
    • Besides, whether to discard the February 29 or not should also be specified.
  3. The adjustments by year method receives a dictionary <year,adjustmentValue> = <int,int|float>. It is used for inflation or similar adjustments of a DataFrame. It is specified in percentage, so a 10 indicate a positive adjustment of a 10%, a -32.0 represents a negative adjustment of 32%, and a 347.89 represents just that.

  4. In case a posterior upsampling or downsampling of the data wanted to be performed, the corresponding methods are used to specify the granularity when running the Adjustments.upsample(...) and Adjustments.downsample(...) methods.

    • The granularity (here frequency) should be an integer followed by a unit ('D': daily, 'H': hourly, 'T': minutely, 'S': secondly). E.g. "2T" == and entry for every 2 minutes.
    • The interpolation method and the aggregation function for upsampling and downsampling respectively, should be specified too.
  5. Finally, for sampling the current data by means of te Sampling.getSamples(...) method, we should provide

    • a number of desired samples to be generated
    • and the probability distribution to consider.

Examples

A similar example has been included and extended in the ./notebooks/fullExample.ipynb Jupyter notebook.

import synthDataGen.controller as controller
from datetime import datetime

controller = controller.LocalDFLoader("./synthDataGen/settings/inputParams.json")
df = controller.getDataFromSource(initialYear=2007, datetime.now(), hoursAhead=10, include29February=False)

# DataFrame adjustments
from synthDataGen.adjustments import FactorByYear, ChangeResolution

df = FactorByYear.run(df, adjustmentsDict={2022: 10, 2021: 10, 2020: 10, 2019: 10, 2018: 10, 2017: 10, 2016: 10, 2015: 10, 2014: 10, 2013: 10, 2012: 10, 2011: 10, 2010: 10, 2009: 10, 2008: 10, 2007: 10})

# Up/down sampling
df = ChangeResolution.upsample(df, frequency="15T", method="polynomial", order=2)
df = ChangeResolution.downsample(df, frequency="2H", aggregationFunc="mean")

# Samples generation
from synthDataGen.utils import Sampling

df = Sampling.getSamples(df, 5000, "truncnorm")

Acknowledgements

© Copyright 2024, Germán Navarro $^\dagger$, Santiago Fernández Prieto $^{\ddagger,1}$, David Aller Giraldez $^\ddagger$, Ricardo Enríquez Miranda $^{\ddagger,2}$, Javier Hernanz Zájara $^{\ddagger,2}$,

$^\dagger$ Barcelona Supercomputing Center
$^\ddagger$ Repsol

$^1$ Repsol-BSC Research Center

$^2$ Repsol Quantum Advisory Team

Developed within the framework of the project CUCO. Financed by the CDTI and with the support of the Spanish Ministry of Science and Innovation under the Recovery, Transformation and Resilience Plan (RTRP).

Metadata

Release files for synthDataGen 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for synthDataGen 0.4
File Size Uploaded Provenance Actions
synthdatagen-0.4.tar.gz 27.3 kB Without provenance Details for synthdatagen-0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for synthDataGen 0.4
File Interpreter ABI Platform Actions
synthDataGen-0.4-py3-none-any.whl Python 3 none any Details for synthDataGen-0.4-py3-none-any.whl

Total release size: 53.2 kB

Release files / synthdatagen-0.4.tar.gz

Download URL synthdatagen-0.4.tar.gz
Size 27.3 kB
Tags Source
SHA-256 checksum
How to use checksums
261df566f85162bdaf6f0f7ac0ae87bd7a2cd55720272d10e12948b2ecf05643
BLAKE2b-256 checksum
How to use checksums
95e0417e221ff53f2260e38a0e0ac239737574a287ea24d604e64e324165f194
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / synthDataGen-0.4-py3-none-any.whl

Download URL synthDataGen-0.4-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c46cefcc9488ed86f5276cb60bf3f1ecc617235f78a68326ee2a3208452ba87
BLAKE2b-256 checksum
How to use checksums
c918c3fc234f6ee8128c4b4c0d5bf21ba0631e23ebc03446dedd1c095905c24b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for synthDataGen 0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page