22from pathlib import Path
33
44import click
5+ import plotly .graph_objects as go
56from rich .logging import RichHandler
67
78from .cold import cold_cli , import_weather , ColdConfig , Repartition
@@ -65,7 +66,10 @@ def validate_float_between_0_and_1(ctx, param, value):
6566 default = 1 / 2 ,
6667 help = "Share of cold energy within consumption associated to low activity on weekend profile consummed in a temperature sensitive manner" ,
6768)
69+ @click .option ("-start" , "--date-start" , default = None , help = "date start" )
70+ @click .option ("-end" , "--date-end" , default = None , help = "date end" )
6871@click .option ("-v" , "--verbose" , is_flag = True , help = "Enable debug logging" )
72+ @click .option ("-s" , "--show" , is_flag = True , help = "Show graphs of the result" )
6973def cold (
7074 weather_csv ,
7175 output_csv ,
@@ -75,14 +79,18 @@ def cold(
7579 full_week_share ,
7680 full_week_temperature_sensitivity ,
7781 week_end_temperature_sensitivity ,
82+ date_start ,
83+ date_end ,
7884 verbose ,
85+ show ,
7986):
8087 logging .basicConfig (
8188 level = logging .DEBUG if verbose else logging .INFO ,
8289 format = "%(message)s" ,
8390 handlers = [RichHandler (rich_tracebacks = True )],
8491 )
85- weather = import_weather (Path (weather_csv ))
92+ weather = import_weather (Path (weather_csv )).loc [date_start :date_end ]
93+ logging .debug (weather .index .max ())
8694 cold_config = ColdConfig (
8795 set_temperature ,
8896 loss ,
@@ -110,6 +118,40 @@ def cold(
110118 result = cold_cli (weather , year_energy_reference , cold_config )
111119 result .to_csv (Path (output_csv ), sep = ";" , float_format = "%.2f" )
112120
121+ if show :
122+ daily_temperature = weather .resample ("d" ).mean ()
123+ go .Figure (
124+ [
125+ go .Scattergl (
126+ x = weather .index ,
127+ y = result ["total_consumption_kW" ],
128+ name = "Total cold consumption" ,
129+ yaxis = "y1" ,
130+ ),
131+ go .Scattergl (
132+ x = daily_temperature .index ,
133+ y = daily_temperature ,
134+ name = "Daily outdoor temperature" ,
135+ yaxis = "y2" ,
136+ marker_color = "#1f77b4" ,
137+ marker_opacity = 0.5 ,
138+ line_dash = "dash" ,
139+ ),
140+ ],
141+ ).update_layout (
142+ hovermode = "x unified" ,
143+ yaxis = dict (
144+ title_text = "Power (<b>kW</b>)" ,
145+ ),
146+ yaxis2 = dict (
147+ title_text = "Temperature (<b>°C</b>)" ,
148+ anchor = "x" ,
149+ overlaying = "y" ,
150+ side = "right" ,
151+ range = [- 5 , 40 ],
152+ ),
153+ ).show ()
154+
113155
114156if __name__ == "__main__" :
115157 cli ()
0 commit comments