[comparator] [log extractor] extract cons even without emag output

This commit is contained in:
Noe Brucy
2021-01-05 16:09:00 +01:00
parent d78d33ef83
commit 8aec5532e8
3 changed files with 14 additions and 6 deletions
+2
View File
@@ -5,3 +5,5 @@ ignore =
E203 E203
# Line break before binary operator # Line break before binary operator
W503 W503
# Invalid escape sequence '\['
W605
+10 -6
View File
@@ -253,11 +253,13 @@ class Comparator(Aggregator, HDF5Container):
return series return series
def _extract_cons_from_log(self, series, log_filename, run): def _extract_cons_from_log(self, series, log_filename, run):
cmd_grep = "grep 'Main step' {} -A 2".format(log_filename) mhd = self.pp_params.input.mhd
nlines = 2 + int(mhd) # Number of useful lines
cmd_grep = "grep 'Main step' {} -A {}".format(log_filename, nlines - 1)
content = os.popen(cmd_grep).readlines() content = os.popen(cmd_grep).readlines()
for i in range(0, len(content), 4): for i in range(0, len(content), nlines + 1):
series["time"][run].append( series["time"][run].append(
np.float(content[i + 2].split("=")[2].split()[0]) np.float(content[i + nlines - 1].split("=")[2].split()[0])
) )
series["step"][run].append(np.int(content[i].split("=")[1].split()[0])) series["step"][run].append(np.int(content[i].split("=")[1].split()[0]))
series["mcons"][run].append(np.float(content[i].split("=")[2].split()[0])) series["mcons"][run].append(np.float(content[i].split("=")[2].split()[0]))
@@ -265,9 +267,11 @@ class Comparator(Aggregator, HDF5Container):
series["epot"][run].append(np.float(content[i].split("=")[4].split()[0])) series["epot"][run].append(np.float(content[i].split("=")[4].split()[0]))
series["ekin"][run].append(np.float(content[i].split("=")[5].split()[0])) series["ekin"][run].append(np.float(content[i].split("=")[5].split()[0]))
series["eint"][run].append(np.float(content[i].split("=")[6].split()[0])) series["eint"][run].append(np.float(content[i].split("=")[6].split()[0]))
series["emag"][run].append( if mhd:
np.float(content[i + 1].split("=")[1].split()[0]) emag = np.float(content[i + 1].split("=")[1].split()[0])
) series["emag"][run].append(emag)
else:
series["emag"][run].append(0.0)
return series return series
def _extract_rms_from_log(self, series, log_filename, run): def _extract_rms_from_log(self, series, log_filename, run):
+2
View File
@@ -45,6 +45,7 @@ pymses: # Parameters for Pymses reader
variables : ["rho","vel","Br","Bl","P", "g", "phi"] # Read these variables variables : ["rho","vel","Br","Bl","P", "g", "phi"] # Read these variables
order : '<' # Bit order order : '<' # Bit order
# Processing options # Processing options
levelmax : 20 # Maximal AMR level visited when looking levels levelmax : 20 # Maximal AMR level visited when looking levels
fft : False # Quick and dirty rendering using FFT fft : False # Quick and dirty rendering using FFT
@@ -66,6 +67,7 @@ input: # Parameters on how to look for input files (= output from Ramses)
log_prefix : "run.log" # Prefix of the log file log_prefix : "run.log" # Prefix of the log file
label_filename : "label.txt" # Name of the label file label_filename : "label.txt" # Name of the label file
nml_filename : "run.nml" # name of the namelist file nml_filename : "run.nml" # name of the namelist file
mhd : True # Is MHD activated
out: # Parameters for post processing out: # Parameters for post processing
tag : "" # Tag for the image tag : "" # Tag for the image