bsrn.modeling.clear_sky.add_clearsky_columns#
- bsrn.modeling.clear_sky.add_clearsky_columns(df, station_code=None, lat=None, lon=None, elev=None, model='ineichen', mcclear_email=None)[source]#
Adds clear-sky radiation columns to a DataFrame based on its DatetimeIndex.
Location can be given by BSRN station code or by explicit lat/lon/elev (e.g. for non-BSRN stations), consistent with the QC wrapper metadata pattern.
- Parameters:
df (pd.DataFrame) – Input data with pd.DatetimeIndex.
station_code (str, optional) – BSRN station abbreviation. [e.g. ‘QIQ’] Used if lat/lon/elev not provided.
lat (float, optional) – Latitude. [degrees] Required for non-BSRN stations if station_code omitted.
lon (float, optional) – Longitude. [degrees] Required for non-BSRN stations if station_code omitted.
elev (float, optional) – Elevation. [m] Required for non-BSRN stations if station_code omitted.
model (str, default 'ineichen') – Clear-sky model to use. [‘ineichen’, ‘mcclear’, ‘rest2’, or ‘tj’]
mcclear_email (str, optional) – SoDa account email used when downloading McClear automatically for the ‘mcclear’ model.
- Returns:
df – DataFrame with added _clear columns.
- Return type:
pd.DataFrame
- Raises:
ValueError – If
df.indexis not aDatetimeIndex.ValueError – If solar geometry columns are missing and the DataFrame frequency is >5 min, causing the automatic add_solpos_columns fallback to fail.
ValueError – If neither a valid station_code nor complete (lat, lon, elev) is provided.