Temperature response testing#

[18]:
import sys

import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
import astropy.time
from astropy.visualization import quantity_support
from aiapy.calibrate.util import get_pointing_table

from synthesizAR.atomic.idl import read_spectral_table

sys.path.append('../')
from mocksipipeline.physics.dem.data_prep import DataQuery
from mocksipipeline.physics.dem.dem_models import get_aia_temperature_response, get_xrt_temperature_response
[3]:
obstime = astropy.time.Time('2020-11-09 18:00:00')
[4]:
pt = get_pointing_table(obstime-12*u.h, obstime+12*u.h)
[5]:
tbin_edges = 10**np.arange(5.5,7.5, .1,) * u.K
[9]:
spec_table = read_spectral_table('../pipeline-runs/chiantia-spectra-full.asdf')
WARNING: UnitsWarning: The unit 'Angstrom' has been deprecated in the VOUnit standard. Suggested: 0.1nm. [astropy.units.format.utils]
WARNING: AstropyDeprecationWarning: The truth value of a Quantity is ambiguous. In the future this will raise a ValueError. [astropy.units.quantity]
[11]:
dq = DataQuery('../pipeline-runs/test-1/',
               obstime,
               tbin_edges,
               spectra=spec_table,
               aia_correction_table='/Users/wtbarnes/ssw/sdo/aia/response/aia_V8_20171210_050627_response_table.txt',
               aia_error_table='/Users/wtbarnes/ssw/sdo/aia/response/aia_V3_error_table.txt',
               aia_pointing_table=pt)
[12]:
kernels = dq.response_kernels
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 9 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 10 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/astropy/units/quantity.py:626: RuntimeWarning: invalid value encountered in sqrt
  result = super().__array_ufunc__(function, method, *arrays, **kwargs)
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 9 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 10 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/astropy/units/quantity.py:626: RuntimeWarning: invalid value encountered in sqrt
  result = super().__array_ufunc__(function, method, *arrays, **kwargs)
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 9 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 10 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/astropy/units/quantity.py:626: RuntimeWarning: invalid value encountered in sqrt
  result = super().__array_ufunc__(function, method, *arrays, **kwargs)
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 9 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 10 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/astropy/units/quantity.py:626: RuntimeWarning: invalid value encountered in sqrt
  result = super().__array_ufunc__(function, method, *arrays, **kwargs)
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 9 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 10 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/astropy/units/quantity.py:626: RuntimeWarning: invalid value encountered in sqrt
  result = super().__array_ufunc__(function, method, *arrays, **kwargs)
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 9 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/erfa/core.py:154: ErfaWarning: ERFA function "dtf2d" yielded 10 of "dubious year (Note 6)"
  warnings.warn('ERFA function "{}" yielded {}'.format(func_name, wmsg),
/Users/wtbarnes/mambaforge/envs/mocksipipeline/lib/python3.9/site-packages/astropy/units/quantity.py:626: RuntimeWarning: invalid value encountered in sqrt
  result = super().__array_ufunc__(function, method, *arrays, **kwargs)
WARNING: UnitsWarning: The unit 'Angstrom' has been deprecated in the VOUnit standard. Suggested: 0.1nm. [astropy.units.format.utils]
[21]:
aia_responses_ssw = get_aia_temperature_response('../mocksipipeline/data/aia_temperature_response.asdf',
                                                 [94, 131, 171, 193, 211, 335] * u.angstrom,
                                                 dq.temperature_bin_centers)
xrt_responses_ssw = get_xrt_temperature_response('../mocksipipeline/data/xrt_temperature_response.asdf',
                                                 ['Be_thin'],
                                                 dq.temperature_bin_centers,
                                                 correction_factor=1)
all_responses_ssw = {**aia_responses_ssw, **xrt_responses_ssw}
[23]:
all_responses_ssw.keys()
[23]:
dict_keys(['94.0 Angstrom', '131.0 Angstrom', '171.0 Angstrom', '193.0 Angstrom', '211.0 Angstrom', '335.0 Angstrom', 'Be thin-Open'])
[33]:
fig = plt.figure(figsize=(12, 12))
with quantity_support():
    for i,k in enumerate(kernels):
        ax = fig.add_subplot(3,3,i+1)
        l, = ax.plot(dq.temperature_bin_centers, kernels[k].to('cm5 ct pix-1 s-1'), label='on the fly')
        ax.plot(dq.temperature_bin_centers, all_responses_ssw[k].to('cm5 ct pix-1 s-1'), color=l.get_color(), ls=':', label='SSW tabulated')
        ax.set_yscale('log')
        ax.set_xscale('log')
        ax.set_ylim(1e-28, 2e-24)
        ax.set_title(k)
        ax.label_outer()
        if i == 0:
            ax.legend()
../_images/reports_temperature-response-testing_10_0.png
[31]:
spec_table.meta
[31]:
{'ioneq_filename': 'chianti.ioneq',
 'abundance_filename': 'sun_coronal_1992_feldman_ext.abund',
 'ion_list': 'all',
 'version': '10.0.2'}
[ ]: