Remove depencency on Patrick's file, add wait option

This commit is contained in:
Noe Brucy
2019-04-14 11:52:39 +02:00
parent 260dcfc7a5
commit 9f53414ab1
2 changed files with 294 additions and 206 deletions
+50 -21
View File
@@ -1,11 +1,11 @@
# coding: utf-8
import sys
import numpy as np
import module_extract as me
import extract_disk as d
import pymses
import os
from shutil import copy
import argparse
import time
import disk_postprocess as dp
@@ -24,19 +24,39 @@ parser.add_argument("-s", "--step", help="step between two output", type=int, de
parser.add_argument(
"-d", "--disk", help="do specific disk radial analysis", action="store_true"
)
parser.add_argument("-p", "--project", help="specify project name", default="disk")
parser.add_argument(
"-w", "--watch", help="wait and watch for missing outputs", action="store_true"
)
parser.add_argument(
"-wt",
"--waiting_time",
help="time between to successive try when watching new outputs (in second)",
type=int,
default=120,
)
parser.add_argument(
"-af",
"--allowed_failures",
help="number of allowed failures when waiting",
default=30,
)
args = parser.parse_args()
user = "nbrucy"
folder = "simus"
project = "disk"
project = args.project
runs = args.runs
first = args.first_output
last = args.last_output
step = args.step
for run in runs:
path_suffix = user + "/" + folder + "/" + project + "/" + run
path_in = storage_in + path_suffix
@@ -44,23 +64,32 @@ for run in runs:
if not os.path.exists(path_out):
os.makedirs(path_out)
copy(path_in + "/disk.nml", path_out)
copy(path_in + "/output_00001/compilation.txt", path_out)
for i in range(first, last + 1, step):
me.make_image_zoom(
path_in,
i,
[0.5],
sinks=False,
force=False,
path_out=path_out,
tag=run + "_",
cpuamr=False,
mag_im=False,
AU_units=False,
)
# me.look(path_in, i)
if args.disk:
dp.disk_prop(
path_in, i, path_out=path_out, rad_ext=1, nb_bin=50, force=True
)
dp.plot_disk_prop(path_out, i, tag=run + "_")
failures = 0
success = False
while not success:
try:
dp.make_image_disk(
path_in, i, path_out=path_out, tag=run, map_size=1024
)
if args.disk:
dp.disk_prop(
path_in, i, path_out=path_out, rad_ext=1, nb_bin=50, force=False
)
dp.plot_disk_prop(path_out, i, tag=run)
success = True
except ValueError:
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, i, args.waiting_time, args.allowed_failures - failures
)
)
time.sleep(args.waiting_time)
else:
raise