-
Notifications
You must be signed in to change notification settings - Fork 108
refactor: minor change to Mars dataset downloading logic. #503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
refactor: minor change to Mars dataset downloading logic. #503
Conversation
Thanks for the PR. It looks good, but I'll need about 2 weeks before I can get to this. After we agree on this, we'll have to make changes to a couple similar datasets that do the same thing. |
@MarkWieczorek Thanks, I can get started on applying this to other datasets if you'd like. I see a total of nine datasets which offer multiple resolutions. Just let me know which of these two implementations you'd prefer:
The latter is more abstracted/complicated, but since it would apply to nine datasets, it would hopefully make future adjustments much easier (cleanness and aesthetics are a bonus). Like I said I'm happy to implement either one, just want to avoid stepping on any toes. Thanks again for your time. |
Thanks for your effort on putting this together, and sorry about how long it took to get back to you. I am thinking that it might be best to create some kind of small helper function to find out if a suitable local file already exists. But instead of putting it in the I just have one comment about this comment in the code:
I think that you are assuming that the registry will always be ordered like in this example. Maybe that is ok, but I am just worried that in the future someone might use an inverted order. Perhaps we shouldn't make any assumptions on the ordering. What do you think? |
087eb30
to
0d90fbc
Compare
…isting high-res models instead of downloading lower-res models. - Context: - Some datasets have multiple resolutions, e.g. `pyshtools.datasets.Mars.MOLA_shape` has degrees 5759, 2879, 1439, and 719. - Current behavior: - When a user loads a dataset, pyshtools chooses the smallest model which satisfies the user's input lmax -- for example, calling `MOLA_shape(2000)` will download the 2879 model. However, if you then call `MOLA_shape(1000)`, pyshtools will download the 1439 model. We would save space/time to reuse the previously downloaded 2879 model. - Improvement: - This commit makes it so in aforementioned scenario, pyshtools will load the existing 2879 model. - In terms of code, all datasets with multiple resolutions now call the method `_choose_sh_model(...)` (located in `/pyshtools/datasets/_utils.py`). This takes the user's desired lmax and a pooch object containing available models, and either loads any existing model with sufficient resolution, or downloads the smallest model with enough resolution.
0d90fbc
to
b38cdc9
Compare
@MarkWieczorek Apologies for the delay. I've cleaned up this PR so it's a single commit with all intended changes. To summarize (since it's been a while):
|
Right now, the dataset
pyshtools.datasets.Mars.MOLA_shape
has multiple resolutions available (5759, 2879, 1439, and 719), and chooses/downloads the smallest model which satisfies the user's inputlmax
. For example, if you callMOLA_shape(2000)
, it will download the 2879 model. However, if you then callMOLA_shape(1000)
, it will download the 1439 model instead of reusing the previously downloaded 2879 model. This commit modifiesMOLA_shape
so in the aforementioned scenario, it will use the 2879 model.Note that this relies on dictionaries maintaining order of declaration/insertion which was implemented in python 3.6.
This change is only applied to Mars datasets. I'd be happy to apply this change to other datasets with multiple resolutions as well, just let me know.
Reminders
develop
branch: themaster
branch is used only when releasing new versions.make check
to ensure that the python code follows standard formatting conventions.