Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixes in sca.py #27

Merged
merged 4 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
147 changes: 147 additions & 0 deletions config/skyCatalog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
Cosmology:
H0: 71.0
Ob0: 0.0448
Om0: 0.2648
n_s: 0.963
sigma8: 0.8
MW_extinction_values:
a_v:
mode: data
r_v:
mode: constant
value: 3.1
# catalog_dir: /lus/eagle/projects/RomanDESC/roman_rubin_cats_v1.1.2_faint
catalog_dir: /hpc/group/cosmology/OpenUniverse2024/roman_rubin_cats_v1.1.2_faint
catalog_name: skyCatalog
galaxy_magnitude_cut: 32.0
knots_magnitude_cut: 27.0
object_types:
bulge_basic:
MW_extinction: F19
internal_extinction: CCM
parent: galaxy
sed_model: tophat
spatial_model: sersic2D
subtype: bulge
diffsky_bulge:
MW_extinction: F19
internal_extinction: CCM
parent: diffsky_galaxy
sed_model: TBD
spatial_model: sersic2D
subtype: bulge
diffsky_disk:
MW_extinction: F19
internal_extinction: CCM
parent: diffsky_galaxy
sed_model: TBD
spatial_model: sersic2D
subtype: disk
diffsky_galaxy:
area_partition:
nside: 32
ordering: ring
type: healpix
composite:
bulge: required
disk: required
knots: optional
data_file_type: parquet
file_template: galaxy_(?P<healpix>\d+).parquet
flux_file_template: galaxy_flux_(?P<healpix>\d+).parquet
sed_file_template: galaxy_sed_(?P<healpix>\d+).hdf5
diffsky_knots:
MW_extinction: F19
internal_extinction: CCM
parent: diffsky_galaxy
sed_model: TBD
spatial_model: knots
subtype: knots
disk_basic:
MW_extinction: F19
internal_extinction: CCM
parent: galaxy
sed_model: tophat
spatial_model: sersic2D
subtype: disk
gaia_star:
area_partition: None
butler_parameters:
collections: HSC/defaults
dstype: gaia_dr2_20200414
data_file_type: butler_refcat
sed_method: use_lut
galaxy:
area_partition:
nside: 32
ordering: ring
type: healpix
attribute_aliases:
size_knots_true: size_disk_true
size_minor_knots_true: size_minor_disk_true
composite:
bulge: required
disk: required
knots: optional
data_file_type: parquet
file_template: galaxy_(?P<healpix>\d+).parquet
flux_file_template: galaxy_flux_(?P<healpix>\d+).parquet
knots_basic:
MW_extinction: F19
internal_extinction: CCM
parent: galaxy
sed_model: tophat
spatial_model: knots
subtype: knots
snana:
area_partition:
nside: 32
ordering: ring
type: healpix
data_file_type: parquet
file_template: snana_(?P<healpix>\d+).parquet
internal_extinction: None
sed_model: snana
sncosmo:
MW_extinction: F19
area_partition:
nside: 32
ordering: ring
type: healpix
data_file_type: parquet
file_template: pointsource_(?P<healpix>\d+).parquet
internal_extinction: None
sed_model: sncosmo
star:
MW_extinction: F19
area_partition:
nside: 32
ordering: ring
type: healpix
data_file_type: parquet
file_template: pointsource_(?P<healpix>\d+).parquet
flux_file_template: pointsource_flux_(?P<healpix>\d+).parquet
internal_extinction: None
sed_file_root_env_var: SIMS_SED_LIBRARY_DIR
sed_model: file_nm
provenance:
inputs:
galaxy_truth: roman_rubin_2023_v1.1.2_elais
sn_truth: /global/cfs/projectdirs/lsst/www/DESC_TD_PUBLIC/Roman+DESC/PQ+HDF5_ROMAN+LSST_LARGE/
star_truth: /pscratch/sd/j/jrbogart/desc/UW_star_catalog/
skyCatalogs_repo:
git_branch: main
git_hash: 8318bbf88e3f01b29d071c34e07026d73a768e82
git_status:
- UNCOMMITTED_FILES
- UNTRACKED_FILES
versioning:
code_version: 1.7.0-rc2
schema_version: 1.2.0
diffmah: 0.4.2
diffsky: 0.1.1
diffstar: 0.2.2
dsps: 0.3.4
lsstdesc-diffsky: 0.1.6.dev46+g0b637a0
# skycatalog_root: /lus/eagle/projects/RomanDESC/roman_rubin_cats_v1.1.2_faint
skycatalog_root: /hpc/group/cosmology/OpenUniverse2024/roman_rubin_cats_v1.1.2_faint
43 changes: 29 additions & 14 deletions config/was.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,24 @@ image:
draw_method: 'auto'

# These are all by default turned on, but you can turn any of them off if desired:
ignore_noise: True
stray_light: False
thermal_background: False
reciprocity_failure: False
dark_current: False
nonlinearity: False
ipc: False
read_noise: False
# ignore_noise: True
# stray_light: False
# thermal_background: False
# reciprocity_failure: False
# dark_current: False
# nonlinearity: False
# ipc: False
# read_noise: False
# sky_subtract: False

ignore_noise: False
stray_light: True
thermal_background: True
reciprocity_failure: True
dark_current: True
nonlinearity: True
ipc: True
read_noise: True
sky_subtract: False

# nobjects: 500
Expand Down Expand Up @@ -114,23 +124,27 @@ gal:

input:
obseq_data:
file_name: /lus/grand/projects/RomanDESC/final_roman_runfiles/was/Roman_WAS_obseq_11_1_23.fits
visit: 80840
# file_name: /lus/grand/projects/RomanDESC/final_roman_runfiles/was/Roman_WAS_obseq_11_1_23.fits
file_name: /hpc/group/cosmology/OpenUniverse2024/RomanWAS/Roman_WAS_obseq_11_1_23.fits
visit: 1
SCA: '@image.SCA'
roman_psf:
SCA: '@image.SCA'
n_waves: 5
sky_catalog:
file_name: /lus/grand/projects/RomanDESC/roman_rubin_cats_v1.1.2_faint/skyCatalog.yaml
# file_name: /lus/grand/projects/RomanDESC/roman_rubin_cats_v1.1.2_faint/skyCatalog.yaml
# file_name: /hpc/group/cosmology/OpenUniverse2024/roman_rubin_cats_v1.1.2_faint/skyCatalog.yaml
file_name: /hpc/home/yf194/Work/projects/roman_imsim/config/skyCatalog.yaml
edge_pix: 512
mjd: { type: ObSeqData, field: mjd }
exptime: { type: ObSeqData, field: exptime }
exptime: { type: ObSeqData, field: exptime }
obj_types: ['diffsky_galaxy','star','snana']

output:

nfiles: 1
dir: /lus/grand/projects/RomanDESC/roman_output/RomanWAS/images/truth
# dir: /lus/grand/projects/RomanDESC/roman_output/RomanWAS/images/truth
dir: /hpc/group/cosmology/yuedong/roman_output/RomanWAS/images/truth
file_name:
type: FormattedStr
format: "Roman_WAS_truth_%s_%i_%i.fits.gz"
Expand All @@ -140,7 +154,8 @@ output:
- '@image.SCA'

truth:
dir: /lus/grand/projects/RomanDESC/roman_output/RomanWAS/truth
# dir: /lus/grand/projects/RomanDESC/roman_output/RomanWAS/truth
dir: /hpc/group/cosmology/yuedong/roman_output/RomanWAS/truth
file_name:
type: FormattedStr
format: "Roman_WAS_index_%s_%i_%i.txt"
Expand Down
20 changes: 10 additions & 10 deletions roman_imsim/sca.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ def buildImage(self, config, base, image_num, obj_num, logger):
full_image.header = galsim.FitsHeader()
full_image.header['EXPTIME'] = self.exptime
full_image.header['MJD-OBS'] = self.mjd
full_image.header['DATE-OBS'] = str(Time(self.mjd,format='mjd').datetime)
full_image.header['DATE-OBS'] = Time(self.mjd,format='mjd').datetime.isoformat()
full_image.header['FILTER'] = self.filter
full_image.header['ZPTMAG'] = 2.5*np.log10(self.exptime*roman.collecting_area)

base['current_image'] = full_image

if 'image_pos' in config and 'world_pos' in config:
raise GalSimConfigValueError(
raise galsim.GalSimConfigValueError(
"Both image_pos and world_pos specified for Scattered image.",
(config['image_pos'], config['world_pos']))

Expand Down Expand Up @@ -215,8 +215,8 @@ def addNoise(self, image, config, base, image_num, obj_num, current_var, logger)
sky_level = roman.getSkyLevel(bp, world_pos=wcs.toWorld(image.true_center))
logger.debug('Adding sky_level = %s',sky_level)
if self.stray_light:
logger.debug('Stray light fraction = %s',stray_light_fraction)
sky_level *= (1.0 + stray_light_fraction)
logger.debug('Stray light fraction = %s',roman.stray_light_fraction)
sky_level *= (1.0 + roman.stray_light_fraction)
wcs.makeSkyImage(sky_image, sky_level)

# The other background is the expected thermal backgrounds in this band.
Expand Down Expand Up @@ -258,7 +258,7 @@ def addNoise(self, image, config, base, image_num, obj_num, current_var, logger)
roman.addReciprocityFailure(image)

if self.dark_current:
dc = dark_current * self.exptime
dc = roman.dark_current * self.exptime
logger.debug("Adding dark current: %s",dc)
sky_image += dc
dark_noise = galsim.noise.DeviateNoise(galsim.random.PoissonDeviate(rng, dc))
Expand All @@ -276,18 +276,18 @@ def addNoise(self, image, config, base, image_num, obj_num, current_var, logger)
roman.applyIPC(image)

if self.read_noise:
logger.debug("Adding read noise %s",read_noise)
image.addNoise(GaussianNoise(rng, sigma=read_noise))
logger.debug("Adding read noise %s", roman.read_noise)
image.addNoise(galsim.GaussianNoise(rng, sigma=roman.read_noise))

logger.debug("Applying gain %s",gain)
image /= gain
logger.debug("Applying gain %s",roman.gain)
image /= roman.gain

# Make integer ADU now.
image.quantize()

if self.sky_subtract:
logger.debug("Subtracting sky image")
sky_image /= gain
sky_image /= roman.gain
sky_image.quantize()
image -= sky_image

Expand Down