You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@telenskyt Could you please try setting nn_interpol = FALSE for location_series(). I suspect the problem might be that interpolating locations that fall into the sea might slow down the whole thing.
Ok, having had a look at the code, I can see that we are rather inefficient. That logic was designed when we had a maximum of a couple of hundred time steps, so efficiency was not a big concern with those original datasets.
So, that function requires a bit of a redesign; I don't think it will happen before Christmas, but it should be a fun project in the New Year.
@telenskyt Actually, there were a couple of easy wins to optimise the code. Try using the code in the branch faster_extract, you should find it a bit more speedy (not ideal yet, but better). You can install it with: devtools::install_github("EvolEcolGroup/pastclim@faster_extract")
I had a go at the rest of the algorithm. I can now extract all 5k time points for a location in just short of 40 seconds. Most of that is setting up the raster in terra, so further points should have limited impact on time.
Hello, thanks for the information! I was just wondering, there are already tons of perfectly optimized functions for that, aren't they? Like e.g. terra::extract(), or I was using exactextractr::exact_extract() for polygons. These functions should be pretty fast.
Activity
telenskyt commentedon Dec 15, 2025
Surprisingly, the region_series() function seems to work much faster, even though it extracts much more data, volume-wise, which is weird.
dramanica commentedon Dec 15, 2025
@telenskyt Could you please try setting
nn_interpol = FALSEforlocation_series(). I suspect the problem might be that interpolating locations that fall into the sea might slow down the whole thing.telenskyt commentedon Dec 16, 2025
@dramanica I am surprised by this suggestion,
nn_interpol = FALSEis the default setting, so why should it make a difference?Ok, I did it anyway, and the result seems the same. Now I freed a lot of RAM (have 7 GB free now), and 101 data points took 143.4 seconds to extract:
dramanica commentedon Dec 16, 2025
My bad, I had forgotten it is the default for
location_slice()but notlocation_series().dramanica commentedon Dec 16, 2025
Ok, having had a look at the code, I can see that we are rather inefficient. That logic was designed when we had a maximum of a couple of hundred time steps, so efficiency was not a big concern with those original datasets.
So, that function requires a bit of a redesign; I don't think it will happen before Christmas, but it should be a fun project in the New Year.
dramanica commentedon Dec 18, 2025
@telenskyt Actually, there were a couple of easy wins to optimise the code. Try using the code in the branch
faster_extract, you should find it a bit more speedy (not ideal yet, but better). You can install it with:devtools::install_github("EvolEcolGroup/pastclim@faster_extract")dramanica commentedon Dec 18, 2025
I had a go at the rest of the algorithm. I can now extract all 5k time points for a location in just short of 40 seconds. Most of that is setting up the raster in
terra, so further points should have limited impact on time.telenskyt commentedon Dec 19, 2025
Hello, thanks for the information! I was just wondering, there are already tons of perfectly optimized functions for that, aren't they? Like e.g.
terra::extract(), or I was usingexactextractr::exact_extract()for polygons. These functions should be pretty fast.dramanica commentedon Dec 19, 2025
We use
terra::extract. Now all the time is due to building up a spatraster with 5k layers, the rest is almost instantaneous.telenskyt commentedon Jan 8, 2026
Hello again Andrea, if you already have that code, e.g. in some experimental branch, which I could pull with git, would be very helpful right now! :)
dramanica commentedon Jan 8, 2026
devtools::install_github("EvolEcolGroup/pastclim@faster_extract")dramanica commentedon Feb 11, 2026
Now implemented in
devin #80