From 0466c6c6aed47c46e5140d2852767ba6f6958f74 Mon Sep 17 00:00:00 2001 From: Will Hobbs <45701090+williamhobbs@users.noreply.github.com> Date: Tue, 13 Sep 2022 10:32:39 -0500 Subject: [PATCH 1/2] Update nwp.py --- solarforecastarbiter/io/fetch/nwp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solarforecastarbiter/io/fetch/nwp.py b/solarforecastarbiter/io/fetch/nwp.py index 7668eb6d..4d9e2cea 100644 --- a/solarforecastarbiter/io/fetch/nwp.py +++ b/solarforecastarbiter/io/fetch/nwp.py @@ -140,7 +140,7 @@ 'var_VGRD': 'on', 'update_freq': '1h', 'valid_hr_gen': ( - lambda x: range(37) if x in (0, 6, 12, 18) else range(19)), + lambda x: range(49) if x in (0, 6, 12, 18) else range(19)), 'time_between_fcst_hrs': 120, 'delay_to_first_forecast': '45min', 'avg_max_run_length': '70min', From 37e95c7eee6554fc0f36272d1f3ef16e7ad54fec Mon Sep 17 00:00:00 2001 From: Will Hobbs <45701090+williamhobbs@users.noreply.github.com> Date: Wed, 3 May 2023 14:45:41 -0500 Subject: [PATCH 2/2] Update models.py Added an option for HRRR hourly to hourly mean using irradiance from the NWP. --- .../reference_forecasts/models.py | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/solarforecastarbiter/reference_forecasts/models.py b/solarforecastarbiter/reference_forecasts/models.py index 564c4bc8..30981022 100644 --- a/solarforecastarbiter/reference_forecasts/models.py +++ b/solarforecastarbiter/reference_forecasts/models.py @@ -269,7 +269,58 @@ def hrrr_subhourly_to_hourly_mean(latitude, longitude, elevation, return (ghi, dni, dhi, air_temperature, wind_speed, resampler, solar_pos_calculator) - +def hrrr_hourly_to_hourly_mean(latitude, longitude, elevation, + init_time, start, end, interval_label, + load_forecast=load_forecast, + *, __model='hrrr_hourly'): + """ + Hourly mean forecast from HRRR Hourly. + GHI, DNI, DHI directly from model, resampled. + Max forecast horizon 18 or 48 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 rap_ghi_to_instantaneous(latitude, longitude, elevation, init_time, start, end, interval_label, load_forecast=load_forecast,