Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle filling aca image array differently #297

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions mica/archive/aca_l0.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ def get_l0_images(start, stop, slot, imgsize=None, columns=None):
if 'IMGCOL0' not in columns:
columns.append('IMGCOL0')

# It doesn't make any sense to include IMGRAW in the meta-data columns
# of ACAImages so just remove it if the user has requested that.
if 'IMGRAW' in columns:
columns.remove('IMGRAW')

slot_columns = list(set(columns + ['QUALITY', 'IMGRAW', 'IMGSIZE']))
dat = get_slot_data(start, stop, slot, imgsize=imgsize, columns=slot_columns)

Expand All @@ -233,21 +238,17 @@ def get_l0_images(start, stop, slot, imgsize=None, columns=None):
if temp in dat.dtype.names:
dat[temp] -= 273.15

# Masked array col access ~100 times slower than ndarray so convert
dat = dat.filled(-9999)
dat["IMGRAW"].set_fill_value(-9999)
dat = dat[~dat["IMGSIZE"].mask]
imgraws = dat["IMGRAW"].filled()

imgs = []
imgsizes = dat['IMGSIZE']
imgraws = dat['IMGRAW']
cols = {name: dat[name] for name in columns}

for i, row in enumerate(dat):
imgraw = imgraws[i].reshape(8, 8)
sz = imgsizes[i]
for row, imgraw in zip(dat, imgraws):
imgraw = imgraw.reshape(8, 8)
sz = row["IMGSIZE"]
if sz < 8:
imgraw = imgraw[:sz, :sz]

meta = {name: col[i] for name, col in cols.items() if col[i] != -9999}
meta = {name: row[name] for name in columns if not np.any(row.mask[name])}
imgs.append(ACAImage(imgraw, meta=meta))

return imgs
Expand Down Expand Up @@ -723,7 +724,7 @@ def _move_archive_files(self, archfiles):
os.unlink(f)

def _fetch_by_time(self, range_tstart, range_tstop):
logger.info("Fetching %s from %s to %s"
logger.info("Fetching %s from %s to %s"
% ('ACA L0 Data',
DateTime(range_tstart).date,
DateTime(range_tstop).date))
Expand Down