-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
ccd_tempreture taking astropy unit #150
base: main
Are you sure you want to change the base?
Changes from 33 commits
eda4374
7b4f3f3
9625f71
33d13fa
85f3ff6
5ddc1b0
752a01d
fc20b49
fcbd964
55acee0
7e74533
832b89c
2277451
119f05b
7b0e0e8
e5c8160
5da93f3
c47016c
dc30d6f
d8b1cae
4f2a35b
cca132c
37c05d6
d7f11bb
0340232
89c08d7
4e5fd72
22c8f7c
427ada4
49d11b6
0b1de6a
e1b7abf
c2d1899
c98c627
6084b6c
eb45e53
64148c9
f2bf28a
9436955
c203be7
26a0548
4337ea4
89e9221
35e03e0
91063ca
85689ee
f0d5c8d
8fd73da
70d6339
c99b66f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Updated `~.get_response` to enforce ``ccd_temperature`` as an `astropy.units.Quantity` |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -101,7 +101,8 @@ | |||||
return _despike(data, dqf, filter_width) | ||||||
|
||||||
|
||||||
def get_response(request, spacecraft=16, ccd_temperature=-60.0, exposure_type="long"): | ||||||
@u.quantity_input(ccd_temperature=u.deg_C) | ||||||
def get_response(request, spacecraft=16, ccd_temperature=-60.0 * u.deg_C, exposure_type="long"): | ||||||
""" | ||||||
Get the SUVI instrument response for a specific wavelength channel, | ||||||
spacecraft, CCD temperature, and exposure type. | ||||||
|
@@ -114,17 +115,15 @@ | |||||
Parameters | ||||||
---------- | ||||||
request: `str` or {94 | 131 | 171 | 195 | 284 | 304}. | ||||||
Abinash-bit marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
Either an L1b filename (FITS or netCDF), or an integer | ||||||
specifying the wavelength channel. | ||||||
spacecraft: `int`, optional. | ||||||
Either an L1b filename (FITS or netCDF), or an integer specifying the wavelength channel. | ||||||
spacecraft: `int`, optional | ||||||
Which GOES spacecraft, default is 16. | ||||||
ccd_temperature: `float`, optional. | ||||||
The CCD temperature, in degrees Celsius, default is -60. | ||||||
ccd_temperature: `astropy.units.Quantity` | ||||||
The CCD temperature, in degrees Celsius, default is -60.0 * u.deg_C. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not resolve comments unless they are fixed. |
||||||
Needed for getting the correct gain number. | ||||||
exposure_type: {"long" | "short" | "short_flare"}, optional. | ||||||
exposure_type: {"long" | "short" | "short_flare"}, optional | ||||||
The exposure type of the SUVI image. | ||||||
The exposure type is needed for the correct focal plane | ||||||
filter selection. | ||||||
The exposure type is needed for the correct focal plane filter selection. | ||||||
|
||||||
Can be: | ||||||
* "long", "short", "short_flare" for 94 and 131 | ||||||
|
@@ -156,7 +155,8 @@ | |||||
header, _, _ = read_suvi(request) | ||||||
wavelength_channel = int(header["WAVELNTH"]) | ||||||
spacecraft = int(header["TELESCOP"].replace(" ", "").replace("G", "")) | ||||||
ccd_temperature = (header["CCD_TMP1"] + header["CCD_TMP2"]) / 2.0 | ||||||
ccd_temp_avg = (header["CCD_TMP1"] + header["CCD_TMP2"]) / 2.0 | ||||||
ccd_temperature = ccd_temp_avg * u.deg_C | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we redefine |
||||||
exposure_type = "_".join( | ||||||
header["SCI_OBJ"].replace(" ", "").split(sep="_")[3:] | ||||||
).replace("_exposure", "") | ||||||
|
@@ -195,7 +195,7 @@ | |||||
temp_x = gain_table[:, 0] | ||||||
gain_y = gain_table[:, 1] | ||||||
gain_vs_temp = interpolate.interp1d(temp_x, gain_y) | ||||||
gain = gain_vs_temp(ccd_temperature) | ||||||
gain = gain_vs_temp(ccd_temperature.to(u.deg_C).value) | ||||||
|
||||||
geometric_area = 19.362316 * u.cm * u.cm | ||||||
solid_angle = ((2.5 / 3600.0 * (np.pi / 180.0)) ** 2.0) * u.sr | ||||||
|
@@ -210,7 +210,7 @@ | |||||
"response": response, | ||||||
"wavelength_channel": wavelength_channel, | ||||||
"spacecraft": "GOES-" + str(spacecraft), | ||||||
"ccd_temperature": ccd_temperature * u.deg_C, | ||||||
"ccd_temperature": ccd_temperature, | ||||||
"exposure_type": exposure_type, | ||||||
"flight_model": FLIGHT_MODEL[spacecraft], | ||||||
"gain": float(gain), | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,12 +1,12 @@ | ||||||
import numpy as np | ||||||
import pytest | ||||||
|
||||||
import astropy.units as u | ||||||
|
||||||
from sunkit_instruments import suvi | ||||||
|
||||||
# Test files are all remote data. | ||||||
pytestmark = pytest.mark.remote_data | ||||||
|
||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines should be added back. |
||||||
def test_suvi_despiking_fits(L1B_FITS): | ||||||
_, l1b_fits_data, _ = suvi.read_suvi( | ||||||
L1B_FITS, | ||||||
|
@@ -24,15 +24,33 @@ | |||||
|
||||||
|
||||||
def test_get_response_nc(L1B_NC): | ||||||
header, _, _ = suvi.read_suvi(L1B_NC) | ||||||
ccd_temp_avg = (header["CCD_TMP1"] + header["CCD_TMP2"]) / 2.0 * u.deg_C | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
l1b_nc_response = suvi.get_response(L1B_NC) | ||||||
assert l1b_nc_response["wavelength_channel"] == 171 | ||||||
nabobalis marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
assert l1b_nc_response["ccd_temperature"] == ccd_temp_avg | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
def test_get_response_fits(L1B_FITS): | ||||||
header, _, _ = suvi.read_suvi(L1B_FITS) | ||||||
ccd_temperature = (header["CCD_TMP1"] + header["CCD_TMP2"]) / 2.0 * u.deg_C | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
l1b_fits_response = suvi.get_response(L1B_FITS) | ||||||
assert l1b_fits_response["wavelength_channel"] == 171 | ||||||
assert l1b_fits_response["ccd_temperature"] == ccd_temperature | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
def test_get_response_wavelength(): | ||||||
response_195 = suvi.get_response(195) | ||||||
assert response_195["wavelength_channel"] == 195 | ||||||
|
||||||
|
||||||
def test_get_response_explicit_temperature(): | ||||||
temp = -70.0 * u.deg_C | ||||||
response = suvi.get_response(195, ccd_temperature=temp) | ||||||
assert response["ccd_temperature"] == temp | ||||||
|
||||||
|
||||||
def test_get_response_invalid_temperature(): | ||||||
temp = -70.0 # Without units | ||||||
with pytest.raises(TypeError): | ||||||
suvi.get_response(195, ccd_temperature=temp) | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this file.