Hi José,Dealing with plotting a hierarchical grid in full generality (with/without ghost zones, handling multiple possibly overlapping components, ...) is a hard problem.This is especially the case for 2/3D grids, which are commonly plotted with heatmaps/colormaps. To go around this, we resample the grids to a uniform gridfor plotting purposes. In kuibit, these are "UniformGridData". These can be plotted directly.In the 1D case, we can just resample everything onto the finest grid, and that's why you see more points. By default, the resampling method is just nearestneighbor, so this method is not making data up, just adding more "intermediate" points where there are fewer.Indeed, as you say, HierarchicalGridData objects have all the information to plot one level at the time and it is probably feasible to use them for simple 1D plots.`HierarchicalGridData` can be iterated over: when you iterate over with something like:for ref_level, component, grid_data in hier_grid:Here you plot the grid_data(I haven't tested this)kuibit also has a method `to_GridSeries()`. This is a specialized method for 1D variables. Currently, this is only implemented for UniformGridData, so you'd haveto merge the refinement levels to use it. We could extend it to HierarchicalGridData and instead of resampling to the finest grid, we'd just collect all the points.In this way, you could just call this method and call `plt.plot` to have a line plot (as you do with timeseries in kuibit). This should be straightforward (it's essentiallywhat I sketched above) and I can guide you to the implementation if that's something you'd be interested in contributing.Please, let me know if this helps,Gabriele_______________________________________________On Tue, Oct 8, 2024 at 10:05 AM José Ferreira <jpmferreira@ua.pt> wrote:_______________________________________________Dear toolkit community,
I’m struggling to find a way to plot a 1D quantity in Kuibit without merging the different meshes originated from the mesh refinement.
As a workaround, I have made a Python script that reads the file of a grid function and plots every point along the axis and its corresponding value. I can share this script if somebody is interested, but it is not very good as it breaks once you use checkpoints and has hardcoded paths.
However, it gets the job done, as you can see in an example plot below, where it is hopefully obvious that there is an increase in the number of points as z approaches 0.
![]()
Obviously, a solution that uses Kuibit would be much better. However, I cannot come up with such a solution and so I’m writing this e-mail.
From the documentation, the object that represents the simulation data (including the mesh refinement levels), is the
HierarchicalGridData, and I know how to go from a grid function to this object.For instance, to get the
HierarchicalGridDatathat represents the real part of a scalar field along the x-axis at t=0, we dosd = SimDir("<output>") gf = sd.gf phi1=gf.x["phi1"].get_time(0)All I have to do now is plot this somehow. As it turns out, this is impossible, because according to the documentation
We cannot plot directly this object, because it is a complicated object. To plot it, we have to merge the refinement levels to a single
UniformGridData. We can do this withrefinement_levels_merged().But, all of the information regarding the mesh refinement levels is here, so it should be possible to extract this information and plot it, right?
Looking at the methods and variables in
HierarchicalGridDataI came up with nothing.Does anybody have a solution to this?
Thank you in advance,
Best Regards,
José Ferreira
Users mailing list
Users@einsteintoolkit.org
http://lists.einsteintoolkit.org/mailman/listinfo/users
Users mailing list
Users@einsteintoolkit.org
http://lists.einsteintoolkit.org/mailman/listinfo/users
Prof. Bruno Giacomazzo
Department of Physics
University of Milano-Bicocca
Piazza della Scienza 3
20126 Milano
Italy
email: bruno.giacomazzo@unimib.it
phone: (+39) 02 6448 2321
web: http://www.brunogiacomazzo.org
---------------------------------------------------------------------
There are only 10 types of people in the world:
Those who understand binary, and those who don't
----------------------------------------------------------------------