Skip to content

Commit

Permalink
Adding the table formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DhruvSondhi committed Jun 9, 2021
1 parent c73cfad commit 900972b
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions tardis/simulation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from tardis.montecarlo import montecarlo_configuration as mc_config_module
from tardis.visualization.widgets.util import create_table_widget

# from ipython.display import display

# Adding logging support
logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -397,29 +395,28 @@ def interactive_widget(self):
"""

# Creating the List for no of iterations
iteration_number = []
for iteration in range(self.iterations):
iteration_number.append(iteration)
iterations = np.arange(self.iterations)

# Instantiated the Dataframes for storing the Plasma Data
df = pd.DataFrame(index=np.arange(len(self.model.t_rad)))

# Populating the DataFrame for the Simulation Data for t_rad & w
for iteration in range(0, self.iterations):
df[f"t_rad[{iteration}]"] = self.iterations_t_rad[iteration]
df[f"w[{iteration}]"] = self.iterations_w[iteration]
for iteration in iterations:
df[f"t_rad [{iteration}]"] = self.iterations_t_rad[iteration]
df[f"w [{iteration}]"] = self.iterations_w[iteration]

# Instantiated the Dropdown Widget
drop_down = widgets.Dropdown(
options=iteration_number, value=0, description="Iteration No",
options=iterations, value=0, description="Iteration No.",
)

# Displays the t_rad & w values for the chosen iteration
def display_with_iteration(value):
df_output = df[[f"t_rad[{value}]", f"w[{value}]"]]
df_output = df[[f"t_rad [{value}]", f"w [{value}]"]]
df_output.index.name = "Shell No."
table_output = create_table_widget(
data=df_output,
col_widths=[6, 47, 47],
col_widths=[20, 40, 40],
table_options={"maxVisibleRows": 10},
)
display(table_output)
Expand All @@ -428,12 +425,12 @@ def display_with_iteration(value):
out = widgets.Output()

# Checks for the change in the values of the Drop down list
def fun(ipw_obj):
def observe_change_index(ipw_obj):
with out:
out.clear_output()
display_with_iteration(ipw_obj["new"])

drop_down.observe(fun, "index")
drop_down.observe(observe_change_index, "index")
display(drop_down, out)

def log_plasma_state(
Expand Down

0 comments on commit 900972b

Please sign in to comment.