Skip to content

Netcdf Importer

pyconvexity.io.netcdf_importer

NetCDF importer for PyConvexity energy system models. Imports PyPSA NetCDF files into PyConvexity database format.

NetCDFModelImporter

Import PyPSA NetCDF files into PyConvexity database format

import_netcdf_to_database(netcdf_path: str, db_path: str, network_name: str, network_description: Optional[str] = None, progress_callback: Optional[Callable[[int, str], None]] = None, strict_validation: bool = False) -> Dict[str, Any]

Import a PyPSA NetCDF file into a new database.

Parameters:

Name Type Description Default
netcdf_path str

Path to the PyPSA NetCDF file

required
db_path str

Path where to create the database

required
network_name str

Name for the imported network

required
network_description Optional[str]

Optional description

None
progress_callback Optional[Callable[[int, str], None]]

Optional callback for progress updates (progress: int, message: str)

None
strict_validation bool

Whether to skip undefined attributes rather than failing completely. If True, will fail on any attribute not defined in the database schema. If False (default), will skip undefined attributes with warnings.

False

Returns:

Type Description
Dict[str, Any]

Dictionary with import results and statistics

import_csv_to_database(csv_directory: str, db_path: str, network_name: str, network_description: Optional[str] = None, progress_callback: Optional[Callable[[int, str], None]] = None, strict_validation: bool = False) -> Dict[str, Any]

Import a PyPSA network from CSV files into a new database.

Parameters:

Name Type Description Default
csv_directory str

Path to the directory containing PyPSA CSV files

required
db_path str

Path where to create the database

required
network_name str

Name for the imported network

required
network_description Optional[str]

Optional description

None
progress_callback Optional[Callable[[int, str], None]]

Optional callback for progress updates (progress: int, message: str)

None
strict_validation bool

Whether to skip undefined attributes rather than failing

False

Returns:

Type Description
Dict[str, Any]

Dictionary with import results and statistics