Guest User

Untitled

a guest
Jun 20th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. import pvlib
  2. import pandas as pd
  3.  
  4. import psutil
  5. import os
  6.  
  7. cec_modules = pvlib.pvsystem._parse_raw_sam_df('/media/share/libraries/CEC Modules.csv')
  8. # Following parameters are set as defaults as suggested in the PVLib source code
  9. cec_modules.loc['b', :] = 0.05
  10. cec_modules.loc['EgRef', :] = 1.121
  11. cec_modules.loc['dEgdT', :] = -0.0002677
  12. cec_inverters = pvlib.pvsystem._parse_raw_sam_df('/media/share/libraries/cecinverter.csv')
  13.  
  14.  
  15. def get_system():
  16. return pvlib.pvsystem.PVSystem(surface_tilt=25,
  17. surface_azimuth=180,
  18. inverter='Siemens_Industry__SINVERT_PVM20_UL_480V__CEC_2012_',
  19. module='Canadian_Solar_CS5P_235P',
  20. inverter_parameters=cec_inverters['Siemens_Industry__SINVERT_PVM20_UL_480V__CEC_2012_'],
  21. module_parameters=cec_modules['Canadian_Solar_CS5P_235P'],
  22. name='test')
  23.  
  24.  
  25. def get_location():
  26. return pvlib.location.Location(latitude=50.936389, longitude=6.952778, altitude=50)
  27.  
  28.  
  29. def get_mc(system, location):
  30. return pvlib.modelchain.ModelChain(system, location,
  31. dc_model='singlediode', ac_model='snlinverter', spectral_model='no_loss',
  32. temp_model='sapm', aoi_model='ashrae', solar_position_method='nrel_numba',
  33. transposition_model='haydavies', losses_model='pvwatts',
  34. clearsky_model='simplified_solis', orientation_strategy=None)
  35.  
  36.  
  37. def get_weather(mc, times):
  38. weather = pd.DataFrame(index=times, data={'temp_air': 20, 'wind_speed': 5})
  39.  
  40. weather[['ghi', 'dni', 'dhi']] = mc.location.get_clearsky(mc.solar_position.index,
  41. mc.clearsky_model)
  42. return weather
  43.  
  44.  
  45. def get_mem_usage(process):
  46. return process.memory_info()[0] / float(2 ** 20)
  47.  
  48.  
  49. times = pd.DatetimeIndex(start='2018-06-18 00:00', end='2018-06-19 00:00', freq='15min')
  50. result = pd.DataFrame(data={'output': 0}, index=[times])
  51. rg = 30
  52.  
  53. process = psutil.Process(os.getpid())
  54. mem_usage = pd.Series(index=range(rg))
  55.  
  56. for i in range(rg):
  57. system = get_system()
  58. location = get_location()
  59. mc = get_mc(system, location)
  60.  
  61. mc.solar_position = mc.location.get_solarposition(times)
  62.  
  63. weather = get_weather(mc, times)
  64.  
  65. mc.run_model(times=times, weather=weather)
  66.  
  67. print('{} of {}'.format(i, rg))
  68.  
  69. result['output'] += mc.ac
  70.  
  71. mem_usage[i] = get_mem_usage(process)
  72.  
  73.  
  74. print('Mem_usage with pvlib version {}'.format(pvlib.__version__))
  75. print(mem_usage)
  76. mem_usage.to_csv('/media/share/mem_usage.csv', sep=';', decimal=',', header=True)
Add Comment
Please, Sign In to add comment