pvlib

PVLIB - plot of power against time of several days


I want to get a plot output comparing AC output during a day but at different dates (e.g. June, December). That should be the overlay of the results of several days with the x-axis only having the time, not the date. I.e. the x-axis should be time independent. I don't know how to get rid of the date before plotting leaving just the time of the day. Here's my code:

import pvIdealModule
import matplotlib.pyplot as plt
from pvlib import pvsystem, modelchain, location
import pandas as pd

def run(beginTime, endTime):
    array_kwargs = dict(
        module_parameters=dict(pdc0=0.385, gamma_pdc=-0.004),
        temperature_model_parameters=dict(a=-3.47, b=-0.0594, deltaT=3)
    )   
    
    arrays = [
        pvsystem.Array(pvsystem.FixedMount(40, 88), name='East',
                       modules_per_string=12,
                       **array_kwargs),
        pvsystem.Array(pvsystem.FixedMount(40, 268), name='West',
                       modules_per_string=10,
                       **array_kwargs),
        ]
    
    # latitude, longitude, TZ, height, name
    timeZone = 'Europe/Berlin'
    loc = location.Location(51.3, 9.5, timeZone)
    system = pvsystem.PVSystem(arrays=arrays, inverter_parameters=dict(pdc0=8))
    mc = modelchain.ModelChain(system, loc, aoi_model='physical',
                               spectral_model='no_loss')
    
    times = pd.date_range(beginTime, endTime, freq='5min', tz=timeZone)
    weather = loc.get_clearsky(times)    
       
    mc.run_model(weather)
     
    return mc, system


plt.rcParams['figure.figsize'] = [20, 12]
fig, ax = plt.subplots()

mc, system = pvIdealModule.run('2022-03-21 05:00', '2022-03-21 21:30')    
mc.results.ac.plot(label='March')

mc, system = pvIdealModule.run('2022-06-21 05:00', '2022-06-21 21:30')    
mc.results.ac.plot(label='June')

mc, system = pvIdealModule.run('2022-09-23 05:00', '2022-09-23 21:30')    
mc.results.ac.plot(label='September')

mc, system = pvIdealModule.run('2022-12-21 05:00', '2022-12-21 21:30')    
mc.results.ac.plot(label='December')

plt.ylabel('AC Power')
plt.legend()
plt.show()

That's the result: distributed plot


Solution

  • You could replace each of these:

    mc.results.ac.plot(label='xxx')
    

    By:

    ac = mc.results.ac
    ac.index = ac.index.time
    ac.plot(label='xxx')