From 07a18aa0b06e7126e4f83208e505b3b93cf6d331 Mon Sep 17 00:00:00 2001 From: Eddie Schlafly Date: Mon, 30 Oct 2023 14:03:07 -0400 Subject: [PATCH] Add read_pattern metadata to simulated files. (#89) * Add read_pattern metadata to simulated files. * Actually use the computed read_pattern... --- romanisim/l1.py | 8 ++++++-- romanisim/util.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/romanisim/l1.py b/romanisim/l1.py index 4bce80cc..a9eb43a1 100644 --- a/romanisim/l1.py +++ b/romanisim/l1.py @@ -424,7 +424,7 @@ def make_asdf(resultants, dq=None, filepath=None, metadata=None, persistence=Non return out, extras -def ma_table_to_tij(ma_table_number): +def ma_table_to_tij(ma_table_number, read_time=None): """Get the times of each read going into resultants for a MA table. Currently only ma_table_number = 1 is supported, corresponding to a simple @@ -439,17 +439,21 @@ def ma_table_to_tij(ma_table_number): ma_table_number : int or list[list] if int, id of multiaccum table to use otherwise a list of (first_read, n_reads) tuples going into resultants. + read_time : number + Frame read time to use. If None, use romanisim.parameters.read_time. Returns ------- list[list[float]] list of list of readout times for each read entering a resultant """ + if read_time is None: + read_time = parameters.read_time if isinstance(ma_table_number, int): tab = parameters.ma_table[ma_table_number] else: tab = ma_table_number - tij = [parameters.read_time * np.arange(f, f + n) for (f, n) in tab] + tij = [read_time * np.arange(f, f + n) for (f, n) in tab] return tij diff --git a/romanisim/util.py b/romanisim/util.py index 27a16595..658f47fb 100644 --- a/romanisim/util.py +++ b/romanisim/util.py @@ -7,7 +7,7 @@ from astropy.time import Time import galsim -from romanisim import parameters +from romanisim import parameters, l1 from scipy import integrate @@ -217,6 +217,8 @@ def add_more_metadata(metadata): metadata['exposure']['exposure_time'] = openshuttertime metadata['exposure']['effective_exposure_time'] = openshuttertime metadata['exposure']['duration'] = openshuttertime + read_pattern = l1.ma_table_to_tij(ma_table, read_time=1) + metadata['exposure']['read_pattern'] = [list(x) for x in read_pattern] # integration_start? integration_end? nints = 1? ...