Skip to content

Commit

Permalink
pupil_area updates for instcat code
Browse files Browse the repository at this point in the history
  • Loading branch information
jchiang87 committed May 14, 2024
1 parent 5cbd896 commit 85cf33e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions config/imsim-config-instcat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ input.instance_catalog:
# This should be overridden below or on the command line.
file_name: default_catalog_file.txt
sed_dir: $os.environ.get('SIMS_SED_LIBRARY_DIR')
pupil_area: # pupil area before vignetting in units of cm^2
type: Eval
str: "np.pi * (pupil_R_outer**2 - pupil_R_inner**2) * 100**2"

input.opsim_data:
# Read the visit meta data. By default, we use the same file as the above
Expand Down
8 changes: 6 additions & 2 deletions imsim/instcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from galsim import CelestialCoord
import galsim
import pickle
from .utils import RUBIN_AREA


def clarify_radec_limits(
Expand Down Expand Up @@ -171,11 +172,13 @@ class InstCatalog(object):

def __init__(self, file_name, wcs, xsize=4096, ysize=4096, sed_dir=None,
edge_pix=100, sort_mag=True, flip_g2=True, approx_nobjects=None,
min_source=None, skip_invalid=True, logger=None):
pupil_area=RUBIN_AREA, min_source=None, skip_invalid=True,
logger=None):
logger = galsim.config.LoggerWrapper(logger)
self.file_name = file_name
self.flip_g2 = flip_g2
self.approx_nobjects = approx_nobjects
self.pupil_area = pupil_area
self._sed_cache = {}

if sed_dir is None:
Expand Down Expand Up @@ -516,7 +519,7 @@ def getObj(self, index, gsparams=None, rng=None, exptime=30):

# This gives the normalization in photons/cm^2/sec.
# Multiply by area and exptime to get photons.
fAt = flux * self._rubin_area * exptime
fAt = flux * self.pupil_area * exptime

sed = self.getSED(index)
return obj.withFlux(fAt) * sed
Expand Down Expand Up @@ -599,6 +602,7 @@ def getKwargs(self, config, base, logger):
'sort_mag' : bool,
'flip_g2' : bool,
'approx_nobjects' : int,
'pupil_area' : float,
'min_source' : int,
'skip_invalid' : bool,
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_instcat_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def test_object_extraction_stars(self):
# Instead, this basically recapitulates the calculation in the InstCatalog class.
magnorm = cat.getMagNorm(i)
flux = np.exp(-0.9210340371976184 * magnorm)
rubin_area = 0.25 * np.pi * 649**2 # cm^2
rubin_area = np.pi * (418**2 - 255**2) # cm^2
exptime = 30
fAt = flux * rubin_area * exptime
sed = cat.getSED(i)
Expand Down Expand Up @@ -459,7 +459,7 @@ def test_object_extraction_galaxies(self):
# Instead, this basically recapitulates the calculation in the InstCatalog class.
magnorm = cat.getMagNorm(i)
flux = np.exp(-0.9210340371976184 * magnorm)
rubin_area = 0.25 * np.pi * 649**2 # cm^2
rubin_area = np.pi * (418**2 - 255**2) # cm^2
exptime = 30
fAt = flux * rubin_area * exptime
sed = cat.getSED(i) # This applies the redshift internally.
Expand Down

0 comments on commit 85cf33e

Please sign in to comment.