Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

EarthEnv landcover + WorldClim 2.1 + CHELSA V1 #21

Merged
merged 73 commits into from
Jul 17, 2020
Merged

Conversation

tpoisot
Copy link
Member

@tpoisot tpoisot commented Apr 10, 2020

The new data have the same API as worldclim, but the files are much larger. In fact, the tests do not run as GitHub actions using the whole layer, and it takes a solid machine to run them at all. They work, but they can't be tested automatically -- as a quick check, I still run them using the new ability to only load parts of a dataset.

Because these new data do not always have a NaN type, the absence of data is now represented as nothing - this had all sort of consequences for almost everything in the package, none of which broke the API at all. But internally, this is a very extensive rewrite.

This PR also comes with improvements, specifically the sliding window analysis, the ability to broadcast over layers, and the ability to get a subset of the data from a file. The last point in particular makes a lot of data loading much faster.

@tpoisot tpoisot changed the title Landcover data from EarthEnv Landcover data from EarthEnv + WorldClim 2.1 Apr 10, 2020
@codecov-commenter
Copy link

codecov-commenter commented Jul 11, 2020

Codecov Report

Merging #21 into master will increase coverage by 0.30%.
The diff coverage is 79.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #21      +/-   ##
==========================================
+ Coverage   81.09%   81.40%   +0.30%     
==========================================
  Files          11       16       +5     
  Lines         201      285      +84     
==========================================
+ Hits          163      232      +69     
- Misses         38       53      +15     
Flag Coverage Δ
#unittests 81.40% <79.87%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/operations/sliding.jl 0.00% <0.00%> (ø)
src/datasets/chelsa.jl 33.33% <33.33%> (ø)
src/datasets/landcover.jl 33.33% <33.33%> (ø)
src/datasets/sources.jl 83.33% <83.33%> (ø)
src/lib/overloads.jl 83.56% <92.85%> (-0.05%) ⬇️
src/SimpleSDMLayers.jl 80.00% <100.00%> (+13.33%) ⬆️
src/datasets/download_layer.jl 100.00% <100.00%> (ø)
src/datasets/geotiff.jl 100.00% <100.00%> (ø)
src/datasets/raster.jl 100.00% <100.00%> (ø)
src/datasets/worldclim.jl 100.00% <100.00%> (ø)
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd79fc1...8b3e1a2. Read the comment docs.

@tpoisot
Copy link
Member Author

tpoisot commented Jul 13, 2020

@gabrieldansereau Can you make sure that nothing in this PR is going to break what you are about to present at JuliaCon? This is a fairly big rewrite internally, but it didn't break any of the existing unit tests.

@gabrieldansereau
Copy link
Member

I'll make sure it works while finishing my poster. I mean to show something similar to the examples in the documentation. As long as these are not broken, what I present shouldn't be either.

@gabrieldansereau
Copy link
Member

@tpoisot Is this normal? The following

temperature = worldclim(1);
temperature_europe = temperature[left=-11.0, right=31.1, bottom=29.0, top=71.1];
size(temperature)
size(temperature_europe)

returns (2160, 1080) & (507, 128) with this version, but returns (1080, 2160) & (254, 254) on v0.2.2. Should the dimensions really be inversed in the first case and different in the second?

The coarsen example in the documentation is broken because of this.

@tpoisot
Copy link
Member Author

tpoisot commented Jul 14, 2020

@gabrieldansereau I have no idea why that's the case. I'll check this evening.

@tpoisot
Copy link
Member Author

tpoisot commented Jul 15, 2020

So, this is because the code of geotiff changed, and I would tempted to believe the new geotiff code, as using

worldclim(1; left=-11.0, right=31.1, bottom=29.0, top=71.1)

gives the correct result in terms of which area is covered. Let me check the size issue, it's weird.

@tpoisot
Copy link
Member Author

tpoisot commented Jul 15, 2020

Mmhhh. You're right @gabrieldansereau , it looks like the size is inverted:

julia> latitudes(temperature) |> length
2160

julia> longitudes(temperature) |> length
1080

julia> stride(temperature)
(0.16666666666666666, 0.04158950617283951)

In particular, the stride should have the same values - let me add a test to check this and then fix the bug.

@tpoisot
Copy link
Member Author

tpoisot commented Jul 15, 2020

GREAT now the github actions are not running. This is just fantastic. I'm ready to start a new life hoarding goats or something - nevermind, https://www.githubstatus.com/ says it's a site wide problem.

Copy link
Member

@gabrieldansereau gabrieldansereau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All fine for me! Works with my JuliaCon poster. I had no problems running the examples and playing with it a bit after the small fix to similar().
Thanks for the fix to worldclim() & layer sizes!

@@ -240,7 +240,7 @@ the use of `copy`, manual update, and `convert`.
function Base.similar(layer::T) where {T <: SimpleSDMLayer}
emptygrid = similar(layer.grid)
for i in eachindex(emptygrid)
emptygrid[i] = isnothing(layer.grid[i]) ? nothing : zero(eltype(layer.grid))
emptygrid[i] = isnothing(layer.grid[i]) ? nothing : zero(eltype(layer.grid[i]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar() didn't work without this for climate layers & all. eltype(temperature.grid) is always Union{Nothing, Float32}, which has no method for zero()

@tpoisot tpoisot merged commit 64760fc into master Jul 17, 2020
@gabrieldansereau gabrieldansereau deleted the feature/landcover branch July 20, 2020 14:00
@tpoisot tpoisot mentioned this pull request Jul 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
domain-data enhancement New feature or request
Projects
None yet
3 participants