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

Make expand_dimensions definitions non ambiguous #795

Merged
merged 21 commits into from
Sep 14, 2024
Merged

Conversation

asinghvi17
Copy link
Collaborator

@asinghvi17 asinghvi17 commented Sep 2, 2024

@asinghvi17
Copy link
Collaborator Author

I am now routing all convert_arguments through the conversion trait for the overridden functions. Since we don't dispatch on raw plot types for these in convert_arguments anyway, this seems reasonable to me.

This also gets rid of plots not converting correctly.

The currently outstanding issue with this approach, is that updating plots created in this way isn't possible with traditional updating syntax (plt[1] = new_dimarray). You have to pass in an Observable or do the conversion and unwrap it yourself. Both of which are bad ideas. That's next on the list but would involve cleaning up the whole recipe system anyway.

This also fixes the convert_args for vertexgrid which was using the wrong array for lookup, causing y-flipped contourf for example.
@asinghvi17
Copy link
Collaborator Author

Ah, categorical lookups have to be handled like regular ones.

ext/DimensionalDataMakie.jl Outdated Show resolved Hide resolved
function _lookup_to_vertex_vector(l)
if isintervals(l)
bs = intervalbounds(l)
return @. first(bs) + (last(bs) - first(bs)) / 2
Copy link
Owner

Choose a reason for hiding this comment

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

Isn't this just parent(shiftlocus(Center, l)) ?

Then we don't need to check Points/Intervals either.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it? If so that would be great. Does shiftlocus also handle converting point sampling to interval sampling?

Copy link
Owner

@rafaqz rafaqz Sep 7, 2024

Choose a reason for hiding this comment

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

No you have to do that separatly: shiftlocus(Start(), set(lookup, Intervals())). Points will always turn into Intervals(Center()) by default.

(mostly because shifting Points() to Center() could still give Points, so its kind of ambiguous)

Copy link
Owner

Choose a reason for hiding this comment

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

Its good to always use the methods like shiftlocus for things like this so we can centralise handling of the edge cases.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok people. I just tested this one in combination with rafaqz/Rasters.jl#723, and things seems to work really well. So, I would like to merge this one, so that we can also fix Rasters#main.

Copy link
Collaborator

@lazarusA lazarusA left a comment

Choose a reason for hiding this comment

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

thanks a lot @asinghvi17 for bringing this up to the finish line. Great work!

Co-authored-by: Rafael Schouten <rafaelschouten@gmail.com>
The lookup was:
$l

You can solve this by resampling your raster, or by using a more permissive plot type like `heatmap`, `surface`, `contour`, or `contourf`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rafaqz I just hit this edge case for raster's volume-like cases. what would be the way to get a regular-spaced raster? a better suggestion is needed here. Maybe one-liner to resample a given raster A?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yeah a one liner would be good to add there. I should also add an option to customize the error message so this can be used in volume plots...

Copy link
Owner

@rafaqz rafaqz Sep 12, 2024

Choose a reason for hiding this comment

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

With image or heatmap? heatmap should work Maybe we can just warn for image and plot anyway?

Copy link
Collaborator

Choose a reason for hiding this comment

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

the issue I found was for something with X, Y, Ti, creating a volume, where the axis for Ti is usually irregular, hence failing afterwards to plot, I just want say, treat this as a regular thing as well, it makes sense for daily data, but I'm sure there should be others where we should not do that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Aha ok! Yeah I guess it's a bit restrictive to error all the time.

@asinghvi17
Copy link
Collaborator Author

asinghvi17 commented Sep 9, 2024

TODOs on my end are:

  • Special-case axis and figure attributes so they DON'T get converted to Observables.
  • Better and more configurable error messages when checking regular lookups
  • Use shiftlocus and set when converting lookups to vectors.

ext/DimensionalDataMakie.jl Outdated Show resolved Hide resolved
ext/DimensionalDataMakie.jl Outdated Show resolved Hide resolved
@lazarusA
Copy link
Collaborator

something went wrong with the latest axis, args removal.

@asinghvi17
Copy link
Collaborator Author

asinghvi17 commented Sep 11, 2024

Yeah it's just passing a bunch of axis kwargs to LScene when it shouldn't. Will look at that.

@asinghvi17
Copy link
Collaborator Author

asinghvi17 commented Sep 11, 2024

Things look good enough to me. @rafaqz feel free to merge whenever.

x=nothing, y=nothing, colorbarkw=(;), attributes...
)
replacements = _keywords2dimpairs(x, y)
_, _, args, _ = _surface2(A, $f2, attributes, replacements)
# No ColourBar in the ! in-place versions
return Makie.$f2!(axis, args...; attributes...)
# No Colorbar in the ! in-place versions
Copy link
Owner

Choose a reason for hiding this comment

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

Hey I'm Australian ;)

The lookup was:
$l

You can solve this by resampling your raster, or by using a more permissive plot type like `heatmap`, `surface`, `contour`, or `contourf`.
Copy link
Owner

@rafaqz rafaqz Sep 12, 2024

Choose a reason for hiding this comment

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

With image or heatmap? heatmap should work Maybe we can just warn for image and plot anyway?

@rafaqz
Copy link
Owner

rafaqz commented Sep 14, 2024

Are the spy fixes good for merging now too?

@asinghvi17
Copy link
Collaborator Author

Yes, I'd say it's better than nothing. We can only fix the remaining issues on the Makie end.

@rafaqz rafaqz merged commit d857504 into main Sep 14, 2024
8 checks passed
@rafaqz rafaqz deleted the asinghvi17-patch-3 branch September 14, 2024 23:49
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

Successfully merging this pull request may close these issues.

3 participants