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

Creating a custom PCA background for Athena #31

Open
pboorm opened this issue Dec 3, 2021 · 6 comments
Open

Creating a custom PCA background for Athena #31

pboorm opened this issue Dec 3, 2021 · 6 comments

Comments

@pboorm
Copy link

pboorm commented Dec 3, 2021

I am running BXA v2.10 on macOS Mojave v10.14.6, and am trying to create a new PCA model for the Athena/X-IFU from the publicly available background file (available from http://x-ifu.irap.omp.eu/resources/for-the-community) with the command:
python autobackgroundmodel/__init__.py bkg1.pha bkg2.pha bkg3.pha

First, the spectrum did not have a COUNTS column, so I created one with astropy based on the pre-existing RATE column and EXPOSURE header keywords. Since the spectrum appears to contain many counts, I wondered if it would be sufficient by itself to create a PCA model, instead of requiring multiple individual observations stacked together.

I then ran the following command:
python3 /astrosoftware/BXA/autobackgroundmodel/__init__.py Total_pointsources_XIFU_CC_BASELINECONF_2018_10_10_COUNTS.pha

But I get the error message:

fetching counts from 1 files ...
  reading "Total_pointsources_XIFU_CC_BASELINECONF_2018_10_10_COUNTS.pha"
combining ... 10
Traceback (most recent call last):
  File "/astrosoftware/BXA/autobackgroundmodel/__init__.py", line 131, in <module>
    assert len(telescopes) == 1, "trying to combine multiple telescopes!"
AssertionError: trying to combine multiple telescopes!

Is it possible this error is arising because I am using a much older version of BXA than the current one? If not, is there a way I can generate the PCA background for the X-IFU?

@JohannesBuchner
Copy link
Owner

JohannesBuchner commented Dec 3, 2021

You need to make sure that TELESCOP and INSTRUME header is consistent across files.

Also, counts should be in integers. However, I don't know if really something bad happens if it isn't.

@pboorm
Copy link
Author

pboorm commented Dec 3, 2021

Thanks for getting back to me so quickly!

I tried adding the INSTRUME="XIFU" and TELESCOP="ATHENA" keywords to the primary header (as they were only present in the spectrum header previously), but this did not fix the problem (I get the same error as before).

Also, after experimenting a bit the telescopes set is {"ATHENA", None} because there is only one dataset being read in. This may be why TELESCOP is not unique - is it possible to use the script with just one dataset?

@JohannesBuchner
Copy link
Owner

Maybe replace

datasets = joblib.Parallel(-1)((joblib.delayed(compile)(filenames[i::10]) for i in range(10)))

with

datasets = compile(filenames)

@JohannesBuchner
Copy link
Owner

and have a look what datasets contains

@pboorm
Copy link
Author

pboorm commented Dec 3, 2021

Thanks! I replaced the datasets line and also converted it to a list to match the form of datasets from the previous line.

Now I get a new error due to newdata being [] before the line newdata = numpy.vstack(tuple(newdata)):

Traceback (most recent call last):
  File "/astrosoftware/BXA/autobackgroundmodel/__init__.py", line 169, in <module>
    newdata, repackedfile = repack(outfile)
  File "/astrosoftware/BXA/autobackgroundmodel/__init__.py", line 91, in repack
    newdata = numpy.vstack(tuple(newdata))
  File "<__array_function__ internals>", line 6, in vstack
  File "/Users/pboorman/anaconda3/lib/python3.7/site-packages/numpy/core/shape_base.py", line 283, in vstack
    return _nx.concatenate(arrs, 0)
  File "<__array_function__ internals>", line 6, in concatenate
ValueError: need at least one array to concatenate

From what I can work out, the condition if pack.sum() > mincts: is not met for some reason.

@JohannesBuchner
Copy link
Owner

do all your spectra have fewer counts than mincts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants