Skip to content

BUG: netcdf4 conversion error in forecast.py  #944

Closed

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.

Activity

  1. added this to the 0.7.3 milestone on Mar 27, 2020
  2. wholmgren commented on Mar 28, 2020

    @wholmgren
    Member

    Duplicate of #920?

  3. changed the title [-]BUG: NETCDF4 conversion error in forcast.py [/-] [+]BUG: netcdf4 conversion error in forecast.py [/+] on Mar 28, 2020
  4. CameronTStark commented on Mar 28, 2020

    @CameronTStark
    ContributorAuthor

    I don't think so but I can't say they're not related.

    The error described in #920 is not the same as here nor does the solution proposed in #921 fix this issue.

  5. kandersolar commented on Mar 28, 2020

    @kandersolar
    Member

    FWIW I cannot reproduce the errors on my machine.

    Maybe not relevant, but just in case: #900 handled the cftime change that added only_use_cftime_datetimes, but there was another recent change to add only_use_python_datetimes: https://github.com/Unidata/cftime/pull/139/files#diff-9225bec7bdd479a2dfbc187bb72953d1R259

  6. augustecolle commented on Mar 28, 2020

    @augustecolle

    Downgrading cftime from 1.1.1 to 1.0.4 solved this issue for me.

  7. CameronTStark commented on Mar 28, 2020

    @CameronTStark
    ContributorAuthor

    That did it for me. Thanks, @augustecolle!

  8. wholmgren commented on Mar 30, 2020

    @wholmgren
    Member

    @CameronTStark do you still see this problem when using pvlib/pvlib-python/master? I think @kanderso-nrel's suggestion might have fixed it and #947 might be unnecessary. Sorry I got confused about which issue to reference.

  9. modified the milestones: 0.7.3, 0.7.2 on Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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