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

adding xrt_teem #89

Merged
merged 50 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
c442075
Added xrt_teem.py
jslavin Sep 20, 2022
045ae37
small tweaks to xrt_teem.py
jslavin Sep 20, 2022
05be3f6
Delete xrt_teem.py
jslavin Sep 21, 2022
f2b4210
Add files via upload
jslavin Sep 21, 2022
5d8fb21
Delete xrt_teem.py
jslavin Nov 29, 2022
21856d7
improved version of xrt_teem
jslavin Nov 29, 2022
ca0c2f6
fixes to xrt_teem.py
jslavin Nov 30, 2022
2749141
Merge branch 'HinodeXRT:main' into jslavin-patch-2
jslavin Dec 1, 2022
79727c0
Added tests for xrt_teem. Also edited setup.cfg to remove line that w…
jslavin Dec 9, 2022
16e1df8
edited setup.cfg
jslavin Dec 9, 2022
fe0a769
Merge branch 'jslavin-patch-2' of https://github.com/jslavin/xrtpy in…
jslavin Dec 9, 2022
6cc2d94
Added notebook on usage of xrt_teem
jslavin Dec 9, 2022
b07863d
Fixed header for xrt_teem so as to pass flake8 rst checks
jslavin Dec 12, 2022
d03c5ce
fixed file reference and tolerances in test_xrt_teem.py
jslavin Dec 12, 2022
75f8c2f
Merge branch 'HinodeXRT:main' into jslavin-patch-2
jslavin Dec 12, 2022
6307e40
Update xrtpy/response/xrt_teem.py
jslavin Dec 14, 2022
31362a8
Update xrtpy/response/xrt_teem.py
jslavin Dec 14, 2022
40cfc5d
Update xrtpy/response/xrt_teem.py
jslavin Dec 14, 2022
e80f8d9
Changed variable Te to T_e and also Terror to T_error to avoid issues…
jslavin Dec 15, 2022
c87c151
Removed reference to variable name Te which slipped through in merge
jslavin Dec 15, 2022
bbe1132
Merge branch 'HinodeXRT:main' into jslavin-patch-2
jslavin Jan 25, 2023
cb3da6d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2023
be6df43
updated .gitignore
jslavin Jan 25, 2023
7b870d8
Merge branch 'jslavin-patch-2' of https://github.com/jslavin/xrtpy in…
jslavin Jan 26, 2023
44f9e85
Changed from headers and data array inputs to using SunPy maps
jslavin Jan 26, 2023
30761b8
Update getting_started.rst
jslavin Jan 26, 2023
bb81bfa
Merge branch 'HinodeXRT:main' into jslavin-patch-2
jslavin Jan 31, 2023
3579b9f
Split off parts of the main routine into functions derive_temperature…
jslavin Jan 31, 2023
5d51116
Merge branch 'HinodeXRT:main' into jslavin-patch-2
jslavin Feb 2, 2023
39b0956
Merge branch 'jslavin-patch-2' of https://github.com/jslavin/xrtpy in…
jslavin Feb 2, 2023
6269dfd
Changed output from xrt_teem to be SunPy maps. Updated tests and note…
jslavin Feb 7, 2023
baab3e3
Fixed typos in test_xrt_teem.py
jslavin Feb 7, 2023
d9a7aaa
Change header doc section to note
jslavin Feb 9, 2023
55a965f
reStructured quoting added
jslavin Feb 9, 2023
31722b7
more rst quoting
jslavin Feb 9, 2023
6393b23
include __all__ definition
jslavin Feb 9, 2023
62823d4
Merge branch 'HinodeXRT:main' into jslavin-patch-2
jslavin Feb 13, 2023
fb94fb0
Another substitution of reStructuredText |Map| for map
jslavin Feb 13, 2023
f3b7e74
reStructuredText substitution of |Map| for map
jslavin Feb 13, 2023
792f6d4
Removed comments on units of effective area
jslavin Feb 13, 2023
e415cf2
Created measurement_to_filtername function for converting SunPy Map m…
jslavin Feb 13, 2023
9bd8c1f
Merge branch 'jslavin-patch-2' of https://github.com/jslavin/xrtpy in…
jslavin Feb 13, 2023
ef4e499
Fixed error in variable name in measurement_to_filtername
jslavin Feb 13, 2023
51b38f5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 13, 2023
d8fee3a
Add api_static stub file for xrt_teem
namurphy Feb 13, 2023
6a08fdf
Add notebook to example TOC
namurphy Feb 13, 2023
9ee5289
Merge branch 'main' of github.com:HinodeXRT/xrtpy into jslavin-patch-2
namurphy Feb 13, 2023
071a9ac
Ignore 'missing substitutions' flake8 extension error
namurphy Feb 13, 2023
60cc5b2
Merge branch 'main' of github.com:HinodeXRT/xrtpy into jslavin-patch-2
namurphy Feb 13, 2023
9db5b49
Fix TOC for example gallery
namurphy Feb 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 202 additions & 0 deletions docs/notebooks/data_analysis/Using_xrt_teem.ipynb

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

121 changes: 121 additions & 0 deletions xrtpy/response/tests/test_xrt_teem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
from scipy.io import readsav
import numpy as np
from astropy.io import fits
import pkg_resources
from pathlib import Path
import pytest

from xrtpy.response.xrt_teem import xrt_teem


def get_observed_data():

directory = pkg_resources.resource_filename(
"xrtpy", "response/tests/data/xrt_teem_testing_files"
)
data_files = sorted(Path(directory).glob('L1_XRT20110128_*.*.fits'))
jslavin marked this conversation as resolved.
Show resolved Hide resolved

return data_files


def get_IDL_results_data():

directory = pkg_resources.resource_filename(
"xrtpy", "response/tests/data/xrt_teem_testing_files"
)
results_files = sorted(Path(directory).glob('IDL_results_*.sav'))

return results_files


def test_standard_case():
"""
Test case with all default values:
no binning, no masking, no temperature range, standard thresholds
"""

data_files = get_observed_data()
# it turns out that the IDL test data was generated with the inverse order
# of the files
file1 = data_files[1]
file2 = data_files[0]
hdu1 = fits.open(file1)
data1 = hdu1[0].data
hdr1 = hdu1[0].header
hdu2 = fits.open(file2)
hdr2 = hdu2[0].header
data2 = hdu2[0].data
hdu1.close()
hdu2.close()

Te,EM,Terr,EMerr = xrt_teem(hdr1, data1, hdr2, data2)

testdata = get_IDL_results_data()

# This is needed because there are multiple test data sets, though so far
# only a test written for the standard case
fnames = [td.name for td in testdata]
idata1 = fnames.index('IDL_results_bin1.sav')
testdata1 = testdata[idata1]

idldata = readsav(testdata1)
goodT = (Te > 0.) & (idldata.te > 0.)
goodE = (EM > 0.) & (idldata.em > 0.)
assert np.allclose(10.**Te[goodT], 10.**idldata.te[goodT], atol=2.E5,
rtol=0.02)
assert np.allclose(10.**EM[goodE], 10.**idldata.em[goodE], atol=4.E44,
rtol=0.03)
assert np.allclose(10.**Terr[goodT], 10.**idldata.et[goodT], atol=1.E4,
rtol=0.08)
assert np.allclose(10.**EMerr[goodE], 10.**idldata.ee[goodE], atol=4.E43,
rtol=0.02)

def test_binning_case():
"""
Test case with following parameters:
binning by a factor of 2
no masking
no temperature range
standard thresholds
"""

data_files = get_observed_data()
# it turns out that the IDL test data was generated with the inverse order
# of the files
file1 = data_files[1]
file2 = data_files[0]
hdu1 = fits.open(file1)
data1 = hdu1[0].data
hdr1 = hdu1[0].header
hdu2 = fits.open(file2)
hdr2 = hdu2[0].header
data2 = hdu2[0].data
hdu1.close()
hdu2.close()

Te,EM,Terr,EMerr = xrt_teem(hdr1, data1, hdr2, data2, binfac=2)

testdata = get_IDL_results_data()

# This is needed because there are multiple test data sets, though so far
# only a test written for the standard case
fnames = [td.name for td in testdata]
idata1 = fnames.index('IDL_results_bin2.sav')
testdata1 = testdata[idata1]

idldata = readsav(testdata1)
goodT = (Te > 0.) & (idldata.te > 0.)
goodE = (EM > 0.) & (idldata.em > 0.)

delta = (10.**Te[goodT] - 10.**idldata.te[goodT])
x = 10.**idldata.te[goodT]


assert np.allclose(10.**Te[goodT], 10.**idldata.te[goodT], atol=2.E5,
rtol=0.02)
assert np.allclose(10.**EM[goodE], 10.**idldata.em[goodE], atol=1.E44,
rtol=0.05)
assert np.allclose(10.**Terr[goodT], 10.**idldata.et[goodT], atol=1.E4,
rtol=0.1)
assert np.allclose(10.**EMerr[goodE], 10.**idldata.ee[goodE], atol=2.E43,
rtol=0.03)
Loading