question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: netcdf4 conversion error in forecast.py

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
augustecollecommented, Mar 28, 2020

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

0reactions
wholmgrencommented, Mar 30, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[netcdfgroup] Python and netCDF4: AttributeError: NetCDF
I'm running some Python code that uses the netCDF4 module (from here: ... and I'm getting a numeric conversion error when attempting to...
Read more >
Datetime conversion error in NetCDF4 file - Stack Overflow
I have been using the xarray module to open NetCDF4 data and the matplotlib.plt to visualise the data. Here is the code:
Read more >
NCO 5.1.4-alpha04 User Guide - NCO netCDF Operators
Conversion of HDF4 to netCDF4 as above suffices when the data will only be processed by NCO and other netCDF4-aware tools. However, many...
Read more >
Change log - Index of / - NOAA
Sergey Varlamov: add netcdf4 to Netcdf.c etc Reinoud Bokhorst: added -tosubmsg ... f_misc: added check for code table 4.3 - add "forecast/analysis error"...
Read more >
NetCDF Climate and Forecast (CF) Metadata Conventions
Conversion of the metadata between files of different formats will be facilitated if conventions for all formats are based on similar ideas. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found