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

XSPEC: update model parameters to match XSPEC 12.13.1 / HEASOFT 6.32 #1853

Merged
merged 2 commits into from Sep 12, 2023

Conversation

DougBurke
Copy link
Contributor

@DougBurke DougBurke commented Aug 21, 2023

Summary

Update the XSPEC parameter names and ranges to match those from XSPEC 12.13.1 / HEASOFT 6.32.

Details

These updates were pointed out by running scripts/check_xspec_update.py on the model.dat from HEASOFT 6.32 (XSPEC version 12.13.1). I am not sure when these changes were first made to XSPEC, but they are mainly "documentation" style changes so I do not worry about using them in a build with an XSPEC library before these changes were made.

The two changes are

  • reducing the maximum for the Velocity parameter from 1e6 to 1e4 km/s
  • updating the ismabs model to use the latest version of the XSPEC parameter names

For the latter, I noted to HEASARC quite some time ago that there existing naming scheme (of <element><species>) lead to a confusion for the Si and S parameters for a system like Sherpa where the parameter names are case insensitive, since is "sii" meant to be "SiI" or "SII". So we called these two parameters "Si_species" and "S_species". HEASARC have finally applied this to all the elements (apart from H and Fe), so we make this change as well and use the "aliases" capability of the model to allow the old names to be used.

I had added a test to check the old behaviour, so this test had to be updated to follow the new behaviour, and I added in a check that the deprecation warning is created when an "old" parameter name is used.

Note that the parameter name is ignored by the XSPEC model library, as all the code cares about is getting an array of npar numbers, so we can actually call these parameters whatever we want, as long as the ordering matches.

I added a note for the bwcycl model to point out that we are not going to follow the XSPEC naming of the del parameter because we can not. My guess is that this parameter has always been called del and we decided to use delta, rather than it changing from delta to del at some point.

Example

Here's how the ISMABS model works now

In [1]: from sherpa.astro.ui import *
WARNING: imaging routines will not be available, 
failed to import sherpa.image.ds9_backend due to 
'RuntimeErr: DS9Win unusable: Could not find ds9 on your PATH'

In [2]: xsismabs.mdl
Out[2]: <XSismabs model instance 'xsismabs.mdl'>

In [3]: print(mdl)
xsismabs.mdl
   Param        Type          Value          Min          Max      Units
   -----        ----          -----          ---          ---      -----
   mdl.H        thawed          0.1            0        1e+06      10^22
   mdl.He_II    frozen            0            0        1e+06      10^16
   mdl.C_I      thawed         33.1            0        1e+06      10^16
   mdl.C_II     frozen            0            0        1e+06      10^16
   mdl.C_III    frozen            0            0        1e+06      10^16
   mdl.N_I      thawed         8.32            0        1e+06      10^16
   mdl.N_II     frozen            0            0        1e+06      10^16
   mdl.N_III    frozen            0            0        1e+06      10^16
   mdl.O_I      thawed         67.6            0        1e+06      10^16
   mdl.O_II     frozen            0            0        1e+06      10^16
   mdl.O_III    frozen            0            0        1e+06      10^16
   mdl.Ne_I     thawed           12            0        1e+06      10^16
   mdl.Ne_II    frozen            0            0        1e+06      10^16
   mdl.Ne_III   frozen            0            0        1e+06      10^16
   mdl.Mg_I     thawed          3.8            0        1e+06      10^16
   mdl.Mg_II    frozen            0            0        1e+06      10^16
   mdl.Mg_III   frozen            0            0        1e+06      10^16
   mdl.Si_I     thawed         3.35            0        1e+06      10^16
   mdl.Si_II    frozen            0            0        1e+06      10^16
   mdl.Si_III   frozen            0            0        1e+06      10^16
   mdl.S_I      thawed         2.14            0        1e+06      10^16
   mdl.S_II     frozen            0            0        1e+06      10^16
   mdl.S_III    frozen            0            0        1e+06      10^16
   mdl.Ar_I     thawed         0.25            0        1e+06      10^16
   mdl.Ar_II    frozen            0            0        1e+06      10^16
   mdl.Ar_III   frozen            0            0        1e+06      10^16
   mdl.Ca_I     thawed         0.22            0        1e+06      10^16
   mdl.Ca_II    frozen            0            0        1e+06      10^16
   mdl.Ca_III   frozen            0            0        1e+06      10^16
   mdl.Fe       thawed         3.16            0        1e+06      10^16
   mdl.redshift frozen            0           -1           10           

In [4]: mdl.ArI = 0.4

In [5]: mdl.ari
Out[5]: <XSParameter 'Ar_I' of model 'mdl'>

In [6]: print(mdl)
xsismabs.mdl
   Param        Type          Value          Min          Max      Units
   -----        ----          -----          ---          ---      -----
   mdl.H        thawed          0.1            0        1e+06      10^22
   mdl.He_II    frozen            0            0        1e+06      10^16
   mdl.C_I      thawed         33.1            0        1e+06      10^16
   mdl.C_II     frozen            0            0        1e+06      10^16
   mdl.C_III    frozen            0            0        1e+06      10^16
   mdl.N_I      thawed         8.32            0        1e+06      10^16
   mdl.N_II     frozen            0            0        1e+06      10^16
   mdl.N_III    frozen            0            0        1e+06      10^16
   mdl.O_I      thawed         67.6            0        1e+06      10^16
   mdl.O_II     frozen            0            0        1e+06      10^16
   mdl.O_III    frozen            0            0        1e+06      10^16
   mdl.Ne_I     thawed           12            0        1e+06      10^16
   mdl.Ne_II    frozen            0            0        1e+06      10^16
   mdl.Ne_III   frozen            0            0        1e+06      10^16
   mdl.Mg_I     thawed          3.8            0        1e+06      10^16
   mdl.Mg_II    frozen            0            0        1e+06      10^16
   mdl.Mg_III   frozen            0            0        1e+06      10^16
   mdl.Si_I     thawed         3.35            0        1e+06      10^16
   mdl.Si_II    frozen            0            0        1e+06      10^16
   mdl.Si_III   frozen            0            0        1e+06      10^16
   mdl.S_I      thawed         2.14            0        1e+06      10^16
   mdl.S_II     frozen            0            0        1e+06      10^16
   mdl.S_III    frozen            0            0        1e+06      10^16
   mdl.Ar_I     thawed          0.4            0        1e+06      10^16
   mdl.Ar_II    frozen            0            0        1e+06      10^16
   mdl.Ar_III   frozen            0            0        1e+06      10^16
   mdl.Ca_I     thawed         0.22            0        1e+06      10^16
   mdl.Ca_II    frozen            0            0        1e+06      10^16
   mdl.Ca_III   frozen            0            0        1e+06      10^16
   mdl.Fe       thawed         3.16            0        1e+06      10^16
   mdl.redshift frozen            0           -1           10           

So we can still set a parameter using the "old" names (e.g. "ArI" above) but that is internally converted to the "new" name ("Ar_I" in this case).

These updates were pointed out by running scripts/check_xspec_update.py
on the model.dat from HEASOFT 6.32 (XSPEC version 12.13.1). I am not
sure when these changes were first made to XSPEC, but they are mainly
"documentation" style changes so I do not worry about using them in
a build with an XSPEC library before these changes were made.

The two changes are

- reducing the maximum for the Valocity parameter from 1e6 to 1e4 km/s
- updating the ismabs model to use the latest version of the XSPEC
  parameter names

For the latter, I noted to HEASARC quite some time ago that there
existing naming scheme (of <elemement><species>) lead to a confusion
for the Si and S parameters for a system like Sherpa where the
parameter names are case insensitive, since is "sii" meant to be
"SiI" or "SII". So we called these two parameters "Si_species" and
"S_species". HEASARC have finally applied this to all the elements
(apart from H and Fe), so we make this change as well and use the
"aliases" capability of the model to allow the old names to be used.

I had added a test to check the old behavior, so this test had to
be updated to follow the new behavior, and I added in a check that
the deprecation warning is created when an "old" parameter name is
used.

Note that the parameter name is ignored by the XSPEC model library,
as all the code cares about is getting an array of npar numbers, so
we can actually call these parameters whatever we want, as long as
the ordering matches.

I added a note for the bwcycl model to point out that we are not
going to follow the XSPEC naming of the del parameter because we
can not. My guess is that this parameter has always been called
del and we decided to use delta, rather than it changing from
delta to del at some point.
Co-authored-by: wmclaugh <wmclaugh@cfa.harvard.edu>
@codecov
Copy link

codecov bot commented Sep 11, 2023

Codecov Report

Merging #1853 (b471d0c) into main (cdbedd1) will increase coverage by 0.02%.
Report is 63 commits behind head on main.
The diff coverage is 82.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1853      +/-   ##
==========================================
+ Coverage   81.22%   81.24%   +0.02%     
==========================================
  Files          73       73              
  Lines       26416    26487      +71     
  Branches     3954     3963       +9     
==========================================
+ Hits        21456    21519      +63     
- Misses       4799     4804       +5     
- Partials      161      164       +3     
Files Changed Coverage Δ
sherpa/astro/xspec/__init__.py 74.54% <82.14%> (+0.09%) ⬆️

... and 12 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdbedd1...b471d0c. Read the comment docs.

@wmclaugh wmclaugh merged commit 5e5a9a7 into sherpa:main Sep 12, 2023
17 checks passed
@DougBurke DougBurke deleted the update-xspec-params-12.13.1 branch September 12, 2023 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants