Skip to content

Solar position values are incorrect when using DatetimeIndex with unit='us' #1932

@patricksheehan

Description

@patricksheehan

Describe the bug
Solar elevation values are wrong when using the default nrel_numpy method

To Reproduce
Steps to reproduce the behavior:

import pvlib

# Example usage:
latitude = 37.7749  # Replace with the desired latitude
longitude = -122.4194  # Replace with the desired longitude

# Create a sample DatetimeIndex (replace with your own datetime index)
date_index = pd.date_range(start='2023-01-01', end='2023-01-05', freq='H')

correct_results = pvlib.solarposition.get_solarposition(
    time=date_index,
    latitude=37.804363,
    longitude=-122.271111,
    method="pyephem"
)

incorrect_results = pvlib.solarposition.get_solarposition(
    time=date_index,
    latitude=37.804363,
    longitude=-122.271111,
) 

Expected behavior
solar altitude should be on a negative/positive cycle throughout a day

Screenshots

Versions:

  • pvlib.__version__: 0.10.2
  • pandas.__version__: 2.1.4
  • python: 3.10.13

Additional context
Add any other context about the problem here.

There's obviously a workaround, but this was a surprising error, is this known?

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