Some improvements
This commit is contained in:
+171
-156
@@ -109,26 +109,23 @@ parser.add_argument("--print_outputs",
|
||||
help="print names of outputs",
|
||||
action='store_true')
|
||||
|
||||
parser.add_argument(
|
||||
"--fft", help="use quick and dirty fft rendering", action="store_true"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--images",
|
||||
nargs="*",
|
||||
default=["coldens", "rho", "speed", "Q", "T"],
|
||||
choices=["coldens", "rho", "speed", "Q", "T", "levels", "cpu"],
|
||||
)
|
||||
parser.add_argument(
|
||||
"--axes", nargs="*", default=["x", "y", "z"], choices=["x", "y", "z"]
|
||||
)
|
||||
parser.add_argument("--zoom", help="zoom", type=float, default=2.0)
|
||||
parser.add_argument(
|
||||
"-ms",
|
||||
"--mapsize",
|
||||
help="size of the maps created in he map mode (in pixel)",
|
||||
type=int,
|
||||
default=1024,
|
||||
)
|
||||
parser.add_argument("--fft",
|
||||
help="use quick and dirty fft rendering",
|
||||
action='store_true')
|
||||
parser.add_argument("--images", nargs='*',
|
||||
default=['coldens', 'rho', 'speed', 'Q', 'T'],
|
||||
choices=['coldens', 'rho', 'speed', 'Q', 'T', 'levels', 'cpu', 'jeans', 'jeans_ratio'])
|
||||
parser.add_argument("--axes", nargs='*',
|
||||
default=['x', 'y', 'z'],
|
||||
choices=['x', 'y', 'z'])
|
||||
parser.add_argument("--zoom",
|
||||
help="zoom",
|
||||
type=float,
|
||||
default=2.)
|
||||
parser.add_argument("-ms", "--mapsize",
|
||||
help="size of the maps created in he map mode (in pixel)",
|
||||
type=int,
|
||||
default=1024)
|
||||
|
||||
|
||||
parser.add_argument("--nb_bin",
|
||||
@@ -206,8 +203,8 @@ if args.format == 'pdf':
|
||||
|
||||
|
||||
if args.beamer:
|
||||
dp.P.rcParams['font.family'] = 'sans-serif'
|
||||
dp.P.rcParams['figure.figsize'] = (7, 4.5)
|
||||
dp.P.rcParams['font.family'] = 'sans-serif'
|
||||
dp.P.rcParams['figure.figsize'] = (7, 4.5)
|
||||
|
||||
# Plot properties
|
||||
dp.P.rcParams['image.cmap'] = args.colormap
|
||||
@@ -221,148 +218,166 @@ me.P = dp.P
|
||||
# List of id that were successfully computed
|
||||
run_succeded = {}
|
||||
|
||||
|
||||
# Care for dependencies
|
||||
images = args.images
|
||||
if 'jeans_ratio' in images and not 'jeans' in images :
|
||||
images = ['jeans'] + images
|
||||
if 'jeans_ratio' in images and not 'levels' in images :
|
||||
images.append('levels')
|
||||
if 'jeans' in images and not 'T' in images :
|
||||
images.append('T')
|
||||
if ('T' in images or 'jeans' in images) and not 'rho' in images :
|
||||
images.append('rho')
|
||||
if 'Q' in images and not 'coldens' in images :
|
||||
images.append('coldens')
|
||||
|
||||
# Go through all runs
|
||||
for run in runs:
|
||||
path_suffix = project + "/" + run
|
||||
path_in = storage_in + path_suffix
|
||||
path_out = storage_out + path_suffix
|
||||
path_suffix = project + '/' + run
|
||||
path_in = storage_in + path_suffix
|
||||
path_out = storage_out + path_suffix
|
||||
|
||||
if args.tag == '':
|
||||
tag_run = run
|
||||
else:
|
||||
tag_run = run + '_' + args.tag
|
||||
if args.tag == '':
|
||||
tag_run = run
|
||||
else:
|
||||
tag_run = run + '_' + args.tag
|
||||
|
||||
if not os.path.exists(path_out):
|
||||
os.makedirs(path_out)
|
||||
try:
|
||||
copy(path_in + "/disk.nml", path_out)
|
||||
copy(path_in + "/output_00001/compilation.txt", path_out)
|
||||
except:
|
||||
pass
|
||||
if not os.path.exists(path_out):
|
||||
os.makedirs(path_out)
|
||||
try:
|
||||
copy(path_in + '/disk.nml', path_out)
|
||||
copy(path_in + '/output_00001/compilation.txt', path_out)
|
||||
except:
|
||||
pass
|
||||
|
||||
run_succeded[run] = []
|
||||
run_succeded[run] = []
|
||||
|
||||
if args.which_outputs in ['all', 'time'] :
|
||||
names = glob.glob(path_in + "/output_[0-9][0-9][0-9][0-9][0-9]")
|
||||
nums_all = [int(n.split('/')[-1].split('_')[1]) for n in names]
|
||||
nums_all = np.sort(nums_all)
|
||||
if args.which_outputs == 'all':
|
||||
nums = nums_all
|
||||
else:
|
||||
time = [dp.get_time(path_in, n) for n in nums_all]
|
||||
nums = [n for i,n in enumerate(nums_all) if time[i] >= args.time_begin and time[i] < args.time_end]
|
||||
else:
|
||||
nums = range(first, last + 1, step)
|
||||
if args.which_outputs in ['all', 'time'] :
|
||||
names = glob.glob(path_in + "/output_[0-9][0-9][0-9][0-9][0-9]")
|
||||
nums_all = [int(n.split('/')[-1].split('_')[1]) for n in names]
|
||||
nums_all = np.sort(nums_all)
|
||||
if args.which_outputs == 'all':
|
||||
nums = nums_all
|
||||
else:
|
||||
time = [dp.get_time(path_in, n) for n in nums_all]
|
||||
nums = [n for i,n in enumerate(nums_all) if time[i] >= args.time_begin and time[i] < args.time_end]
|
||||
else:
|
||||
nums = range(first, last + 1, step)
|
||||
|
||||
for num in nums:
|
||||
failures = 0
|
||||
success = False
|
||||
for num in nums:
|
||||
failures = 0
|
||||
success = False
|
||||
|
||||
while not success:
|
||||
try:
|
||||
maps_disk = None
|
||||
if args.print_outputs:
|
||||
print("[{}, {}]".format(run, num))
|
||||
if args.maps:
|
||||
print("[{}, {}] computing maps".format(run, num))
|
||||
maps_disk = dp.compute_image_data(path_in, num,
|
||||
radius=rad,
|
||||
path_out=path_out,
|
||||
tag=tag_run,
|
||||
map_size=args.mapsize,
|
||||
force=args.force_redo,
|
||||
axes_los=args.axes,
|
||||
images=args.images,
|
||||
pos_star=np.array([args.x, args.y, args.z]),
|
||||
fft=args.fft)
|
||||
print("[{}, {}] maps computed".format(run, num))
|
||||
if args.plot_maps:
|
||||
print("[{}, {}] plotting maps".format(run, num))
|
||||
maps_disk = dp.plot_maps(path_out, num,
|
||||
maps_disk=maps_disk,
|
||||
axes_los=args.axes,
|
||||
images=args.images,
|
||||
tag=tag_run,
|
||||
force=args.force_redo,
|
||||
interactive=args.interactive,
|
||||
put_title=(not args.beamer))
|
||||
print("[{}, {}] maps plotted".format(run, num))
|
||||
if args.disk:
|
||||
print("[{}, {}] computing disk props".format(run, num))
|
||||
dp.disk_prop(path_in, num, path_out=path_out,
|
||||
nb_bin=args.nb_bin,
|
||||
binning=args.binning,
|
||||
rad_ext=args.rad_ext,
|
||||
force=args.force_redo,
|
||||
pos_star=np.array([args.x, args.y, args.z]))
|
||||
print("[{}, {}] disk_props computed".format(run, num))
|
||||
if args.plot_disk:
|
||||
print("[{}, {}] plotting disk props".format(run, num))
|
||||
dp.plot_disk_prop(path_out, num, tag=tag_run,
|
||||
while not success:
|
||||
try:
|
||||
maps_disk = None
|
||||
if args.print_outputs:
|
||||
print("[{}, {}]".format(run, num))
|
||||
if args.maps:
|
||||
print("[{}, {}] computing maps".format(run, num))
|
||||
maps_disk = dp.compute_image_data(path_in, num,
|
||||
radius=rad,
|
||||
path_out=path_out,
|
||||
tag=tag_run,
|
||||
map_size=args.mapsize,
|
||||
force=args.force_redo,
|
||||
axes_los=args.axes,
|
||||
images=images,
|
||||
pos_star=np.array([args.x, args.y, args.z]),
|
||||
fft=args.fft)
|
||||
print("[{}, {}] maps computed".format(run, num))
|
||||
if args.plot_maps:
|
||||
print("[{}, {}] plotting maps".format(run, num))
|
||||
maps_disk = dp.plot_maps(path_out, num,
|
||||
maps_disk=maps_disk,
|
||||
axes_los=args.axes,
|
||||
images=images,
|
||||
tag=tag_run,
|
||||
force=args.force_redo,
|
||||
interactive=args.interactive,
|
||||
put_title=(not args.beamer))
|
||||
print("[{}, {}] maps plotted".format(run, num))
|
||||
if args.disk:
|
||||
print("[{}, {}] computing disk props".format(run, num))
|
||||
dp.disk_prop(path_in, num, path_out=path_out,
|
||||
nb_bin=args.nb_bin,
|
||||
binning=args.binning,
|
||||
rad_ext=args.rad_ext,
|
||||
force=args.force_redo,
|
||||
interactive=args.interactive,
|
||||
put_title=(not args.beamer))
|
||||
print("[{}, {}] disk props plotted".format(run, num))
|
||||
if args.pdf:
|
||||
print("[{}, {}] computing pdf #1".format(run, num))
|
||||
dp.disk_pdf(path_out, num, maps_disk,
|
||||
pos_star=np.array([args.x, args.y, args.z]),
|
||||
force=args.force_redo,
|
||||
tag=tag_run,
|
||||
nb_bin_hist=args.pdf_nb_bin,
|
||||
interactive=args.interactive,
|
||||
put_title=(not args.beamer))
|
||||
print("[{}, {}] pdf #1 computed".format(run, num))
|
||||
if args.pdf2:
|
||||
print("[{}, {}] computing pdf #2".format(run, num))
|
||||
me.get_pdf(path_in, num, path_out=path_out,
|
||||
force=args.force_redo,
|
||||
tag=tag_run)
|
||||
print("[{}, {}] pdf #2 computed".format(run, num))
|
||||
if args.clump:
|
||||
print("[{}, {}] computing clumps".format(run, num))
|
||||
dp.clump_study(path_in, num, path_out, tag_run)
|
||||
print("[{}, {}] clumps computed".format(run, num))
|
||||
# If we are here, success !
|
||||
success = True
|
||||
run_succeded[run].append(num)
|
||||
except (ValueError, IOError, KeyError) as e:
|
||||
print(e)
|
||||
if args.watch and failures < args.allowed_failures:
|
||||
failures = failures + 1
|
||||
print("Unable to proceed for run {} output {}. Trying again in {} s ({} tries remaining)".format(run, num, args.waiting_time, args.allowed_failures - failures))
|
||||
time.sleep(args.waiting_time)
|
||||
elif args.skip:
|
||||
break
|
||||
else:
|
||||
raise
|
||||
if args.evolution:
|
||||
print("[{}] plotting evolution".format(run))
|
||||
dp.evolution(path_out, run_succeded[run],
|
||||
force=args.force_redo,
|
||||
tag=args.tag,
|
||||
interactive=args.interactive,
|
||||
pdf=args.pdf or args.cpdf)
|
||||
print("[{}] evolution plotted".format(run))
|
||||
pos_star=np.array([args.x, args.y, args.z]))
|
||||
print("[{}, {}] disk_props computed".format(run, num))
|
||||
if args.plot_disk:
|
||||
print("[{}, {}] plotting disk props".format(run, num))
|
||||
dp.plot_disk_prop(path_out, num, tag=tag_run,
|
||||
force=args.force_redo,
|
||||
interactive=args.interactive,
|
||||
put_title=(not args.beamer))
|
||||
print("[{}, {}] disk props plotted".format(run, num))
|
||||
if args.pdf:
|
||||
print("[{}, {}] computing pdf #1".format(run, num))
|
||||
dp.disk_pdf(path_out, num, maps_disk,
|
||||
pos_star=np.array([args.x, args.y, args.z]),
|
||||
force=args.force_redo,
|
||||
tag=tag_run,
|
||||
nb_bin_hist=args.pdf_nb_bin,
|
||||
interactive=args.interactive,
|
||||
put_title=(not args.beamer))
|
||||
print("[{}, {}] pdf #1 computed".format(run, num))
|
||||
if args.pdf2:
|
||||
print("[{}, {}] computing pdf #2".format(run, num))
|
||||
me.get_pdf(path_in, num, path_out=path_out,
|
||||
force=args.force_redo,
|
||||
tag=tag_run)
|
||||
print("[{}, {}] pdf #2 computed".format(run, num))
|
||||
if args.clump:
|
||||
print("[{}, {}] computing clumps".format(run, num))
|
||||
dp.clump_study(path_in, num, path_out, tag_run)
|
||||
print("[{}, {}] clumps computed".format(run, num))
|
||||
if args.interactive:
|
||||
print("[{}, {}] Interactive session".format(run, num))
|
||||
maps_disk = dp.interactive_plots(args, path_out, num, tag=tag_run)
|
||||
# If we are here, success !
|
||||
success = True
|
||||
run_succeded[run].append(num)
|
||||
except (ValueError, IOError, KeyError) as e:
|
||||
print(e)
|
||||
if(args.watch and failures < args.allowed_failures):
|
||||
failures = failures + 1
|
||||
print("Unable to proceed for run {} output {}. Trying again in {} s ({} tries remaining)".format(run, num, args.waiting_time, args.allowed_failures - failures))
|
||||
time.sleep(args.waiting_time)
|
||||
elif args.skip:
|
||||
break
|
||||
else:
|
||||
raise
|
||||
if args.evolution:
|
||||
print("[{}] plotting evolution".format(run))
|
||||
dp.evolution(path_out, run_succeded[run],
|
||||
force=args.force_redo,
|
||||
tag=args.tag,
|
||||
interactive=args.interactive,
|
||||
pdf=args.pdf or args.cpdf)
|
||||
print("[{}] evolution plotted".format(run))
|
||||
|
||||
if args.compare:
|
||||
path_suffix = project
|
||||
path = storage_out + path_suffix
|
||||
path_suffix = project
|
||||
path = storage_out + path_suffix
|
||||
|
||||
if (args.time_avg):
|
||||
dp.compare(path, runs, run_succeded,
|
||||
path_out=path + '/comp',
|
||||
force=args.force_redo,
|
||||
interactive=args.interactive,
|
||||
Q_in_name=args.Q_in_name,
|
||||
tag=args.tag,
|
||||
pdf=args.pdf or args.cpdf)
|
||||
else:
|
||||
for i in range(first, last + 1, step):
|
||||
# Select usable runs
|
||||
runs_ok = [run for run in runs if i in run_succeded[run]]
|
||||
if (args.time_avg):
|
||||
dp.compare(path, runs, run_succeded,
|
||||
path_out=path + '/comp',
|
||||
force=args.force_redo,
|
||||
interactive=args.interactive,
|
||||
Q_in_name=args.Q_in_name,
|
||||
tag=args.tag,
|
||||
pdf=args.pdf or args.cpdf)
|
||||
else:
|
||||
for i in range(first, last + 1, step):
|
||||
# Select usable runs
|
||||
runs_ok = [run for run in runs if i in run_succeded[run]]
|
||||
|
||||
try:
|
||||
if len(runs_ok) > 1:
|
||||
try:
|
||||
if len(runs_ok) > 1:
|
||||
dp.compare(path, runs_ok, i,
|
||||
path_out=path + '/comp',
|
||||
force=args.force_redo,
|
||||
@@ -370,9 +385,9 @@ if args.compare:
|
||||
Q_in_name=args.Q_in_name,
|
||||
tag=args.tag,
|
||||
pdf=args.pdf or args.cpdf)
|
||||
except (KeyError, IOError) as e:
|
||||
print(e)
|
||||
if args.skip:
|
||||
except (KeyError, IOError) as e:
|
||||
print(e)
|
||||
if (args.skip):
|
||||
pass
|
||||
else:
|
||||
else:
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user