cedadev / ceda-jaspy-envs

Conda (Jaspy) environments for CEDA/JASMIN
BSD 2-Clause "Simplified" License
5 stars 0 forks source link

regridding with xesmf not working on JASMIN #52

Closed leifdenby closed 3 years ago

leifdenby commented 3 years ago

Apologies if this is not the right place to raise this, but with the jaspy environment on JASMIN I get the following error when trying to use xesmf to regrid some data:

[lcdenby@sci1 radar]$ module load jaspy/3.7/r20200606
[lcdenby@sci1 radar]$ python test_xesmf.py
Create weight file: bilinear_25x53_59x87.nc
Traceback (most recent call last):
  File "test_xesmf.py", line 11, in <module>
    regridder = xe.Regridder(ds, ds_out, 'bilinear')
  File "/apps/jasmin/jaspy/miniconda_envs/jaspy3.7/m3-4.6.14/envs/jaspy3.7-m3-4.6.14-r20200606/lib/python3.7/site-packages/xesmf/frontend.py", line 235, in __init__
    self._write_weight_file()
  File "/apps/jasmin/jaspy/miniconda_envs/jaspy3.7/m3-4.6.14/envs/jaspy3.7-m3-4.6.14-r20200606/lib/python3.7/site-packages/xesmf/frontend.py", line 279, in _write_weight_file
    ignore_degenerate=self.ignore_degenerate)
  File "/apps/jasmin/jaspy/miniconda_envs/jaspy3.7/m3-4.6.14/envs/jaspy3.7-m3-4.6.14-r20200606/lib/python3.7/site-packages/xesmf/backend.py", line 280, in esmf_regrid_build
    ignore_degenerate=ignore_degenerate)
  File "/apps/jasmin/jaspy/miniconda_envs/jaspy3.7/m3-4.6.14/envs/jaspy3.7-m3-4.6.14-r20200606/lib/python3.7/site-packages/ESMF/util/decorators.py", line 64, in new_func
    return func(*args, **kwargs)
  File "/apps/jasmin/jaspy/miniconda_envs/jaspy3.7/m3-4.6.14/envs/jaspy3.7-m3-4.6.14-r20200606/lib/python3.7/site-packages/ESMF/api/regrid.py", line 134, in __init__
    raise ImportError(msg)
ImportError: Regrid(filename) requires PIO and does not work if ESMF has not been built with MPI support

Scripts to reproduce:

# (test_xesmf.py)
import xarray as xr
import xesmf as xe
import numpy as np

ds = xr.tutorial.open_dataset('air_temperature') 
ds_out = xr.Dataset({'lat': (['lat'], np.arange(16, 75, 1.0)),
                     'lon': (['lon'], np.arange(200, 330, 1.5)),
                    }
                   )

regridder = xe.Regridder(ds, ds_out, 'bilinear')

I tried loading the eb/OpenMPI and jasmin-sci modules too see if that would help, but didn't work. On our system in Leeds I had to load an mpich module. I couldn't work out what copy of esmf that esmfpy is built against on JASMIN though to debug this further.

I expect it's the same issue as on https://discourse.pangeo.io/t/regridding-error-while-using-xesmf-mpi-module-missing/749

agstephens commented 3 years ago

Hi @leifdenby, sorry for the delay in getting back to you. We will look into this, but the best option is probably for you to try building your own python (using conda) and installing xesmf into it. My colleague has recently put together this script for doing such an installation (but this was not done on JASMIN):

https://github.com/roocs/regrid-prototype/blob/main/docs/notebooks/Create_Env_xESMF.sh

leifdenby commented 3 years ago

thank you @agstephens! I've created my own conda environment for time being, cheers

agstephens commented 3 years ago

Add the above test in: quick-software-tests repo.

agstephens commented 3 years ago

https://github.com/agstephens/quick-software-tests/commit/67956ad4f658d8f550cfb5b55b99b5da08ec0855

alaniwi commented 3 years ago

This test is passing in Jaspy autumn release. Can close.