Skip to content

Commit 5a7c670

Browse files
committed
fixes after review
1 parent 62a458a commit 5a7c670

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

stixcore/io/product_processors/fits/processors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ def generate_primary_header(cls, filename, product, *, version=0):
739739
("DATAMIN", product.dmin, "Minimum valid physical value"),
740740
("DATAMAX", product.dmax, "Maximum valid physical value"),
741741
("BUNIT", product.bunit, "Units of physical value, after application of BSCALE, BZERO"),
742-
("XPOSURE", product.exposure, "[s] shortest exposure time"),
742+
("XPOSURE", product.min_exposure, "[s] shortest exposure time"),
743743
("XPOMAX", product.max_exposure, "[s] maximum exposure time"),
744744
)
745745

@@ -783,7 +783,7 @@ def generate_primary_header(self, filename, product, *, version=0):
783783
("DATAMIN", empty_if_nan(product.dmin), "Minimum valid physical value"),
784784
("DATAMAX", empty_if_nan(product.dmax), "Maximum valid physical value"),
785785
("BUNIT", product.bunit, "Units of physical value, after application of BSCALE, BZERO"),
786-
("XPOSURE", empty_if_nan(product.exposure), "[s] shortest exposure time"),
786+
("XPOSURE", empty_if_nan(product.min_exposure), "[s] shortest exposure time"),
787787
("XPOMAX", empty_if_nan(product.max_exposure), "[s] maximum exposure time"),
788788
)
789789

@@ -999,7 +999,7 @@ def generate_primary_header(self, filename, product, *, version=0):
999999
("DATAMIN", empty_if_nan(product.dmin), "Minimum valid physical value"),
10001000
("DATAMAX", empty_if_nan(product.dmax), "Maximum valid physical value"),
10011001
("BUNIT", product.bunit, "Units of physical value, after application of BSCALE, BZERO"),
1002-
("XPOSURE", empty_if_nan(product.exposure), "[s] shortest exposure time"),
1002+
("XPOSURE", empty_if_nan(product.min_exposure), "[s] shortest exposure time"),
10031003
("XPOMAX", empty_if_nan(product.max_exposure), "[s] maximum exposure time"),
10041004
)
10051005

stixcore/io/product_processors/tests/test_processors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ def test_count_data_mixin(p_file):
192192
p = Product(p_file)
193193

194194
if isinstance(p.data["timedel"], SCETimeDelta):
195-
assert p.exposure == p.data["timedel"].as_float().min().to_value("s")
195+
assert p.min_exposure == p.data["timedel"].as_float().min().to_value("s")
196196
assert p.max_exposure == p.data["timedel"].as_float().max().to_value("s")
197197
else:
198-
assert p.exposure == p.data["timedel"].min().to_value("s")
198+
assert p.min_exposure == p.data["timedel"].min().to_value("s")
199199
assert p.max_exposure == p.data["timedel"].max().to_value("s")
200200

201201
assert p.dmin == p.data["counts"].min().value
@@ -204,7 +204,7 @@ def test_count_data_mixin(p_file):
204204
test_data = {
205205
"DATAMAX": p.dmax,
206206
"DATAMIN": p.dmin,
207-
"XPOSURE": p.exposure,
207+
"XPOSURE": p.min_exposure,
208208
"XPOMAX": p.max_exposure,
209209
"BUNIT": "counts",
210210
}
@@ -264,7 +264,7 @@ def test_level1_processor_generate_primary_header(product, soop_manager):
264264
product.dmax = 1
265265
product.dunit = ""
266266
product.max_exposure = 1
267-
product.exposure = 1
267+
product.min_exposure = 1
268268
product.service_type = 1
269269
product.service_subtype = 2
270270
product.ssid = 3

stixcore/processing/tests/test_publish.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_publish_fits_to_esa_incomplete(product, out_dir):
146146
product.date_obs = beg.to_datetime()
147147
product.date_beg = beg.to_datetime()
148148
product.date_end = end.to_datetime()
149-
product.exposure = 2
149+
product.min_exposure = 2
150150
product.max_exposure = 3
151151
product.dmin = 2
152152
product.dmax = 3
@@ -257,7 +257,7 @@ def test_fits_incomplete_switch_over(out_dir):
257257
product.date_obs = beg.to_datetime()
258258
product.date_beg = beg.to_datetime()
259259
product.date_end = end.to_datetime()
260-
product.exposure = 2
260+
product.min_exposure = 2
261261
product.max_exposure = 3
262262
product.dmin = 2
263263
product.dmax = 3
@@ -398,7 +398,7 @@ def test_publish_fits_to_esa(product, out_dir):
398398
product.date_obs = beg.to_datetime()
399399
product.date_beg = beg.to_datetime()
400400
product.date_end = end.to_datetime()
401-
product.exposure = 2
401+
product.min_exposure = 2
402402
product.max_exposure = 3
403403
product.dmin = 2
404404
product.dmax = 3

stixcore/products/level3/flarelist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def dmax(self):
515515
return (self.data["lc_peak"].sum(axis=1)).max().value if len(self.data) > 0 else np.nan
516516

517517
@property
518-
def exposure(self):
518+
def min_exposure(self):
519519
return self.data["duration"].min().to_value("s") if len(self.data) > 0 else np.nan
520520

521521
@property
@@ -649,7 +649,7 @@ def dmax(self):
649649
return (self.data["lc_peak"].sum(axis=1)).max().value if len(self.data) > 0 else np.nan
650650

651651
@property
652-
def exposure(self):
652+
def min_exposure(self):
653653
return self.data["duration"].min().to_value("s") if len(self.data) > 0 else np.nan
654654

655655
@property

stixcore/products/product.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@ def __call__(self, *args, **kwargs):
263263
if level not in ["LB", "LL01"] and "timedel" in data.colnames and "time" in data.colnames:
264264
# select the time format based on available header keywords
265265
offset = None
266-
if "TIMESYS" in pri_header and pri_header["TIMESYS"] == "UTC":
266+
if pri_header.get("TIMESYS", "") == "UTC":
267267
try:
268268
offset = Time(pri_header["DATE-OBS"])
269-
except Exception:
269+
except ValueError:
270270
offset = None
271271

272-
# fallback to OBT_BEG if no TIMESYS=UTC or DATE-OBS is present or not parseable
272+
# fallback to OBT_BEG if no TIMESYS=UTC or DATE-OBS is present or can not be parsed
273273
if offset is None:
274274
offset = SCETime.from_float(pri_header["OBT_BEG"] * u.s)
275275
data["timedel"] = SCETimeDelta(data["timedel"])
@@ -589,7 +589,7 @@ def bunit(self):
589589
return " "
590590

591591
@property
592-
def exposure(self):
592+
def min_exposure(self):
593593
# default for FITS HEADER
594594
return 0.0
595595

@@ -890,7 +890,7 @@ def bunit(self):
890890
return "counts"
891891

892892
@property
893-
def exposure(self):
893+
def min_exposure(self):
894894
if isinstance(self.data["timedel"], SCETimeDelta):
895895
return self.data["timedel"].as_float().min().to_value("s")
896896
else:
@@ -962,8 +962,8 @@ def utc_timerange(self):
962962
self.scet_timerange.to_timerange()
963963
else:
964964
return TimeRange(
965-
(self.data["time"][0] - self.data["timedel"][0] / 2).datetime,
966-
(self.data["time"][-1] + self.data["timedel"][-1] / 2).datetime,
965+
(self.data["time"][0] - self.data["timedel"][0] / 2),
966+
(self.data["time"][-1] + self.data["timedel"][-1] / 2),
967967
)
968968

969969
@classmethod

stixcore/soop/manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ def add_soop_file_to_index(self, path, *, rebuild_index=True, **args):
529529
all_soop_file = Path(CONFIG.get("SOOP", "soop_files_download")) / f"{plan}.{version}.all.json"
530530

531531
if not all_soop_file.exists():
532+
# TODO reactivate when API is back
533+
return
532534
self.download_all_soops_from_api(plan, version, all_soop_file)
533535

534536
with open(all_soop_file) as f_all:

0 commit comments

Comments
 (0)