Writing table models#190
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #190 +/- ##
==========================================
- Coverage 56.81% 0.00% -56.82%
==========================================
Files 39 39
Lines 2654 2690 +36
==========================================
- Hits 1508 0 -1508
- Misses 1146 2690 +1544 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fjebaker
left a comment
There was a problem hiding this comment.
Thanks for this Andy (and for the AI disclaimer!)
It all looks good, just a few stylistic changes, and a request to move the code in the examples folder into the documentation somewhere. See the various other little comments too.
Co-authored-by: Fergus Baker <fergus@cosroe.com>
…tegrated quantities
|
When testing the broken power law model I found a mistake in that the parameters were not ordered as expected. I think I have now updated things to that the FITS writing routine takes an array in Julia order (i.e., first index changes fastest) and then reorders it into an XSPEC order (i.e., last index changes fastest). This means that the arrays passed into the writer and the arrays returned by the reader are in the same order. If my logic is correct. But please watch out for bugs related to this; if the parameter orders ever seem "wrong" I've likely made a mistake! |
|
I am going to consider this superseded by Darius's #200 and close without merging. Thanks for your help with this in any case! |
I have had a go at writing a routine to write table models to a FITS file following "OGIP Memo 92-009 (XSPEC Table Model File Format)". I've put the routine in
table-models.jland there's a test, some documentation, and an example. You might not want to merge the example. It seems to work - I have tried creating a 1D power-law table model and reading it into XSPEC. However, you might want to make sure models you create use bin integrated quantities (might not be obvious in the examples because they have evenly spaced linear grids).Please note that, as an experiment, and because this is a very well-defined task (and I was somewhat time-limited) I enlisted the help of an AI (Claude Sonnet 4.5) to write this. It required some iteration but seems to have worked. I was quite impressed with its performance. Obviously this means that I would really appreciate the code being human-checked! In particular, there may be some stylistic inconsistencies, or practices you would rather not follow. If that's the case please let me know and/or edit. A specific example might be the use of,
isfile(path) && rm(path), for example - I'm not sure what we want to do if the user requests a table model overwrites an existing file (currently it will just go ahead and replace it). I will also do some more testing myself.This is a draft pull request and needs reviewing.
@fjebaker - how does this sit with the rest of the code base?
@DariusMichienzi - you might want to experiment creating your own table models from, e.g., Gradus line profiles.