Skip to content

Commit

Permalink
Add Quantity to demo11
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeyers314 committed Sep 16, 2024
1 parent c9136d7 commit 0db480e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
8 changes: 6 additions & 2 deletions examples/demo11.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def main(argv):
observation. However, we whiten the noise of the final image so the final image has
stationary Gaussian noise, rather than correlated noise.
"""
import astropy.units as u
logging.basicConfig(format="%(message)s", level=logging.INFO, stream=sys.stdout)
logger = logging.getLogger("demo11")

Expand All @@ -95,7 +96,10 @@ def main(argv):
# (This corresponds to 8 galaxies / arcmin^2)
grid_spacing = 90.0 # The spacing between the samples for the power spectrum
# realization (arcsec)
tel_diam = 4 # Let's figure out the flux for a 4 m class telescope
tel_diam = 4*u.m # Let's figure out the flux for a 4 m class telescope. We'll
# also show how astropy units can be used here (see especially
# the eval_variables section of the yaml version of this
# demo).
exp_time = 300 # exposing for 300 seconds.
center_ra = 19.3*galsim.hours # The RA, Dec of the center of the image on the sky
center_dec = -33.1*galsim.degrees
Expand All @@ -106,7 +110,7 @@ def main(argv):
# is 2.4 but there is obscuration (a linear factor of 0.33). Here, we assume that the telescope
# we're simulating effectively has no obscuration factor. We're also ignoring the pi/4 factor
# since it appears in the numerator and denominator, so we use area = diam^2.
hst_eff_area = 2.4**2 * (1.-0.33**2)
hst_eff_area = (2.4*u.m)**2 * (1.-0.33**2)
flux_scaling = (tel_diam**2/hst_eff_area) * exp_time

# random_seed is used for both the power spectrum realization and the random properties
Expand Down
11 changes: 7 additions & 4 deletions examples/demo11.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
# - image.noise : symmetrize
# - wcs type : Tan(dudx, dudy, dvdx, dvdy, units, origin, ra, dec)
# - top level field eval_variables
# - quantity letter type for eval variable.
#
# - Power spectrum shears and magnifications for non-gridded positions.
# - Reading a compressed FITS image (using BZip2 compression).
Expand Down Expand Up @@ -74,8 +75,10 @@ eval_variables :
# An unusual prefix: a = Angle.
atheta : &theta 0.17 degrees

# tel_diam = the telescope diameter in meters.
ftel_diam : &tel_diam 4
# tel_diam = the telescope diameter. Prefixing this with a 'q' means it is an
# astropy.units.Quantity. We'll specify centimeters here, note the interaction with
# meters down below when we use it to calculate the scale_flux.
qtel_diam : &tel_diam 4 m

# exp_time = the exposure time in seconds.
fexp_time : &exp_time 300
Expand Down Expand Up @@ -167,7 +170,7 @@ gal :
# noise_pad_size = 40 * sqrt(2) * 0.2 arcsec/pixel = 11.3 arcsec
noise_pad_size : 11.3

# We will select a galaxy at random from the catalog. One could easily do this by setting
# We will select a galaxy at random from the catalog. One could easily do this by setting
# index : { type : Random }
# but we will instead allow the catalog to choose a random galaxy for us. It will remove any
# selection effects involved in postage stamp creation using weights that are stored in the
Expand All @@ -192,7 +195,7 @@ gal :
# second exposures. The COSMOS galaxies have their flux set to be appropriate for HST
# (a 2.4 m telescope with a linear obscuration factor of 0.33) with 1 second exposures.
# So the flux should be scaled by (4**2/(2.4*(1-0.33**2))) * 300
"$(tel_diam**2 / (2.4**2*(1.-0.33**2))) * exp_time"
"$(tel_diam**2 / ((2.4*u.m)**2*(1.-0.33**2))) * exp_time"


# Define some other information about the images
Expand Down
4 changes: 2 additions & 2 deletions examples/json/demo11.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"eval_variables" : {
"fpixel_scale" : 0.2,
"atheta" : "0.17 degrees",
"ftel_diam" : 4,
"qtel_diam" : "4 m",
"fexp_time" : 300,
"fimage_size" : 2048,
"inobjects" : 288,
Expand All @@ -44,7 +44,7 @@
"shear" : { "type" : "PowerSpectrumShear" },
"magnification" : { "type" : "PowerSpectrumMagnification" },
"rotation" : { "type" : "Random" },
"scale_flux" : "$(tel_diam**2 / (2.4**2*(1.-0.33**2))) * exp_time"
"scale_flux" : "$(tel_diam**2 / ((2.4*u.m)**2*(1.-0.33**2))) * exp_time"
},

"image" : {
Expand Down

0 comments on commit 0db480e

Please sign in to comment.