Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made h5 backend for PyROA MCMC the default #30

Merged
merged 2 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 9 additions & 2 deletions src/pypetal/pyroa/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,12 @@ 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,
'delay_dist':delay_dist[i], 'psi_types':[psi_types[i]], 'Nsamples':nchain, 'Nburnin':nburn}
'delay_dist':delay_dist[i], 'psi_types':[psi_types[i]], 'Nsamples':nchain, 'Nburnin':nburn,
'use_backend':True}

try:
signal.signal(signal.SIGALRM, handler)
Expand Down Expand Up @@ -636,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 @@ -644,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 All @@ -655,7 +659,8 @@ def handler(signum, frame):

args = (lc_dir, objname, line_names, prior_arr,)
kwargs = {'add_var':add_var, 'init_tau':init_tau, 'init_delta':init_delta, 'sig_level':sig_level,
'delay_dist':delay_dist, 'psi_types':psi_types, 'Nsamples':nchain, 'Nburnin':nburn}
'delay_dist':delay_dist, 'psi_types':psi_types, 'Nsamples':nchain, 'Nburnin':nburn,
'use_backend':True}

try:
signal.signal(signal.SIGALRM, handler)
Expand All @@ -682,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
Loading