No update_hash method for GridDefinition
GridDefinition or the BaseDefinition don't have an update_hash method, even though the BaseDefinition.get_hash() tries to call it.
https://github.com/pytroll/pyresample/blob/18805996beb4b82fcdc0cc62f09b8d4caede2051/pyresample/geometry.py#L105
I've been using SatPys .resample() to regrid incoming datasets to a defined Grid but the cached weights relies on the .get_hash() method. It seems like for GridDefinitions, and maybe some others, the .update_hash() method doesn't exist. Was this intentional, still on the cards, or just missed so far?
Creating a child class with a fairly simple update_hash method makes things work smoothly.
e.g.
class GridDefinition_w_hash(geometry.GridDefinition):
def update_hash(self, the_hash=None):
if the_hash is None:
the_hash = hashlib.sha1()
the_hash.update(geometry.get_array_hashable(self.lons))
the_hash.update(geometry.get_array_hashable(self.lats))
try:
if self.lons.mask is not np.bool_(False):
the_hash.update(geometry.get_array_hashable(self.lons.mask))
except AttributeError:
pass
return the_hash
If you use a SwathDefinition instead of a GridDefinition it should work and serve essentially the same purpose.
This is missing functionality in pyresample as Satpy doesn't currently use GridDefinitions in any advertised way. Unless I'm forgetting something, on a code functionality level GridDefinitions are essentially the same thing as SwathDefinitions and I've kind of wanted to remove them (in pyresample 2.0, whenever we do that).
@mraspaud Please correct me if I'm wrong. Could GridDefinition be changed to be a subclass of SwathDefinition?