Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PSR Factory

Factory is a library that helps to manage SDDP cases. It contains functions that create, load, and save studies, and also functions that create, access, and modify objects in a study.

Installation

Open the command prompt and run the following command:

pip install psr-factory

Factory will be available to all Python scripts in your system after importing it:

import psr.factory

Usage sample

import psr.factory

study = psr.factory.load_study(r"C:\temp\my\study")
system_1 = study.find("System.*")[0]

battery = study.create("Battery")
battery.code = 1
battery.name = "Battery 1"
battery.set("InstalledCapacity", 10.0)
battery.set("RefSystem", system_1)
study.add(battery)

study.save(r"C:\temp\my\updated_study")

Reading results

load_dataframe reads a result file whole. When one is too large for that -- an hourly case easily is -- scan_dataframe reads it in batches, so memory follows the batch size and not the file size:

import psr.factory

with psr.factory.scan_dataframe(r"C:\case\gerter.hdr",
                                batch_rows=100_000,
                                filter_agents=["Thermal 1"]) as scan:
    peak = max(float(batch["Thermal 1"].max()) for batch in scan)

psr.factory.write_dataframe(destination, scan) writes one back the same way, so a whole file-to-file transform never holds either end. Batches are ordinary DataFrame objects: index them with numpy, or convert with to_pandas() / to_polars(), or hand them straight to pyarrow, polars or DuckDB through the Arrow protocol.

Setting psr.factory.set_setting("FAST_RESULT_READER", True) selects a faster reader for the common result formats, falling back automatically for the rest.

Full documentation

The full documentation and reference is available at https://docs.psr-inc.com/knowledgehub/solutions/additional_tools/factory/getting_started/introduction.html.

Releases

New releases can be found in PyPI website at https://pypi.org/project/psr-factory.

And the release notes at https://psrenergy-docs.github.io/factory/releases.html.

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

psr_factory-5.0.0b152-py3-none-win_amd64.whl (13.8 MB view details)

Uploaded Python 3Windows x86-64

File details

Details for the file psr_factory-5.0.0b152-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for psr_factory-5.0.0b152-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 ad5603a8b0344986230e84569bed3c4caf3de80b912184d5ed0dca1220dacfe9
MD5 e5945cf025c186f3b749ec38b03f64f1
BLAKE2b-256 e9a027cf8484a41e379707b9bba51301903e6e50b4d8de29e78e1fcefb93b6ac

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

5.0.0b152 This release

1 file

5.0.0b67

1 file

5.0.0b2

1 file

5.0.0b1

1 file

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