NCAR / ucomp-pipeline

Data processing pipeline for UCoMP
Other
6 stars 3 forks source link

Add median value quality checks when reading flats #284

Open bberkeyU opened 4 months ago

bberkeyU commented 4 months ago

Currently, we do not perform image data quality checks on the flats, which has allowed some marginal or deficient flats to be used in the image correction.

Between spot-checking good and bad flats and looking at metrics across the UCoMP mission, I find that for a given epoch, good flats have a range of meidan values vary by wave region, epoch, camera, and onband tuning.

I have computed a table of high and low flat values for each of the 637,706,1074, and 1079 regions. I also looked at 530, but all flats were equally good (or bad?), so the pipeline should pass all the 530 data. If the pipeline needs values for 530 and the other wavelengths, we should start with min=0 and max =4095 and allow everything to pass.

For the analysis, the median value of the raw L0 flat pixels within an annulus centered in the middle of the detector with an inner radius of 375 and an outer radius of 600 pixels was computed; the computation also excluded post values between x=550 ->700 in the raw detector coordinate systems. These median values were then divided by NUMSUM, and the mean was computed across the 4 modulation states.

The table below contains the high and low flat limits for the following states:

Date-beg and date-end define the start and stop of the epochs.

@mgalloy Please let me know if this table should be in a different format; I can easily transform and recreate it.

               date-beg                date-end  waveRegion  cam0-on-low  cam0-on-high  cam0-off-low  cam0-off-high  cam1-on-low  cam1-on-high  cam1-off-low  cam1-off-high
2022-11-18 12:00:00.000 2022-12-06 12:00:00.000      1074.0        340.0         360.0         300.0          330.0        320.0         340.0         285.0          315.0
2022-06-16 19:12:00.000 2022-11-17 12:00:00.000      1074.0        335.0         365.0         300.0          325.0        335.0         364.0         295.0          325.0
2022-03-19 12:00:00.000 2022-06-16 19:12:00.000      1074.0        355.0         380.0         310.0          340.0        350.0         375.0         310.0          335.0
2022-02-23 19:12:00.000 2022-03-19 12:00:00.000      1074.0        370.0         385.0         320.0          340.0        365.0         378.0         320.0          342.0
2022-02-02 12:00:00.000 2022-02-23 19:12:00.000      1074.0        860.0         880.0         815.0          840.0        850.0         865.0         800.0          820.0
2022-01-14 12:00:00.000 2022-02-02 12:00:00.000      1074.0        740.0         765.0         720.0          740.0        735.0         760.0         705.0          730.0
2021-11-11 12:00:00.000 2022-01-14 12:00:00.000      1074.0        750.0         785.0         730.0          755.0        740.0         775.0         720.0          750.0
2021-10-08 00:00:00.000 2021-11-11 12:00:00.000      1074.0        805.0         830.0         775.0          790.0        795.0         815.0         760.0          780.0
2021-08-11 12:00:00.000 2021-10-08 00:00:00.000      1074.0        770.0         795.0         740.0          760.0        760.0         780.0         730.0          750.0
2021-07-29 12:00:00.000 2021-08-11 12:00:00.000      1074.0        800.0         860.0         765.0          820.0        800.0         860.0         750.0          820.0
2022-11-18 12:00:00.000 2022-12-06 12:00:00.000      1079.0        371.0         410.0         285.0          336.0        353.0         390.0         273.0          321.0
2022-06-16 19:12:00.000 2022-11-17 12:00:00.000      1079.0        330.0         436.0         270.0          340.0        330.0         441.0         270.0          350.0
2022-03-19 12:00:00.000 2022-06-16 19:12:00.000      1079.0        340.0         460.0         280.0          379.0        340.0         466.0         280.0          371.0
2022-02-23 19:12:00.000 2022-03-19 12:00:00.000      1079.0        380.0         460.0         290.0          380.0        370.0         460.0         280.0          380.0
2022-02-02 12:00:00.000 2022-02-23 19:12:00.000      1079.0        860.0         946.0         740.0          887.0        860.0         919.0         740.0          875.0
2022-01-14 12:00:00.000 2022-02-02 12:00:00.000      1079.0        760.0         815.0         680.0          772.0        760.0         804.0         680.0          761.0
2021-11-11 12:00:00.000 2022-01-14 12:00:00.000      1079.0        750.0         830.0         684.0          770.0        733.0         820.0         650.0          760.0
2021-10-08 00:00:00.000 2021-11-11 12:00:00.000      1079.0        800.0         879.0         740.0          805.0        800.0         868.0         740.0          794.0
2021-08-11 12:00:00.000 2021-10-08 00:00:00.000      1079.0        770.0         839.0         710.0          775.0        770.0         829.0         701.0          764.0
2021-07-29 12:00:00.000 2021-08-11 12:00:00.000      1079.0        840.0         905.0         758.0          832.0        818.0         910.0         730.0          840.0
2022-11-18 12:00:00.000 2022-12-06 12:00:00.000       789.0        121.0         134.0         103.0          118.0        115.0         129.0          96.0          112.0
2022-06-16 19:12:00.000 2022-11-17 12:00:00.000       789.0        100.0         136.0         100.0          121.0        100.0         138.0         100.0          124.0
2022-03-19 12:00:00.000 2022-06-16 19:12:00.000       789.0        110.0         139.0          95.0          120.0        105.0         138.0          95.0          120.0
2022-02-23 19:12:00.000 2022-03-19 12:00:00.000       789.0        115.0         140.0         100.0          130.0        115.0         140.0         100.0          125.0
2022-02-02 12:00:00.000 2022-02-23 19:12:00.000       789.0        610.0         640.0         600.0          620.0        610.0         630.0         590.0          610.0
2022-01-14 12:00:00.000 2022-02-02 12:00:00.000       789.0        582.0         604.0         574.0          591.0        580.0         596.0         559.0          583.0
2021-11-11 12:00:00.000 2022-01-14 12:00:00.000       789.0        580.0         617.0         573.0          600.0        584.0         610.0         550.0          592.0
2021-10-08 00:00:00.000 2021-11-11 12:00:00.000       789.0        575.0         650.0         570.0          620.0        580.0         620.0         550.0          600.0
2021-08-11 12:00:00.000 2021-10-08 00:00:00.000       789.0        580.0         612.0         570.0          598.0        580.0         605.0         555.0          591.0
2022-11-18 12:00:00.000 2022-12-06 12:00:00.000       706.0         87.0         100.0          74.0           84.0         84.0          98.0          70.0           81.0
2022-06-16 19:12:00.000 2022-11-17 12:00:00.000       706.0         85.0         110.0          60.0           90.0         85.0         110.0          70.0           90.0
2022-03-19 12:00:00.000 2022-06-16 19:12:00.000       706.0         85.0         103.0          70.0           85.0         80.0         100.0          65.0           85.0
2022-02-23 19:12:00.000 2022-03-19 12:00:00.000       706.0         80.0         110.0          80.0          100.0         80.0         110.0          80.0          100.0
2021-10-08 00:00:00.000 2021-11-11 12:00:00.000       706.0        587.0         588.0         581.0          582.0        578.0         578.0         572.0          572.0
2021-08-11 12:00:00.000 2021-10-08 00:00:00.000       706.0        542.0         591.0         542.0          583.0        533.0         583.0         533.0          575.0
2021-07-29 12:00:00.000 2021-08-11 12:00:00.000       706.0        564.0         645.0         578.0          636.0        580.0         778.0         566.0          768.0
2022-02-02 12:00:00.000 2022-02-23 19:12:00.000       706.0        555.0         604.0         554.0          596.0        546.0         595.0         545.0          587.0
2022-11-18 12:00:00.000 2022-12-06 12:00:00.000       637.0         81.0          93.0          72.0           90.0         79.0          92.0          70.0           90.0
2022-06-16 19:12:00.000 2022-11-17 12:00:00.000       637.0         60.0          98.0          60.0           95.0         60.0          99.0          60.0           97.0
2022-03-19 12:00:00.000 2022-06-16 19:12:00.000       637.0         74.0          95.0          70.0           91.0         70.0          94.0          70.0           92.0
2022-02-23 19:12:00.000 2022-03-19 12:00:00.000       637.0         70.0         100.0          70.0          100.0         70.0         100.0          70.0          100.0
2022-02-02 12:00:00.000 2022-02-23 19:12:00.000       637.0        546.0         591.0         546.0          588.0        538.0         582.0         538.0          579.0
2022-01-14 12:00:00.000 2022-02-02 12:00:00.000       637.0        552.0         576.0         557.0          573.0        552.0         567.0         544.0          564.0
2021-11-11 12:00:00.000 2022-01-14 12:00:00.000       637.0        542.0         590.0         552.0          576.0        541.0         571.0         533.0          593.0
2021-10-08 00:00:00.000 2021-11-11 12:00:00.000       637.0        550.0         585.0         550.0          585.0        545.0         580.0         545.0          580.0
2021-08-11 12:00:00.000 2021-10-08 00:00:00.000       637.0        550.0         582.0         550.0          578.0        540.0         573.0         540.0          570.0
2021-07-29 12:00:00.000 2021-08-11 12:00:00.000       637.0        568.0         634.0         577.0          631.0        569.0         779.0         564.0          775.0

Possible epoch value definitions, which are all 2-element arrays of min/max values:

rcam_onband_flat_range  : type=float, extract=YES
rcam_offband_flat_range : type=float, extract=YES
tcam_onband_flat_range  : type=float, extract=YES
tcam_offband_flat_range : type=float, extract=YES

Tasks

mgalloy commented 4 months ago

@bberkeyU Are the times listed in Julian date? Why is 12:00:00 so frequent? i.e. is the "2022-11-18 12:00:00.000" listed actually "2022-11-18T12:00:00Z"?

mgalloy commented 4 months ago

I think there is a missing epoch for 706. I think that the next epoch after:

2021-10-08 00:00:00.000 2021-11-11 12:00:00.000

is:

2022-02-23 19:12:00.000 2022-03-19 12:00:00.000

So 2021-11-11 12:00:00.000 to 2022-02-23 19:12:00.000 is missing.

mgalloy commented 4 months ago

@bberkeyU Are there example files that you know will fail the quality check? I would like some good days to test on.

bberkeyU commented 4 months ago

@mgalloy I think they are in Julian Dates:

To get the epochs, I pulled the DATE-BEG from all of the header files and converted it to Julian data with the astropy.time import Time with the following command: Time(ext.header['DATE-BEG']).jd,fit[0]

I then plotted the flat medians vs this Julien data and tweaked my X and Y limits until I found good start/stop times and intensity limits. (Note: when doing the start/stop finding, I subtracted 2459000 from all of the Julien dates so I could think about smaller numbers.

I converted the values back from Julien date to date time strings with the following command flatRanges["date-beg"] = Time(flatRanges["jdstart"]+2459000,format="jd").iso

This process gave a 12:00 reference instead of a 00:00 reference time. In most but not all cases, the epochs change at the beginning or end of an observing day, so the exact timestamp isn't going to be important.

bberkeyU commented 4 months ago

@mgalloy I am looking into finding bad days that are both clearly and marginally bad.

bberkeyU commented 3 months ago

I created a workbook with Flat epoch plots. It is a fairly long document with the interesting part most of the way down.

In this example plot from the 637 section image we can see an epoch for 2022-03-19 to 2022-06-16 There are four plots in this images separated by camera and onband. Orange dots represent the median flat values in the "coronal" region. Most points fall within the yellow bars representing high and low limit values, but a handful is clearly below the low-intensity limit.

There is a similar plot for each of the six wave regions (530, 637, 706, 789, 1074,1079) for each epoch region I identified. The upper and lower limits were empirically selected; and others might pick different values.