Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b452e8a
Machinery to write photons outside image bounds as extra output to FITS.
welucas2 Feb 18, 2025
eaaad4e
Put scattered photons in focal plane coords.
welucas2 Feb 24, 2025
dcaab5b
First partial attempt at reading in the photons from file.
welucas2 May 9, 2025
8cb0e96
Working scattered photon input
welucas2 Jun 13, 2025
50b7a50
Initial full working pipeline
welucas2 Jul 10, 2025
a21c744
FIXUP useful comment in photon scattering pointing out code for testi…
welucas2 Jul 10, 2025
55dfc29
Full focal plane tests
welucas2 Jul 15, 2025
8943635
Move gathering of scattered photons into new function in photon_scatt…
welucas2 Jul 16, 2025
2be310f
Initial go at code to find a science detectors neighbours as part of …
welucas2 Jul 23, 2025
635e282
Make references to 'scattered' photons 'off-detector' photons instead…
welucas2 Jul 23, 2025
f3712a3
Rename photon_scattering.py to full_focal_plane.py
welucas2 Jul 23, 2025
04c2300
FIXUP change the name to full_focal_plane in __init__.py
welucas2 Jul 28, 2025
53faedc
FIXUP tidy up the adjacent_detector code a little
welucas2 Jul 28, 2025
4de62fc
Changes to variable names in get_adjacent_detectors()
welucas2 Aug 8, 2025
77d13c3
Move off detector photons from photon pooling config to FFP pass 1 ex…
welucas2 Aug 22, 2025
9dee32c
Doing some horrible initial experimentation in instcat.py.
welucas2 Aug 22, 2025
6937c53
Make the fiducial WCS a component of the instcat in the YAML config.
welucas2 Aug 26, 2025
de63624
Big improvements to the instcat multi detector object handling. And i…
welucas2 Aug 29, 2025
5a2ad9e
First go at getting skyCatalog interface to accept/reject objects by …
welucas2 Sep 10, 2025
09620d4
Add example_instance_catalog_ffp.txt
welucas2 Sep 11, 2025
3bc992e
Add the fiducial WCS to imsim-config-skycat.yaml.
welucas2 Sep 11, 2025
06fdbbe
First attempt at logic to filter out objects closer to other dets in …
welucas2 Sep 11, 2025
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
29 changes: 28 additions & 1 deletion config/imsim-config-instcat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Get most of the configuration from the base imSim config template.
modules:
- imsim
template: imsim-config
template: imsim-config-photon-pooling

####################################################################
# The following entries are added to the base configuration above.
Expand All @@ -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"
54 changes: 54 additions & 0 deletions examples/imsim-user-instcat-ffp-pass2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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.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: ""

input.initial_image:
file_name: "eimage_00398414-0-r-R22_S12-det095.fits"
dir: "output"

input.off_detector_photons:
file_name: "output/off_det_00398414-0-r-R22_S11-det094.fits"
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