Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions analysator/pyPlots/plot_vdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,21 +809,40 @@ def plot_vdf(filename=None,

# Extracts Vbulk (used in case (i) slice in B-frame and/or (ii) cbulk is neither None nor a string
Vbulk=None
warn_bulk_centering = False
if vlsvReader.check_variable('moments'):
# This should be a restart file
Vbulk = vlsvReader.read_variable('restart_V',cellid)
elif vlsvReader.check_variable('V'):
# regular bulk file, currently analysator supports pre- and post-multipop files with "V"
Vbulk = vlsvReader.read_variable('V',cellid)
elif vlsvReader.check_variable('vg_v'):
# regular bulk file, v5 analysator supports pre- and post-multipop files with "vg_v"
Vbulk = vlsvReader.read_variable('vg_v',cellid)
elif vlsvReader.check_variable(pop+'/vg_v'):
# multipop v5 bulk file
Vbulk = vlsvReader.read_variable(pop+'/vg_v',cellid)
warn_bulk_centering = True
elif vlsvReader.check_variable(pop+'/V'):
# multipop bulk file
Vbulk = vlsvReader.read_variable(pop+'/V',cellid)
warn_bulk_centering = True
elif vlsvReader.check_variable(pop+'/vg_v'):
# multipop V5 bulk file
Vbulk = vlsvReader.read_variable(pop+'/vg_v',cellid)
warn_bulk_centering = True
else:
# regular bulk file, currently analysator supports pre- and post-multipop files with "V"
Vbulk = vlsvReader.read_variable('V',cellid)
# fallback: get bulkV from the VDF itself
velcells = vlsvReader.read_velocity_cells(cellid, pop=pop)
velcellslist = list(zip(*velcells.items()))
f = np.asarray(velcellslist[1])
V = vlsvReader.get_velocity_cell_coordinates(velcellslist[0], pop=pop)
Vbulk = np.average(V, axis=0, weights=f)
warn_bulk_centering = True

if(warn_bulk_centering):
logging.warning("Bulk V centering based on population bulkV, not total plasma center-of-mass bulkV")

if Vbulk is None:
logging.info("Error in finding plasma bulk velocity!")
sys.exit()
Expand Down