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

Option to use stsynphot to make IMPHTTAB #28

Open
wants to merge 1 commit into
base: master
from

Conversation

@pllim
Copy link
Contributor

commented Sep 7, 2019

Fix #24 .

To make a table using stsynphot, do this in command line (this is the default behavior if you have not previously set any MKIMPHTTAB_USE_PYSYNPHOT before running create_table():

export MKIMPHTTAB_USE_PYSYNPHOT=0

To make a table using PySynphot, do this in command line:

export MKIMPHTTAB_USE_PYSYNPHOT=1

Then run the function as usual:

from reftools import mkimphttab

mkimphttab.create_table('test_stis', 'stis', '*', 'Sep 03 2019 00:00:00')

For sanity check, which software and version would be listed under DESCRIP column of the output table.

I ran them both and used the following to quickly compare the EXT=1 results (see also astropy table set difference) but more detailed comparison should be done by INS:

>>> from astropy.io import fits
>>> from astropy.table import Table, setdiff
>>> with fits.open('result_from_pysynphot.fits') as pf:
...     t_pysyn = Table(pf[1].data)
>>> with fits.open('result_from_stsynphot.fits') as pf:
...     t_stsyn = Table(pf[1].data)
>>> # DESCRIP is bound to be different, so remove it from comparison.
>>> t_pysyn.remove_column('DESCRIP')
>>> t_stsyn.remove_column('DESCRIP')
>>> sdiff = setdiff(t_pysyn, t_stsyn, keys=['OBSMODE', 'DATACOL'])
>>> sdiff  # Length 0 is good
<Table length=0>
OBSMODE DATACOL PHOTFLAM PHOTFLAM1 PAR1NAMES PAR1VALUES NELEM1 PEDIGREE
 str40   str12  float64    object     str4     object   int16   str30  
------- ------- -------- --------- --------- ---------- ------ --------

Or another way using simple table diff:

>>> import sys
>>> from astropy.utils.diff import report_diff_values
>>> identical = report_diff_values(t_pysyn, t_stsyn, fileobj=sys.stdout)
>>> # You will see some output regardless but there is + and - if there is a difference.
>>> identical
True

I did not time them explicitly, but it felt like using PySynphot was a bit faster than using stsynphot. I wonder if it is all the underlying Astropy compound models being generated or something else. Currently, optimizing this is not high on my priority list as this function has low usage traffic.

I also generated a file from current master at 52ab23c and found no difference as well from my quick check above.

The files I used for comparison above are available at https://stsci.app.box.com/folder/86611518709 (permission required for access).

@pllim pllim added the enhancement label Sep 7, 2019
@pllim pllim requested a review from sean-lockwood Sep 7, 2019
@pllim pllim force-pushed the pllim:new-syn branch from 2b0f50b to e7b1ba3 Sep 7, 2019
@pllim pllim force-pushed the pllim:new-syn branch from e7b1ba3 to 6a6357f Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.