pytroll / pytroll/pyresample

No update_hash method for GridDefinition

Open
#211 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug question
Dominant language
Python
Stars
385
Forks
102
Avg merge
4d 2h
Merged PRs (30d)
9

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pyresample/geometry.py at the referenced BaseDefinition.get_hash() call and inspect existing update_hash implementations. Check GridDefinition and related definitions, then verify that hashing a GridDefinition works with the cached-weight path used by SatPy resampling.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.