NCAR / GeoCAT

GeoCAT website
https://geocat.ucar.edu/
14 stars 12 forks source link

geocat.comp.rcm2points error: axes don't match array #30

Closed kevmcgrath closed 3 years ago

kevmcgrath commented 3 years ago

We have a script that uses geocat.comp.rcm2points() to extract linearly interpolated values from a non-uniform grid. This command works just fine for my colleague, who has an older version of geocat-comp:

conda list | grep geocat
geocat-comp               0.1a             py37h03ebfcd_5    ncar

When I install geocomp into a fresh anaconda 3 environment ($ conda create -n geocat -c conda-forge -c ncar geocat-comp pygrib), the following geocat packages are installed:

geocat-comp               2021.05.1                  py_0    ncar
geocat-f2py               2021.05.1        py39h3d0eb6f_0    ncar

geocat.comp.rcm2points() throws an error when the exact same script is run from the new environment. Here are the shapes of our variables and the generated error:

>>> gridlat_0.shape
(1597, 2345)

>>> gridlon_0.shape
(1597, 2345)

>>> max_temp.shape
(1597, 2345)

>>> lat.shape
(1,)

>>> lon.shape
(1,)

>>> geocat.comp.rcm2points(gridlat_0, gridlon_0, max_temp, lat, lon)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/geocat/f2py/rcm2points_wrapper.py", line 184, in rcm2points
    fo = xr.DataArray(fo.compute(), attrs=fi.attrs)
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/dask/base.py", line 285, in compute
    (result,) = compute(self, traverse=False, **kwargs)
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/dask/base.py", line 567, in compute
    results = schedule(dsk, keys, **kwargs)
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/dask/threaded.py", line 79, in get
    results = get_async(
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/dask/local.py", line 514, in get_async
    raise_exception(exc, tb)
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/dask/local.py", line 325, in reraise
    raise exc
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/dask/local.py", line 223, in execute_task
    result = _execute_task(task, data)
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/dask/core.py", line 121, in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/dask/optimization.py", line 963, in __call__
    return core.get(self.dsk, self.outkey, dict(zip(self.inkeys, args)))
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/dask/core.py", line 151, in get
    result = _execute_task(task, cache)
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/dask/core.py", line 121, in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/geocat/f2py/rcm2points_wrapper.py", line 17, in _rcm2points
    fi = np.transpose(fi, axes=(2, 1, 0))
  File "<__array_function__ internals>", line 5, in transpose
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 658, in transpose
    return _wrapfunc(a, 'transpose', axes)
  File "/gpfs/dell3/mdl/mdlverif/noscrub/usr/Kevin.M.Mcgrath/anaconda3/envs/geocatWithPygrib/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 58, in _wrapfunc
    return bound(*args, **kwds)
ValueError: axes don't match array

Any advice would be greatly appreciated. We've reviewed the documentation at _https://geocat-f2py.readthedocs.io/en/latest/autoapi/generated/geocat/f2py/rcm2points_wrapper/index.html_ but can't find any glaring issues.

I've attached output of conda info and conda list.

Cheers, Kevin condaInfo.txt condaList.txt

erogluorhan commented 3 years ago

Hi @kevmcgrath

Thanks a lot for reporting this issue to us! I am sorry if it led any inconvenience for you.

Hi @michaelavs , could you please have a look at this issue about rcm2points function?

Orhan - GeoCAT

michaelavs commented 3 years ago

Hi @kevmcgrath, I have been looking into it today and have a couple of thoughts on what may be causing the issue. My first thought is to compare the conda list between your environment and you colleagues to see if there are any major differences in versions of packages installed. If that doesn't go anywhere, I believe the issue is stemming from numpy, dask, or xarray and how they are communicating with each other. I have a couple of theories, but I think it would be best to start with the conda list route and work back around.

If you are still needing assistance with this issue, would you mind providing that information for me? If you have resolved the issue, would you mind letting me know what resolved the issue for future reference?

Thank you!

michaelavs commented 3 years ago

Hi @kevmcgrath, Is there any update on this issue? If we don't hear from you, we may close this issue but want to make sure you get the support you need before we do that.

kevmcgrath commented 3 years ago

Hi Michaela,

My sincerest apologies for the lack of response! I was on vacation last week, which caused me to be rather under water this week.

Our project no longer requires us to perform linear interpolation and as such, we have no need for rcm2points at this time. You can go ahead and close the issue. Thank you much for the support!

Cheers, Kevin