Skip to main content

Tools for managing Pastas time series models.

Project description

pastastore Documentation Status Codacy Badge Codacy Badge PyPI

pastastore

This module stores Pastas time series and models in a database.

Storing time series and models in a database allows the user to manage time series and Pastas models on disk, which allows the user to pick up where they left off without having to reload everything.

Installation

Install the module with pip install pastastore.

For development, clone the repository and install all development, testing, and documentation dependencies with:

pip install -e .[dev]

For plotting background maps, the contextily and pyproj packages are required. For a full install, including optional dependencies for plotting and labeling data on maps, use: pip install pastastore[optional] Windows users are asked to install rasterio themselves since it often cannot be installed using pip. rasterio is a dependency of contextily.

Usage

The following snippets show typical usage. The first step is to define a so-called Connector object. This object contains methods to store time series or models to the database, or read objects from the database.

The following code creates a PasConnector, which uses Pastas JSON-styled ".pas-files" to save models in a folder on your computer (in this case a folder called pastas_db in the current directory).

import pastastore as pst

# create connector instance
conn = pst.PasConnector(name="pastas_db", path=".")

The next step is to pass that connector to the PastaStore object. This object contains all kinds of useful methods to analyze and visualize time series, and build and analyze models.

# create PastaStore instance
pstore = pst.PastaStore(conn)

Now the user can add time series, models or analyze or visualize existing objects in the database. Some examples showing the functionality of the PastaStore object are shown below:

import pandas as pd
import pastas as ps

# load oseries from CSV and add to database
oseries = pd.read_csv("oseries.csv")
pstore.add_oseries(oseries, "my_oseries", metadata={"x": 100_000, "y": 400_000})

# read oseries from database
oseries = pstore.get_oseries("my_oseries")

# view oseries metadata DataFrame
pstore.oseries

# plot oseries location on map
ax = pstore.maps.oseries()
pstore.maps.add_background_map(ax)  # add a background map

# plot my_oseries time series
ax2 = pstore.plot.oseries(names=["my_oseries"])

# create a model with pastas
ml = ps.Model(oseries, name="my_model")

# add model to database
pstore.add_model(ml)

# load model from database
ml2 = pstore.get_models("my_model")

# export whole database to a zip file
pstore.to_zip("my_backup.zip")

For more elaborate examples, refer to the Notebooks.

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

pastastore-1.13.0.tar.gz (95.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pastastore-1.13.0-py3-none-any.whl (103.1 kB view details)

Uploaded Python 3

File details

Details for the file pastastore-1.13.0.tar.gz.

File metadata

  • Download URL: pastastore-1.13.0.tar.gz
  • Upload date:
  • Size: 95.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pastastore-1.13.0.tar.gz
Algorithm Hash digest
SHA256 ace2a90920a483d78c385042d31bcf8cc8bb12b7fe7da5c195aa968171391fc7
MD5 c18733c2fc3a870c5b4649882195a54d
BLAKE2b-256 38c33635d65a22e48cb638bd6859c0ff866821f8be49a2046689a9829ddda79e

See more details on using hashes here.

File details

Details for the file pastastore-1.13.0-py3-none-any.whl.

File metadata

  • Download URL: pastastore-1.13.0-py3-none-any.whl
  • Upload date:
  • Size: 103.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pastastore-1.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04a691a2809572eeeacb507434cc3a9dfc9874e992f1f233a68ee7db0376d9d1
MD5 f37f14b69da97eb762ad99f6da98d0e9
BLAKE2b-256 546a47d87f94154285640b092e72e4d6fb7bbdad495b897ff09caa834a9168b0

See more details on using hashes here.

Supported by

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