dkist-processing-common 12.0.0rc5__py3-none-any.whl → 12.2.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.
Files changed (35) hide show
  1. dkist_processing_common/codecs/fits.py +27 -6
  2. dkist_processing_common/models/constants.py +16 -10
  3. dkist_processing_common/models/extras.py +35 -0
  4. dkist_processing_common/models/flower_pot.py +230 -9
  5. dkist_processing_common/models/tags.py +13 -0
  6. dkist_processing_common/parsers/average_bud.py +0 -2
  7. dkist_processing_common/parsers/cs_step.py +10 -10
  8. dkist_processing_common/parsers/id_bud.py +8 -10
  9. dkist_processing_common/parsers/lookup_bud.py +7 -11
  10. dkist_processing_common/parsers/near_bud.py +7 -12
  11. dkist_processing_common/parsers/retarder.py +9 -13
  12. dkist_processing_common/parsers/time.py +19 -55
  13. dkist_processing_common/parsers/unique_bud.py +7 -14
  14. dkist_processing_common/tasks/l1_output_data.py +23 -14
  15. dkist_processing_common/tasks/output_data_base.py +25 -4
  16. dkist_processing_common/tasks/parse_l0_input_data.py +4 -2
  17. dkist_processing_common/tasks/transfer_input_data.py +1 -0
  18. dkist_processing_common/tasks/write_extra.py +333 -0
  19. dkist_processing_common/tasks/write_l1.py +2 -55
  20. dkist_processing_common/tasks/write_l1_base.py +67 -0
  21. dkist_processing_common/tests/test_codecs.py +57 -11
  22. dkist_processing_common/tests/test_construct_dataset_extras.py +224 -0
  23. dkist_processing_common/tests/test_flower_pot.py +147 -5
  24. dkist_processing_common/tests/test_output_data_base.py +24 -2
  25. dkist_processing_common/tests/test_parse_l0_input_data.py +28 -4
  26. dkist_processing_common/tests/test_stems.py +140 -193
  27. dkist_processing_common/tests/test_transfer_l1_output_data.py +1 -0
  28. dkist_processing_common/tests/test_trial_catalog.py +2 -0
  29. dkist_processing_common/tests/test_workflow_task_base.py +0 -11
  30. dkist_processing_common/tests/test_write_l1.py +0 -1
  31. {dkist_processing_common-12.0.0rc5.dist-info → dkist_processing_common-12.2.0.dist-info}/METADATA +4 -4
  32. {dkist_processing_common-12.0.0rc5.dist-info → dkist_processing_common-12.2.0.dist-info}/RECORD +34 -31
  33. {dkist_processing_common-12.0.0rc5.dist-info → dkist_processing_common-12.2.0.dist-info}/WHEEL +1 -1
  34. changelog/288.misc.rst +0 -1
  35. {dkist_processing_common-12.0.0rc5.dist-info → dkist_processing_common-12.2.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
- bud = UniqueBud(
326
+ bud_obj = UniqueBud(
327
327
  constant_name="constant",
328
328
  metadata_key="constant_thing",
329
329
  )
330
- assert bud.stem_name == "constant"
330
+ assert bud_obj.stem_name == "constant"
331
331
  for fo in basic_header_objs:
332
332
  key = fo.name
333
- bud.update(key, fo)
333
+ bud_obj.update(key, fo)
334
334
 
335
- petal = list(bud.petals)
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
- bud = UniqueBud(
344
+ bud_obj = UniqueBud(
347
345
  constant_name="constant",
348
346
  metadata_key="constant_thing",
349
347
  )
350
- assert bud.stem_name == "constant"
348
+ assert bud_obj.stem_name == "constant"
351
349
  for fo in bad_header_objs:
352
350
  key = fo.name
353
- bud.update(key, fo)
351
+ bud_obj.update(key, fo)
354
352
 
355
- with pytest.raises(ValueError):
356
- assert next(bud.petals)
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
- bud = TaskUniqueBud(
370
+ bud_obj = TaskUniqueBud(
373
371
  constant_name="proposal", metadata_key="proposal_id", ip_task_types=ip_task_type
374
372
  )
375
- assert bud.stem_name == "proposal"
373
+ assert bud_obj.stem_name == "proposal"
376
374
  for fo in basic_header_objs:
377
375
  key = fo.name
378
- bud.update(key, fo)
376
+ bud_obj.update(key, fo)
379
377
 
380
- petal = list(bud.petals)
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
- list(bud.petals)
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
- bud = TaskDatetimeBudBase(
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 bud.stem_name == "datetimes"
451
+ assert bud_obj.stem_name == "datetimes"
456
452
  for fo in basic_header_objs:
457
453
  key = fo.name
458
- bud.update(key, fo)
454
+ bud_obj.update(key, fo)
459
455
 
460
- petal = list(bud.petals)
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
- bud = TaskRoundTimeBudBase(
473
+ bud_obj = TaskRoundTimeBudBase(
479
474
  stem_name="rounded_time", metadata_key="roundable_time", ip_task_types=ip_task_type
480
475
  )
481
- assert bud.stem_name == "rounded_time"
476
+ assert bud_obj.stem_name == "rounded_time"
482
477
  for fo in basic_header_objs:
483
478
  key = fo.name
484
- bud.update(key, fo)
479
+ bud_obj.update(key, fo)
485
480
 
486
- petal = list(bud.petals)
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
- num_cs_bud = NumCSStepBud(max_cs_step_time_sec=max_cs_step_time_sec)
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
- num_cs_bud.update(step, h)
515
+ num_cs_bud_obj.update(step, h)
523
516
 
524
517
  for h in non_polcal_headers:
525
- num_cs_bud.update("foo", h)
518
+ num_cs_bud_obj.update("foo", h)
526
519
 
527
- bud = list(num_cs_bud.petals)
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
- bud = ProposalIdBud()
539
- assert bud.stem_name == BudName.proposal_id.value
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
- bud.update(key, fo)
533
+ bud_obj.update(key, fo)
543
534
 
544
- petal = list(bud.petals)
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
- bud = ContributingProposalIdsBud()
556
- assert bud.stem_name == BudName.contributing_proposal_ids.value
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
- bud.update(key, fo)
548
+ bud_obj.update(key, fo)
560
549
 
561
- petal = list(bud.petals)
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
- bud = ExperimentIdBud()
573
- assert bud.stem_name == BudName.experiment_id.value
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
- bud.update(key, fo)
563
+ bud_obj.update(key, fo)
577
564
 
578
- petal = list(bud.petals)
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
- bud = ContributingExperimentIdsBud()
590
- assert bud.stem_name == BudName.contributing_experiment_ids.value
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
- bud.update(key, fo)
578
+ bud_obj.update(key, fo)
594
579
 
595
- petal = list(bud.petals)
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
- bud = TaskContributingIdsBud(
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 bud.stem_name == BudName.experiment_id.value
594
+ assert bud_obj.stem_name == BudName.experiment_id.value
612
595
  for fo in basic_header_objs:
613
596
  key = fo.name
614
- bud.update(key, fo)
597
+ bud_obj.update(key, fo)
615
598
 
616
- petal = list(bud.petals)
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
- bud = TaskContributingObservingProgramExecutionIdsBud(
608
+ bud_obj = TaskContributingObservingProgramExecutionIdsBud(
628
609
  constant_name="NOT_A_REAL_BUD",
629
610
  ip_task_types=TaskName.observe,
630
611
  )
631
- assert bud.stem_name == "NOT_A_REAL_BUD"
612
+ assert bud_obj.stem_name == "NOT_A_REAL_BUD"
632
613
  for fo in basic_header_objs:
633
614
  key = fo.name
634
- bud.update(key, fo)
615
+ bud_obj.update(key, fo)
635
616
 
636
- petal = list(bud.petals)
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
- bud = ObsIpStartTimeBud()
737
- assert bud.stem_name == BudName.obs_ip_start_time.value
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
- bud.update(key, fo)
719
+ bud_obj.update(key, fo)
741
720
 
742
- petals = list(bud.petals)
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
- dark_bud = TaskExposureTimesBud(stem_name=BudName.dark_exposure_times, ip_task_types="DARK")
754
- obs_bud = TaskExposureTimesBud(stem_name="obs_exp_times", ip_task_types="OBSERVE")
755
- assert dark_bud.stem_name == BudName.dark_exposure_times.value
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
- dark_bud.update(key, fo)
759
- obs_bud.update(key, fo)
735
+ dark_bud_obj.update(key, fo)
736
+ obs_bud_obj.update(key, fo)
760
737
 
761
- dark_petal = list(dark_bud.petals)
762
- assert len(dark_petal) == 1
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
- obs_petal = list(obs_bud.petals)
767
- assert len(obs_petal) == 1
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
- dark_bud = TaskReadoutExpTimesBud(stem_name=BudName.dark_exposure_times, ip_task_types="DARK")
779
- obs_bud = TaskReadoutExpTimesBud(stem_name="obs_exp_times", ip_task_types="OBSERVE")
780
- assert dark_bud.stem_name == BudName.dark_exposure_times.value
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
- dark_bud.update(key, fo)
784
- obs_bud.update(key, fo)
758
+ dark_bud_obj.update(key, fo)
759
+ obs_bud_obj.update(key, fo)
785
760
 
786
- dark_petal = list(dark_bud.petals)
787
- assert len(dark_petal) == 1
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
- obs_petal = list(obs_bud.petals)
792
- assert len(obs_petal) == 1
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
- bud = TotalDspsRepeatsBud()
799
- assert bud.stem_name == BudName.num_dsps_repeats.value
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
- bud.update(key, fo)
778
+ bud_obj.update(key, fo)
803
779
 
804
- petal = list(bud.petals)
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
- bud = AverageCadenceBud()
836
- assert bud.stem_name == BudName.average_cadence.value
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
- bud.update(key, fo)
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 petal[0].value == 1.5
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
- bud = MaximumCadenceBud()
855
- assert bud.stem_name == BudName.maximum_cadence.value
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
- bud.update(key, fo)
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 petal[0].value == 2
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
- bud = MinimumCadenceBud()
874
- assert bud.stem_name == BudName.minimum_cadence.value
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
- bud.update(key, fo)
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 petal[0].value == 1
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
- bud = VarianceCadenceBud()
893
- assert bud.stem_name == BudName.variance_cadence.value
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
- bud.update(key, fo)
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 petal[0].value == 0.25
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
- bud = TaskDateBeginBud(constant_name=BudName.dark_date_begin, ip_task_types=TaskName.dark)
912
- assert bud.stem_name == BudName.dark_date_begin.value
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
- bud.update(key, fo)
877
+ bud_obj.update(key, fo)
916
878
 
917
- petal = list(bud.petals)
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
- bud = ObserveWavelengthBud()
929
- assert bud.stem_name == BudName.wavelength.value
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
- bud.update(key, fo)
892
+ bud_obj.update(key, fo)
933
893
 
934
- petal = list(bud.petals)
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
- bud = NearFloatBud(
903
+ bud_obj = NearFloatBud(
946
904
  constant_name="near",
947
905
  metadata_key="near_thing",
948
906
  tolerance=0.5,
949
907
  )
950
- assert bud.stem_name == "near"
908
+ assert bud_obj.stem_name == "near"
951
909
  for fo in basic_header_objs:
952
910
  key = fo.name
953
- bud.update(key, fo)
911
+ bud_obj.update(key, fo)
954
912
 
955
- petal = list(bud.petals)
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
- bud = TaskNearFloatBud(
922
+ bud_obj = TaskNearFloatBud(
967
923
  constant_name="near", metadata_key="near_thing", ip_task_types="observe", tolerance=0.5
968
924
  )
969
- assert bud.stem_name == "near"
925
+ assert bud_obj.stem_name == "near"
970
926
  for fo in basic_header_objs:
971
927
  key = fo.name
972
- bud.update(key, fo)
928
+ bud_obj.update(key, fo)
973
929
 
974
- petal = list(bud.petals)
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
- bud = TaskNearFloatBud(
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
- bud.update(fo.name, fo)
954
+ good_bud_obj.update(fo.name, fo)
1001
955
 
1002
- petal = list(bud.petals)
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
- bad_bud = TaskNearFloatBud(
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
- bad_bud.update(fo.name, fo)
965
+ bad_bud_obj.update(fo.name, fo)
1014
966
 
1015
967
  with pytest.raises(ValueError, match="near values are not close enough"):
1016
- list(bad_bud.petals)
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
- bud = NearFloatBud(
977
+ bud_obj = NearFloatBud(
1026
978
  constant_name="near",
1027
979
  metadata_key="near_thing",
1028
980
  tolerance=0.5,
1029
981
  )
1030
- assert bud.stem_name == "near"
982
+ assert bud_obj.stem_name == "near"
1031
983
  for fo in bad_header_objs:
1032
984
  key = fo.name
1033
- bud.update(key, fo)
985
+ bud_obj.update(key, fo)
1034
986
 
1035
987
  with pytest.raises(ValueError):
1036
- assert next(bud.petals)
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
- bud = RetarderNameBud()
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
- bud.update(key, fo)
1001
+ bud_obj.update(key, fo)
1050
1002
 
1051
- assert bud.bud.value == retarder_name
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
- bud = RetarderNameBud()
1012
+ bud_obj = RetarderNameBud()
1061
1013
  for fo in bad_polcal_header_objs:
1062
1014
  key = fo.name
1063
- bud.update(key, fo)
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 non-clear retarder names found. Names: {'RET(1)?(?(1)|2)', 'RET(?(1)2|1)'}",
1021
+ match=r"Multiple RETARDER_NAME values found! Values: {'RET(1)?(?(1)|2)', 'RET(?(1)2|1)'}",
1070
1022
  ):
1071
- _ = bud.bud
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
- bud = TaskAverageBud(
1032
+ bud_obj = TaskAverageBud(
1081
1033
  constant_name="average", metadata_key="near_thing", ip_task_types="observe"
1082
1034
  )
1083
- assert bud.stem_name == "average"
1035
+ assert bud_obj.stem_name == "average"
1084
1036
  for fo in basic_header_objs:
1085
1037
  key = fo.name
1086
- bud.update(key, fo)
1038
+ bud_obj.update(key, fo)
1087
1039
 
1088
- petal = list(bud.petals)
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 len(bud.petals) == 1
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 len(bud.petals) == 1
1134
- expected_value = ((12.345, (1,)),)
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