SolarArbiter / solarforecastarbiter-core

Core data gathering, validation, processing, and reporting package for the Solar Forecast Arbiter
https://solarforecastarbiter-core.readthedocs.io
MIT License
33 stars 21 forks source link

DatetimeIndex.get_loc() got an unexpected keyword argument 'method' #819

Closed adamsocrat closed 1 year ago

adamsocrat commented 1 year ago

When I want to run example function given in run_nwp

from solarforecastarbiter.reference_forecasts.main import run_nwp

run_time = pd.Timestamp('20190515T0200Z')
issue_time = pd.Timestamp('20190515T0000Z')
modeling_parameters = datamodel.FixedTiltModelingParameters(
    surface_tilt=30, surface_azimuth=180,
    ac_capacity=10, dc_capacity=15,
    temperature_coefficient=-0.4, dc_loss_factor=0,
    ac_loss_factor=0)
power_plant = datamodel.SolarPowerPlant(
    name='Test plant', latitude=32.2, longitude=-110.9,
    elevation=715, timezone='America/Phoenix',
    modeling_parameters=modeling_parameters)
forescast = datamodel.Forecast(
    name='Test plant fx',
    site=power_plant,
    variable='ac_power',
    interval_label='ending',
    interval_value_type='interval_mean',
    interval_length=pd.Timedelta("1h"),
    issue_time_of_day=datetime.time(hour=0),
    run_length=pd.Timedelta('24h'),
    lead_time_to_start=pd.Timedelta('0h'))
ghi, dni, dhi, temp_air, wind_speed, ac_power = run_nwp(
     forescast, models.hrrr_subhourly_to_hourly_mean,
    run_time, issue_time)

I get

File ~/IdeaProjects/DynamicTariffApp/python/venv/lib/python3.11/site-packages/solarforecastarbiter/reference_forecasts/utils.py:54, in get_issue_times(forecast, start_from)
     51 possible_times = pd.DatetimeIndex(possible_times).tz_convert(
     52     start_from.tz).drop_duplicates()
     53 # then slice the broad range based on start_from day
---> 54 startloc = possible_times.get_loc(start_from.floor('1d'), method='bfill')
     55 endloc = possible_times.get_loc(
     56     (start_from + pd.Timedelta('1d')).floor('1d'), method='bfill') + 1
     57 return list(possible_times[startloc:endloc])

TypeError: DatetimeIndex.get_loc() got an unexpected keyword argument 'method'
lboeman commented 1 year ago

Hi @adamsocrat, it looks like you're using a newer version of pandas than is supported by the Arbiter. The method keyword argument seems to be removed from the DatetimeIndex.get_loc function in versions >1.5. Docs for the supported 1.0-1.4 version can be found here: https://pandas.pydata.org/pandas-docs/version/1.0/reference/api/pandas.Index.get_loc.html, and the newer version can be seen without that argument: https://pandas.pydata.org/docs/reference/api/pandas.Index.get_loc.html.

To ensure you're using all the compatible versions of dependencies, you can run pip install -r requirements.txt using the requirements.txt file in this repo.

adamsocrat commented 1 year ago

Yes, it makes sense now. But why the maintainers not upgrading to the new versions?