From 2474b1d0ae47ca2ac173babc778bfdb6fd87ed04 Mon Sep 17 00:00:00 2001 From: shimwell Date: Thu, 24 Nov 2022 23:19:15 +0000 Subject: [PATCH 1/2] fxed aspect ratio of directional plot --- openmc_source_plotter/core.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/openmc_source_plotter/core.py b/openmc_source_plotter/core.py index c44dcea..ef2e343 100644 --- a/openmc_source_plotter/core.py +++ b/openmc_source_plotter/core.py @@ -99,7 +99,7 @@ def plot_source_position( n_samples: int = 2000, prn_seed: int = 1, ): - """makes a plot of the initial creation postions of an OpenMC source(s) + """makes a plot of the initial creation positions of an OpenMC source(s) Args: figure: Optional base plotly figure to use for the plot. Passing in @@ -148,7 +148,7 @@ def plot_source_direction( n_samples: int = 2000, prn_seed: int = 1, ): - """makes a plot of the initial creation postions of an OpenMC source(s) + """makes a plot of the initial creation positions of an OpenMC source(s) Args: figure: Optional base plotly figure to use for the plot. Passing in @@ -166,6 +166,18 @@ def plot_source_direction( data = self.sample_initial_particles(n_samples, prn_seed) + biggest_coord = max(max([particle.r[0] for particle in data]), max([particle.r[1] for particle in data]), max([particle.r[2] for particle in data])) + smallest_coord = min(min([particle.r[0] for particle in data]), min([particle.r[1] for particle in data]), min([particle.r[2] for particle in data])) + + figure.add_trace( + { + "type": 'scatter3d', + "marker":{"color": 'rgba(255,255,255,0)'}, + "x": [biggest_coord, smallest_coord], + "y": [biggest_coord, smallest_coord], + "z": [biggest_coord, smallest_coord], + } + ) figure.add_trace( { "type": "cone", From 57774ee3b1206ce3f69a49b9b1688921204c988e Mon Sep 17 00:00:00 2001 From: shimwell Date: Thu, 24 Nov 2022 23:20:11 +0000 Subject: [PATCH 2/2] [skip ci] Apply formatting changes --- openmc_source_plotter/core.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/openmc_source_plotter/core.py b/openmc_source_plotter/core.py index ef2e343..0c30a39 100644 --- a/openmc_source_plotter/core.py +++ b/openmc_source_plotter/core.py @@ -166,13 +166,21 @@ def plot_source_direction( data = self.sample_initial_particles(n_samples, prn_seed) - biggest_coord = max(max([particle.r[0] for particle in data]), max([particle.r[1] for particle in data]), max([particle.r[2] for particle in data])) - smallest_coord = min(min([particle.r[0] for particle in data]), min([particle.r[1] for particle in data]), min([particle.r[2] for particle in data])) + biggest_coord = max( + max([particle.r[0] for particle in data]), + max([particle.r[1] for particle in data]), + max([particle.r[2] for particle in data]), + ) + smallest_coord = min( + min([particle.r[0] for particle in data]), + min([particle.r[1] for particle in data]), + min([particle.r[2] for particle in data]), + ) figure.add_trace( { - "type": 'scatter3d', - "marker":{"color": 'rgba(255,255,255,0)'}, + "type": "scatter3d", + "marker": {"color": "rgba(255,255,255,0)"}, "x": [biggest_coord, smallest_coord], "y": [biggest_coord, smallest_coord], "z": [biggest_coord, smallest_coord],