Skip to content

Pyet.oudin throws error with DataArray input #89

Description

@pauwiersma

According to their documentation, pyet.oudin and pyet.hamon take the same input arguments. But when I give them the same DataArray of temperature and a latitude Float, pyet.oudin throws the following error and pyet.hamon does not:

ValueError                                Traceback (most recent call last)
Cell In[6], [line 3](vscode-notebook-cell:?execution_count=6&line=3)
      [1](vscode-notebook-cell:?execution_count=6&line=1) pet_hamon = pyet.hamon(forcing.tas,lat = 46)
      [2](vscode-notebook-cell:?execution_count=6&line=2) print(pet_hamon.mean().item())
----> [3](vscode-notebook-cell:?execution_count=6&line=3) pet_oudin = pyet.oudin(forcing.tas,lat = 46)
      [4](vscode-notebook-cell:?execution_count=6&line=4) print(pet_oudin.mean())

File ~/.local/share/mamba/envs/ewc_5625/lib/python3.10/site-packages/pyet/radiation.py:449, in oudin(tmean, lat, k1, k2, clip_zero)
    [447](.../site-packages/pyet/radiation.py:447) index = get_index(tmean)
    [448](.../site-packages/pyet/radiation.py:448) ra = extraterrestrial_r(index, lat)
--> [449](.../site-packages/pyet/radiation.py:449) pet = ra * (tmean + k2) / lambd / k1
    [450](.../site-packages/pyet/radiation.py:450) pet = pet.where((tmean + k2) >= 0, 0)
    [451](.../site-packages/pyet/radiation.py:451) pet = clip_zeros(pet, clip_zero)

File ~/.local/lib/python3.10/site-packages/pandas/core/ops/common.py:76, in _unpack_zerodim_and_defer.<locals>.new_method(self, other)
     [72](.../site-packages/pandas/core/ops/common.py:72)             return NotImplemented
     [74](.../site-packages/pandas/core/ops/common.py:74) other = item_from_zerodim(other)
---> [76](...//site-packages/pandas/core/ops/common.py:76) return method(self, other)

File ~/.local/lib/python3.10/site-packages/pandas/core/arraylike.py:202, in OpsMixin.__mul__(self, other)
    [200](.../site-packages/pandas/core/arraylike.py:200) @unpack_zerodim_and_defer("__mul__")
    [201](.../site-packages/pandas/core/arraylike.py:201) def __mul__(self, other):
--> [202](.../site-packages/pandas/core/arraylike.py:202)     return self._arith_method(other, operator.mul)
...
--> [818](.../site-packages/xarray/computation/apply_ufunc.py:818) result_data = func(*input_data)
    [820](.../site-packages/xarray/computation/apply_ufunc.py:820) if signature.num_outputs == 1:
    [821](.../site-packages/xarray/computation/apply_ufunc.py:821)     result_data = (result_data,)

ValueError: operands could not be broadcast together with shapes (9131,) (9131,25,23)

Let me know if you can reproduce this error or if there's something else going wrong on my side. Thanks!

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions