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

Create epochs to avoid using bad cal files with wrong polarizer angle(s) #336

Closed
35 tasks done
jburkepile opened this issue May 20, 2023 · 14 comments
Closed
35 tasks done
Assignees
Labels
bug fix of a problem in the existing code process process data
Milestone

Comments

@jburkepile
Copy link
Collaborator

jburkepile commented May 20, 2023

Need to avoid using a number of calibration files that contain at least a few calibration polarizer images taken with the polarizer at the wrong angle: the polarizer was at 23.9 degrees instead of zero or 180 degrees. 23.9 degrees is NOT a invalid angle and will corrupt the integrity of the calibration. Need to:

  1. create epochs to avoid using bad cal files
  2. reprocess days impacted by bad cal files

Create epochs:

  • 20140102 09:02:00 [HST] DO NOT PROCESS. Bad calpol angle
  • 20140102 09:14:23 [HST] Begin processing good data
  • 20140224 09:33:29 [HST] DO NOT PROCESS. Bad calpol angle
  • 20140224 09:45:52 [HST] Begin processing good data
  • 20140509 10:35:31 [HST] DO NOT PROCESS. Bad calpol angle
  • 20140509 10:47:55 [HST] Begin processing good data
  • 20140523 07:53:42 [HST] DO NOT PROCESS. Bad calpol angle
  • 20140523 08:06:05 [HST] Begin processing good data
  • 20141115 09:28:41 [HST] DO NOT PROCESS. Bad calpol angle
  • 20141115 09:40:49 [HST] Begin processing good data
  • 20141208 10:56:23 [HST] DO NOT PROCESS. Bad calpol angle
  • 20141208 11:08:47 [HST] Begin processing good data
  • 20141219 09:10:34 [HST] DO NOT PROCESS. Bad calpol angle
  • 20141219 09:22:58 [HST] Begin processing good data
  • 20141229 09:10:05 [HST] DO NOT PROCESS. Bad calpol angle
  • 20141229 09:22:44 [HST] Begin processing good data

NEXT: Reprocess days impacted by bad cal files:

  • 20140102
  • 20140224
  • 20140509
  • 20140522
  • 20140523
  • 20141115
  • 20141208
  • 20141219
  • 20141229
  • 20141206 - bad calibration polarizer angle 23.8 deg [days above this had angle of 23.9 deg]
  • 20141210 - bad calibration polarizer angle 23.8 deg
  • 20141211 - bad calibration polarizer angle 23.8 deg
  • 20141215 - bad calibration polarizer angle 23.8 deg
  • 20141226 - bad calibration polarizer angle 23.8 deg
  • 20141230 - bad calibration polarizer angle 23.8 deg
  • 20141231 - No cal file this day. 12/30 calibration was used for beginning of this day. Need to reprocess with good file

Tasks

  • update kcor_check_angles to return a mask array, instead of a single binary value, to check the files with dark=out, diff=in, calpol=in:
    1. must have all required_angles = [0.0, 45.0, 90.0, 135.0] degrees
    2. can have required_angles + 22.5
    3. throw out any observations (files) where the angle is not required_angles or required_angles + 22.5
  • verify files/types in cal file metadata vs logs of calibration processing vs calibration_files.txt in process to make sure that the right files are eliminated
  • verify full processing of above test dates is good

Summary

The pipeline now handles cal pol files with non-nominal angles — removing the observations with bad angles, but processing the rest of the cal data unless all the required angles are not present.

We verified that the changes made to remove the 'bad' angles from the calibration files was successful. The 'evil twin' CME on Dec 20 2014 (see 00:48 image further down in this ticket) was removed in the reprocessed data. We also examined the stability of the calibrated pB images (see pB plots from Dec 31, 2014 further down in this ticket). The pB calibration was much more stable over the day when the 'bad' calibration angles were removed.

@jburkepile jburkepile added the bug fix of a problem in the existing code label May 20, 2023
@jburkepile jburkepile added this to the 2.0 L1 reprocess milestone May 20, 2023
@mgalloy mgalloy added the process process data label May 25, 2023
@mgalloy
Copy link
Member

mgalloy commented Jul 12, 2023

Actually, there are many, many days with bad cal files with odd cal angles. These days must automatically catch the bad days. For some reason kcor_check_angles is not finding those days.

@mgalloy
Copy link
Member

mgalloy commented Jul 12, 2023

OK, kcor_check_angles checks to make sure every required angle is present in the calibration polarization angles, but not if there are extra angles present. Will check both ways.

mgalloy added a commit that referenced this issue Jul 12, 2023
- KCOR_CHECK_ANGLES was already checking to make sure every required angle was present in the calibration polarization angles. Now it checks to make sure every calibration polarization angle is in the required angles.
@mgalloy
Copy link
Member

mgalloy commented Oct 30, 2023

Reprocessing the mission #346 will address this issue. Closing.

@mgalloy mgalloy closed this as completed Oct 30, 2023
@mgalloy mgalloy mentioned this issue Oct 30, 2023
4 tasks
@mgalloy mgalloy reopened this Dec 4, 2023
mgalloy added a commit that referenced this issue Apr 2, 2024
If required_angles = [0.0, 45.0, 90.0, 135.0], then previously checking
if angles are required_angles or required_angles + 22.5. Now, checking
to make sure required_angles are all present, and optionally allowing
some required_angles + 22.5 to be present. No other angles allowed.
@mgalloy
Copy link
Member

mgalloy commented Apr 23, 2024

I reprocessed 20140102 in raw.latest to test this. I changed the epochs.cfg file for the test to process all the files for the day, not manually removing the bad files. In the log, I got:

2024-04-23 15:38:02 DEBUG: KCOR_CHECK_ANGLES: cal angle 23.85 not required or optional, removing...
2024-04-23 15:38:02 DEBUG: KCOR_CHECK_ANGLES: cal angle 23.85 not required or optional, removing...
2024-04-23 15:38:02 DEBUG: KCOR_CHECK_ANGLES: cal angle 23.85 not required or optional, removing...

I think this correctly corresponds to the three bad files in the calibration_files.txt file:

20140102_190331_kcor.fts.gz       1.0000  ms  start state: 0 0  Data: calibration   Dark: out   Diff: in   Cal: in   Ang:   23.9  means:  9.07264e+03    1.39455e+04    2.78674e+03    7.88718e+03    7.28369e+03    2.10529e+03    1.33537e+04    8.52280e+03
20140102_190346_kcor.fts.gz       1.0000  ms  start state: 0 0  Data: calibration   Dark: out   Diff: in   Cal: in   Ang:   23.9  means:  9.06800e+03    1.39496e+04    2.77096e+03    7.88025e+03    7.28307e+03    2.09446e+03    1.33632e+04    8.52410e+03
20140102_190401_kcor.fts.gz       1.0000  ms  start state: 0 0  Data: calibration   Dark: out   Diff: in   Cal: in   Ang:   23.9  means:  9.07404e+03    1.39658e+04    2.76485e+03    7.88376e+03    7.28352e+03    2.08375e+03    1.33765e+04    8.52718e+03

Interestingly, the epochs.cfg file removed more files:

# bad calpol angle
[20140102.090200]
process                        : NO

[20140102.091423]
process                        : YES

@mgalloy
Copy link
Member

mgalloy commented Apr 23, 2024

If this works, we can probably remove a lot of bad cal file epochs.

@mgalloy
Copy link
Member

mgalloy commented Apr 24, 2024

We should record the calibration files used in some way:

  • a calibration_files_used.txt in process
  • a metadata field in the netCDF calibration file

@mgalloy mgalloy reopened this Apr 24, 2024
@jburkepile
Copy link
Collaborator Author

jburkepile commented Apr 24, 2024

Mike:
Looks like your code successfully removed the 3 'bad' calpol files from the 20140102 calibration. These are indeed the only 3 'bad' files that day and these are what you reported above. Nice job!

  • 20140102_190331_kcor.fts.gz
  • 20140102_190346_kcor.fts.gz
  • 20140102_190401_kcor.fts.gz

@mgalloy
Copy link
Member

mgalloy commented Apr 24, 2024

There are already "Input File List" and "Input File Type" that list all the calibration files and their type used in the calibration. Need to fix those up.

@mgalloy
Copy link
Member

mgalloy commented Apr 25, 2024

Producing cal files from the days with the given epochs removed and the new algorithm filtering files. Results are in raw.polangle.

@mgalloy
Copy link
Member

mgalloy commented Apr 25, 2024

For some reason, the last three files listed in Input File List are repeated, and I think the same is true for Input File Types.

@mgalloy
Copy link
Member

mgalloy commented Apr 25, 2024

In raw.polangle, I confirm that:

  • there are 31 total calibration files in calibration_files.txt, 3 of them are "calibration" type files with angle 23.85, so there are 28 good calibration files
  • in the calibration netCDF file produced for the day, the "Input File Type" and "Input File List" are 28 elements long and exclude the correct 3 bad calibration files
  • the end-of-day log for the processing of the day, mentions removing the correct three bad files with bad polarization angles

@mgalloy mgalloy added the needs testing needs more testing/verification label Apr 27, 2024
mgalloy added a commit that referenced this issue May 1, 2024
Now using the KCOR_CHECK_ANGLES algorithm to find bad angles in the calibration files.
@jburkepile
Copy link
Collaborator Author

I have begun checking the days Mike reprocessed, that remove the bad polarizer angle files from the calibration, beginning with day 20141219:

20141219 - this day had an 'evil twin' CME; i.e. a CME that had a faint duplicate of itself occurring 45 degrees away due to coronal signal 'leaking' into the background polarization. This was caused by the bad calibration file that contained cross-talk between Stokes I,Q,U states. RESULT: The reprocessed 20141219 data looks good. There is no longer an evil-twin CME.
OLD DATA WITH BAD CAL FILE:
20141220_004859_kcor_minus_003853_good_badcal

NEW DATA WITH GOOD CAL IMAGES:
20141220_004844_kcor_minus_003807_good_goodcal

The calibrated pB intensities changed as well. The change was greatest in the inner corona with the most visible change occurring in the south-southeast. This region appeared to have closed field in the bad image. This is gone in the reprocessed data:
OLD pB image with BAD CAL FILE:
20141219_175544_badcal_kcor_l2

NEW pB image with GOOD CAL FILE:
20141219_175544_goodcal_kcor_l2

The bad image contained spurious coronal signal from cross-talk. The good image now shows the south-southeast region with no obvious helmet and looking more like a coronal hole. This is now consistent with what is seen by CoMP on this day:
20141219 comp 1074 daily_enhanced_intensity 3

I need to check more days to ensure all is well, but this is very reassuring.

@mgalloy
Copy link
Member

mgalloy commented May 16, 2024

The new test dates with bad calibration polarization angle are processed. Results in raw.polangle.

@jburkepile
Copy link
Collaborator Author

jburkepile commented May 28, 2024

Check that the new calibration files, with the 'bad' angle images removed, do indeed improve the polarization brightness calibrated intensities. To verify that, I looked at the plots of azimuthally averaged pB at a fixed height. These plots are made by Mike each day for 4 heights in the corona. On Dec 31, 2014, there was a large data gap in the middle of the day. The processing looks for the calibration file nearest in time to the science images. It turns out that on this day, the data taken early in the day were processed with the Dec 30, 2014 cal file, while the data taken late in the day, after the data gap, were processed with the cal file from Jan 1, 2015. The Dec 30, 2014 cal file contained bad polarization angles.
The plots below show the change in calibrated pB intensities between the data processed with the 'bad' calibration (Dec 30, 2014) and the data processed with a good cal file (Jan 1, 2015). The pB value at a fixed height should be the same value over a day, unless a large CME occurred and blew out part of the corona on/near the limb. There was a small, faint possible CME this day but it was much too small to impact the pB plots. The plots below show the change in calibrated pB intensities between the data processed with the 'bad' calibration (Dec 30, 2014) and the data processed with a good cal file (Jan 1, 2015).
20141231 kcor mean-pb-1 11

20141231 kcor mean-pb-1 30

Below are the same plots, but now the data taken in the morning were calibrated with the 'corrected' calibration on Dec 30, 2014. Note that the pB values before and after the data gap are now in much better agreement.
20141231 kcor mean-pb-1 11_with_corrected_cal

20141231 kcor mean-pb-1 30_with_corrected_cal

This strongly suggests that the changes made to the pipeline to remove the 'bad' angle calibration files are working correctly and the pB values are much more accurate and consistent.
I think it is safe to mark this as closed.

@mgalloy mgalloy removed the needs testing needs more testing/verification label May 28, 2024
@mgalloy mgalloy closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix of a problem in the existing code process process data
Projects
None yet
Development

No branches or pull requests

2 participants