Skip to content

Sherpa function to facilitate loading HETG responses associated with a PHA2 file#1031

Draft
dprincipe2 wants to merge 2 commits intocxcsds:mainfrom
dprincipe2:load_hetg_resp
Draft

Sherpa function to facilitate loading HETG responses associated with a PHA2 file#1031
dprincipe2 wants to merge 2 commits intocxcsds:mainfrom
dprincipe2:load_hetg_resp

Conversation

@dprincipe2
Copy link
Contributor

If users generated or obtained an HETG PHA2 file through relatively standard means (e.g., Chandra archive or running chandra_repro) then this function will load their PHA2 file into sherpa and find/assign the associated ARFs and RMFs.

…th only a PHA2 file as input. Added the ability to choose a sherpa dataset ID to start loading from so users can load multiple PHA2 datasets into the same session. Also added documentation.
@DougBurke
Copy link
Member

I suggest moving the two local routines - find_resp_files and match_resp_order - to the top level as it looks like (not 100% convinced) they don't rely on any specialized knowledge provided by load_hetg_pha2. Splitting them out makes them easier to test and the code a little easier to follow.

Looking at the code, I see there's a number of cases where you have something like

for i in range(len(some_array)):
   ... do something with some_array[i] ...

This can often be written as

for val in some_array:
   ... do something with val ...

which I personally find easier to read (this is not always the case; it depends on whether you need the index for anything other than grabbing the value from a container like some_array).

I tried this with a HETG dataset I grabbed from TGCat but it raised an error, so I'm either using it wrong or it doesn't handle the TGCat case"

sherpa-4.18.0+2.ga0c5211a> load_hetg_pha2("pha2.gz")
ValueError: Could not identify PHA2 file root. Please load responses manually.

@dprincipe2
Copy link
Contributor Author

dprincipe2 commented Mar 4, 2026

Sure, I can do those things. I tend to loop over ranges because many times I need the index but I can change that for this code for readability. I haven't tested this for tgcat- or tgextract-generated pha2 files but those can probably be added easy enough. Currently it's for chandra repro and the standard archive files.

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

Successfully merging this pull request may close these issues.

3 participants