Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow node params on links #736

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/calliope/preprocess/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
from collections.abc import Hashable
from pathlib import Path
import warnings

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -154,7 +155,7 @@ def node_dict(self, techs_incl_inheritance: AttrDict) -> AttrDict:
techs_incl_inheritance[tech].get("base_tech", None)
== "transmission"
):
self._raise_error(
self._raise_warning(
"Cannot define transmission technology data over the `nodes` dimension"
Copy link
Contributor Author

@jnnr jnnr Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we change the message to something like this?
"Trying to define transmission technology data over the nodes dimension. Be sure that you know what you are doing."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want a more descriptive message, stating the possible error that this might create.

)
else:
Expand Down Expand Up @@ -361,6 +362,10 @@ def _check_processed_tdf(self, tdf: pd.Series):
if len(unique_index_names) != len(tdf.index.names):
self._raise_error(f"Duplicate dimension names found: {tdf.index.names}")

def _raise_warning(self, message):
"""Format warning message and then raise Calliope ModelWarning."""
warnings.warn(self.MESSAGE_TEMPLATE.format(name=self.name, message=message), exceptions.ModelWarning)

def _raise_error(self, message):
"""Format error message and then raise Calliope ModelError."""
raise exceptions.ModelError(
Expand Down