Skip to content

Commit 2716861

Browse files
committed
Add scaled fwhm quantities.
1 parent 52a2fd1 commit 2716861

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

decasu/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class Configuration:
7272
band_field: str = 'band'
7373
mjd_field: str = 'mjd_obs'
7474
skyvar_field: str = 'skyvar'
75+
fwhm_field: str = 'fwhm'
7576
bad_amps: Dict[int, list] = field(default_factory=_default_bad_amps)
7677
bad_ccds: List[int] = field(default_factory=_default_bad_ccds)
7778
latitude: float = -30.1690

decasu/lsst_wcs_consdb.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from astropy.coordinates import EarthLocation
88

99
from . import decasu_globals
10+
from .utils import compute_visit_iqr_and_optics_scale
1011

1112
try:
1213
import lsst.obs.lsst
@@ -97,8 +98,12 @@ def __init__(self, config, dbstring, bands, compute_pixels=True):
9798
print(f"Found {len(db_table)} detector visits for {len(self.bands)} bands.")
9899

99100
# Add extra columns.
101+
# Units of degrees.
100102
db_table["decasu_lst"] = np.zeros(len(db_table))
103+
# Units of electrons.
101104
db_table["skyvar"] = db_table["sky_noise"]**2.
105+
# Units of arcsec.
106+
db_table[config.fwhm_field] = 2.355*config.argsec_per_pix*db_table["psf_sigma"]
102107

103108
print("Computing local sidereal time...")
104109
loc = EarthLocation(lat=config.latitude*units.degree,
@@ -107,7 +112,14 @@ def __init__(self, config, dbstring, bands, compute_pixels=True):
107112

108113
t = Time(db_table[config.mjd_field], format="mjd", location=loc)
109114
lst = t.sidereal_time("apparent")
110-
db_table["decasu_lst"] = lst.to_value(units.degree)
115+
db_table["decasu_lst"][:] = lst.to_value(units.degree)
116+
117+
# Compute a couple of additional psf quantities.
118+
db_table[f"{config.fwhm_field}_iqr"] = np.zeros(len(db_table))
119+
db_table[f"{config.fwhm_field}_optics_scale"] = np.zeros(len(db_table))
120+
121+
print('Computing fwhm scaled properties...')
122+
compute_visit_iqr_and_optics_scale(self.config, db_table)
111123

112124
instrument = lsst.obs.lsst.LsstCam()
113125
camera = instrument.getCamera()

decasu/utils.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,28 @@ def read_maskfiles(expnums, maskfiles, exp_field):
166166
masktable = np.append(masktable, subtable[b])
167167

168168
return masktable
169+
170+
171+
def compute_visit_iqr_and_optics_scale(config, table):
172+
"""Compute the visit IQR and optics scale.
173+
174+
Parameters
175+
----------
176+
config : `decasu.Configuration`
177+
table : `np.ndarray` or `astropy.table.Table`
178+
"""
179+
u, inv = np.unique(table[config.exp_field], return_inverse=True)
180+
h, rev = esutil.stat.histogram(inv, rev=True)
181+
inds, = np.where(h > 0)
182+
183+
table[f"{config.fwhm_field}_iqr"][:] = 0.0
184+
table[f"{config.fwhm_field}_optics_scale"][:] = 1.0
185+
186+
for ind in inds:
187+
i1a = rev[rev[ind]: rev[ind + 1]]
188+
isfinite = np.isfinite(table[config.fwhm_field][i1a]) & (table[config.fwhm_field][i1a] > 0.0)
189+
if np.any(isfinite):
190+
five, lo, hi = np.percentile(table[config.fwhm_field][i1a][isfinite], [5.0, 25.0, 75.0])
191+
table[f"{config.fwhm_field}_iqr"][i1a][isfinite] = hi - lo
192+
193+
table[f"{config.fwhm_field}_optics_scale"][i1a] = table[f"{config.fwhm_field}"][i1a] / five

decasu/wcs_table.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from astropy.coordinates import EarthLocation
99

1010
from . import decasu_globals
11+
from .utils import compute_visit_iqr_and_optics_scale
1112

1213

1314
class WcsTableBuilder:
@@ -48,6 +49,8 @@ def __init__(self, config, infiles, bands, pfw_attempt_ids=[], compute_pixels=Tr
4849

4950
# And add in the hour angle and parallactic angle fields
5051
dtype.extend([('decasu_lst', 'f8')])
52+
dtype.extend([(f'{config.fwhm_field}_iqr', 'f4')])
53+
dtype.extend([(f'{config.fwhm_field}_optics_scale', 'f4')])
5154

5255
table = np.zeros(table_in.size, dtype=dtype)
5356
for name in table_in.dtype.names:
@@ -90,6 +93,9 @@ def __init__(self, config, infiles, bands, pfw_attempt_ids=[], compute_pixels=Tr
9093

9194
print('Found %d CCDs for %d bands.' % (len(fulltable), len(bands)))
9295

96+
print('Computing fwhm scaled properties...')
97+
compute_visit_iqr_and_optics_scale(self.config, fulltable)
98+
9399
print('Computing local sidereal time...')
94100
loc = EarthLocation(lat=config.latitude*units.degree,
95101
lon=config.longitude*units.degree,

0 commit comments

Comments
 (0)