From d9877c799381fde54a72444e66ba8653be3d0bed Mon Sep 17 00:00:00 2001 From: csendlinger Date: Fri, 18 Sep 2026 10:55:12 +0200 Subject: [PATCH] more changes to plot_charge --- analysis/plot_charge.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/analysis/plot_charge.py b/analysis/plot_charge.py index 4bf5d9b..35a78b3 100644 --- a/analysis/plot_charge.py +++ b/analysis/plot_charge.py @@ -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-"