Skip to content
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

AHN caching does not seem to be working? #149

Closed
dbrakenhoff opened this issue Mar 10, 2023 · 2 comments
Closed

AHN caching does not seem to be working? #149

dbrakenhoff opened this issue Mar 10, 2023 · 2 comments

Comments

@dbrakenhoff
Copy link
Collaborator

A repeated run of the following function gives me the log message below:

ahn_ds = nlmod.read.ahn.get_ahn(ds, cachedir=ds.cachedir, cachename="ahn")

Log:

INFO:nlmod.cache:coordinate x has different values in cached dataset, not using cache

I should be seeing a message that AHN is loaded from cache.

@OnnoEbbens
Copy link
Collaborator

The get_ahn function calls the nlmod.dims.resample.structured_da_to_ds function. In this function the da.rio.reproject_match(ds, resampling, nodata=nodata) function is called which will add 3 attributes to x and y dataarrays:
long_name : x coordinate of projection
standard_name : projection_x_coordinate
units : metre

For the cache we check if the cached dataset (ahn_ds) has the same coordinates and attributes as the given dataset (ds). This check fails because of the new attributes. We decided to check coordinate attributes because some attributes of the time dimension are essential model parameters so should be checked.

The structured_da_to_ds already has some logic to remove coordinates added by the rio.reproject_match function. I will add some code to remove these attributes of the coordinates as well.

@OnnoEbbens
Copy link
Collaborator

It turned out to be a lot more complex with coordinates that are added and modified by different functions. With the help of @dbrakenhoff we fixed it but then I referenced the wrong issue number (#150 instead of #149) and everything became even more complex. However I think this issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants