AngelFP / VisualPIC

Data Visualization for Particle-in-Cell Codes.
GNU General Public License v3.0
50 stars 13 forks source link

Some changes to make VisualPIC work well with OSIRIS #69

Closed Iamtheboneofmysword closed 6 months ago

Iamtheboneofmysword commented 6 months ago

VisualPIC is such a wonderful tool to visualize 3D PIC data! Recently, I encountered some issues while using it to process my OSIRIS-3D data. I found that making the following changes can resolve them. Furthermore, I have tested the compatibility of the modified code with openPMD format data, and I believe these changes should be safe.

  1. The add_derived_field() function in visualpic/data_handling/data_container.py performs normally when using openPMD data, but will report the following errors that cannot access local variable 'base_fields' where it is not associated with a value when loading OSIRIS data. Notice that before the Reuse add_derived_field commit, the add_derived_field() was implemented actually within the _generate_derived_fields(self) function, and the line derived_field_list.append(...) would be executed only when the condition if set(required_fields).issubset(folder_field_names): was met. So I do the same in the add_derived_field() function.
  2. The setup_interface(): function in the visualpic/ui/basic_render_window.py will report setRange(self, min: int, max: int): argument 1 has unexpected type 'numpy.float64' only when using OSIRIS-3D data. And I convert the relevant variables to integer type to solve the issue.
  3. I changed the __init__ function in visualpic/ui/controls/mpl_figure_with_draggable_points.py to solve the issue that whenever I try to edit visual properties, it reports Figure.__init__() takes from 1 to 3 positional arguments but 9 were given. This issue also happens when using openPMD data.

I hope these small changes can help. Best regards!

AngelFP commented 6 months ago

Hi @Iamtheboneofmysword, that's great, thanks! It's nice to hear you're using visualpic with osiris. It's been a while since we've used osiris here, so I wasn't very confident that the reader was still working.

Could you fix the small formatting problems that flake8 is raising?

./visualpic/ui/basic_render_window.py:98:80: E501 line too long (80 > 79 characters)
./visualpic/ui/basic_render_window.py:99:80: E501 line too long (80 > 79 characters)
./visualpic/ui/controls/mpl_figure_with_draggable_points.py:36:22: E128 continuation line under-indented for visual indent
./visualpic/ui/controls/mpl_figure_with_draggable_points.py:37:22: E128 continuation line under-indented for visual indent
./visualpic/ui/controls/mpl_figure_with_draggable_points.py:38:22: E128 continuation line under-indented for visual indent

After that I'll merge the PR.

AngelFP commented 6 months ago

By the way, do you know how is the progress with openpmd support in OSIRIS? I was actually hoping to be able to remove the osiris data reader, since I'm not able to maintain it anymore.

Iamtheboneofmysword commented 6 months ago

Hi @AngelFP I think the flake8 checks can be passed now. I'm sorry for not sure about the progress in openpmd support in OSIRIS. Perhaps it's not a high priority, I think :(

AngelFP commented 6 months ago

Hi @AngelFP I think the flake8 checks can be passed now. I'm sorry for not sure about the progress in openpmd support in OSIRIS. Perhaps it's not a high priority, I think :(

No worries. Good to know in any case that the reader is still working :)