Skip to content

Commit

Permalink
Adjusts svg repr to the min/max values of the schedule (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Letellier-Duchesne committed Dec 3, 2021
1 parent 778fbb6 commit e99880f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 13 additions & 2 deletions archetypal/schedule.py
Expand Up @@ -1294,7 +1294,11 @@ def series(self):
index = pd.date_range(
start=self.startDate, periods=self.all_values.size, freq="1H"
)
return EnergySeries(self.all_values, index=index, name=self.Name)
if self.Type is not None:
units = self.Type.UnitType
else:
units = None
return EnergySeries(self.all_values, index=index, name=self.Name, units=units)

@staticmethod
def get_schedule_type_limits_name(epbunch):
Expand Down Expand Up @@ -1489,7 +1493,14 @@ def __mul__(self, other):

def _repr_svg_(self):
"""SVG representation for iPython notebook."""
fig, ax = self.series.plot2d(cmap="Greys", show=False, figsize=(7, 2), dpi=72)
if self.Type is not None:
vmin = self.Type.LowerLimit
vmax = self.Type.UpperLimit
else:
vmin, vmax = (0, 0)
fig, ax = self.series.plot2d(
cmap="Greys", show=False, figsize=(7, 2), dpi=72, vmin=vmin, vmax=vmax
)
f = io.BytesIO()
fig.savefig(f, format="svg")
return f.getvalue()
Expand Down
7 changes: 6 additions & 1 deletion archetypal/settings.py
Expand Up @@ -128,7 +128,12 @@

from energy_pandas.units import unit_registry

unit_registry = unit_registry
additional_units = (
"Dimensionless = dimensionless = Fraction",
"@alias degC = Temperature",
)
for unit in additional_units:
unit_registry.define(unit)


class ZoneWeight(object):
Expand Down

0 comments on commit e99880f

Please sign in to comment.