-
Notifications
You must be signed in to change notification settings - Fork 438
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
Port consideration in statistics module #860
Conversation
…gument, modularize and add functions
add gross revenue test
@@ -119,6 +129,11 @@ def get_ports(n, c): | |||
return [col[3:] for col in n.df(c) if col.startswith("bus")] | |||
|
|||
|
|||
def get_stacked_ports(n, c): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this function, because currently it is not used?
elif isinstance(groupby, str): | ||
by = n.df(c)[groupby] | ||
elif isinstance(groupby, dict): | ||
# TODO: fix kwargs behavior. what is this used for again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was formerly used for the energy balance, where we wanted group by the index levels so we needed something like {"level":["bus", "carrier", "bus_carrier"]}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can now remove it
|
||
ports = n.df(c).loc[df.index, f"bus{port}"] | ||
port_carriers = ports.map(n.buses.carrier) | ||
if isinstance(bus_carrier, str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here it would be nice to have somehing like I did before, that we fist check if the string
is in n.buses.carrier.unique() and if not we look if the bus_carriers contain the string
if isinstance(bus_carrier, str): | ||
return df[port_carriers == bus_carrier] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like:
if isinstance(bus_carrier, str): | |
return df[port_carriers == bus_carrier] | |
if isinstance(bus_carrier, str): | |
if bus_carrier in n.buses.carrier.unique(): | |
return df[port_carriers == bus_carrier] | |
else: | |
return df[bus_carrier in port_carriers] |
return [n.df(c)[bus].rename("bus"), get_carrier(n, c, nice_names=nice_names)] | ||
|
||
|
||
def get_bus_unit_and_carrier(n, c, port="", nice_names=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should add it to Groupers
if kind is not None: | ||
if kind == "input": | ||
df = df.clip(lower=0) | ||
elif kind == "output": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the wrong way round
elif kind == "output": | |
df = df.clip(upper=0) |
df = aggregate_components( | ||
n, | ||
func, | ||
if aggregate_bus: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe also add the other attributes from dispatch like groupby
to the energy_balance and add warning that with aggregate_bus=True
, this attribute will be ignored
The statistics module introduces a new keyword argument
at_port
to all functions. This allows considering the port of a component when calculating statistics. Depending on the function, the default ofat_port
is set toTrue
orFalse
, for example for the dispatch all ports are considered.The statistics module now supports an optional
port
argument ingroupby
functions. This allows to group statistics while considering the port of a component.The
statistics.revenue
function introduces a new keyword argumentkind
to optionally calculate the revenue based on theinput
commodity or theoutput
commodity of a component.Checklist
doc
.environment.yaml
,environment_docs.yaml
andsetup.py
(if applicable).doc/release_notes.rst
of the upcoming release is included.