def single_pv_set(year, key, module_name, inverter_name, orientation): c = config.get_configuration() weatherpath = os.path.join(c.paths['weather'], c.pattern['weather']) weather = pd.read_hdf(weatherpath.format(year=year), 'A' + str(key)) latlon = pd.read_csv(os.path.join(c.paths['geometry'], c.files['grid_centroid']), index_col='gid').loc[key] location = {'latitude': latlon['st_y'], 'longitude': latlon['st_x']} weather = f.adapt_weather_to_pvlib(weather, location) sandia_modules = pvlib.pvsystem.retrieve_sam('sandiamod') sapm_inverters = pvlib.pvsystem.retrieve_sam('sandiainverter') smodule = { 'module_parameters': sandia_modules[module_name], 'inverter_parameters': sapm_inverters[inverter_name], 'surface_azimuth': orientation['azimuth'], 'surface_tilt': orientation['tilt'], 'albedo': 0.2 } p_peak = (smodule['module_parameters'].Impo * smodule['module_parameters'].Vmpo) mc = f.feedin_pvlib_modelchain(location, smodule, weather) ac = mc.ac # .clip(0).fillna(0).div(p_peak) dc = mc.dc.p_mp # .clip(0).fillna(0).div(p_peak) print('ac:', ac.sum()) print('dc:', dc.sum())
def analyse_pv_orientation(year, key, module_name): c = config.get_configuration() weatherpath = os.path.join(c.paths['weather'], c.pattern['weather']) weather = pd.read_hdf(weatherpath.format(year=year), 'A' + str(key)) latlon = pd.read_csv(os.path.join(c.paths['geometry'], c.files['grid_centroid']), index_col='gid').loc[key] location = {'latitude': latlon['st_y'], 'longitude': latlon['st_x']} weather = f.adapt_weather_to_pvlib(weather, location) sandia_modules = pvlib.pvsystem.retrieve_sam('sandiamod') sapm_inverters = pvlib.pvsystem.retrieve_sam('sandiainverter') invertername = 'SMA_America__SB5000US_11_208V__CEC_2007_' azimuth = range(0, 361, 10) tilt = range(0, 91, 10) # df_ts = pd.DataFrame() df_dc = pd.DataFrame() df_ac = pd.DataFrame() df_sun = pd.DataFrame() length = len(azimuth) * len(tilt) # from matplotlib import pyplot as plt for az in azimuth: for tlt in tilt: name = 'az{0}_tlt{1}'.format(az, tlt) logging.info("{0}, {1}".format(name, length)) length -= 1 smodule = { 'module_parameters': sandia_modules[module_name], 'inverter_parameters': sapm_inverters[invertername], 'surface_azimuth': az, 'surface_tilt': tlt, 'albedo': 0.2 } p_peak = (smodule['module_parameters'].Impo * smodule['module_parameters'].Vmpo) mc = f.feedin_pvlib_modelchain(location, smodule, weather) df_dc.loc[az, tlt] = mc.dc.p_mp.clip(0).div(p_peak).sum() df_ac.loc[az, tlt] = mc.ac.clip(0).div(p_peak).sum() # print(mc.total_irrad.columns) # print(mc.total_irrad['poa_global'].fillna(0).div(p_peak).sum()) df_sun.loc[az, tlt] = mc.total_irrad['poa_global'].div(p_peak).sum() # df_ts.to_csv(os.path.join(paths['analysis'], 'orientation_feedin.csv')) df_sun.to_csv(os.path.join(c.paths['analysis'], 'sun.csv')) df_dc.to_csv(os.path.join(c.paths['analysis'], 'orientation_feedin_dc.csv')) df_ac.to_csv(os.path.join(c.paths['analysis'], 'orientation_feedin_ac.csv'))
def analyse_pv_types(year, key, orientation): c = config.get_configuration() weatherpath = os.path.join(c.paths['weather'], c.pattern['weather']) weather = pd.read_hdf(weatherpath.format(year=year), 'A' + str(key)) latlon = pd.read_csv(os.path.join(c.paths['geometry'], c.files['grid_centroid']), index_col='gid').loc[key] location = {'latitude': latlon['st_y'], 'longitude': latlon['st_x']} weather = f.adapt_weather_to_pvlib(weather, location) sandia_modules = pvlib.pvsystem.retrieve_sam('sandiamod') sapm_inverters = pvlib.pvsystem.retrieve_sam('sandiainverter') invertername = 'ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_' for modu in sandia_modules.keys(): if 'BP_Solar' in modu: print(modu) exit(0) df_ts_ac = pd.DataFrame() df = pd.DataFrame() length = len(sandia_modules.keys()) for smod in sandia_modules.keys(): name = smod # .replace('__', '_') logging.info("{0}, {1}".format(name, length)) length -= 1 smodule = { 'module_parameters': sandia_modules[smod], 'inverter_parameters': sapm_inverters[invertername], 'surface_azimuth': orientation['azimuth'], 'surface_tilt': orientation['tilt'], 'albedo': 0.2 } p_peak = (smodule['module_parameters'].Impo * smodule['module_parameters'].Vmpo) mc = f.feedin_pvlib_modelchain(location, smodule, weather) df_ts_ac[name] = mc.ac.clip(0).fillna(0).div(p_peak) df.loc[name, 'ac'] = df_ts_ac[name][:8760].sum() df.loc[name, 'dc_norm'] = mc.dc.p_mp.clip(0).div(p_peak).sum() df.loc[name, 'dc'] = mc.dc.p_mp.clip(0).sum() df.to_csv(os.path.join(c.paths['analysis'], 'module_feedin.csv')) df_ts_ac.to_csv( os.path.join(c.paths['analysis'], 'module_feedin_ac_ts.csv'))
def analyse_inverter(year, key, module_name, orientation): c = config.get_configuration() weatherpath = os.path.join(c.paths['weather'], c.pattern['weather']) weather = pd.read_hdf(weatherpath.format(year=year), 'A' + str(key)) latlon = pd.read_csv(os.path.join(c.paths['geometry'], c.files['grid_centroid']), index_col='gid').loc[key] location = {'latitude': latlon['st_y'], 'longitude': latlon['st_x']} weather = f.adapt_weather_to_pvlib(weather, location) sandia_modules = pvlib.pvsystem.retrieve_sam('sandiamod') sapm_inverters = pvlib.pvsystem.retrieve_sam('sandiainverter') inv = pd.DataFrame() failed = pd.Series() length = len(sapm_inverters.keys()) for sinv in sapm_inverters.keys(): name = sinv # .replace('__', '_') logging.info("{0}, {1}".format(name, length)) length -= 1 smodule = { 'module_parameters': sandia_modules[module_name], 'inverter_parameters': sapm_inverters[sinv], 'surface_azimuth': orientation['azimuth'], 'surface_tilt': orientation['tilt'], 'albedo': 0.2 } p_peak = (smodule['module_parameters'].Impo * smodule['module_parameters'].Vmpo) try: mc = f.feedin_pvlib_modelchain(location, smodule, weather) inv.loc[name, 'ac'] = mc.ac.clip(0).fillna(0).div(p_peak).sum() inv.loc[name, 'dc'] = mc.dc.p_mp.clip(0).fillna(0).div(p_peak).sum() except ValueError: logging.info("Inverter {0} failed.".format(name)) failed.loc[name] = 'failed' inv.to_csv( os.path.join(c.paths['analysis'], 'sapm_inverters_feedin_full2.csv')) failed.to_csv( os.path.join(c.paths['analysis'], 'sapm_inverters_failed.csv'))
def analyse_pv_orientation_region(): c = config.get_configuration() weatherpath = os.path.join(c.paths['weather'], c.pattern['weather']) my_index = pd.MultiIndex(levels=[[], [], []], labels=[[], [], []], names=['coastdat', 'year', 'system']) my_cols = pd.MultiIndex(levels=[[], []], labels=[[], []], names=['type', 'angle']) df = pd.DataFrame(columns=my_cols, index=my_index) key = 1141078 for n in range(22): key += 1 key -= 1000 for year in [2008]: weather = pd.read_hdf(weatherpath.format(year=year), 'A' + str(key)) latlon = pd.read_csv(os.path.join( c.paths['geometry'], c.files['coastdatgrid_centroids']), index_col='gid').loc[key] location = { 'latitude': latlon['st_y'], 'longitude': latlon['st_x'] } weather = f.adapt_weather_to_pvlib(weather, location) sandia_modules = pvlib.pvsystem.retrieve_sam('sandiamod') sapm_inverters = pvlib.pvsystem.retrieve_sam('sandiainverter') systems = { # 1: {'m': 'LG_LG290N1C_G3__2013_', # 'i': 'ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'}, 2: { 'm': 'BP_Solar_BP2150S__2000__E__', 'i': 'SolarBridge_Technologies__P235HV_240_240V__CEC_2011_' }, # 3: {'m': 'Solar_Frontier_SF_160S__2013_', # 'i': 'ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'} } for system in systems.values(): name = system['m'][:2].replace('o', 'F') logging.info("{0} - {1} - {2}".format(key, year, name)) azimuth = np.arange(190, 201, 0.5) tilt = np.arange(32, 39, 0.5) dc = pd.DataFrame() ac = pd.DataFrame() ir = pd.DataFrame() for az in azimuth: for tlt in tilt: smodule = { 'module_parameters': sandia_modules[system['m']], 'inverter_parameters': sapm_inverters[system['i']], 'surface_azimuth': az, 'surface_tilt': tlt, 'albedo': 0.2 } p_peak = (smodule['module_parameters'].Impo * smodule['module_parameters'].Vmpo) mc = f.feedin_pvlib_modelchain(location, smodule, weather) dc.loc[az, tlt] = mc.dc.p_mp.clip(0).div(p_peak).sum() ac.loc[az, tlt] = mc.ac.clip(0).div(p_peak).sum() ir.loc[az, tlt] = mc.total_irrad['poa_global'].clip( 0).sum() dc_max = get_index_of_max(dc) df.loc[(key, year, name), ('dc', 'tilt')] = dc_max[0] df.loc[(key, year, name), ('dc', 'azimuth')] = dc_max[1] ac_max = get_index_of_max(dc) df.loc[(key, year, name), ('ac', 'tilt')] = ac_max[0] df.loc[(key, year, name), ('ac', 'azimuth')] = ac_max[1] ir_max = get_index_of_max(dc) df.loc[(key, year, name), ('ir', 'tilt')] = ir_max[0] df.loc[(key, year, name), ('ir', 'azimuth')] = ir_max[1] df.to_csv( os.path.join(c.paths['analysis'], 'optimal_orientation_multi_BP.csv')) logging.info('Done')
def analyse_performance_ratio(year, key): c = config.get_configuration() sets = dict() set_ids = ['solar_set1', 'solar_set2', 'solar_set3', 'solar_set4'] sets['system'] = list() for s in set_ids: m = cfg.get(s, 'module_name') i = cfg.get(s, 'inverter_name') sets['system'].append((m, i)) sets['azimuth'] = [120, 180, 240] sets['tilt'] = [0, 30, 60, 90] weatherpath = os.path.join(c.paths['weather'], c.pattern['weather']) weather = pd.read_hdf(weatherpath.format(year=year), 'A' + str(key)) latlon = pd.read_csv(os.path.join(c.paths['geometry'], c.files['coastdatgrid_centroids']), index_col='gid').loc[key] location = {'latitude': latlon['st_y'], 'longitude': latlon['st_x']} weather = f.adapt_weather_to_pvlib(weather, location) sandia_modules = pvlib.pvsystem.retrieve_sam('sandiamod') sapm_inverters = pvlib.pvsystem.retrieve_sam('sandiainverter') my_index = pd.MultiIndex(levels=[[], [], []], labels=[[], [], []], names=['name', 'azimuth', 'tilt']) cols = ['irrad', 'dc', 'ac', 'dc/i', 'ac/i', 'ac/dc'] df = pd.DataFrame(columns=cols, index=my_index) for system in sets['system']: for tlt in sets['tilt']: if tlt == 0: az_s = [0] else: az_s = sets['azimuth'] for az in az_s: name = system[0].replace('_', '')[:10] logging.info("{0}, {1}, {2}".format(system, tlt, az)) smodule = { 'module_parameters': sandia_modules[system[0]], 'inverter_parameters': sapm_inverters[system[1]], 'surface_azimuth': az, 'surface_tilt': tlt, 'albedo': 0.2 } p_peak = (smodule['module_parameters'].Impo * smodule['module_parameters'].Vmpo) area = smodule['module_parameters'].Area mc = f.feedin_pvlib_modelchain(location, smodule, weather) dc = mc.dc.p_mp.clip(0).div(p_peak).sum() ac = mc.ac.clip(0).div(p_peak).sum() i = mc.total_irrad['poa_global'].multiply(area).div( p_peak).sum() df.loc[(name, az, tlt), 'dc'] = dc df.loc[(name, az, tlt), 'ac'] = ac df.loc[(name, az, tlt), 'irrad'] = i df.loc[(name, az, tlt), 'dc/i'] = dc / i df.loc[(name, az, tlt), 'ac/i'] = ac / i df.loc[(name, az, tlt), 'ac/dc'] = ac / dc # df_ts.to_csv(os.path.join(paths['analysis'], 'orientation_feedin.csv')) df.to_csv(os.path.join(c.paths['analysis'], 'performance_ratio.csv'))