I have solar data in the format:
I want to convert the time index to hour angle using the pvlib package. So far my code reads in the input data from a .csv file using pandas and extracts the time data. I need to convert this data (in 30-minute intervals) into hour angles, but I keep getting the error:
TypeError: index is not a valid DatetimeIndex or PeriodIndex
Here is my code so far:
# Import modules
import pandas as pd
import pvlib
# Read in data from .csv file for time and DHI
headers = ["Time","DHI"]
data_file = pd.read_csv("path to csv file",names=headers)
time_data = data_file["Time"]
# Find equation of time for hour angle calc
equation_of_time = pvlib.solarposition.equation_of_time_spencer71(1)
# Find hour angle
hour_angle = pvlib.solarposition.hour_angle(time_data, -89.401230, equation_of_time)