Tools for managing Pastas time series models.
Project description
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 installing in development mode, clone the repository and install by typing
pip install -e .
from the module root directory.
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("my_db", path="./pastas_db")
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("my_project", 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
# 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"])
# export whole database to a zip file
pstore.to_zip("my_db_backup.zip")
For more elaborate examples, refer to the Notebooks.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pastastore-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61f704375e6766eaa93f830bf8148db3ee5436a00799b820ea370e8f8893f7d6 |
|
MD5 | f6dcb35306f34e30727e530a47ac3fa8 |
|
BLAKE2b-256 | fa58d2956aa3b580c95614bbda8353a47a95c0b4b1405ff2845efc44b172b640 |