MCPcopy Create free account
hub / github.com/ahalev/python-microgrid / plot

Method plot

src/pymgrid/utils/DataGenerator.py:532–592  ·  view source on GitHub ↗
(self, stacked_data, days_to_plot=(0,10),
             plot_sample=True, plot_original=True, plot_upper_lower_bounds=True, plot_points_of_distribution=False,
             plot_daily_maxes=False, plot_parabolas=False, month_xticks=False)

Source from the content-addressed store, hash-verified

530 return new_stacked_data
531
532 def plot(self, stacked_data, days_to_plot=(0,10),
533 plot_sample=True, plot_original=True, plot_upper_lower_bounds=True, plot_points_of_distribution=False,
534 plot_daily_maxes=False, plot_parabolas=False, month_xticks=False):
535
536 if isinstance(stacked_data, pd.DataFrame):
537 stacked_data = stacked_data.squeeze()
538
539 if not isinstance(stacked_data, pd.Series):
540 if plot_sample:
541 print('Warning: stacked_data is an arbitrary sample. Must be pd.Series to plot passed stacked_data, is '
542 '{}'.format((type(stacked_data))))
543 stacked_data = self.sample()
544
545 indices = slice(24 * days_to_plot[0], 24 * days_to_plot[1])
546 daily_slice = slice(*days_to_plot)
547 if plot_sample:
548 plt.plot(stacked_data[indices].index, stacked_data[indices].values, label='Sample')
549
550 if plot_original:
551 plt.plot(stacked_data[indices].index, self.unmunged_data[indices].values, label='Original')
552
553 if plot_upper_lower_bounds:
554 plt.plot(stacked_data[indices].index,
555 self.most_light_curve_eval('max', cumulative_hours=stacked_data[indices].index), color='k',
556 label='Parabola distribution UB')
557
558 plt.plot(stacked_data[indices].index,
559 self.most_light_curve_eval('min', cumulative_hours=stacked_data[indices].index), color='c',
560 label='Parabola distribution LB')
561
562 if plot_points_of_distribution:
563 if self.distribution_bounds is None:
564 raise RuntimeError('Could not find distribution bounds, must call \'sample\' at least once to plot')
565 else:
566 lower_distribution_bounds, upper_distribution_bounds = self.distribution_bounds
567
568 plt.scatter(self.daily_maxes['cumulative_hr'].iloc[daily_slice], lower_distribution_bounds[daily_slice],
569 marker='.', color='r')
570 plt.scatter(self.daily_maxes['cumulative_hr'].iloc[daily_slice], upper_distribution_bounds[daily_slice],
571 marker='.', color='r')
572
573 if plot_daily_maxes:
574 plt.scatter(self.daily_maxes['cumulative_hr'].iloc[daily_slice],self.daily_maxes['max_GHI'].iloc[daily_slice],
575 marker='.', color='r', label='Underlying daily max pv')
576 if plot_parabolas:
577 parabolas = self.parabolic_baseline.transpose().stack().squeeze()
578 print(parabolas)
579 plt.plot(stacked_data[indices].index, parabolas.iloc[indices],color='c',label='Parabolic Baseline')
580 if month_xticks:
581 print(plt.xticks())
582 locs = [j*30*24 for j in range(13) if j*12>=days_to_plot[0] and j*12<=days_to_plot[1]]
583 ticks = [j for j in range(13) if j*12>=days_to_plot[0] and j*12<=days_to_plot[1]]
584 print(locs)
585 print(ticks)
586 plt.xticks(locs, ticks)
587
588 plt.xlabel('Month')
589 plt.ylabel('PV')

Callers 5

sampleMethod · 0.95
plotMethod · 0.45
plotMethod · 0.45
print_cumsum_costMethod · 0.45

Calls 2

sampleMethod · 0.95
most_light_curve_evalMethod · 0.95

Tested by

no test coverage detected