Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
zhichen3 committed Dec 23, 2024
1 parent 2262adc commit e286601
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions Exec/science/xrb_spherical/analysis/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,9 @@ def slice(fnames:List[str], fields:List[str],
# Output plot file name
outName = "xrb_spherical_slice.png"

# Determine the appropriate time unit
refTimeStamp = ts[0].current_time
timeUnit = "ms"
if float(refTimeStamp) < 1e-4:
timeUnit = "us"

refTimeStamp = ts[0].current_time.in_units(timeUnit)

# We will check if all files have the same timestamp later.
# This matters on how we annotate timestamp for the slice plots.
sameTime = True
if len(fnames) > 1:
sameTime = all(refTimeStamp == ds.current_time.in_units(timeUnit) for ds in ts)

for j, ds in enumerate(ts):
# Process information for each dataset

currentTime = ds.current_time.in_units(timeUnit)

# Some geometry properties
rr = ds.domain_right_edge[0].in_units("km")
rl = ds.domain_left_edge[0].in_units("km")
Expand Down Expand Up @@ -103,7 +87,7 @@ def slice(fnames:List[str], fields:List[str],
for i, field in enumerate(fields):
# Plot each field parameter

sp = yt.SlicePlot(ds, 'phi', field, width=box_widths, fontsize=14)
sp = yt.SlicePlot(ds, 'phi', field, width=box_widths, fontsize=16)
sp.set_center(center)

sp.set_cmap(field, "viridis")
Expand Down Expand Up @@ -131,10 +115,23 @@ def slice(fnames:List[str], fields:List[str],

sp._setup_plots()

if sameTime:
# fig.text(0.8, 0.05, f"t = {refTimeStamp:.2f}",
# horizontalalignment='right', verticalalignment='center',
# color="black", transform=fig.transFigure)
if len(fnames) == 1:
time = ts[0].current_time.in_units("ms")
if float(time) < 1e-1:
time = ts[0].current_time.in_units("us")

# Determine position of the text on grid
xyPositions = {(1, 1): (0.78, 0.02),
(1, 2): (0.95, 0.075),
(2, 2): (0.78, 0.02),
(2, 3): (0.9, 0.02),
(3, 3): (0.78, 0.02)
}
xPosition, yPosition = xyPositions.get((nx, ny), (0.78, 0.02))

fig.text(xPosition, yPosition, f"t = {time:.3f}", fontsize=16,
horizontalalignment='right', verticalalignment='bottom',
color="black", transform=fig.transFigure)

outName = f"{ts[0]}_slice.png"

Expand Down

0 comments on commit e286601

Please sign in to comment.