dkist-processing-common 12.0.0rc7__py3-none-any.whl → 12.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dkist_processing_common/codecs/fits.py +27 -6
- dkist_processing_common/models/constants.py +2 -2
- dkist_processing_common/models/flower_pot.py +230 -9
- dkist_processing_common/parsers/average_bud.py +0 -2
- dkist_processing_common/parsers/cs_step.py +10 -10
- dkist_processing_common/parsers/id_bud.py +4 -9
- dkist_processing_common/parsers/lookup_bud.py +7 -11
- dkist_processing_common/parsers/near_bud.py +7 -12
- dkist_processing_common/parsers/retarder.py +9 -13
- dkist_processing_common/parsers/time.py +19 -55
- dkist_processing_common/parsers/unique_bud.py +7 -14
- dkist_processing_common/tasks/parse_l0_input_data.py +4 -2
- dkist_processing_common/tasks/transfer_input_data.py +1 -0
- dkist_processing_common/tests/test_codecs.py +57 -11
- dkist_processing_common/tests/test_flower_pot.py +147 -5
- dkist_processing_common/tests/test_parse_l0_input_data.py +28 -4
- dkist_processing_common/tests/test_stems.py +140 -193
- dkist_processing_common/tests/test_workflow_task_base.py +0 -11
- {dkist_processing_common-12.0.0rc7.dist-info → dkist_processing_common-12.1.0.dist-info}/METADATA +2 -2
- {dkist_processing_common-12.0.0rc7.dist-info → dkist_processing_common-12.1.0.dist-info}/RECORD +22 -23
- {dkist_processing_common-12.0.0rc7.dist-info → dkist_processing_common-12.1.0.dist-info}/WHEEL +1 -1
- changelog/278.misc.rst +0 -1
- {dkist_processing_common-12.0.0rc7.dist-info → dkist_processing_common-12.1.0.dist-info}/top_level.txt +0 -0
|
@@ -323,18 +323,16 @@ def test_unique_bud(basic_header_objs):
|
|
|
323
323
|
When: Ingesting headers with a UniqueBud and asking for the value
|
|
324
324
|
Then: The Bud's value is the header constant value
|
|
325
325
|
"""
|
|
326
|
-
|
|
326
|
+
bud_obj = UniqueBud(
|
|
327
327
|
constant_name="constant",
|
|
328
328
|
metadata_key="constant_thing",
|
|
329
329
|
)
|
|
330
|
-
assert
|
|
330
|
+
assert bud_obj.stem_name == "constant"
|
|
331
331
|
for fo in basic_header_objs:
|
|
332
332
|
key = fo.name
|
|
333
|
-
|
|
333
|
+
bud_obj.update(key, fo)
|
|
334
334
|
|
|
335
|
-
|
|
336
|
-
assert len(petal) == 1
|
|
337
|
-
assert petal[0].value == 6.28
|
|
335
|
+
assert bud_obj.bud.value == 6.28
|
|
338
336
|
|
|
339
337
|
|
|
340
338
|
def test_unique_bud_non_unique_inputs(bad_header_objs):
|
|
@@ -343,17 +341,17 @@ def test_unique_bud_non_unique_inputs(bad_header_objs):
|
|
|
343
341
|
When: Ingesting headers with a UniqueBud and asking for the value
|
|
344
342
|
Then: An error is raised
|
|
345
343
|
"""
|
|
346
|
-
|
|
344
|
+
bud_obj = UniqueBud(
|
|
347
345
|
constant_name="constant",
|
|
348
346
|
metadata_key="constant_thing",
|
|
349
347
|
)
|
|
350
|
-
assert
|
|
348
|
+
assert bud_obj.stem_name == "constant"
|
|
351
349
|
for fo in bad_header_objs:
|
|
352
350
|
key = fo.name
|
|
353
|
-
|
|
351
|
+
bud_obj.update(key, fo)
|
|
354
352
|
|
|
355
|
-
with pytest.raises(ValueError):
|
|
356
|
-
|
|
353
|
+
with pytest.raises(ValueError, match="Multiple constant values found! Values:"):
|
|
354
|
+
_ = bud_obj.bud
|
|
357
355
|
|
|
358
356
|
|
|
359
357
|
@pytest.mark.parametrize(
|
|
@@ -369,17 +367,15 @@ def test_task_unique_bud(basic_header_objs, ip_task_type):
|
|
|
369
367
|
When: Ingesting headers with a TaskUniqueBud and asking for the value
|
|
370
368
|
Then: The bud's value is the header constant value
|
|
371
369
|
"""
|
|
372
|
-
|
|
370
|
+
bud_obj = TaskUniqueBud(
|
|
373
371
|
constant_name="proposal", metadata_key="proposal_id", ip_task_types=ip_task_type
|
|
374
372
|
)
|
|
375
|
-
assert
|
|
373
|
+
assert bud_obj.stem_name == "proposal"
|
|
376
374
|
for fo in basic_header_objs:
|
|
377
375
|
key = fo.name
|
|
378
|
-
|
|
376
|
+
bud_obj.update(key, fo)
|
|
379
377
|
|
|
380
|
-
|
|
381
|
-
assert len(petal) == 1
|
|
382
|
-
assert petal[0].value == "proposal_id_1"
|
|
378
|
+
assert bud_obj.bud.value == "proposal_id_1"
|
|
383
379
|
|
|
384
380
|
|
|
385
381
|
@pytest.mark.parametrize(
|
|
@@ -403,8 +399,8 @@ def test_task_unique_bud_non_unique_inputs(bad_header_objs, ip_task_type):
|
|
|
403
399
|
key = fo.name
|
|
404
400
|
bud.update(key, fo)
|
|
405
401
|
|
|
406
|
-
with pytest.raises(ValueError):
|
|
407
|
-
|
|
402
|
+
with pytest.raises(ValueError, match="Multiple constant values found! Values:"):
|
|
403
|
+
_ = bud.bud
|
|
408
404
|
|
|
409
405
|
|
|
410
406
|
def test_single_value_single_key_flower(basic_header_objs):
|
|
@@ -447,18 +443,17 @@ def test_task_datetime_base_bud(basic_header_objs, ip_task_type, expected_value)
|
|
|
447
443
|
When: Ingesting headers with a `TaskDatetimeBudBase` bud and asking for the value
|
|
448
444
|
Then: The bud's value is the list of datetimes in seconds
|
|
449
445
|
"""
|
|
450
|
-
|
|
446
|
+
bud_obj = TaskDatetimeBudBase(
|
|
451
447
|
stem_name="datetimes",
|
|
452
448
|
metadata_key=FitsReaderMetadataKey.time_obs,
|
|
453
449
|
ip_task_types=ip_task_type,
|
|
454
450
|
)
|
|
455
|
-
assert
|
|
451
|
+
assert bud_obj.stem_name == "datetimes"
|
|
456
452
|
for fo in basic_header_objs:
|
|
457
453
|
key = fo.name
|
|
458
|
-
|
|
454
|
+
bud_obj.update(key, fo)
|
|
459
455
|
|
|
460
|
-
|
|
461
|
-
assert petal[0].value == expected_value
|
|
456
|
+
assert bud_obj.bud.value == expected_value
|
|
462
457
|
|
|
463
458
|
|
|
464
459
|
@pytest.mark.parametrize(
|
|
@@ -475,17 +470,15 @@ def test_task_round_time_base_bud(basic_header_objs, ip_task_type, expected_valu
|
|
|
475
470
|
When: Ingesting headers with a `TaskRoundTimeBudBase` bud and asking for the value
|
|
476
471
|
Then: The bud's value is the header constant value
|
|
477
472
|
"""
|
|
478
|
-
|
|
473
|
+
bud_obj = TaskRoundTimeBudBase(
|
|
479
474
|
stem_name="rounded_time", metadata_key="roundable_time", ip_task_types=ip_task_type
|
|
480
475
|
)
|
|
481
|
-
assert
|
|
476
|
+
assert bud_obj.stem_name == "rounded_time"
|
|
482
477
|
for fo in basic_header_objs:
|
|
483
478
|
key = fo.name
|
|
484
|
-
|
|
479
|
+
bud_obj.update(key, fo)
|
|
485
480
|
|
|
486
|
-
|
|
487
|
-
assert len(petal) == 1
|
|
488
|
-
assert petal[0].value == expected_value
|
|
481
|
+
assert bud_obj.bud.value == expected_value
|
|
489
482
|
|
|
490
483
|
|
|
491
484
|
def test_cs_step_flower(grouped_cal_sequence_headers, non_polcal_headers, max_cs_step_time_sec):
|
|
@@ -516,17 +509,15 @@ def test_num_cs_step_bud(grouped_cal_sequence_headers, non_polcal_headers, max_c
|
|
|
516
509
|
When: Updating the NumCSStepBud with all headers
|
|
517
510
|
Then: The bud reports the correct number of CS Steps (thus ignoring the non-PolCal frames)
|
|
518
511
|
"""
|
|
519
|
-
|
|
512
|
+
num_cs_bud_obj = NumCSStepBud(max_cs_step_time_sec=max_cs_step_time_sec)
|
|
520
513
|
for step, headers in grouped_cal_sequence_headers.items():
|
|
521
514
|
for h in headers:
|
|
522
|
-
|
|
515
|
+
num_cs_bud_obj.update(step, h)
|
|
523
516
|
|
|
524
517
|
for h in non_polcal_headers:
|
|
525
|
-
|
|
518
|
+
num_cs_bud_obj.update("foo", h)
|
|
526
519
|
|
|
527
|
-
bud
|
|
528
|
-
assert len(bud) == 1
|
|
529
|
-
assert bud[0].value == len(grouped_cal_sequence_headers.keys())
|
|
520
|
+
assert num_cs_bud_obj.bud.value == len(grouped_cal_sequence_headers.keys())
|
|
530
521
|
|
|
531
522
|
|
|
532
523
|
def test_proposal_id_bud(basic_header_objs):
|
|
@@ -535,15 +526,13 @@ def test_proposal_id_bud(basic_header_objs):
|
|
|
535
526
|
When: Ingesting the headers with a ProposalIdBud
|
|
536
527
|
Then: The Bud's petal has the correct value
|
|
537
528
|
"""
|
|
538
|
-
|
|
539
|
-
assert
|
|
529
|
+
bud_obj = ProposalIdBud()
|
|
530
|
+
assert bud_obj.stem_name == BudName.proposal_id.value
|
|
540
531
|
for fo in basic_header_objs:
|
|
541
532
|
key = fo.name
|
|
542
|
-
|
|
533
|
+
bud_obj.update(key, fo)
|
|
543
534
|
|
|
544
|
-
|
|
545
|
-
assert len(petal) == 1
|
|
546
|
-
assert petal[0].value == "proposal_id_1"
|
|
535
|
+
assert bud_obj.bud.value == "proposal_id_1"
|
|
547
536
|
|
|
548
537
|
|
|
549
538
|
def test_contributing_proposal_ids_bud(basic_header_objs):
|
|
@@ -552,15 +541,13 @@ def test_contributing_proposal_ids_bud(basic_header_objs):
|
|
|
552
541
|
When: Ingesting the headers with a ContributingProposalIdsBud
|
|
553
542
|
Then: The Bud's petal is the tuple of all input proposal IDs
|
|
554
543
|
"""
|
|
555
|
-
|
|
556
|
-
assert
|
|
544
|
+
bud_obj = ContributingProposalIdsBud()
|
|
545
|
+
assert bud_obj.stem_name == BudName.contributing_proposal_ids.value
|
|
557
546
|
for fo in basic_header_objs:
|
|
558
547
|
key = fo.name
|
|
559
|
-
|
|
548
|
+
bud_obj.update(key, fo)
|
|
560
549
|
|
|
561
|
-
|
|
562
|
-
assert len(petal) == 1
|
|
563
|
-
assert sorted(list(petal[0].value)) == ["proposal_id_1", "proposal_id_2"]
|
|
550
|
+
assert sorted(list(bud_obj.bud.value)) == ["proposal_id_1", "proposal_id_2"]
|
|
564
551
|
|
|
565
552
|
|
|
566
553
|
def test_experiment_id_bud(basic_header_objs):
|
|
@@ -569,15 +556,13 @@ def test_experiment_id_bud(basic_header_objs):
|
|
|
569
556
|
When: Ingesting the headers with a ExperimentIdBud
|
|
570
557
|
Then: The Bud's petal has the correct value
|
|
571
558
|
"""
|
|
572
|
-
|
|
573
|
-
assert
|
|
559
|
+
bud_obj = ExperimentIdBud()
|
|
560
|
+
assert bud_obj.stem_name == BudName.experiment_id.value
|
|
574
561
|
for fo in basic_header_objs:
|
|
575
562
|
key = fo.name
|
|
576
|
-
|
|
563
|
+
bud_obj.update(key, fo)
|
|
577
564
|
|
|
578
|
-
|
|
579
|
-
assert len(petal) == 1
|
|
580
|
-
assert petal[0].value == "experiment_id_1"
|
|
565
|
+
assert bud_obj.bud.value == "experiment_id_1"
|
|
581
566
|
|
|
582
567
|
|
|
583
568
|
def test_contributing_experiment_ids_bud(basic_header_objs):
|
|
@@ -586,15 +571,13 @@ def test_contributing_experiment_ids_bud(basic_header_objs):
|
|
|
586
571
|
When: Ingesting the headers with a ContributingExperimentIdsBud
|
|
587
572
|
Then: The Bud's petal is the tuple of all input experiment IDs
|
|
588
573
|
"""
|
|
589
|
-
|
|
590
|
-
assert
|
|
574
|
+
bud_obj = ContributingExperimentIdsBud()
|
|
575
|
+
assert bud_obj.stem_name == BudName.contributing_experiment_ids.value
|
|
591
576
|
for fo in basic_header_objs:
|
|
592
577
|
key = fo.name
|
|
593
|
-
|
|
578
|
+
bud_obj.update(key, fo)
|
|
594
579
|
|
|
595
|
-
|
|
596
|
-
assert len(petal) == 1
|
|
597
|
-
assert sorted(list(petal[0].value)) == ["experiment_id_1", "experiment_id_2"]
|
|
580
|
+
assert sorted(list(bud_obj.bud.value)) == ["experiment_id_1", "experiment_id_2"]
|
|
598
581
|
|
|
599
582
|
|
|
600
583
|
def test_task_contributing_ids_bud(basic_header_objs):
|
|
@@ -603,19 +586,17 @@ def test_task_contributing_ids_bud(basic_header_objs):
|
|
|
603
586
|
When: Ingesting the headers with a TaskContributingIdsBud for the dark task
|
|
604
587
|
Then: The Bud's petal is just the experiment ID for the dark task
|
|
605
588
|
"""
|
|
606
|
-
|
|
589
|
+
bud_obj = TaskContributingIdsBud(
|
|
607
590
|
constant_name=BudName.experiment_id,
|
|
608
591
|
metadata_key=MetadataKey.experiment_id,
|
|
609
592
|
ip_task_types=TaskName.dark,
|
|
610
593
|
)
|
|
611
|
-
assert
|
|
594
|
+
assert bud_obj.stem_name == BudName.experiment_id.value
|
|
612
595
|
for fo in basic_header_objs:
|
|
613
596
|
key = fo.name
|
|
614
|
-
|
|
597
|
+
bud_obj.update(key, fo)
|
|
615
598
|
|
|
616
|
-
|
|
617
|
-
assert len(petal) == 1
|
|
618
|
-
assert sorted(list(petal[0].value)) == ["experiment_id_2"]
|
|
599
|
+
assert sorted(list(bud_obj.bud.value)) == ["experiment_id_2"]
|
|
619
600
|
|
|
620
601
|
|
|
621
602
|
def test_task_contributing_observing_program_execution_ids_bud(basic_header_objs):
|
|
@@ -624,18 +605,16 @@ def test_task_contributing_observing_program_execution_ids_bud(basic_header_objs
|
|
|
624
605
|
When: Ingesting the headers with a TaskContributingObservingProgramExecutionIdsBud for a task type
|
|
625
606
|
Then: The Bud's petal is the observing program execution IDs for the that task type
|
|
626
607
|
"""
|
|
627
|
-
|
|
608
|
+
bud_obj = TaskContributingObservingProgramExecutionIdsBud(
|
|
628
609
|
constant_name="NOT_A_REAL_BUD",
|
|
629
610
|
ip_task_types=TaskName.observe,
|
|
630
611
|
)
|
|
631
|
-
assert
|
|
612
|
+
assert bud_obj.stem_name == "NOT_A_REAL_BUD"
|
|
632
613
|
for fo in basic_header_objs:
|
|
633
614
|
key = fo.name
|
|
634
|
-
|
|
615
|
+
bud_obj.update(key, fo)
|
|
635
616
|
|
|
636
|
-
|
|
637
|
-
assert len(petal) == 1
|
|
638
|
-
assert sorted(list(petal[0].value)) == [
|
|
617
|
+
assert sorted(list(bud_obj.bud.value)) == [
|
|
639
618
|
"observing_program_execution_id_1",
|
|
640
619
|
"observing_program_execution_id_2",
|
|
641
620
|
]
|
|
@@ -733,15 +712,13 @@ def test_obs_ip_start_time_bud(basic_header_objs):
|
|
|
733
712
|
When: Ingesting with a ObsIpStartTimeBud
|
|
734
713
|
Then: The correct value from *only* the observe IP is returned
|
|
735
714
|
"""
|
|
736
|
-
|
|
737
|
-
assert
|
|
715
|
+
bud_obj = ObsIpStartTimeBud()
|
|
716
|
+
assert bud_obj.stem_name == BudName.obs_ip_start_time.value
|
|
738
717
|
for fo in basic_header_objs:
|
|
739
718
|
key = fo.name
|
|
740
|
-
|
|
719
|
+
bud_obj.update(key, fo)
|
|
741
720
|
|
|
742
|
-
|
|
743
|
-
assert len(petals) == 1
|
|
744
|
-
assert petals[0].value == "2023-09-28T10:23.000"
|
|
721
|
+
assert bud_obj.bud.value == "2023-09-28T10:23.000"
|
|
745
722
|
|
|
746
723
|
|
|
747
724
|
def test_fpa_exp_times_bud(basic_header_objs):
|
|
@@ -750,23 +727,19 @@ def test_fpa_exp_times_bud(basic_header_objs):
|
|
|
750
727
|
When: Ingesting with a TaskExposureTimesBud
|
|
751
728
|
Then: All (rounded) exposure times are accounted for in the resulting tuple
|
|
752
729
|
"""
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
assert
|
|
730
|
+
dark_bud_obj = TaskExposureTimesBud(stem_name=BudName.dark_exposure_times, ip_task_types="DARK")
|
|
731
|
+
obs_bud_obj = TaskExposureTimesBud(stem_name="obs_exp_times", ip_task_types="OBSERVE")
|
|
732
|
+
assert dark_bud_obj.stem_name == BudName.dark_exposure_times.value
|
|
756
733
|
for fo in basic_header_objs:
|
|
757
734
|
key = fo.name
|
|
758
|
-
|
|
759
|
-
|
|
735
|
+
dark_bud_obj.update(key, fo)
|
|
736
|
+
obs_bud_obj.update(key, fo)
|
|
760
737
|
|
|
761
|
-
|
|
762
|
-
assert
|
|
763
|
-
assert type(dark_petal[0].value) is tuple
|
|
764
|
-
assert tuple(sorted(dark_petal[0].value)) == (12.345,)
|
|
738
|
+
assert type(dark_bud_obj.bud.value) is tuple
|
|
739
|
+
assert tuple(sorted(dark_bud_obj.bud.value)) == (12.345,)
|
|
765
740
|
|
|
766
|
-
|
|
767
|
-
assert
|
|
768
|
-
assert type(obs_petal[0].value) is tuple
|
|
769
|
-
assert tuple(sorted(obs_petal[0].value)) == (0.0013, 100.0)
|
|
741
|
+
assert type(obs_bud_obj.bud.value) is tuple
|
|
742
|
+
assert tuple(sorted(obs_bud_obj.bud.value)) == (0.0013, 100.0)
|
|
770
743
|
|
|
771
744
|
|
|
772
745
|
def test_readout_exp_times_bud(basic_header_objs):
|
|
@@ -775,35 +748,36 @@ def test_readout_exp_times_bud(basic_header_objs):
|
|
|
775
748
|
When: Ingesting with a TaskReadoutExpTimesBud
|
|
776
749
|
Then: All (rounded) exposure times are accounted for in the resulting tuple
|
|
777
750
|
"""
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
751
|
+
dark_bud_obj = TaskReadoutExpTimesBud(
|
|
752
|
+
stem_name=BudName.dark_exposure_times, ip_task_types="DARK"
|
|
753
|
+
)
|
|
754
|
+
obs_bud_obj = TaskReadoutExpTimesBud(stem_name="obs_exp_times", ip_task_types="OBSERVE")
|
|
755
|
+
assert dark_bud_obj.stem_name == BudName.dark_exposure_times.value
|
|
781
756
|
for fo in basic_header_objs:
|
|
782
757
|
key = fo.name
|
|
783
|
-
|
|
784
|
-
|
|
758
|
+
dark_bud_obj.update(key, fo)
|
|
759
|
+
obs_bud_obj.update(key, fo)
|
|
785
760
|
|
|
786
|
-
|
|
787
|
-
assert
|
|
788
|
-
assert type(dark_petal[0].value) is tuple
|
|
789
|
-
assert tuple(sorted(dark_petal[0].value)) == (1.123457,)
|
|
761
|
+
assert type(dark_bud_obj.bud.value) is tuple
|
|
762
|
+
assert tuple(sorted(dark_bud_obj.bud.value)) == (1.123457,)
|
|
790
763
|
|
|
791
|
-
|
|
792
|
-
assert
|
|
793
|
-
assert type(obs_petal[0].value) is tuple
|
|
794
|
-
assert tuple(sorted(obs_petal[0].value)) == (10.0, 11.0)
|
|
764
|
+
assert type(obs_bud_obj.bud.value) is tuple
|
|
765
|
+
assert tuple(sorted(obs_bud_obj.bud.value)) == (10.0, 11.0)
|
|
795
766
|
|
|
796
767
|
|
|
797
768
|
def test_dsps_bud(basic_header_objs):
|
|
798
|
-
|
|
799
|
-
|
|
769
|
+
"""
|
|
770
|
+
Given: A set of filepaths and associated headers with DSPSREPS keywords
|
|
771
|
+
When: Ingesting with a TotalDspsRepeatsBud
|
|
772
|
+
Then: The total number of DSPS repeates is parsed correctly
|
|
773
|
+
"""
|
|
774
|
+
bud_obj = TotalDspsRepeatsBud()
|
|
775
|
+
assert bud_obj.stem_name == BudName.num_dsps_repeats.value
|
|
800
776
|
for fo in basic_header_objs:
|
|
801
777
|
key = fo.name
|
|
802
|
-
|
|
778
|
+
bud_obj.update(key, fo)
|
|
803
779
|
|
|
804
|
-
|
|
805
|
-
assert len(petal) == 1
|
|
806
|
-
assert petal[0].value == 2
|
|
780
|
+
assert bud_obj.bud.value == 2
|
|
807
781
|
|
|
808
782
|
|
|
809
783
|
def test_dsps_flower(basic_header_objs):
|
|
@@ -832,17 +806,14 @@ def test_average_cadence_bud(basic_header_objs):
|
|
|
832
806
|
When: Ingesting with the AverageCadenceBud
|
|
833
807
|
Then: The correct values are returned
|
|
834
808
|
"""
|
|
835
|
-
|
|
836
|
-
assert
|
|
809
|
+
bud_obj = AverageCadenceBud()
|
|
810
|
+
assert bud_obj.stem_name == BudName.average_cadence.value
|
|
837
811
|
for fo in basic_header_objs:
|
|
838
812
|
key = fo.name
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
petal = list(bud.petals)
|
|
842
|
-
assert len(petal) == 1
|
|
813
|
+
bud_obj.update(key, fo)
|
|
843
814
|
|
|
844
815
|
# Because there are 3 observe frames in `basic_header_objs` spaced 1, and 2 seconds apart.
|
|
845
|
-
assert
|
|
816
|
+
assert bud_obj.bud.value == 1.5
|
|
846
817
|
|
|
847
818
|
|
|
848
819
|
def test_max_cadence_bud(basic_header_objs):
|
|
@@ -851,17 +822,14 @@ def test_max_cadence_bud(basic_header_objs):
|
|
|
851
822
|
When: Ingesting with the MaxCadenceBud
|
|
852
823
|
Then: The correct values are returned
|
|
853
824
|
"""
|
|
854
|
-
|
|
855
|
-
assert
|
|
825
|
+
bud_obj = MaximumCadenceBud()
|
|
826
|
+
assert bud_obj.stem_name == BudName.maximum_cadence.value
|
|
856
827
|
for fo in basic_header_objs:
|
|
857
828
|
key = fo.name
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
petal = list(bud.petals)
|
|
861
|
-
assert len(petal) == 1
|
|
829
|
+
bud_obj.update(key, fo)
|
|
862
830
|
|
|
863
831
|
# Because there are 3 observe frames in `basic_header_objs` spaced 1, and 2 seconds apart.
|
|
864
|
-
assert
|
|
832
|
+
assert bud_obj.bud.value == 2
|
|
865
833
|
|
|
866
834
|
|
|
867
835
|
def test_minimum_cadence_bud(basic_header_objs):
|
|
@@ -870,17 +838,14 @@ def test_minimum_cadence_bud(basic_header_objs):
|
|
|
870
838
|
When: Ingesting with the MinimumCadenceBud
|
|
871
839
|
Then: The correct values are returned
|
|
872
840
|
"""
|
|
873
|
-
|
|
874
|
-
assert
|
|
841
|
+
bud_obj = MinimumCadenceBud()
|
|
842
|
+
assert bud_obj.stem_name == BudName.minimum_cadence.value
|
|
875
843
|
for fo in basic_header_objs:
|
|
876
844
|
key = fo.name
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
petal = list(bud.petals)
|
|
880
|
-
assert len(petal) == 1
|
|
845
|
+
bud_obj.update(key, fo)
|
|
881
846
|
|
|
882
847
|
# Because there are 3 observe frames in `basic_header_objs` spaced 1, and 2 seconds apart.
|
|
883
|
-
assert
|
|
848
|
+
assert bud_obj.bud.value == 1
|
|
884
849
|
|
|
885
850
|
|
|
886
851
|
def test_variance_cadence_bud(basic_header_objs):
|
|
@@ -889,17 +854,14 @@ def test_variance_cadence_bud(basic_header_objs):
|
|
|
889
854
|
When: Ingesting with the VarianceCadenceBud
|
|
890
855
|
Then: The correct values are returned
|
|
891
856
|
"""
|
|
892
|
-
|
|
893
|
-
assert
|
|
857
|
+
bud_obj = VarianceCadenceBud()
|
|
858
|
+
assert bud_obj.stem_name == BudName.variance_cadence.value
|
|
894
859
|
for fo in basic_header_objs:
|
|
895
860
|
key = fo.name
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
petal = list(bud.petals)
|
|
899
|
-
assert len(petal) == 1
|
|
861
|
+
bud_obj.update(key, fo)
|
|
900
862
|
|
|
901
863
|
# Because there are 3 observe frames in `basic_header_objs` spaced 1, and 2 seconds apart.
|
|
902
|
-
assert
|
|
864
|
+
assert bud_obj.bud.value == 0.25
|
|
903
865
|
|
|
904
866
|
|
|
905
867
|
def test_task_date_begin_bud(basic_header_objs):
|
|
@@ -908,15 +870,13 @@ def test_task_date_begin_bud(basic_header_objs):
|
|
|
908
870
|
When: Ingesting with the TaskDateBeginBud
|
|
909
871
|
Then: The correct value is returned
|
|
910
872
|
"""
|
|
911
|
-
|
|
912
|
-
assert
|
|
873
|
+
bud_obj = TaskDateBeginBud(constant_name=BudName.dark_date_begin, ip_task_types=TaskName.dark)
|
|
874
|
+
assert bud_obj.stem_name == BudName.dark_date_begin.value
|
|
913
875
|
for fo in basic_header_objs:
|
|
914
876
|
key = fo.name
|
|
915
|
-
|
|
877
|
+
bud_obj.update(key, fo)
|
|
916
878
|
|
|
917
|
-
|
|
918
|
-
assert len(petal) == 1
|
|
919
|
-
assert petal[0].value == "2022-06-17T22:00:02.000000"
|
|
879
|
+
assert bud_obj.bud.value == "2022-06-17T22:00:02.000000"
|
|
920
880
|
|
|
921
881
|
|
|
922
882
|
def test_observe_wavelength_bud(basic_header_objs):
|
|
@@ -925,15 +885,13 @@ def test_observe_wavelength_bud(basic_header_objs):
|
|
|
925
885
|
When: Ingesting the headers with the ObserveWavelengthBud
|
|
926
886
|
Then: The petal contains the wavelength header value of the observe frames
|
|
927
887
|
"""
|
|
928
|
-
|
|
929
|
-
assert
|
|
888
|
+
bud_obj = ObserveWavelengthBud()
|
|
889
|
+
assert bud_obj.stem_name == BudName.wavelength.value
|
|
930
890
|
for fo in basic_header_objs:
|
|
931
891
|
key = fo.name
|
|
932
|
-
|
|
892
|
+
bud_obj.update(key, fo)
|
|
933
893
|
|
|
934
|
-
|
|
935
|
-
assert len(petal) == 1
|
|
936
|
-
assert petal[0].value == 666.0
|
|
894
|
+
assert bud_obj.bud.value == 666.0
|
|
937
895
|
|
|
938
896
|
|
|
939
897
|
def test_near_bud(basic_header_objs):
|
|
@@ -942,19 +900,17 @@ def test_near_bud(basic_header_objs):
|
|
|
942
900
|
When: Ingesting headers with a NearBud and asking for the value
|
|
943
901
|
Then: The Bud's value is the average of the header values
|
|
944
902
|
"""
|
|
945
|
-
|
|
903
|
+
bud_obj = NearFloatBud(
|
|
946
904
|
constant_name="near",
|
|
947
905
|
metadata_key="near_thing",
|
|
948
906
|
tolerance=0.5,
|
|
949
907
|
)
|
|
950
|
-
assert
|
|
908
|
+
assert bud_obj.stem_name == "near"
|
|
951
909
|
for fo in basic_header_objs:
|
|
952
910
|
key = fo.name
|
|
953
|
-
|
|
911
|
+
bud_obj.update(key, fo)
|
|
954
912
|
|
|
955
|
-
|
|
956
|
-
assert len(petal) == 1
|
|
957
|
-
assert petal[0].value == 1.23
|
|
913
|
+
assert bud_obj.bud.value == 1.23
|
|
958
914
|
|
|
959
915
|
|
|
960
916
|
def test_task_near_bud(basic_header_objs):
|
|
@@ -963,17 +919,15 @@ def test_task_near_bud(basic_header_objs):
|
|
|
963
919
|
When: Ingesting headers with a TaskNearBud and asking for the value
|
|
964
920
|
Then: The bud's value is the average of the header values of that task type
|
|
965
921
|
"""
|
|
966
|
-
|
|
922
|
+
bud_obj = TaskNearFloatBud(
|
|
967
923
|
constant_name="near", metadata_key="near_thing", ip_task_types="observe", tolerance=0.5
|
|
968
924
|
)
|
|
969
|
-
assert
|
|
925
|
+
assert bud_obj.stem_name == "near"
|
|
970
926
|
for fo in basic_header_objs:
|
|
971
927
|
key = fo.name
|
|
972
|
-
|
|
928
|
+
bud_obj.update(key, fo)
|
|
973
929
|
|
|
974
|
-
|
|
975
|
-
assert len(petal) == 1
|
|
976
|
-
assert round(petal[0].value, 3) == 1.227
|
|
930
|
+
assert round(bud_obj.bud.value, 3) == 1.227
|
|
977
931
|
|
|
978
932
|
|
|
979
933
|
def test_multi_task_near_bud():
|
|
@@ -990,30 +944,28 @@ def test_multi_task_near_bud():
|
|
|
990
944
|
]
|
|
991
945
|
header_objs = [FitsReader.from_header(h, f"{i}") for i, h in enumerate(header_dicts)]
|
|
992
946
|
|
|
993
|
-
|
|
947
|
+
good_bud_obj = TaskNearFloatBud(
|
|
994
948
|
constant_name="near",
|
|
995
949
|
metadata_key="near_thing",
|
|
996
950
|
ip_task_types=["observe", "dark"],
|
|
997
951
|
tolerance=0.1,
|
|
998
952
|
)
|
|
999
953
|
for fo in header_objs:
|
|
1000
|
-
|
|
954
|
+
good_bud_obj.update(fo.name, fo)
|
|
1001
955
|
|
|
1002
|
-
|
|
1003
|
-
assert len(petal) == 1
|
|
1004
|
-
assert round(petal[0].value, 0) == 3.0
|
|
956
|
+
assert round(good_bud_obj.bud.value, 0) == 3.0
|
|
1005
957
|
|
|
1006
|
-
|
|
958
|
+
bad_bud_obj = TaskNearFloatBud(
|
|
1007
959
|
constant_name="near",
|
|
1008
960
|
metadata_key="near_thing",
|
|
1009
961
|
ip_task_types=["observe", "solar"],
|
|
1010
962
|
tolerance=0.1,
|
|
1011
963
|
)
|
|
1012
964
|
for fo in header_objs:
|
|
1013
|
-
|
|
965
|
+
bad_bud_obj.update(fo.name, fo)
|
|
1014
966
|
|
|
1015
967
|
with pytest.raises(ValueError, match="near values are not close enough"):
|
|
1016
|
-
|
|
968
|
+
_ = bad_bud_obj.bud
|
|
1017
969
|
|
|
1018
970
|
|
|
1019
971
|
def test_near_bud_not_near_inputs(bad_header_objs):
|
|
@@ -1022,18 +974,18 @@ def test_near_bud_not_near_inputs(bad_header_objs):
|
|
|
1022
974
|
When: Ingesting headers with a NearBud and asking for the value
|
|
1023
975
|
Then: An error is raised
|
|
1024
976
|
"""
|
|
1025
|
-
|
|
977
|
+
bud_obj = NearFloatBud(
|
|
1026
978
|
constant_name="near",
|
|
1027
979
|
metadata_key="near_thing",
|
|
1028
980
|
tolerance=0.5,
|
|
1029
981
|
)
|
|
1030
|
-
assert
|
|
982
|
+
assert bud_obj.stem_name == "near"
|
|
1031
983
|
for fo in bad_header_objs:
|
|
1032
984
|
key = fo.name
|
|
1033
|
-
|
|
985
|
+
bud_obj.update(key, fo)
|
|
1034
986
|
|
|
1035
987
|
with pytest.raises(ValueError):
|
|
1036
|
-
|
|
988
|
+
_ = bud_obj.bud
|
|
1037
989
|
|
|
1038
990
|
|
|
1039
991
|
def test_retarder_name_bud(basic_header_objs, task_with_polcal_header_objs, retarder_name):
|
|
@@ -1042,13 +994,13 @@ def test_retarder_name_bud(basic_header_objs, task_with_polcal_header_objs, reta
|
|
|
1042
994
|
When: Ingesting the headers with RetarderNameBud and asking for the value
|
|
1043
995
|
Then: The retarder name is returned
|
|
1044
996
|
"""
|
|
1045
|
-
|
|
997
|
+
bud_obj = RetarderNameBud()
|
|
1046
998
|
input_objects = chain(basic_header_objs, task_with_polcal_header_objs)
|
|
1047
999
|
for fo in input_objects:
|
|
1048
1000
|
key = fo.name
|
|
1049
|
-
|
|
1001
|
+
bud_obj.update(key, fo)
|
|
1050
1002
|
|
|
1051
|
-
assert
|
|
1003
|
+
assert bud_obj.bud.value == retarder_name
|
|
1052
1004
|
|
|
1053
1005
|
|
|
1054
1006
|
def test_retarder_name_bud_error(bad_polcal_header_objs):
|
|
@@ -1057,18 +1009,18 @@ def test_retarder_name_bud_error(bad_polcal_header_objs):
|
|
|
1057
1009
|
When: Ingesting the headers with RetarderNameBud and asking for the value
|
|
1058
1010
|
Then: An error is raised
|
|
1059
1011
|
"""
|
|
1060
|
-
|
|
1012
|
+
bud_obj = RetarderNameBud()
|
|
1061
1013
|
for fo in bad_polcal_header_objs:
|
|
1062
1014
|
key = fo.name
|
|
1063
|
-
|
|
1015
|
+
bud_obj.update(key, fo)
|
|
1064
1016
|
|
|
1065
1017
|
# Crazy regex to handle non-deterministic order of sets.
|
|
1066
1018
|
# https://regex101.com/r/zh9iG6/1
|
|
1067
1019
|
with pytest.raises(
|
|
1068
1020
|
ValueError,
|
|
1069
|
-
match=r"Multiple
|
|
1021
|
+
match=r"Multiple RETARDER_NAME values found! Values: {'RET(1)?(?(1)|2)', 'RET(?(1)2|1)'}",
|
|
1070
1022
|
):
|
|
1071
|
-
_ =
|
|
1023
|
+
_ = bud_obj.bud
|
|
1072
1024
|
|
|
1073
1025
|
|
|
1074
1026
|
def test_task_average_bud(basic_header_objs):
|
|
@@ -1077,17 +1029,15 @@ def test_task_average_bud(basic_header_objs):
|
|
|
1077
1029
|
When: Ingesting headers with an TaskAverageBud and asking for the value
|
|
1078
1030
|
Then: The bud's value is the average of the header values of that task type
|
|
1079
1031
|
"""
|
|
1080
|
-
|
|
1032
|
+
bud_obj = TaskAverageBud(
|
|
1081
1033
|
constant_name="average", metadata_key="near_thing", ip_task_types="observe"
|
|
1082
1034
|
)
|
|
1083
|
-
assert
|
|
1035
|
+
assert bud_obj.stem_name == "average"
|
|
1084
1036
|
for fo in basic_header_objs:
|
|
1085
1037
|
key = fo.name
|
|
1086
|
-
|
|
1038
|
+
bud_obj.update(key, fo)
|
|
1087
1039
|
|
|
1088
|
-
|
|
1089
|
-
assert len(petal) == 1
|
|
1090
|
-
assert round(petal[0].value, 3) == 1.227
|
|
1040
|
+
assert round(bud_obj.bud.value, 3) == 1.227
|
|
1091
1041
|
|
|
1092
1042
|
|
|
1093
1043
|
def test_time_lookup_bud(basic_header_objs):
|
|
@@ -1108,9 +1058,7 @@ def test_time_lookup_bud(basic_header_objs):
|
|
|
1108
1058
|
|
|
1109
1059
|
assert type(bud.mapping) == collections.defaultdict
|
|
1110
1060
|
assert bud.mapping == {0.0013: {3}, 12.345: {1}, 100.0: {4, 5}}
|
|
1111
|
-
assert
|
|
1112
|
-
expected_value = ((0.0013, (3,)), (12.345, (1,)), (100.0, (4, 5)))
|
|
1113
|
-
assert bud.petals[0].value == expected_value
|
|
1061
|
+
assert bud.bud.value == {0.0013: [3], 12.345: [1], 100.0: [4, 5]}
|
|
1114
1062
|
|
|
1115
1063
|
|
|
1116
1064
|
def test_task_time_lookup_bud(basic_header_objs):
|
|
@@ -1130,9 +1078,8 @@ def test_task_time_lookup_bud(basic_header_objs):
|
|
|
1130
1078
|
key = fo.name
|
|
1131
1079
|
bud.update(key, fo)
|
|
1132
1080
|
|
|
1133
|
-
assert
|
|
1134
|
-
|
|
1135
|
-
assert bud.petals[0].value == expected_value
|
|
1081
|
+
assert bud.mapping == {12.345: {1}}
|
|
1082
|
+
assert bud.bud.value == {12.345: [1]}
|
|
1136
1083
|
|
|
1137
1084
|
|
|
1138
1085
|
# TODO: test new stem types that have been added to parse_l0_input_data
|