Skip to content

Latest commit

 

History

History
100 lines (54 loc) · 4.97 KB

File metadata and controls

100 lines (54 loc) · 4.97 KB
graph LR
    pypsa_network_io["pypsa.network.io"]
    _import_from_importer["_import_from_importer"]
    _export_to_exporter["_export_to_exporter"]
    _Importer_["_Importer*"]
    _Exporter_["_Exporter*"]
    writer["writer"]
    _retrieve_from_url["_retrieve_from_url"]
    _sort_attrs["_sort_attrs"]
    pypsa_network_io -- "orchestrates" --> _import_from_importer
    pypsa_network_io -- "orchestrates" --> _export_to_exporter
    pypsa_network_io -- "orchestrates" --> _retrieve_from_url
    _import_from_importer -- "calls" --> _Importer_
    _import_from_importer -- "uses" --> _sort_attrs
    _export_to_exporter -- "calls" --> _Exporter_
    _export_to_exporter -- "leverages" --> writer
Loading

CodeBoardingDemoContact

Details

The Data I/O & Persistence subsystem in PyPSA is primarily encapsulated within the pypsa.network.io module. This subsystem is crucial for managing the flow of network data into and out of the PyPSA environment, supporting various file formats and external data sources.

pypsa.network.io

Acts as the public facade for all data import and export operations. It provides a unified interface for users to load and save PyPSA network models, abstracting away the complexities of different file formats. This aligns with the "Abstraction Layer" pattern, simplifying user interaction.

Related Classes/Methods:

_import_from_importer

Manages the overall data import workflow. It dynamically selects and invokes the appropriate format-specific importer (_Importer*) based on the input file type, ensuring correct parsing and integration of external data into the PyPSA network structure. This embodies the "Pipeline/Workflow" pattern for data ingestion.

Related Classes/Methods:

_export_to_exporter

Coordinates the data export workflow. It selects and delegates to the correct format-specific exporter (_Exporter*) to write the PyPSA network data to the desired output format. This also follows the "Pipeline/Workflow" pattern for data egress.

Related Classes/Methods:

_Importer*

Each _Importer* class is responsible for the low-level details of parsing and reading network data from a specific file format (e.g., CSV, HDF5, NetCDF). This modularity allows for easy extension to new formats without altering the core I/O logic, adhering to the "Modular Design" and "Extensibility" principles.

Related Classes/Methods:

_Exporter*

Similar to importers, each _Exporter* class handles the specific logic for writing PyPSA network data to a particular file format. This separation of concerns enhances maintainability and extensibility.

Related Classes/Methods:

writer

Provides common utility functions for writing different categories of network data (e.g., components, attributes) to the chosen export format. It centralizes repetitive writing tasks, promoting code reuse.

Related Classes/Methods:

_retrieve_from_url

Handles the fetching of network data from external URLs, acting as a preliminary step before the data is passed to the import orchestrator. This supports flexible data sourcing.

Related Classes/Methods:

_sort_attrs

Ensures that attributes are consistently ordered or processed during the import phase, which is crucial for maintaining data integrity and predictability in a scientific computing context.

Related Classes/Methods: