0

I have a csv dataset that contains timestamp (local Australia/Darwin timezone), GHI and DHI columns. I have been trying to use PV library in python to calculate/estimate azimuth, Zenith, DNI and POA. Unfortunately, the values I get where inaccurate when compared to other people's findings. I have concerns that my data is missed up with timezone (as pvlib uses UTC). Also, most values of DNI were zeros.

import pandas as pd
import pvlib

# Read in the dataset from a CSV file
df = pd.read_csv('70-Site_3-BP-Solar.csv',usecols=['timestamp','Active_Power','Global_Horizontal_Radiation','Diffuse_Horizontal_Radiation'])
# drop rows with missing values in 'GHI'
df.dropna(subset=['Global_Horizontal_Radiation'], inplace=True)
df['timestamp'] = pd.to_datetime(df['timestamp'])
df = df[(df['timestamp'] <= '2010-01-01') & (df['timestamp'] >= '2009-01-01')]
df = df.set_index('timestamp')
# Set the location information
latitude, longitude = -23.761649507441383, 133.87491253991834 # Alice Springs, Australia
altitude = 560 # meters

# Create a location object
location = pvlib.location.Location(latitude, longitude, tz='Australia/Darwin', altitude=altitude)

# Calculate the solar position
solar_position = location.get_solarposition(df.index)

# Estimate the DNI

dni_estimated=pvlib.irradiance.dirint(ghi=df['Global_Horizontal_Radiation'], solar_zenith =solar_position['apparent_zenith'].values, times=df.index)

# Calculate the POA irradiance
poa_irrad = pvlib.irradiance.get_total_irradiance(
    surface_tilt=20,
    surface_azimuth=0,
    solar_zenith=solar_position['apparent_zenith'].values,
    solar_azimuth=solar_position['azimuth'].values,
    dni=dni_estimated,
    ghi=df['Global_Horizontal_Radiation'],
    dhi=df['Diffuse_Horizontal_Radiation'],
    albedo=0.2,
    model='isotropic'
)

# Extract the POA value
poa = poa_irrad['poa_global']

# Add the POA values to the DataFrame
df['poa'] = poa

# Print the resulting DataFrame
print(df)

Ahmad
  • 1
  • 1
  • 4
  • You probably need to set the correct timezone. Check out: https://assessingsolar.org/gallery/plot_error_time_shift.html#sphx-glr-gallery-plot-error-time-shift-py – Adam R. Jensen Mar 28 '23 at 06:03

0 Answers0