more changes to plot_charge
This commit is contained in:
+13
-6
@@ -145,7 +145,7 @@ if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Program to create a plot of the charge against time from the output of KARL")
|
||||
parser.add_argument("dir", type = str, help="directory where the files are stored in")
|
||||
parser.add_argument("basename", type = str, help = 'identifying pattern of the files (i.e. basename[0-9]*\\.h5])')
|
||||
parser.add_argument('--losses', action='store_true', help = 'create wall loss rate plot instead')
|
||||
parser.add_argument('--losses', nargs='?', choices=['Wall', 'Scattering'], help = 'choose to create loss rate plot (either from wall losses or due to scatterings)')
|
||||
parser.add_argument("--pattern", type = str, nargs = '?', help = 'Regular expression pattern, that specifies the naming of the files (by default [0-9]*). Gets added to dir+basename+pattern+".h5".', default = '[0-9]*')
|
||||
parser.add_argument("--width", type = str, nargs = '?', default="thesis", help = "Either \'thesis\' or \'beamer\' as defined in plot_standards.py")
|
||||
parser.add_argument("--fraction", type = float, default=1, nargs="?", help= "the fraction of width that the plot should occupy, as defined in plot_standards.py")
|
||||
@@ -165,8 +165,11 @@ if __name__ == '__main__':
|
||||
print(f"{args.width} is not a valid parameter for width; fall back to \'thesis\'")
|
||||
args.width = 'thesis'
|
||||
|
||||
if args.losses:
|
||||
times, charges = get_time_and_wall_losses(files, args.species)
|
||||
if args.losses in ['Wall', 'Scattering']:
|
||||
if args.losses == 'Wall':
|
||||
times, charges = get_time_and_wall_losses(files, args.species)
|
||||
else:
|
||||
times, charges = get_time_and_scatter_losses(files, args.species)
|
||||
else:
|
||||
times, charges = get_time_and_total_charge_(files, args.species)
|
||||
|
||||
@@ -178,9 +181,11 @@ if __name__ == '__main__':
|
||||
|
||||
plt.rcParams.update({'font.size': 10})
|
||||
fig = plt.figure(figsize=pst.set_size(args.width))
|
||||
plt.plot(times, charges, marker = 'x', label = legstr)
|
||||
if args.losses:
|
||||
plt.plot(times, charges, marker = '.', label = legstr)
|
||||
if args.losses == 'Wall':
|
||||
plt.ylabel('loss rate (1/s)')
|
||||
elif args.losses == 'Scattering':
|
||||
plt.ylabel("upscattering (particles/s)")
|
||||
else:
|
||||
plt.ylabel('charge (C)')
|
||||
plt.xlabel('time (s)')
|
||||
@@ -196,8 +201,10 @@ if __name__ == '__main__':
|
||||
|
||||
os.makedirs(outname, exist_ok=True)
|
||||
|
||||
if args.losses:
|
||||
if args.losses == 'Wall':
|
||||
outname += args.basename + "_wallLossRateAgainstTime_species-"
|
||||
elif args.losses == 'Scattering':
|
||||
outname += args.basename + "_scatteringLossRateAgainstTime_species-"
|
||||
else:
|
||||
outname += args.basename + "_chargeAgainstTime_species-"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user