#!/usr/bin/env python3
# Author: Akke Viitanen
# Email: akke.viitanen@helsinki.fi
# Date: 2023-07-18 16:35:28
"""
LSST-specific settings and constants.
https://www.lsst.org/scientists/keynumbers
"""
from lsst_inaf_agile import util
# zeropoint
# NOTE: the values reported in the key numbers or smtn-002 appear too faint...
# The numbers listed below
# zeropoint = {
# "u": 27.03,
# "g": 28.38,
# "r": 28.16,
# "i": 27.85,
# "z": 27.46,
# "y": 26.68,
# }
[docs]
zeropoint = {
"u": 26.7899838658703,
"g": 28.6422348533437,
"r": 28.4762158877359,
"i": 28.150403321047,
"z": 27.7604119423889,
"y": 26.9342790022924,
}
# Filter
[docs]
filter_lam_fwhm = {
"u": (0.368483, 0.0516),
"g": (0.480199, 0.146),
"r": (0.623119, 0.1354),
"i": (0.754169, 0.1246),
"z": (0.869047, 0.1024),
"y": (0.973638, 0.0892),
}
# Seeing
[docs]
seeing = {
"u": 0.92,
"g": 0.87,
"r": 0.83,
"i": 0.80,
"z": 0.78,
"y": 0.76,
}
# Sky brightness
[docs]
sky = {
"u": 22.96,
"g": 22.26,
"r": 21.20,
"i": 20.48,
"z": 19.60,
"y": 18.61,
}
# Example LSST psf files
[docs]
psf = {
"u": "data/lsst/660230_144_u_psf.fits",
"g": "data/lsst/781365_170_g_psf.fits",
"r": "data/lsst/755161_141_r_psf.fits",
"i": "data/lsst/654496_187_i_psf.fits",
"z": "data/lsst/707614_42_z_psf.fits",
"y": "data/lsst/647542_93_y_psf.fits",
}
# Limiting magnitudes
[docs]
limiting_magnitude_30s = {
"u": 23.80,
"g": 24.50,
"r": 24.03,
"i": 23.41,
"z": 22.74,
"y": 22.96,
}
[docs]
limiting_magnitude_10yr = {
"u": 25.6,
"g": 26.9,
"r": 26.9,
"i": 26.4,
"z": 25.6,
"y": 24.8,
}
# Number of visits
[docs]
visit = {k: v for k, v in zip("ugrizy", [56, 80, 184, 184, 160, 160], strict=False)}
# Reference: baseline v3.4 http://astro-lsst-01.astro.washington.edu:8080/allMetricResults?runId=4#QSO_Number
# (2024-04-11)
# New website: https://s3df.slac.stanford.edu/data/rubin/sim-data/
[docs]
qso_number_counts_cosmos = {
"u": 8894,
"g": 11763,
"r": 13406,
"i": 14569,
"z": 14431,
"y": 15500,
}
[docs]
qso_number_counts_cosmos_baseline_v4p0 = {
"u": 9169,
"g": 11825,
"r": 13479,
"i": 14657,
"z": 14521,
"y": 15577,
}
[docs]
limiting_magnitude_cosmos = {
"u": 26.92,
"g": 28.55,
"r": 28.55,
"i": 28.17,
"z": 27.67,
"y": 26.24,
}
[docs]
limiting_magnitude_cosmos_baseline_v4p0 = {
"u": 27.16,
"g": 28.56,
"r": 28.58,
"i": 28.20,
"z": 27.69,
"y": 26.25,
}
[docs]
def get_conf(zeropoint, lam, seeing, sky, psf) -> str:
"""Get a skymaker config string."""
return f"""\
IMAGE_TYPE SKY
GAIN 1.0
WELL_CAPACITY 0
SATUR_LEVEL 1e9
READOUT_NOISE 12.7
#READOUT_NOISE 0.0
EXPOSURE_TIME 30.0
MAG_ZEROPOINT {zeropoint}
PIXEL_SIZE 0.20
PSF_TYPE FILE
PSF_NAME {psf}
SEEING_FWHM {seeing}
AUREOLE_RADIUS 0
PSF_OVERSAMP 1
M1_DIAMETER 8.40
M2_DIAMETER 3.42
WAVELENGTH {lam}
#BACK_MAG {sky}
BACK_MAG 99.00
STARCOUNT_ZP 0
VERBOSE_TYPE FULL
NTHREADS 4"""
[docs]
def get_psf(band):
"""Return the mock DP0.2 PSF for the given band."""
return util.read_fits(psf[band])
[docs]
def get_detector(detector: int) -> str:
"""
Return the string representation of the detector.
Refer to the detector layout in the imSim webpage.
Parameters
----------
detector: int
Numerical value of the detector (0-189, inclusive).
Examples
--------
>>> get_detector(94)
'R22_S11'
Raises
------
ValueError
If detector is not within 0-189 (inclusive).
"""
if not (0 <= detector <= 189):
raise ValueError("detector must be in 0-189 (inclusive")
R = (
list(range(1, 4))
+ list(range(10, 15))
+ list(range(20, 25))
+ list(range(30, 35))
+ list(range(41, 44))
)[detector // 9]
# NOTE: S is in base 3
S = detector % 9
S = 10 * (S // 3) + (S % 3)
return f"R{R:02d}_S{S:02d}"