Skip to content

Commit

Permalink
Switched to h5 backend for PyROA MCMC. Moves the 'Fit.h5' MCMC file f…
Browse files Browse the repository at this point in the history
…rom the current directory to the chosen output directory once MCMC is finished.
  • Loading branch information
Zstone19 committed Dec 29, 2024
1 parent 23250ab commit c8b3407
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ celerite >= 0.4.2
colorama >= 0.4.6
corner >= 2.2.1
emcee >= 3.1.3
h5py <= 3.12.1
linmix @ git+https://github.com/jmeyers314/linmix.git
matplotlib >= 3.6.2
numba >= 0.56.4
Expand Down
5 changes: 5 additions & 0 deletions src/pypetal/pyroa/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ def handler(signum, frame):
for i in range(len(fnames)-1):

filters = [line_names[0], line_names[i+1]]
cwd = os.getcwd()

args = (lc_dir, objname, filters, prior_arr[i,:,:],)
kwargs = {'add_var':add_var[i], 'init_tau':[init_tau[i]], 'init_delta':init_delta, 'sig_level':sig_level,
Expand Down Expand Up @@ -637,6 +638,7 @@ def handler(signum, frame):


signal.alarm(0)
shutil.move(cwd + '/Fit.h5', line_dir[i] + '/Fit.h5')

except Exception as e:
proc.terminate()
Expand All @@ -645,6 +647,7 @@ def handler(signum, frame):
print_error('Skipping and continuing to next line')

fit_arr.append(None)
shutil.move(cwd + '/Fit.h5', line_dir[i] + '/Fit.h5')
continue

return fit_arr
Expand Down Expand Up @@ -684,13 +687,15 @@ def handler(signum, frame):
fit = MyFit(line_dir)

signal.alarm(0)
shutil.move(cwd + '/Fit.h5', line_dir + '/Fit.h5')

except Exception as e:
proc.terminate()

print_error('PyROA timed out'.format(line_names[i+1]))

fit = None
shutil.move(cwd + '/Fit.h5', line_dir + '/Fit.h5')


return fit

0 comments on commit c8b3407

Please sign in to comment.