ENH: add xarray interface to Graph#740
Merged
knaaptime merged 12 commits intopysal:mainfrom Jul 16, 2024
Merged
Conversation
Member
Author
|
Oh, another note - I think that the tests of this and of W implementation pass only if |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #740 +/- ##
======================================
Coverage 85.2% 85.2%
======================================
Files 145 147 +2
Lines 15662 15784 +122
======================================
+ Hits 13345 13449 +104
- Misses 2317 2335 +18
|
jGaboardi
approved these changes
Jul 6, 2024
knaaptime
approved these changes
Jul 15, 2024
Member
|
After @martinfleis resolves the conflicts, are we OK to merge or should we get one more approval? |
Member
|
@sjsrey @martinfleis @knaaptime I'll merge this at 5:00pm Eastern time (4 hours from the time of this post) unless there are any detractors. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This attempts to mirror the functionality of the
weights.rastermodule within theGraph. I tried to re-use as much of the code fromweightsas I could which required quite a bit of refactoring there to avoid too many unnecessary conversions back and forth.Contrary to the original implementation, we don't need any new public attribute to facilitate using the graph within esda etc but I have added one private one. If it is not present it is not the end of the world either, you just get
level_0,level_1etc as the dimension names in the DataArray. But I tried to preserve it in most common operations.Compared to the original, there are some minor differences when putting it work. For example, computing LISA would look like this, using the tif from https://data.worldpop.org/GIS/Population/Global_2000_2020/2019/LUX/lux_ppp_2019.tif (which needs to be pulled locally).
It is probably not as fast as the original WSP due to some overhead of Graph but it works.
As a side note, I think that the detection of no data value in the constructor in the
weights.rastermodule needs updating as it only checks forda.attrs["nodatavals"]but the example above usesda.attrs["_FillValue"]. It is generally better to try getting it viada.rio.nodatabut I'll open an issue for that.Another side note - the Raster_Awareness notebook is not executable as it uses files I have no idea where from and some custom branch of
splot.This also includes one line from #739 to ensure this actually works as intended.