def nam_12km_hourly_to_hourly_instantaneous(latitude, longitude, elevation, init_time, start, end, interval_label, load_forecast=load_forecast, *, __model='nam_12km'): """ Hourly instantantaneous forecast. GHI directly from NWP model. DNI, DHI computed. Max forecast horizon 36 hours. Parameters ---------- latitude : float longitude : float elevation : float init_time : pd.Timestamp Full datetime of a model initialization start : pd.Timestamp Forecast start. Forecast is inclusive of this point. end : pd.Timestamp Forecast end. Forecast is exclusive of this point. interval_label : str Must be instant """ start_adj, end_adj = adjust_start_end_for_interval_label( interval_label, start, end, limit_instant=True) ghi, air_temperature, wind_speed = load_forecast( latitude, longitude, init_time, start_adj, end_adj, __model, variables=('ghi', 'air_temperature', 'wind_speed')) dni, dhi, solar_pos_calculator = _ghi_to_dni_dhi( latitude, longitude, elevation, ghi) # hourly instant in, hourly instant out resampler = partial(forecast.resample, freq='1h') return (ghi, dni, dhi, air_temperature, wind_speed, resampler, solar_pos_calculator)
def nam_12km_cloud_cover_to_hourly_mean(latitude, longitude, elevation, init_time, start, end, interval_label, load_forecast=load_forecast, *, __model='nam_12km'): """ Hourly average forecast. GHI from NWP model cloud cover. DNI, DHI computed. Max forecast horizon 72 hours. Parameters ---------- latitude : float longitude : float elevation : float init_time : pd.Timestamp Full datetime of a model initialization start : pd.Timestamp Forecast start. Forecast is inclusive of this instant if interval_label is *beginning* and exclusive of this instant if interval_label is *ending*. end : pd.Timestamp Forecast end. Forecast is exclusive of this instant if interval_label is *beginning* and inclusive of this instant if interval_label is *ending*. interval_label : str Must be *beginning* or *ending* """ cloud_cover, air_temperature, wind_speed = load_forecast( latitude, longitude, init_time, start, end, __model, variables=('cloud_cover', 'air_temperature', 'wind_speed')) return _resample_using_cloud_cover(latitude, longitude, elevation, cloud_cover, air_temperature, wind_speed, start, end, interval_label, 'interpolate')
def rap_ghi_to_instantaneous(latitude, longitude, elevation, init_time, start, end, interval_label, load_forecast=load_forecast, *, __model='rap'): """ Hourly instantantaneous RAP forecast. GHI directly from NWP model. DNI, DHI computed. Max forecast horizon 21 or 39 (3Z, 9Z, 15Z, 21Z) hours. Parameters ---------- latitude : float longitude : float elevation : float init_time : pd.Timestamp Full datetime of a model initialization start : pd.Timestamp Forecast start. Forecast is inclusive of this point. end : pd.Timestamp Forecast end. Forecast is exclusive of this point. interval_label : str Must be instant """ # ghi dni and dhi not in RAP output available from g2sub service ghi, air_temperature, wind_speed = load_forecast( latitude, longitude, init_time, start, end, __model, variables=('ghi', 'air_temperature', 'wind_speed')) dni, dhi, solar_pos_calculator = _ghi_to_dni_dhi( latitude, longitude, elevation, ghi) # hourly instant in, hourly instant out resampler = partial(forecast.resample, freq='1h') return (ghi, dni, dhi, air_temperature, wind_speed, resampler, solar_pos_calculator)
def hrrr_subhourly_to_hourly_mean(latitude, longitude, elevation, init_time, start, end, interval_label, load_forecast=load_forecast, *, __model='hrrr_subhourly'): """ Hourly mean HRRR forecast. GHI, DNI, DHI directly from model, resampled. Max forecast horizon 18 or 36 hours (0Z, 6Z, 12Z, 18Z). Parameters ---------- latitude : float longitude : float elevation : float init_time : pd.Timestamp Full datetime of a model initialization start : pd.Timestamp Forecast start. Forecast is inclusive of this instant if interval_label is *beginning* and exclusive of this instant if interval_label is *ending*. end : pd.Timestamp Forecast end. Forecast is exclusive of this instant if interval_label is *beginning* and inclusive of this instant if interval_label is *ending*. interval_label : str Must be *beginning* or *ending* """ ghi, dni, dhi, air_temperature, wind_speed = load_forecast( latitude, longitude, init_time, start, end, __model) # Interpolate irrad, temp, wind data to 5 min to # minimize weather to power errors. Either start or end is outside of # forecast, but is needed for subhourly interpolation. After # interpolation, we slice the extra point out of the interpolated # output. start_adj, end_adj = adjust_start_end_for_interval_label( interval_label, start, end) resample_interpolate_slicer = partial(forecast.reindex_fill_slice, freq='5min', start_slice=start_adj, end_slice=end_adj) ghi, dni, dhi, air_temperature, wind_speed = [ resample_interpolate_slicer(v) for v in (ghi, dni, dhi, air_temperature, wind_speed) ] # weather (and optionally power) will eventually be resampled # to hourly average using resampler defined below label = datamodel.CLOSED_MAPPING[interval_label] resampler = partial(forecast.resample, freq='1h', label=label) solar_pos_calculator = partial(pvmodel.calculate_solar_position, latitude, longitude, elevation, ghi.index) return (ghi, dni, dhi, air_temperature, wind_speed, resampler, solar_pos_calculator)
def _load_gefs_member(member, solar_position): cloud_cover_mixed, air_temperature, wind_speed = load_forecast( latitude, longitude, init_time, start_floored, end_ceil, member, variables=('cloud_cover', 'air_temperature', 'wind_speed')) cloud_cover = _unmix_various_gefs_intervals( init_time, start_floored, end_ceil, cloud_cover_mixed) return _resample_using_cloud_cover( latitude, longitude, elevation, cloud_cover, air_temperature, wind_speed, start, end, interval_label, 'bfill', solar_position=solar_position)
def gfs_quarter_deg_to_hourly_mean(latitude, longitude, elevation, init_time, start, end, interval_label, load_forecast=load_forecast, *, __model='gfs_0p25'): """ Hourly average forecasts derived from GFS 1, 3, and 12 hr frequency output. GHI from NWP model cloud cover. DNI, DHI computed. Max forecast horizon 384 hours. Parameters ---------- latitude : float longitude : float elevation : float init_time : pd.Timestamp Full datetime of a model initialization start : pd.Timestamp Forecast start. Forecast is inclusive of this instant if interval_label is *beginning* and exclusive of this instant if interval_label is *ending*. end : pd.Timestamp Forecast end. Forecast is exclusive of this instant if interval_label is *beginning* and inclusive of this instant if interval_label is *ending*. interval_label : str Must be *beginning* or *ending* """ start_floored, end_ceil = _adjust_gfs_start_end(start, end) cloud_cover_mixed, air_temperature, wind_speed = load_forecast( latitude, longitude, init_time, start_floored, end_ceil, __model, variables=('cloud_cover', 'air_temperature', 'wind_speed')) cloud_cover = _unmix_various_gfs_intervals(init_time, start_floored, end_ceil, cloud_cover_mixed) return _resample_using_cloud_cover(latitude, longitude, elevation, cloud_cover, air_temperature, wind_speed, start, end, interval_label, 'bfill')
def hrrr_subhourly_to_subhourly_instantaneous(latitude, longitude, elevation, init_time, start, end, interval_label, load_forecast=load_forecast, *, __model='hrrr_subhourly'): """ Subhourly (15 min) instantantaneous HRRR forecast. GHI, DNI, DHI directly from model. Max forecast horizon 18 or 36 hours (0Z, 6Z, 12Z, 18Z). Parameters ---------- latitude : float longitude : float elevation : float init_time : pd.Timestamp Full datetime of a model initialization start : pd.Timestamp Forecast start. Forecast is inclusive of this point. end : pd.Timestamp Forecast end. Forecast is exclusive of this point. interval_label : str Must be instant """ start_adj, end_adj = adjust_start_end_for_interval_label( interval_label, start, end, limit_instant=True) ghi, dni, dhi, air_temperature, wind_speed = load_forecast( latitude, longitude, init_time, start_adj, end_adj, __model) # resampler takes 15 min instantaneous in, retuns 15 min instantaneous out # still want to call resample, rather than pass through lambda x: x # so that DatetimeIndex has well-defined freq attribute resampler = partial(forecast.resample, freq='15min') solar_pos_calculator = partial(pvmodel.calculate_solar_position, latitude, longitude, elevation, ghi.index) return (ghi, dni, dhi, air_temperature, wind_speed, resampler, solar_pos_calculator)