CDAT / cdms

8 stars 10 forks source link

ESMF linear regridding fails with periodic data #87

Closed golaz closed 7 years ago

golaz commented 7 years ago

Regridding a cmds2 variable with the ESMF 'linear' regridder produces a re-gridded variable with missing values in the last row even with 'periodicity' option:

mod_reg = mod.regrid(obs_grid, regridTool='esmf', regridMethod='linear',
                     periodicity=1)
print(mod_reg[0,:,-1])
[-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --]

ESMF 'conservative' works:

mod_reg = mod.regrid(obs_grid, regridTool='esmf', regridMethod='conservative',
                     periodicity=1)
print(mod_reg[0,:,-1])
[ 0.1775848   0.17194211  0.19889209  0.21295014  0.24867538  0.28324196
  0.69440496  1.32830727  1.50522876  1.56897235  1.68829095  1.88622808
  2.13176775  2.45337605  2.81568313  3.28516364  3.68253398  3.81388021
  3.81694198  3.53876781  2.99395347  2.40873313  1.87455702  1.38764656
  0.90896726  0.63228369  0.4988831   0.40273684  0.3616761   0.35790667
  0.31463447  0.23865385  0.2917757   0.62382942  1.50482094  2.78247166
  4.3944869   5.74536467  4.55221224  4.64323425  4.38701391  3.17413998
  1.74064946  0.8630349   0.54839915  0.40030503  0.31123033  0.32339755
  0.66151059  1.69445014  2.08923626  1.66341853  2.42673993  3.43523192
  3.21942377  2.68930316  2.68675494  2.68433309  2.59466863  2.95403409
  3.43042731  2.47113466  1.81030071  1.57754922  1.41838813  1.22518241
  1.03416896  0.88724566  0.7730062   0.67540711  0.62005973  0.61057758]

Complete example: regrid.zip

doutriaux1 commented 7 years ago

@rokuingh pinging you here, is that an expected behaviour of esmf? We are still using 6.3 and ESMP. @dnadeau4 and I need to get in touch about esmpy see #57

rokuingh commented 7 years ago

Hi Charles, I can't say for sure without seeing the implementation in UV-CDAT. However, it seems like the periodic connection is not turned on in this case. I realize UV-CDAT is using the ESMP prototype code, but that is usually done in ESMPy using coord_sys=ESMF.CoordSys.SPH_DEG (instead of the CoordSys.CART). I believe this setting was handled with similarly named flags ESMP_COORDSYS_CART, ESMP_COORDSYS_SPH_DEG in ESMP. It would be worth a grep through the ESMP implementation in UVCDAT using these two strings to see if you can tell coordinate system is being used for the grids in this case.

golaz commented 7 years ago

@dnadeau4 and @doutriaux1 : did you have a chance to look at the ESMP implementation in UVCDAT to check if the correct coordinate system is being passed?

doutriaux1 commented 7 years ago

@dnadeau4 is working on esmpy as his next task.