diff options
author | Volker Hoffmann <volker@cheleb.net> | 2013-09-17 09:10:09 +0200 |
---|---|---|
committer | Volker Hoffmann <volker@cheleb.net> | 2013-09-17 09:10:09 +0200 |
commit | e59dbdfe31d915c500482a910bcb32460418502d (patch) | |
tree | bbfd1747713764e41435779a0269d3d67e0ddd48 | |
parent | de8bed79aa07f73162eb368ec06c65db93c4eb01 (diff) |
use argparse; only show requested figures
-rw-r--r-- | mkcuts_dvpT.py | 151 |
1 files changed, 75 insertions, 76 deletions
diff --git a/mkcuts_dvpT.py b/mkcuts_dvpT.py index 5d1cd42..cc9ed85 100644 --- a/mkcuts_dvpT.py +++ b/mkcuts_dvpT.py @@ -15,25 +15,28 @@ from pymses.analysis.visualization import Camera, ScalarOperator, SliceMap, \ import matplotlib.pyplot as plt import numpy as np import sys +import argparse """ Main Routine. Define Cameras. Take Slices. Plot. """ def main(): - # Defaults - iout = 1 - # Parse Arguments - if len(sys.argv) == 2: - iout = int(sys.argv[1]) + parser = argparse.ArgumentParser() + parser.add_argument("iout", type=int, help='Output', default=1) + parser.add_argument("-d", action="store_true", help='Show Density Cuts') + parser.add_argument("-v", action="store_true", help='Show Velocity Cuts') + parser.add_argument("-p", action="store_true", help='Show Pressure Cuts') + parser.add_argument("-T", action="store_true", help='Show Temperature Cuts') + args = parser.parse_args() # Give Feedback - print "Creating Cuts for Output %i." % iout + print "Creating Cuts for Output %i." % args.iout print "" # Link AMR Data - output = RamsesOutput(".", iout) + output = RamsesOutput(".", args.iout) source = output.amr_source(["rho", "vel", "P"]) # Define Cameras @@ -121,82 +124,78 @@ def main(): ext = output.info["boxlen"] * np.array([-0.5, 0.5, -0.5, 0.5]) # Plot Density - f1 = plt.figure(1) - plt.imshow(rhoZ, cmap=rho_cm, extent=ext, interpolation='none') - plt.colorbar() - plt.grid() - plt.title('Log10 Density Cut [g/cc], t=%.2f' % output.info["time"]) - plt.xlabel('X') - plt.ylabel('Y') - - f2 = plt.figure(2) - plt.imshow(rhoX, cmap=rho_cm, extent=ext, interpolation='none') - plt.colorbar() - plt.grid() - plt.title('Log10 Density Cut [g/cc], t=%.2f' % output.info["time"]) - plt.xlabel('Y') - plt.ylabel('Z') + if args.d: + f1 = plt.figure(1) + plt.imshow(rhoZ, cmap=rho_cm, extent=ext, interpolation='none') + plt.colorbar() + plt.grid() + plt.title('Log10 Density Cut [g/cc], t=%.2f' % output.info["time"]) + plt.xlabel('X') + plt.ylabel('Y') + + f2 = plt.figure(2) + plt.imshow(rhoX, cmap=rho_cm, extent=ext, interpolation='none') + plt.colorbar() + plt.grid() + plt.title('Log10 Density Cut [g/cc], t=%.2f' % output.info["time"]) + plt.xlabel('Y') + plt.ylabel('Z') # Plot Velocity - f3 = plt.figure(3) - plt.imshow(velZ, cmap=vel_cm, extent=ext) - plt.colorbar() - plt.grid() - plt.title('Total Flow Speed Cut [km/s], t=%.2f' % output.info["time"]) - plt.xlabel('X') - plt.ylabel('Y') - - f4 = plt.figure(4) - plt.imshow(velX, cmap=vel_cm, extent=ext) - plt.colorbar() - plt.grid() - plt.title('Total Flow Speed Cut [km/s], t=%.2f' % output.info["time"]) - plt.xlabel('Y') - plt.ylabel('Z') + if args.v: + f3 = plt.figure(3) + plt.imshow(velZ, cmap=vel_cm, extent=ext) + plt.colorbar() + plt.grid() + plt.title('Total Flow Speed Cut [km/s], t=%.2f' % output.info["time"]) + plt.xlabel('X') + plt.ylabel('Y') + + f4 = plt.figure(4) + plt.imshow(velX, cmap=vel_cm, extent=ext) + plt.colorbar() + plt.grid() + plt.title('Total Flow Speed Cut [km/s], t=%.2f' % output.info["time"]) + plt.xlabel('Y') + plt.ylabel('Z') # Plot Pressure - f5 = plt.figure(5) - plt.imshow(preZ, cmap=pre_cm, extent=ext, interpolation='none') - plt.colorbar() - plt.grid() - plt.title('Log10 Pressure Cut [debye], t=%.2f' % output.info["time"]) - plt.xlabel('X') - plt.ylabel('Y') - - f6 = plt.figure(6) - plt.imshow(preX, cmap=pre_cm, extent=ext, interpolation='none') - plt.colorbar() - plt.grid() - plt.title('Log10 Pressure Cut [debye], t=%.2f' % output.info["time"]) - plt.xlabel('Y') - plt.ylabel('Z') + if args.p: + f5 = plt.figure(5) + plt.imshow(preZ, cmap=pre_cm, extent=ext, interpolation='none') + plt.colorbar() + plt.grid() + plt.title('Log10 Pressure Cut [debye], t=%.2f' % output.info["time"]) + plt.xlabel('X') + plt.ylabel('Y') + + f6 = plt.figure(6) + plt.imshow(preX, cmap=pre_cm, extent=ext, interpolation='none') + plt.colorbar() + plt.grid() + plt.title('Log10 Pressure Cut [debye], t=%.2f' % output.info["time"]) + plt.xlabel('Y') + plt.ylabel('Z') # Plot Temperature - f7 = plt.figure(7) - plt.imshow(TZ, cmap=pre_cm, extent=ext, interpolation='none') - plt.colorbar() - plt.grid() - plt.title('Temperature Cut [K], t=%.2f' % output.info["time"]) - plt.xlabel('X') - plt.ylabel('Y') - - f8 = plt.figure(8) - plt.imshow(TX, cmap=pre_cm, extent=ext, interpolation='none') - plt.colorbar() - plt.grid() - plt.title('Temperature Cut [K], t=%.2f' % output.info["time"]) - plt.xlabel('Y') - plt.ylabel('Z') - - #plt.close(f1) - #plt.close(f2) - # plt.close(f3) - # plt.close(f4) - #plt.close(f5) - #plt.close(f6) - - plt.show() + if args.T: + f7 = plt.figure(7) + plt.imshow(TZ, cmap=pre_cm, extent=ext, interpolation='none') + plt.colorbar() + plt.grid() + plt.title('Temperature Cut [K], t=%.2f' % output.info["time"]) + plt.xlabel('X') + plt.ylabel('Y') + + f8 = plt.figure(8) + plt.imshow(TX, cmap=pre_cm, extent=ext, interpolation='none') + plt.colorbar() + plt.grid() + plt.title('Temperature Cut [K], t=%.2f' % output.info["time"]) + plt.xlabel('Y') + plt.ylabel('Z') + plt.show() """ Jump into Main(). |