66
77import numpy as np
88
9+ from stixcore .idb .manager import IDBManager
10+ from stixcore .processing import engineering
911from stixcore .products .level0 .quicklookL0 import QLProduct
1012from stixcore .products .product import L1Mixin
1113from 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
216246class TMStatusFlareList (QLProduct , L1Mixin ):
217247 """Quick Look TM Management status and Flare list data product.
0 commit comments