SciTools / iris

A powerful, format-agnostic, and community-driven Python package for analysing and visualising Earth science data
https://scitools-iris.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
631 stars 283 forks source link

Explain how to make "regrid_conservative_via_esmpy" work. #686

Closed pp-mo closed 3 years ago

pp-mo commented 11 years ago

Needs ESMPy / ESMF installed, which is nowhere clearly explained. In particular, only works with a specific ESMPy revision -- which is not the latest one. Probably wants a(nother) note in the routine docstring.

See also : https://github.com/SciTools/iris/issues/685 "Upgrade regrid_conservative_via_esmpy to latest ESMPy version" (lists different available versions)

pp-mo commented 11 years ago

NOTE: for reference, this recipe works...

mkdir -p ~/odd_downloads/esmpy
cd ~/odd_downloads/esmpy
wget http://www.earthsystemmodeling.org/python_releases/ESMPy_620b10_04/ESMPy_620b10_04.tar.bz2
tar -xvf ESMPy_620b10_04.tar.bz2
export ESMF_DIR=$(ls -d ~/odd_downloads/esmpy/ESMP*/esmf)
export ESMPY_DIR=$(ls -d ~/odd_downloads/esmpy/ESMP*/ESMPy)
cd $ESMF_DIR
make
export ESMFMKFILE=$(find $ESMF_DIR -iname esmf.mk)
cd $ESMPY_DIR
python setup.py
echo "${ESMPY_DIR}/src/" >~/.local/lib/python2.7/site-packages/esmpy.pth

(But that method is specific to the earlier version: install has now changed)

rockdoc commented 11 years ago

I installed the esmf/p packages using these instructions. However, when I run some noddy code that calls the regrid_conservative_via_esmpy function, I get the following traceback:

Traceback (most recent call last):
  File "/opt/ukmo/iris/default/linux64/site-packages/iris/experimental/regrid_conservative.py", line 252, in regrid_conservative_via_esmpy
    dst_frac_field=coverage_field)
  File "/data/local/hadby/oss/ESMPy_620b10_04/ESMPy/src/ESMF/regrid.py", line 72, in __init__
    dstFracField=dst_frac_field)
  File "/data/local/hadby/oss/ESMPy_620b10_04/ESMPy/src/ESMF/cbindings.py", line 1260, in ESMP_FieldRegridStore
    raise NameError('ESMC_FieldRegridStore() failed with rc = '+str(rc)+'.  '+errmsg)
NameError: global name 'errmsg' is not defined

Unless I'm not reading it correctly, it would appear as though the cbindings.py module will always raise an exception owing to all the undefined errmsg references. But this seems too obvious a coding oversight to have slipped through the net, so maybe I'm missing some crucial step (e.g. some sort of package initialisation).

rokuingh commented 11 years ago

El Aug 21, 2013, a las 7:21 AM, Phil Bentley notifications@github.com escribió:

I installed the esmf/p packages using these instructions. However, when I run some noddy code that calls the regrid_conservative_via_esmpy function, I get the following traceback:

Traceback (most recent call last): File "/opt/ukmo/iris/default/linux64/site-packages/iris/experimental/regrid_conservative.py", line 252, in regrid_conservative_via_esmpy dst_frac_field=coverage_field) File "/data/local/hadby/oss/ESMPy_620b10_04/ESMPy/src/ESMF/regrid.py", line 72, in init dstFracField=dst_frac_field) File "/data/local/hadby/oss/ESMPy_620b10_04/ESMPy/src/ESMF/cbindings.py", line 1260, in ESMP_FieldRegridStore raise NameError('ESMC_FieldRegridStore() failed with rc = '+str(rc)+'. '+errmsg) NameError: global name 'errmsg' is not defined Unless I'm not reading it correctly, it would appear as though the cbindings.py module will always raise an exception owing to all the undefined errmsg references. But this seems too obvious a coding oversight to have slipped through the net, so maybe I'm missing some crucial step (e.g. some sort of package initialisation).

This was indeed an egregious mistake, which has been fixed in later versions. If you tell me which version of ESMPy are you currently using I can suggest the next version with the fix. — Reply to this email directly or view it on GitHub.

rockdoc commented 11 years ago

@rokuingh The version string in the setup.py file is "ESMF_6_2_0_beta_snapshot_10_ESMP_02". The value of ESMF.version is "ESMPy_620b10_04".

rokuingh commented 11 years ago

Indeed, this was fixed in the next release: ESMPy_620b20_01. FYI, the latest release is probably the best, 620_01b, and I would suggest you use this one if you are going to upgrade. (Hopefully, the API modifications should prove to be worth the effort)

On Wed, Aug 28, 2013 at 2:59 AM, Phil Bentley notifications@github.comwrote:

@rokuingh https://github.com/rokuingh The version string in the setup.py file is "ESMF_6_2_0_beta_snapshot_10_ESMP_02". The value of ESMF.version is "ESMPy_620b10_04".

— Reply to this email directly or view it on GitHubhttps://github.com/SciTools/iris/issues/686#issuecomment-23400250 .

pp-mo commented 11 years ago

Hi @rokuingh , @rockdoc. Unfortunately, the Iris code is currently still stuck in a timewarp with the early beta version of ESMPy.

Just to be clear, the actual bug in ESMPy_620b10_04 is just a glitch with processing error messages, so if you never do anything wrong it doesn't affect you ;-) @rockdoc you didn't link your actual test code, but If you chase it, it should disclose some other problem with the usage -- but the easiest way to find what is probably just to fix the 'errmsg' usage in your local copy of ESMPy ! ( Though I must admit, I have also encountered some "error" cases which were a bit unexpected )

I'll look into getting the version upgrade done again (#685 as noted in main issue heading).

github-actions[bot] commented 3 years ago

In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.

If this issue is still important to you, then please comment on this issue and the stale label will be removed.

Otherwise this issue will be automatically closed in 28 days time.

github-actions[bot] commented 3 years ago

This stale issue has been automatically closed due to a lack of community activity.

If you still care about this issue, then please either: