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

Recover Sherpa analysis status when fitting PCA backgrounds #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions bxa/sherpa/background/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ def get_unit_response(i):
delete_data("temp_unitrsp")
return bunitrsp

def get_analysis_initial_status(id):
pha = get_data(id)
factor = pha.plot_fac
quantity = pha.units
type = "rate" if pha.rate else "counts"
return quantity, type, factor


class IdentityResponse(RSPModelNoPHA):
def __init__(self, n, model, arf, rmf):
Expand Down Expand Up @@ -346,6 +353,7 @@ def fit(self):
for p, v in zip(bkgmodel.pars, last_final):
p.val = v

analysis_initial_status = get_analysis_initial_status(id)
last_model = convbkgmodel
for i in range(10):
print()
Expand Down Expand Up @@ -405,6 +413,9 @@ def fit(self):
p.val = v
break

set_analysis(id, *analysis_initial_status)


def auto_background(id):
"""Automatically fits background *id* based on PCA-based templates,
and additional gaussian lines as needed by AIC."""
Expand Down