Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nwp.py #794

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solarforecastarbiter/io/fetch/nwp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
53 changes: 52 additions & 1 deletion solarforecastarbiter/reference_forecasts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down