Skip to content

BUG: netcdf4 conversion error in forecast.py  #944

Closed
@CameronTStark

Description

@CameronTStark

Describe the bug
The method get_data() from the parent class ForecastModel has a handling NETCDF data. It produces the following error on multiple tests within test_forecast.py:

TypeError: <class 'cftime._cftime.DatetimeGregorian'> is not convertible to datetime

To Reproduce
Run the command locally:

pytest pvlib/tests/test_forecast.py --remote-data --pdb

This command will ensure the tests marked as remote_data are run and you'll be dropped into a pdb debugger.

Expected behavior
The formatted data would be received without error.

Screenshots
If applicable, add screenshots to help explain your problem.

Versions:

  • pvlib.__version__: 0.7.1 master
  • pandas.__version__: 1.0.3
  • python: 3.7.4

Additional context
I'm unsure about the underlying origin but the disconnect seems to come through get_data() -> _netcdf2pandas() -> set_time() where num2date supplies a DatetimeGregorian that Pandas can't process.

It's notable that there is a suggestion on line 279 of forecast.py about the potential to move to xarray's implementation of NetCDF rather than using the _netcdf2pandas() method. This avenue likely has the potential to be easier than continuing a pvlib implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions