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

v0.8.0 #120

Merged
merged 118 commits into from
Oct 11, 2021
Merged

v0.8.0 #120

merged 118 commits into from
Oct 11, 2021

Conversation

tpoisot
Copy link
Member

@tpoisot tpoisot commented Oct 2, 2021

💥 This PR is backwards incompatible, for good reasons.

📖 This PR is also heavy on documentation change: NEW DOC HERE

The getindex problem

In previous versions, getindex was going to either return a value (or series of values, possibly), or return a layer. This was confusing in that the return type of x[y] depended on you knowing the type of y.

In the current version, getindex is only ever going to return a value (which can be nothing), and resizing a layer through various ways is done with clip.

Internally, the package now transforms coordinates into CartesianIndex (or arrays thereof), and any subtype of SimpleSDMLayer behaves much more like an AbstractArray, but accessing values through Points is recommended.

Coordinates

The mechanism to get a value with layer[longitude, latitude] is still there, but the preferred way is layer[Point(x,y,)], where Point is the type from GeometryBasics. This has been picked over the current GeoInterface.Point as there is a discussion over there to converge towards the GeometryBasics types anyways.

This makes it a lot easier to interact with polygons, rectangles, circles, etc, from GeometryBasics. There is a new example using circles and polygons with the mask function.

As a nice bonus, the internal methods to match coordinates to grid position have been sped up by about 40 times, with a 75% decrease in memory allocation, so the package as a whole should feel more responsive.

Documentation upgrade

The examples are being migrated from Documenter to Literate, so that they are easier to run independently - learners can download them and run them as standard Julia script, which they are.

The documentation of the functions has been regrouped into new pages to make more sense, workflow-wise. The data page has been split into its own section.

Iteration interface

The iteration interface has been much improved, and now returns an array of Pair{Point2, T} where T is the internal type of the layer. Very importantly, this is only ever done for non-nothing cells. The positions of non-empty cells can be accessed using keys, which returns an array of Point2.

Boundaries clipping

In some situations, clipping a layer by another layer resulted in an extra row/column being added; this has been corrected in a few places in the code, and all tests are passing.

New data

The CMIP6 dataset from CHELSA is now accessible. The elevation dataset from WorldClim is also now accessible.

DataFrames support removed

For the moment, I have dropped the DataFrames support from the package, while it's being replaced by a more general Tables interface.

Sliding windows performance

The performance of slidingwindow has been improved, thanks to a combination of using the Distances package and using the new indexing system based on keys.

Pseudo absences

This PR has a number of rand methods to generate pseudo absences, and a new documentation page about it.

@tpoisot tpoisot changed the title Interfaces iteration v0.8.0 Oct 2, 2021
@tpoisot
Copy link
Member Author

tpoisot commented Oct 8, 2021

Oh that's really nice!
I guess you want the inset because it's that square custom color scale? That's a nice idea, but hard (impossible?) to do based just on RecipesBase functionality, I'm afraid.

Outside of RecipesBase, would there be a way involving plot! to do it?

@mkborregaard
Copy link
Contributor

You might be able to do it with RecipesBase, though I haven't tried. You would do it as an insert plot with the inset_subplot keyword (https://docs.juliaplots.org/latest/layouts/#Advanced-Layouts) in a plot recipe (https://docs.juliaplots.org/latest/recipes/#Plot-Recipes), I think.

@tpoisot
Copy link
Member Author

tpoisot commented Oct 10, 2021

You might be able to do it with RecipesBase, though I haven't tried. You would do it as an insert plot with the inset_subplot keyword (https://docs.juliaplots.org/latest/layouts/#Advanced-Layouts) in a plot recipe (https://docs.juliaplots.org/latest/recipes/#Plot-Recipes), I think.

I've some code that I think may work but actually doesn't in #123 - this is a first step before putting the figure as an inset panel

@tpoisot tpoisot marked this pull request as ready for review October 11, 2021 19:39
@tpoisot tpoisot merged commit 5db4a02 into next Oct 11, 2021
@tpoisot tpoisot deleted the interfaces-iteration branch October 15, 2021 15:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants