sot / starcheck

BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Round CCD temperature for check and add 3-digit max T_CCD output #445

Closed taldcroft closed 1 month ago

taldcroft commented 1 month ago

Description

Changes:

Interface impacts

Changes starcheck notes format to add a 3-digit output of the max CCD temperature for diagnostics. No impact to parsing (see functional test below).

Testing

Unit tests

ska3-jeanconn-fido> pytest
=================================================== test session starts ====================================================
platform linux -- Python 3.11.8, pytest-7.4.4, pluggy-1.4.0
rootdir: /proj/sot/ska/jeanproj/git
configfile: pytest.ini
plugins: anyio-4.3.0, timeout-2.2.0
collected 14 items                                                                                                         

starcheck/tests/test_state_checks.py .............                                                                   [ 92%]
starcheck/tests/test_utils.py .                                                                                      [100%]

=================================================== 14 passed in 57.27s

Functional tests

The JUL0824A products showed a critical warning for obsid 26575

Flight (notes for 26575)

>> CRITICAL: CCD temperature exceeds -3.9 C

Probability of acquiring 2 or fewer stars (10^-x):  7.9 
Acquisition Stars Expected  : 7.77
Guide star count: 5.0   
Predicted Max CCD temperature: -3.9 C    N100 Warm Pix Frac 0.498
Dynamic Mag Limits: Yellow 9.76      Red 10.08

Patch (notes for 26575)

$ ./sandbox_starcheck -dir /Users/aldcroft/ska/data/mpcrit1/mplogs/2024/JUL0824/oflsa -out jul0824
...
Probability of acquiring 2 or fewer stars (10^-x):  7.9 
Acquisition Stars Expected  : 7.77
Guide star count: 5.0   
Predicted Max CCD temperature: -3.9 C (-3.892 C)     N100 Warm Pix Frac 0.498
Dynamic Mag Limits: Yellow 9.76      Red 10.08

As expected, all other obsids showed the new 3-digit representation of the max CCD temperature.

Patch with temporary code to force a violation in 26575

Patched one code line as follows, adding 0.1 to the computed CCD temperature:

    my $ccd_temp_round = sprintf("%.1f", $self->{ccd_temp} + 0.1);

This gave:

>> CRITICAL: CCD temperature exceeds -3.9 C

Probability of acquiring 2 or fewer stars (10^-x):  7.9 
Acquisition Stars Expected  : 7.77
Guide star count: 5.0   
Predicted Max CCD temperature: -3.9 C (-3.892 C)     N100 Warm Pix Frac 0.498
Dynamic Mag Limits: Yellow 9.76      Red 10.08

Compare to flight 14.9.0 release

(ska3) ➜  starcheck git:(144485d) diff jul0824{-flight,}.txt
1,2c1,2
<  ------------  Starcheck 14.9.0    -----------------
<  Run on Wed Jul  3 09:22:43 EDT 2024 by aldcroft from saos-MacBook-Pro.local
---
>  ------------  Starcheck 14.10.1.dev1+g495d70c    -----------------
>  Run on Wed Jul  3 09:09:24 EDT 2024 by aldcroft from saos-MacBook-Pro.local
65c65
< OBSID = 26575 at 2024:192:22:53:13.261   7.8 ACQ | 5.0 GUI | Critical: 1 
---
> OBSID = 26575 at 2024:192:22:53:13.261   7.8 ACQ | 5.0 GUI | 
124c124
< Predicted Max CCD temperature: -4.4 C          N100 Warm Pix Frac 0.487
---
> Predicted Max CCD temperature: -4.4 C (-4.417 C)       N100 Warm Pix Frac 0.487
158c158
< Predicted Max CCD temperature: -4.8 C          N100 Warm Pix Frac 0.478
---
> Predicted Max CCD temperature: -4.8 C (-4.839 C)       N100 Warm Pix Frac 0.478
193c193
< Predicted Max CCD temperature: -5.1 C          N100 Warm Pix Frac 0.474
---
> Predicted Max CCD temperature: -5.1 C (-5.065 C)       N100 Warm Pix Frac 0.474
227c227
< Predicted Max CCD temperature: -5.7 C          N100 Warm Pix Frac 0.461
---
> Predicted Max CCD temperature: -5.7 C (-5.691 C)       N100 Warm Pix Frac 0.461
259c259
< Predicted Max CCD temperature: -6.0 C          N100 Warm Pix Frac 0.456
---
> Predicted Max CCD temperature: -6.0 C (-5.979 C)       N100 Warm Pix Frac 0.456
289c289
< Predicted Max CCD temperature: -7.4 C          N100 Warm Pix Frac 0.427
---
> Predicted Max CCD temperature: -7.4 C (-7.360 C)       N100 Warm Pix Frac 0.427
320c320
< Predicted Max CCD temperature: -7.6 C          N100 Warm Pix Frac 0.423
---
> Predicted Max CCD temperature: -7.6 C (-7.611 C)       N100 Warm Pix Frac 0.423
351c351
< Predicted Max CCD temperature: -8.2 C          N100 Warm Pix Frac 0.409
---
> Predicted Max CCD temperature: -8.2 C (-8.242 C)       N100 Warm Pix Frac 0.409
395c395
< Predicted Max CCD temperature: -8.6 C          N100 Warm Pix Frac 0.401
---
> Predicted Max CCD temperature: -8.6 C (-8.622 C)       N100 Warm Pix Frac 0.401
425c425
< Predicted Max CCD temperature: -8.8 C          N100 Warm Pix Frac 0.396
---
> Predicted Max CCD temperature: -8.8 C (-8.838 C)       N100 Warm Pix Frac 0.396
458c458
< Predicted Max CCD temperature: -7.8 C          N100 Warm Pix Frac 0.418
---
> Predicted Max CCD temperature: -7.8 C (-7.845 C)       N100 Warm Pix Frac 0.418
491c491
< Predicted Max CCD temperature: -4.3 C          N100 Warm Pix Frac 0.489
---
> Predicted Max CCD temperature: -4.3 C (-4.327 C)       N100 Warm Pix Frac 0.489
527c527
< Predicted Max CCD temperature: -4.0 C          N100 Warm Pix Frac 0.495
---
> Predicted Max CCD temperature: -4.0 C (-4.015 C)       N100 Warm Pix Frac 0.495
555,556d554
< 
< >> CRITICAL: CCD temperature exceeds -3.9 C
561c559
< Predicted Max CCD temperature: -3.9 C          N100 Warm Pix Frac 0.498
---
> Predicted Max CCD temperature: -3.9 C (-3.892 C)       N100 Warm Pix Frac 0.498
593c591
< Predicted Max CCD temperature: -4.0 C          N100 Warm Pix Frac 0.496
---
> Predicted Max CCD temperature: -4.0 C (-3.956 C)       N100 Warm Pix Frac 0.496
625c623
< Predicted Max CCD temperature: -5.5 C          N100 Warm Pix Frac 0.465
---
> Predicted Max CCD temperature: -5.5 C (-5.549 C)       N100 Warm Pix Frac 0.465
660c658
< Predicted Max CCD temperature: -6.6 C          N100 Warm Pix Frac 0.444
---
> Predicted Max CCD temperature: -6.6 C (-6.555 C)       N100 Warm Pix Frac 0.444
692c690
< Predicted Max CCD temperature: -8.2 C          N100 Warm Pix Frac 0.409
---
> Predicted Max CCD temperature: -8.2 C (-8.241 C)       N100 Warm Pix Frac 0.409
725c723
< Predicted Max CCD temperature: -9.0 C          N100 Warm Pix Frac 0.394
---
> Predicted Max CCD temperature: -9.0 C (-8.960 C)       N100 Warm Pix Frac 0.394
757c755
< Predicted Max CCD temperature: -9.4 C          N100 Warm Pix Frac 0.384
---
> Predicted Max CCD temperature: -9.4 C (-9.415 C)       N100 Warm Pix Frac 0.384
802c800
< Predicted Max CCD temperature: -9.4 C          N100 Warm Pix Frac 0.384
---
> Predicted Max CCD temperature: -9.4 C (-9.449 C)       N100 Warm Pix Frac 0.384
836c834
< Predicted Max CCD temperature: -6.4 C          N100 Warm Pix Frac 0.449
---
> Predicted Max CCD temperature: -6.4 C (-6.354 C)       N100 Warm Pix Frac 0.449
871c869
< Predicted Max CCD temperature: -5.9 C          N100 Warm Pix Frac 0.458
---
> Predicted Max CCD temperature: -5.9 C (-5.877 C)       N100 Warm Pix Frac 0.458
903c901
< Predicted Max CCD temperature: -5.9 C          N100 Warm Pix Frac 0.458
---
> Predicted Max CCD temperature: -5.9 C (-5.869 C)       N100 Warm Pix Frac 0.458
936c934
< Predicted Max CCD temperature: -5.7 C          N100 Warm Pix Frac 0.462
---
> Predicted Max CCD temperature: -5.7 C (-5.660 C)       N100 Warm Pix Frac 0.462
971c969
< Predicted Max CCD temperature: -5.5 C          N100 Warm Pix Frac 0.466
---
> Predicted Max CCD temperature: -5.5 C (-5.500 C)       N100 Warm Pix Frac 0.466
1003c1001
< Predicted Max CCD temperature: -5.7 C          N100 Warm Pix Frac 0.461
---
> Predicted Max CCD temperature: -5.7 C (-5.716 C)       N100 Warm Pix Frac 0.461
1038c1036
< Predicted Max CCD temperature: -4.2 C          N100 Warm Pix Frac 0.491
---
> Predicted Max CCD temperature: -4.2 C (-4.240 C)       N100 Warm Pix Frac 0.491
1071c1069
< Predicted Max CCD temperature: -4.1 C          N100 Warm Pix Frac 0.494
---
> Predicted Max CCD temperature: -4.1 C (-4.054 C)       N100 Warm Pix Frac 0.494
1104c1102
< Predicted Max CCD temperature: -4.2 C          N100 Warm Pix Frac 0.492
---
> Predicted Max CCD temperature: -4.2 C (-4.152 C)       N100 Warm Pix Frac 0.492

Format change does not impact parsing

In [5]: import starcheck.parser
   ...: flight = starcheck.parser.read_starcheck("jul0824-flight.txt")

In [6]: test = starcheck.parser.read_starcheck("jul0824-patch.txt")

In [7]: test == flight
Out[7]: True
taldcroft commented 1 month ago

@jeanconn - is the new 3-digit T_CCD going to break the starcheck parser? How do I test?

jeanconn commented 1 month ago

I think it is going to break it (as in by eye on that regex it won't match so would return None for that part of the update).

https://github.com/sot/starcheck/blob/1b5ec5e5ab176913996570e9922dfad10310467b/starcheck/parser.py#L285

So I think the regex needs a tweak to be fine with more decimals.

For testing, I'd previously just done a functional check like

In [1]: import starcheck.parser

In [2]: test = starcheck.parser.read_starcheck('MAY1324B_test.txt')

In [3]: master = starcheck.parser.read_starcheck('MAY1324B_master.txt')

And confirmed that entries array of dicts were reasonable. I think this would just be the key 'pred_ccd_temp'.

jeanconn commented 1 month ago

Oh, actually, it looks like the regex by-eye would probably be fine on your proposed change if you are just adding more digits for debug after "C".

jeanconn commented 1 month ago

@taldcroft Did you mention in our meeting that you were planning to update the description to note that you checked the parser?

taldcroft commented 1 month ago

@taldcroft Did you mention in our meeting that you were planning to update the description to note that you checked the parser?

Done.