Skip to content

sunset_angle uses numpy.clip that is not compatible with numpy 2 #84

Closed
@deltamarnix

Description

@deltamarnix

Describe the bug
When calling sunset_angle with an xarray object, I receive an error. I have mentioned it here: pydata/xarray#7848 (comment).

The problem is the compatibility of numpy and xarray in numpy 2.
It's likely the best way to solve this by checking for the type of data (xarray.DataArray), and then explicitly calling da.clip(-1,1), instead of numpy.clip(da, -1, 1).

This is the line of code that goes wrong:

return arccos(clip(-tan(sol_dec.values) * tan(lat).T, -1, 1)).T

The error is: TypeError: DataWithCoords.clip() got an unexpected keyword argument 'out'.

numpy version: 2.1.3
xarray version: 2025.1.2
pyet version: 1.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions