Skip to content

Commit 95a4914

Browse files
committed
fix for i4Ds#432
1 parent 319e962 commit 95a4914

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

stixcore/products/level0/quicklookL0.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,8 @@ class EnergyCalibration(QLProduct):
656656
In level 0 format.
657657
"""
658658

659+
PRODUCT_PROCESSING_VERSION = 3
660+
659661
def __init__(
660662
self, *, service_type, service_subtype, ssid, control, data, idb_versions=defaultdict(SCETimeRange), **kwargs
661663
):
@@ -680,6 +682,7 @@ def from_levelb(cls, levelb, parent=""):
680682
control.add_basic(name="integration_time", nix="NIX00122", packets=packets, dtype=np.uint32, attr="value")
681683
control.add_basic(name="quiet_time", nix="NIX00123", packets=packets, dtype=np.uint16, attr="value")
682684
control.add_basic(name="live_time", nix="NIX00124", packets=packets, dtype=np.uint32, attr="value")
685+
683686
control.add_basic(name="average_temperature", nix="NIX00125", packets=packets, dtype=np.uint16, attr="value")
684687
control.add_data("detector_mask", _get_detector_mask(packets))
685688
control.add_data("pixel_mask", _get_pixel_mask(packets))
@@ -720,7 +723,8 @@ def from_levelb(cls, levelb, parent=""):
720723
channels.append(list(chain(*[ch.tolist() for ch in sub_channels])))
721724
control["num_channels"] = [len(c) for c in channels]
722725

723-
duration = SCETimeDelta(packets.get_value("NIX00122").astype(np.uint32))
726+
# fix for wrong calibration in IDB https://github.com/i4Ds/STIXCore/issues/432
727+
duration = SCETimeDelta(packets.get_value("NIX00122") * 10)
724728
time = SCETime(control["scet_coarse"], control["scet_fine"]) + duration / 2
725729

726730
dids = packets.get_value("NIXD0155")

stixcore/products/level1/quicklookL1.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import numpy as np
88

9+
from stixcore.idb.manager import IDBManager
10+
from stixcore.processing import engineering
911
from stixcore.products.level0.quicklookL0 import QLProduct
1012
from stixcore.products.product import L1Mixin
1113
from stixcore.time import SCETimeRange
@@ -191,6 +193,8 @@ class EnergyCalibration(QLProduct, L1Mixin):
191193
In level 1 format.
192194
"""
193195

196+
PRODUCT_PROCESSING_VERSION = 3
197+
194198
def __init__(
195199
self, *, service_type, service_subtype, ssid, control, data, idb_versions=defaultdict(SCETimeRange), **kwargs
196200
):
@@ -212,6 +216,32 @@ def __init__(
212216
def is_datasource_for(cls, *, service_type, service_subtype, ssid, **kwargs):
213217
return kwargs["level"] == "L1" and service_type == 21 and service_subtype == 6 and ssid == 41
214218

219+
@classmethod
220+
def from_level0(cls, l0product, parent=""):
221+
l1 = cls(
222+
service_type=l0product.service_type,
223+
service_subtype=l0product.service_subtype,
224+
ssid=l0product.ssid,
225+
control=l0product.control,
226+
data=l0product.data,
227+
idb_versions=l0product.idb_versions,
228+
comment=l0product.comment,
229+
history=l0product.history,
230+
)
231+
232+
l1.control.replace_column("parent", [parent] * len(l1.control))
233+
l1.level = "L1"
234+
engineering.raw_to_engineering_product(l1, IDBManager.instance)
235+
236+
# fix for wrong calibration in IDB https://github.com/i4Ds/STIXCore/issues/432
237+
# nix00122 was wrong assumed to be in ds but it is plain s
238+
l1.control["integration_time"] = l1.control["integration_time"] * 10
239+
# nix00124 was wrong assumed to be in ds but it is unscaled ms
240+
l1.control["live_time"] = (l1.control["live_time"] / 100.0).to("ms").astype(np.uint32)
241+
# nix00124 was wrong assumed to be in s but it is us
242+
l1.control["quiet_time"] = (l1.control["quiet_time"] / 100000.0).to("us")
243+
return l1
244+
215245

216246
class TMStatusFlareList(QLProduct, L1Mixin):
217247
"""Quick Look TM Management status and Flare list data product.

stixcore/products/tests/test_quicklook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
qll1.EnergyCalibration,
4949
"energy",
5050
"0659318520f00000",
51-
"0659326919f00000",
51+
"0659402519f00000",
5252
1,
5353
),
5454
]

0 commit comments

Comments
 (0)