Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pvlib
- import pandas as pd
- import psutil
- import os
- cec_modules = pvlib.pvsystem._parse_raw_sam_df('/media/share/libraries/CEC Modules.csv')
- # Following parameters are set as defaults as suggested in the PVLib source code
- cec_modules.loc['b', :] = 0.05
- cec_modules.loc['EgRef', :] = 1.121
- cec_modules.loc['dEgdT', :] = -0.0002677
- cec_inverters = pvlib.pvsystem._parse_raw_sam_df('/media/share/libraries/cecinverter.csv')
- def get_system():
- return pvlib.pvsystem.PVSystem(surface_tilt=25,
- surface_azimuth=180,
- inverter='Siemens_Industry__SINVERT_PVM20_UL_480V__CEC_2012_',
- module='Canadian_Solar_CS5P_235P',
- inverter_parameters=cec_inverters['Siemens_Industry__SINVERT_PVM20_UL_480V__CEC_2012_'],
- module_parameters=cec_modules['Canadian_Solar_CS5P_235P'],
- name='test')
- def get_location():
- return pvlib.location.Location(latitude=50.936389, longitude=6.952778, altitude=50)
- def get_mc(system, location):
- return pvlib.modelchain.ModelChain(system, location,
- dc_model='singlediode', ac_model='snlinverter', spectral_model='no_loss',
- temp_model='sapm', aoi_model='ashrae', solar_position_method='nrel_numba',
- transposition_model='haydavies', losses_model='pvwatts',
- clearsky_model='simplified_solis', orientation_strategy=None)
- def get_weather(mc, times):
- weather = pd.DataFrame(index=times, data={'temp_air': 20, 'wind_speed': 5})
- weather[['ghi', 'dni', 'dhi']] = mc.location.get_clearsky(mc.solar_position.index,
- mc.clearsky_model)
- return weather
- def get_mem_usage(process):
- return process.memory_info()[0] / float(2 ** 20)
- times = pd.DatetimeIndex(start='2018-06-18 00:00', end='2018-06-19 00:00', freq='15min')
- result = pd.DataFrame(data={'output': 0}, index=[times])
- rg = 30
- process = psutil.Process(os.getpid())
- mem_usage = pd.Series(index=range(rg))
- for i in range(rg):
- system = get_system()
- location = get_location()
- mc = get_mc(system, location)
- mc.solar_position = mc.location.get_solarposition(times)
- weather = get_weather(mc, times)
- mc.run_model(times=times, weather=weather)
- print('{} of {}'.format(i, rg))
- result['output'] += mc.ac
- mem_usage[i] = get_mem_usage(process)
- print('Mem_usage with pvlib version {}'.format(pvlib.__version__))
- print(mem_usage)
- mem_usage.to_csv('/media/share/mem_usage.csv', sep=';', decimal=',', header=True)
Add Comment
Please, Sign In to add comment