-
-
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?
Conversation
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.
This will need to make sure there is a unit test for this and a changelog entry.
sunkit_instruments/suvi/suvi.py
Outdated
""" | ||
Get the SUVI instrument response for a specific wavelength channel, | ||
spacecraft, CCD temperature, and exposure type. | ||
Get the SUVI instrument response for a specific wavelength channel, spacecraft, CCD temperature, and exposure type. |
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.
Get the SUVI instrument response for a specific wavelength channel, spacecraft, CCD temperature, and exposure type. | |
Get the SUVI instrument response for a specific wavelength channel, spacecraft, | |
CCD temperature, and exposure type. |
sunkit_instruments/suvi/suvi.py
Outdated
parameters are read automatically from the metadata, or the parameters | ||
can be passed manually, with ``request`` specifying the desired wavelength | ||
channel. | ||
``request`` can either be an L1b filename (FITS or netCDF), in which case all of those parameters are read automatically from the metadata, or the parameters can be passed manually, with ``request`` specifying the desired wavelength channel. |
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.
``request`` can either be an L1b filename (FITS or netCDF), in which case all of those parameters are read automatically from the metadata, or the parameters can be passed manually, with ``request`` specifying the desired wavelength channel. | |
``request`` can either be an L1b filename (FITS or netCDF), in which case all of those parameters | |
are read automatically from the metadata, or the parameters can be passed manually, with ``request`` specifying the desired wavelength channel. |
sunkit_instruments/suvi/suvi.py
Outdated
ccd_temperature: `float`, optional. | ||
The CCD temperature, in degrees Celsius, default is -60. | ||
ccd_temperature : astropy.units.Quantity, optional | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
The CCD temperature, in degrees Celsius, default is -60.0 * u.deg_C. | |
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not resolve comments unless they are fixed.
Co-authored-by: Nabil Freij <[email protected]>
Co-authored-by: Nabil Freij <[email protected]>
Co-authored-by: Nabil Freij <[email protected]>
changelog/150.feature.3.rst
Outdated
### Added | ||
- Support for `ccd_temperature` as an Astropy Quantity in the `get_response` function. | ||
### Changed | ||
- Updated the `get_response` function signature to accept `ccd_temperature` as an Astropy Quantity. | ||
- Modified the function to handle `ccd_temperature` inputs with and without units, converting them to degrees Celsius. | ||
- Updated the docstring of the `get_response` function to reflect the new parameter type and units requirement. |
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.
This changelog is too verbose.
In the last 2 commits 4 checks are failing and most of the tests are skipped , how can we proceed? |
We check why they are failing and address that problem. The error is
I would recommend checking the failed logs more often or at least running the unit test suite locally before you push changes. |
I think we are left with test_suvi.py and the data files that is L1B_NC and L1B_FITS. |
You mean adding more tests? |
sunkit_instruments/suvi/suvi.py
Outdated
@@ -23,7 +23,6 @@ | |||
|
|||
PATH_TO_FILES = Path(__file__).parent / "data" | |||
|
|||
|
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.
Revert this
sunkit_instruments/suvi/suvi.py
Outdated
@@ -46,7 +45,6 @@ def _despike(image, dqf_mask, filter_width): | |||
despiked_image[indices] = image_gaussian_filtered[indices] | |||
return despiked_image | |||
|
|||
|
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.
Revert this
sunkit_instruments/suvi/suvi.py
Outdated
@@ -78,7 +76,6 @@ def despike_l1b_file(filename, filter_width=7): | |||
despiked_image = _despike(image, dqf_mask, filter_width) | |||
return sunpy.map.Map(despiked_image, header) | |||
|
|||
|
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.
Revert this
Co-authored-by: Nabil Freij <[email protected]>
The test file says checks are skipped and it is skipped because the file can not get the L1B_NC and L1B_FITS files may be not sure. |
Now please suggest any changes. |
|
||
|
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.
These lines should be added back.
l1b_nc_response = suvi.get_response(L1B_NC) | ||
assert l1b_nc_response["wavelength_channel"] == 171 | ||
assert l1b_nc_response["ccd_temperature"] == ccd_temp_avg |
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.
assert l1b_nc_response["ccd_temperature"] == ccd_temp_avg | |
assert l1b_nc_response["ccd_temperature"] == (header["CCD_TMP1"] + header["CCD_TMP2"]) / 2.0 * u.deg_C |
@@ -24,15 +24,33 @@ def test_suvi_despiking_nc(L1B_NC): | |||
|
|||
|
|||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
ccd_temp_avg = (header["CCD_TMP1"] + header["CCD_TMP2"]) / 2.0 * u.deg_C |
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 comment
The reason will be displayed to describe this comment to others. Learn more.
assert l1b_fits_response["ccd_temperature"] == ccd_temperature | |
assert l1b_fits_response["ccd_temperature"] == (header["CCD_TMP1"] + header["CCD_TMP2"]) / 2.0 * u.deg_C |
|
||
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
ccd_temperature = (header["CCD_TMP1"] + header["CCD_TMP2"]) / 2.0 * u.deg_C |
I have a few more comments but there are some older ones still left unresolved. |
Co-authored-by: Nabil Freij <[email protected]>
Co-authored-by: Nabil Freij <[email protected]>
Co-authored-by: Nabil Freij <[email protected]>
Co-authored-by: Nabil Freij <[email protected]>
Co-authored-by: Nabil Freij <[email protected]>
Co-authored-by: Nabil Freij <[email protected]>
Co-authored-by: Nabil Freij <[email protected]>
As per the old comments:
I think the comments are addressed you can check once you get time. |
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.
@@ -156,7 +156,8 @@ def get_response(request, spacecraft=16, ccd_temperature=-60.0, exposure_type="l | |||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we redefine ccd_temperature
here?
PR Description
Function Signature Update:
Changed ccd_temperature=-60.0 to ccd_temperature=-60.0 * u.deg_C.
Temperature Handling:
Added a check to ensure ccd_temperature is an Astropy Quantity.
Converted non-Quantity inputs to u.deg_C.
Ensured temperature is in degrees Celsius for consistency.
Gain Interpolation:
Used temp_x values directly (assumed in degrees Celsius).
Used .value to get numerical values for interpolation.
Docstring Update:
Described ccd_temperature as an Astropy Quantity with units.
Testing:
The function now accepts both Quantity and float inputs for temperature.
Temperatures provided in different units are converted to degrees Celsius.
This fixes #77