Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9818ff7
Machinery to write photons outside image bounds as extra output to FITS.
welucas2 Feb 18, 2025
9152ec5
Put scattered photons in focal plane coords.
welucas2 Feb 24, 2025
2937c80
First partial attempt at reading in the photons from file.
welucas2 May 9, 2025
eaf79d3
Working scattered photon input
welucas2 Jun 13, 2025
43840a9
Initial full working pipeline
welucas2 Jul 10, 2025
12db575
Full focal plane tests
welucas2 Jul 15, 2025
06ca377
Move gathering of scattered photons into new function in photon_scatt…
welucas2 Jul 16, 2025
ed76d3e
Initial go at code to find a science detectors neighbours as part of …
welucas2 Jul 23, 2025
cb00410
Make references to 'scattered' photons 'off-detector' photons instead…
welucas2 Jul 23, 2025
582c76d
Rename photon_scattering.py to full_focal_plane.py
welucas2 Jul 23, 2025
32e57c1
Changes to variable names in get_adjacent_detectors()
welucas2 Aug 8, 2025
b981791
Move off detector photons from photon pooling config to FFP pass 1 ex…
welucas2 Aug 22, 2025
9062a75
Doing some horrible initial experimentation in instcat.py.
welucas2 Aug 22, 2025
c205bd9
Make the fiducial WCS a component of the instcat in the YAML config.
welucas2 Aug 26, 2025
536f5aa
Big improvements to the instcat multi detector object handling. And i…
welucas2 Aug 29, 2025
95499b1
First go at getting skyCatalog interface to accept/reject objects by …
welucas2 Sep 10, 2025
b1d9bf8
Add example_instance_catalog_ffp.txt
welucas2 Sep 11, 2025
63dbf79
Add the fiducial WCS to imsim-config-skycat.yaml.
welucas2 Sep 11, 2025
2678932
First attempt at logic to filter out objects closer to other dets in …
welucas2 Sep 11, 2025
b050370
keep track of objects to skip instead of trying to use an iterator pr…
jchiang87 Sep 15, 2025
bfcb934
include f-string prefix
jchiang87 Sep 16, 2025
36605bd
don't run AddNoise for pass 2 rendering
jchiang87 Sep 29, 2025
b6fe71c
Config now keys off-detector photons to det_num/name.
welucas2 Oct 17, 2025
c1466fd
Fix test_trimmer.py to set edge_pix=100, the old default, to keep a t…
welucas2 Feb 17, 2026
7a365be
New input.instance_catalog.full_focal_plane enables and disables FFP.
welucas2 Feb 27, 2026
b78dfc6
Have test_image_nobjects set edge_pix=100 as the new default of 200 (…
welucas2 Mar 9, 2026
75cd062
Calculate fiducial WCS before image WCS in order to correctly store _…
welucas2 Mar 9, 2026
68b36b5
Add full_focal_plane parameter to skycat and ensure correct _icrf_to_…
welucas2 Mar 11, 2026
5f8d821
Allow off_detector_photons to be read from multiple files.
welucas2 Mar 16, 2026
85272cf
Update tests to use LsstCamSim.
welucas2 Mar 16, 2026
0292416
Fix edge_pix values used in test_stamp.py to old value of 100.
welucas2 Mar 17, 2026
5342e86
Add tests for off-detector photon loader.
welucas2 Mar 24, 2026
3dee97b
New test for LSST_FocalPlaneImage.
welucas2 Mar 24, 2026
d1c740b
Rework off-detector photons input to lazily read photons and also all…
welucas2 Mar 24, 2026
e5b5134
Minor tidying up in the second pass example config.
welucas2 Mar 26, 2026
f8baa87
Add files in tests/data for new full focal plane tests.
welucas2 Mar 26, 2026
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
27 changes: 27 additions & 0 deletions config/imsim-config-instcat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ input.instance_catalog:
file_name: default_catalog_file.txt
sed_dir: $os.environ.get('SIMS_SED_LIBRARY_DIR')
pupil_area: $pupil_area
# A single WCS calculated used when determining which objects are to be drawn
# by which detector. We could in principle use any WCS. Here we start from the
# same Batoid WCS as in the image. In the code, any SIP components of the
# fiducial WCS, once it's been calculated, are removed.
fiducial_wcs:
type: Batoid

# These are required:
camera: $camera
boresight: $boresight

obstime:
type: Eval
str: "astropy.time.Time(mjd_val, format='mjd', scale='tai')"
fmjd_val: { type: OpsimData, field: mjd }

# The fiducial WCS will use this detector. We default here to the
# central detector, but it can be overrdden if needed.
det_name: "R22_S11"
wavelength: $(@image.bandpass).effective_wavelength

# The rest can be omitted, since these are the default values, but shown here
# for reference.
temperature: 280 # Kelvin
pressure: 72.7 # kPa
H2O_pressure: 1.0 # kPa
order: 3 # Order of the SIP polynomial

input.opsim_data:
# Read the visit meta data. By default, we use the same file as the above
Expand Down
2 changes: 1 addition & 1 deletion config/imsim-config-photon-pooling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ output.photon_pooling_truth:
nominal_flux: "@nominal_flux" # The nominal "expectation value" flux.
phot_flux: "@phot_flux" # The realized flux for photon shooting.
fft_flux: "@fft_flux" # If FFT rendering, then the flux used, including vignetting.
incident_flux: "@incident_flux" # The sum of the fluxes of all photons from the object.
incident_flux: "@incident_flux" # The sum of the fluxes of all photons from the object.
27 changes: 27 additions & 0 deletions config/imsim-config-skycat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,33 @@ input.sky_catalog:
band: $band
mjd: { type: OpsimData, field: mjd }
pupil_area: $pupil_area
# A single WCS calculated used when determining which objects are to be drawn
# by which detector. We could in principle use any WCS. Here we start from the
# same Batoid WCS as in the image. In the code, any SIP components of the
# fiducial WCS, once it's been calculated, are removed.
fiducial_wcs:
type: Batoid

# These are required:
camera: $camera
boresight: $boresight

obstime:
type: Eval
str: "astropy.time.Time(mjd_val, format='mjd', scale='tai')"
fmjd_val: { type: OpsimData, field: mjd }

# The fiducial WCS will use this detector. We default here to the
# central detector, but it can be overrdden if needed.
det_name: "R22_S11"
wavelength: $(@image.bandpass).effective_wavelength

# The rest can be omitted, since these are the default values, but shown here
# for reference.
temperature: 280 # Kelvin
pressure: 72.7 # kPa
H2O_pressure: 1.0 # kPa
order: 3 # Order of the SIP polynomial

input.opsim_data:
file_name: default_opsim.db
Expand Down
23 changes: 23 additions & 0 deletions examples/example_instance_catalog_ffp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
rightascension 60.49045502638662697
declination -38.16437495898705379
mjd 60143.42156961110595148
altitude 53.16185928082865786
azimuth 114.38574818197552929
filter 2
rotskypos 131.23506207988341998
dist2moon 88.2886136
moonalt -28.7317781
moondec 24.6999775
moonphase 0.5804871
moonra 127.0562204
nsnap 1
obshistid 398414
rottelpos 40.0386345
seed 398414
seeing 0.7501810
sunalt -19.2243392
vistime 30.0000000
seqnum 0
object 32166149840900 60.5808675 -38.07410111 13.8487927 starSED/phoSimMLT/lte035-4.5-1.0a+0.4.BT-Settl.spec.gz 0 0 0 0 0 0 point none CCM 0.0112685 3.1
object 32166139536388 60.55213375 -38.04768278 13.2693929 starSED/phoSimMLT/lte035-4.5-1.0a+0.4.BT-Settl.spec.gz 0 0 0 0 0 0 point none CCM 0.01014165 3.1
object 32166139536388 60.55989542 -38.038889 13.2693929 starSED/phoSimMLT/lte035-4.5-1.0a+0.4.BT-Settl.spec.gz 0 0 0 0 0 0 point none CCM 0.01014165 3.1
56 changes: 56 additions & 0 deletions examples/imsim-user-instcat-ffp-pass1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Use imSim custom modules
modules:
- imsim

# Get most of the configuration from the imSim config-template
# for instance catalogs.
template: imsim-config-instcat

################################################################
# Make your changes below.
################################################################

# Put your own commands that override the defaults below here. For example
# input.instance_catalog.file_name: ./imsim_cat_197356.txt
# input.instance_catalog.sort_mag: False
# input.tree_rings.only_dets: [R22_S11]
# image.nobjects: 5

input.instance_catalog.file_name: $os.environ.get('IMSIM_HOME')+'/imSim/examples/example_instance_catalog_ffp.txt'
input.instance_catalog.sort_mag: False

# For now, disable tree rings to make the diffraction spikes
# easier to see in the images.
input.tree_rings: ""
image.sensor.treering_center: ""
image.sensor.treering_func: ""

input.atm_psf: ""
psf:
type: Convolve
items:
-
type: Gaussian
fwhm: 0.3

image.nobjects: 10

stamp.fft_sb_thresh: 1.e30

output.det_num.first: 94
output.nfiles: 2
output.nproc: 1

output.dir: output

output.off_detector_photons:
dir: output
file_name:
type: FormattedStr
format : off_det_%08d-%1d-%s-%s-det%03d.fits
items:
- { type: OpsimData, field: observationId }
- { type: OpsimData, field: snap }
- $band
- $det_name
- "@output.det_num"
81 changes: 81 additions & 0 deletions examples/imsim-user-instcat-ffp-pass2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Use imSim custom modules
modules:
- imsim

# Get most of the configuration from the imSim config-template
# for instance catalogs.
template: imsim-config-instcat

################################################################
# Make your changes below.
################################################################

input.checkpoint: ""
# input.instance_catalog: ""
input.instance_catalog.file_name: $os.environ.get('IMSIM_HOME')+'/imSim/examples/example_instance_catalog_ffp.txt'
input.instance_catalog.sort_mag: False
# input.opsim_data: ""

input.tree_rings: ""
input.atm_psf: ""

# In the second pass, we add off-detector photons to the image generated in the
# first pass from the the on-detector photons. Give the image here.
input.initial_image:
dir: output
file_name:
type: FormattedStr
format : eimage_%08d-%1d-%s-%s-det%03d.fits
items:
- { type: OpsimData, field: observationId }
- { type: OpsimData, field: snap }
- $band
- $det_name
- "@output.det_num"

# Two methods can be used to read files containing off-detector photons. If a
# single file only is to be read, then give the file_name. Alternatively, we can
# give a file_pattern containing the fields DETNAME and DETNUM, which are
# wildcards for the detector name and number in an expected set of files
# matching the pattern. The loader will then attempt to read from all files it
# finds matching this patter, excluding the file with the same name/num as the
# current detector.
input.off_detector_photons:
dir: output
# file_name:
# type: FormattedStr
# format: off_det_%08d-%1d-%s-%s-det%03d.fits
# items:
# - { type: OpsimData, field: observationId }
# - { type: OpsimData, field: snap }
# - $band
# - $det_name
# - "@output.det_num"
file_pattern:
type: FormattedStr
format: off_det_%08d-%1d-%s-DETNAME-detDETNUM.fits
items:
- { type: OpsimData, field: observationId }
- { type: OpsimData, field: snap }
- $band
camera: $camera
det_name: $det_name

psf:
type: Convolve
items:
-
type: Gaussian
fwhm: 0.3

stamp: ""

image.type: LSST_FocalPlaneImage
image.sensor.treering_center: ""
image.sensor.treering_func: ""

output.det_num.first: 95
output.nfiles: 1
output.file_name.format: "eimage_full_focal_%08d-%1d-%s-%s-det%03d.fits"

output.dir: output
1 change: 1 addition & 0 deletions imsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@
from .process_info import *
from .table_row import *
from .photon_pooling import *
from .full_focal_plane import *
39 changes: 39 additions & 0 deletions imsim/camera.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import re
import json
from collections import defaultdict
import numpy as np
import galsim
import lsst.utils
from .meta_data import data_dir
Expand Down Expand Up @@ -214,3 +216,40 @@ def update(self, other):
def __getattr__(self, attr):
"""Provide access to the attributes of the underlying lsst_camera."""
return getattr(self.lsst_camera, attr)

def get_adjacent_detectors(self, det_name):
"""
Given a science detector's name, return a list of the names of science
detectors within the 3x3 grid around it, including itself.
"""
if det_name not in self:
raise galsim.GalSimValueError("Detector is not in camera", det_name)
match = re.match(r"R(\d{2})_S(\d{2})", det_name)
if not match:
# If the given detector is in the list but couldn't be matched, then
# it's a wavefront or guide detector.
raise galsim.GalSimValueError(
"Arg must be a science detector, not wavefront or guide", det_name)
r_det = (int(match.group(1)[0]), int(match.group(1)[1]))
s_det = (int(match.group(2)[0]), int(match.group(2)[1]))

# The following method of manipulating the indices in the detector name
# is about 5000 times faster than using lsst.afw.cameraGeom to find the
# detector's center and then the names of those shifted away by one
# detector width/height.

# We'll always have a full set of the nine S index pairs, but they need
# to be permuted to match the position within the raft.
s_rows = np.roll(np.array([0, 1, 2]), 1 - s_det[0])
s_cols = np.roll(np.array([0, 1, 2]), 1 - s_det[1])

# A little integer arithmetic is used to increment or decrement the raft
# indices if the detector is positioned on an edge of the raft.
r_rows = np.array([r_det[0]-s_rows[0]//2, r_det[0], r_det[0]+(2-s_rows[2])//2])
r_cols = np.array([r_det[1]-s_cols[0]//2, r_det[1], r_det[1]+(2-s_cols[2])//2])

adjacent_detectors = [f"R{ri}{rj}_S{si}{sj}"
for ri, si in zip(r_rows, s_rows)
for rj, sj in zip(r_cols, s_cols)
if f"R{ri}{rj}_S{si}{sj}" in self]
return adjacent_detectors
Loading
Loading