From 1f545aaee12a702ee0891a2097db12f44d507adf Mon Sep 17 00:00:00 2001 From: Yuedong Fang Date: Fri, 27 Sep 2024 17:17:49 -0400 Subject: [PATCH 1/4] minor fixes in sca.py for some noise options --- roman_imsim/sca.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/roman_imsim/sca.py b/roman_imsim/sca.py index 551ebbdf..73b61461 100644 --- a/roman_imsim/sca.py +++ b/roman_imsim/sca.py @@ -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. @@ -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)) @@ -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 From a250b3b466d7a806351261f08bd07f63baf12815 Mon Sep 17 00:00:00 2001 From: Yuedong Fang Date: Fri, 27 Sep 2024 17:18:29 -0400 Subject: [PATCH 2/4] add some config files --- config/skyCatalog.yaml | 147 +++++++++++++++++++++++++++++++++++++++++ config/was.yaml | 43 ++++++++---- 2 files changed, 176 insertions(+), 14 deletions(-) create mode 100644 config/skyCatalog.yaml diff --git a/config/skyCatalog.yaml b/config/skyCatalog.yaml new file mode 100644 index 00000000..36bbff9b --- /dev/null +++ b/config/skyCatalog.yaml @@ -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\d+).parquet + flux_file_template: galaxy_flux_(?P\d+).parquet + sed_file_template: galaxy_sed_(?P\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\d+).parquet + flux_file_template: galaxy_flux_(?P\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\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\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\d+).parquet + flux_file_template: pointsource_flux_(?P\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 diff --git a/config/was.yaml b/config/was.yaml index 61f1c5ef..8c9a1640 100644 --- a/config/was.yaml +++ b/config/was.yaml @@ -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 @@ -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" @@ -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" From 7b47d3c31a3d50dc597f4e99c83c995d51d8a630 Mon Sep 17 00:00:00 2001 From: Yuedong Fang Date: Fri, 4 Oct 2024 16:29:24 -0400 Subject: [PATCH 3/4] make DATE-OBS format match the FITS(ISO) standard --- roman_imsim/sca.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roman_imsim/sca.py b/roman_imsim/sca.py index 73b61461..98d796ac 100644 --- a/roman_imsim/sca.py +++ b/roman_imsim/sca.py @@ -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'] = str(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'])) From b5cb594c784ca09c0ba9d46787440fbd3b14c867 Mon Sep 17 00:00:00 2001 From: Yuedong Fang Date: Fri, 4 Oct 2024 16:57:00 -0400 Subject: [PATCH 4/4] remove str() casting --- roman_imsim/sca.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roman_imsim/sca.py b/roman_imsim/sca.py index 98d796ac..f5e59449 100644 --- a/roman_imsim/sca.py +++ b/roman_imsim/sca.py @@ -128,7 +128,7 @@ 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.isoformat()) + 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)