pangeo-data / xESMF

Universal Regridder for Geospatial Data
http://xesmf.readthedocs.io/
MIT License
189 stars 34 forks source link

Extrapolation seems to only work if input mask is set? #263

Open axelschweiger opened 1 year ago

axelschweiger commented 1 year ago

I'm regridding some 2D grids (time,lat,lon) that requires some extrapolation. It works fine when I specify a mask for both input and output for each time. However, since my input mask varies slightly over time that doesn't work. The documentation suggests that an input mask isn't necessary if the data to be regridded that correspond to the mask are already set to "nan". Since it is a pretty large grid/time recomputing weights doesn't work. I'm a bit confused if I can use adaptive masking for this and how?

Since the input data are sizable, creating a working sample is a bit hard so I'm trying to see if somebody has maybe found a solution already. Thanks Axel

aulemahal commented 1 year ago

Sadly, extrapolation indeed only works if the mask is set. This is a consequence on how adaptive masking is an addition from xESMF whereas extrapolation is a feature from ESMF itself.

Regridding in xESMF is two step process : compute the regridding weights first and then apply them to the data. The adaptive masking occurs in the latter step, while the extrapolation occurs in the former. Extrapolation needs to know which points are "unmapped", which is done through masking. at weight compuation time. Adaptive masking is implemented as an on-the-fly modification of the pre-computed weights at regridding time.

I fear that making extrapolation work with adaptive masking would either necessitate to reimplement extrapolation within xESMF OR implement adaptative masking within ESMF. Both solutions are out-of-scope for xESMF, as far as I understand...

axelschweiger commented 1 year ago

Pascal Thank you for this explanation and reply. I think I found a work around by making a constant mask which is the superset of all the time varying masks. This then yields a few unnecessary inter/extrapolations but in my case that’s tolerable.

Axel

From: Pascal Bourgault @.> Sent: Wednesday, May 10, 2023 13:03 To: pangeo-data/xESMF @.> Cc: Axel J Schweiger @.>; Author @.> Subject: Re: [pangeo-data/xESMF] Extrapolation seems to only work if input mask is set? (Issue #263)

Sadly, extrapolation indeed only works if the mask are set. This is a consequence on how adaptive masking is an addition from xESMF whereas extrapolation is a feature from ESMF itself.

Regridding in xESMF is two step process : compute the regridding weights first and then apply them to the data. The adaptive masking occurs in the latter step, while the extrapolation occurs in the former. Extrapolation needs to know which points are "unmapped", which is done through masking. at weight compuation time. Adaptive masking is implemented as an on-the-fly modification of the pre-computed weights at regridding time.

I fear that making extrapolation work with adaptive masking would either necessitate to reimplement extrapolation within xESMF OR implement adaptative masking within ESMF. Both solutions are out-of-scope for xESMF, as far as I understand...

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/pangeo-data/xESMF/issues/263*issuecomment-1542735734__;Iw!!K-Hz7m0Vt54!mdjeutmqLP7kId5aPWwVU70Lq-C-Fl9-XtiB7rqZKhPiJiYqs1ltPo89IEI6pM4rWD9JGGeVl87l9gAVG6h6O4c$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ALJTXMJ53YDLDOTTEUHBYITXFPX53ANCNFSM6AAAAAAX34RHY4__;!!K-Hz7m0Vt54!mdjeutmqLP7kId5aPWwVU70Lq-C-Fl9-XtiB7rqZKhPiJiYqs1ltPo89IEI6pM4rWD9JGGeVl87l9gAVgQbt0qc$. You are receiving this because you authored the thread.Message ID: @.**@.>>

aulemahal commented 1 year ago

Ah true, this can be reasonable solution depending on the data!

I'll keep this issue open as a reminder that this should be explained in the doc. For example, the "extrapolation" section could mention that this is requires a mask and is unavailable with adaptive masking.