BXA
BXA copied to clipboard
Creating a custom PCA background for Athena
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?
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.
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?
Maybe replace
datasets = joblib.Parallel(-1)((joblib.delayed(compile)(filenames[i::10]) for i in range(10)))
with
datasets = compile(filenames)
and have a look what datasets contains
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.
do all your spectra have fewer counts than mincts
?