diff --git a/README.md b/README.md index da117f278e416b49342d6c698e6b25820793d835..02c46df1f7cfdaa6155da8d5931e853daf5c060e 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -Pipeline for source injection \ No newline at end of file +## Pipeline for source injection \ No newline at end of file diff --git a/SingleEpochImage.py b/SingleEpochImage.py deleted file mode 100644 index 62b2f768779baaf1473f3d2c464a7e3171d75d96..0000000000000000000000000000000000000000 --- a/SingleEpochImage.py +++ /dev/null @@ -1,202 +0,0 @@ -import numpy as np -import copy -from astropy import wcs -from astropy.io import fits -import galsim - -from ObservationSim.Instrument import Chip, Filter, FilterParam, FocalPlane, Telescope -from ObservationSim.PSF import PSFGauss, PSFInterp - -class SingleEpochImage(object): - - def __init__(self, config, filepath): - self.header0, self.header_img, self.img = self.read_initial_image(filepath) - self._get_wcs(self.header_img) - self._determine_unique_area(config) - self.output_img_fname = config['output_img_name'] - - if config['n_objects'] is not None: - # Fixed number of objects per image - self.objs_per_real = config['n_objects'] - elif config['object_density'] is not None: - # Fixed number density of objects - self.objs_per_real = round(self.u_area * config['object_density']) - else: - # Grid types: calculate nobjects later - self.objs_per_real = None - - self.tel = Telescope() - # Determine which CCD - self.chip_ID = int(self.header0['DETECTOR'][-2:]) - # Determine epxosure time - self.exp_time = float(self.header0['EXPTIME']) - config["obs_setting"]={} - config["obs_setting"]["exp_time"] = self.exp_time - # Construnct Chip object - self.chip = Chip(chipID=self.chip_ID, config=config) - # Load PSF model - if config["psf_setting"]["psf_model"] == "Gauss": - self.psf_model = PSFGauss(chip=self.chip) - elif config["psf_setting"]["psf_model"] == "Interp": - self.psf_model = PSFInterp(chip=self.chip, PSF_data_file=config["psf_setting"]["psf_dir"]) - - filter_id, filter_type = self.chip.getChipFilter() - filter_param = FilterParam() - self.filt = Filter(filter_id=filter_id, - filter_type=filter_type, - filter_param=filter_param) - self.focal_plane = FocalPlane() - - self.setup_image_for_injection() - - def setup_image_for_injection(self): - ra_cen = self.wcs.wcs.crval[0] - dec_cen = self.wcs.wcs.crval[1] - self.wcs_fp = self.focal_plane.getTanWCS(ra_cen, dec_cen, self.pos_ang*galsim.degrees, self.pixel_scale) - # self.inj_img = galsim.ImageF(self.chip.npix_x, self.chip.npix_y) - self.chip.img = galsim.Image(self.img, copy=True) - self.chip.img.setOrigin(self.chip.bound.xmin, self.chip.bound.ymin) - self.chip.img.wcs = self.wcs_fp - print(self.chip.img.array) - - def read_initial_image(self, filepath): - data = fits.open(filepath) - header0 = data[0].header - header1 = data[1].header - image = fits.getdata(filepath) - - # (TEMP) - image = np.float64(image) - image *= 1.1 - image -= 500. - - temp_img = galsim.Image(image, copy=True) - - temp_img.array[temp_img.array > 65535] = 65535 - temp_img.replaceNegative(replace_value=0) - temp_img.quantize() - temp_img = galsim.Image(temp_img.array, dtype=np.uint16) - # self.chip.img = galsim.Image(self.chip.img.array, dtype=np.int32) - hdu1 = fits.PrimaryHDU(header=header0) - hdu2 = fits.ImageHDU(temp_img.array, header=header1) - hdu1 = fits.HDUList([hdu1, hdu2]) - fname = "nullwt_image_for_injection.fits" - hdu1.writeto(fname, output_verify='ignore', overwrite=True) - return header0, header1, image - - def _get_wcs(self, header): - crpix1 = float(header['CRPIX1']) - crpix2 = float(header['CRPIX2']) - - crval1 = float(header['CRVAL1']) - crval2 = float(header['CRVAL2']) - - ctype1 = str(header['CTYPE1']) - ctype2 = str(header['CTYPE2']) - - cd1_1 = float(header['CD1_1']) - cd1_2 = float(header['CD1_2']) - cd2_1 = float(header['CD2_1']) - cd2_2 = float(header['CD2_2']) - self.pos_ang = float(header['POS_ANG']) - - # Create WCS object - self.wcs = wcs.WCS() - self.wcs.wcs.crpix = [crpix1, crpix2] - self.wcs.wcs.crval = [crval1, crval2] - self.wcs.wcs.ctype = [ctype1, ctype2] - self.wcs.wcs.cd = [[cd1_1, cd1_2], [cd2_1, cd2_2]] - - self.pixel_scale = 0.074 - self.Npix_x = int(header['NAXIS1']) - self.Npix_y = int(header['NAXIS2']) - - def _determine_unique_area(self, config): - coners = np.array([(1, 1), (1, self.Npix_y), (self.Npix_x, 1), (self.Npix_x, self.Npix_y)]) - coners = self.wcs.wcs_pix2world(coners, 1) - ra_coners = coners[:, 0] - dec_coners = coners[:, 1] - self.ramin, self.ramax = min(ra_coners), max(ra_coners) - self.decmin, self.decmax = min(dec_coners), max(dec_coners) - - if self.ramax - self.ramin > 1.: - self.ra_boundary_cross = True - else: - self.ra_boundary_cross = False - - d1, d2 = np.deg2rad([self.decmin, self.decmax]) - r1, r2 = self.ramin, self.ramax - - if self.ra_boundary_cross: - r2 = r2 + 360. - - # In deg^2 - a = (180. / np.pi) * (r2 - r1) * (np.sin(d2) - np.sin(d1)) - # Save in arcmin^2 - self.u_area = 3600. * a - - def inject_objects(self, pos, cat): - nobj = len(pos) - # Make sure we have enough objects to inject - assert nobj <= len(cat.objs) - - for i in range(nobj): - obj = cat.objs[i] - try: - sed_data = cat.load_sed(obj) - norm_filt = cat.load_norm_filt(obj) - obj.sed, obj.param["mag_%s"%self.filt.filter_type], obj.param["flux_%s"%self.filt.filter_type] = cat.convert_sed( - mag=obj.param["mag_use_normal"], - sed=sed_data, - target_filt=self.filt, - norm_filt=norm_filt) - except Exception as e: - print(e) - continue - - # Update object position to a point on grid - obj.param['ra'], obj.param['dec'] = pos[i][0], pos[i][1] - - pos_img, offset, local_wcs = obj.getPosImg_Offset_WCS(img=self.chip.img) - print(pos_img.x, pos_img.y) - try: - isUpdated, pos_shear = obj.drawObj_multiband( - tel=self.tel, - pos_img=pos_img, - psf_model=self.psf_model, - bandpass_list=self.filt.bandpass_sub_list, - filt=self.filt, - chip=self.chip, - g1=obj.g1, - g2=obj.g2, - exptime=self.exp_time) - if isUpdated: - # TODO: add up stats - # print("updating output catalog...") - print('Updated') - pass - else: - # print("object omitted", flush=True) - continue - except Exception as e: - print(e) - pass - # Unload SED: - obj.unload_SED() - del obj - - def save_injected_img(self): - self.chip.img.array[self.chip.img.array > 65535] = 65535 - self.chip.img.replaceNegative(replace_value=0) - self.chip.img.quantize() - self.chip.img = galsim.Image(self.chip.img.array, dtype=np.uint16) - # self.chip.img = galsim.Image(self.chip.img.array, dtype=np.int32) - hdu1 = fits.PrimaryHDU(header=self.header0) - hdu2 = fits.ImageHDU(self.chip.img.array, header=self.header_img) - hdu1 = fits.HDUList([hdu1, hdu2]) - # fname = 'test_inject.fits' - # fname = '20220621_test_injection.fits' - fname = self.output_img_fname - hdu1.writeto(fname, output_verify='ignore', overwrite=True) - - diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/config_injection.yaml b/config/config_injection.yaml similarity index 66% rename from config_injection.yaml rename to config/config_injection.yaml index 396c55ad502f0655834766e42d08f1d19fe0b54d..a25b31a8fc526811997493ec142fe921b4b7a190 100644 --- a/config_injection.yaml +++ b/config/config_injection.yaml @@ -5,15 +5,21 @@ # Last modified: 2022/06/19 # ############################################### -n_objects: 20 -rotate_objs: False +# n_objects: 500 +rotate_objs: NO +use_mpi: YES +run_name: "test_20230509" + pos_sampling: # type: "HexGrid" - type: "RectGrid" - grid_spacing: 74 # arcsec (~1000 pixels) + # type: "RectGrid" + # grid_spacing: 18.5 # arcsec (~250 pixels) + type: "uniform" + object_density: 50 # arcmin^-2 + +output_img_dir: "./workspace" +input_img_list: "/share/home/fangyuedong/injection_pipeline/input_L1_img_MSC_0000000.list" -# output_img_name: "test_HexGrid_20220628.fits" -output_img_name: "test_RectGrid_20220628.fits" ############################################### # PSF setting ############################################### @@ -31,14 +37,14 @@ psf_setting: # path to PSF data # NOTE: only valid for "Interp" PSF - psf_dir: "/data/simudata/CSSOSDataProductsSims/data/csstPSFdata/psfCube" + psf_dir: "/share/simudata/CSSOSDataProductsSims/data/psfCube1" ############################################### # Input path setting # (NOTE) Used NGP Catalog for testing ############################################### # Default path settings for NGP footprint simulation -data_dir: "/data/simudata/CSSOSDataProductsSims/data/" +data_dir: "/share/simudata/CSSOSDataProductsSims/data/" input_path: cat_dir: "OnOrbitCalibration/CTargets20211231" @@ -61,13 +67,13 @@ ins_effects: bright_fatter: ON # Whether to simulate Brighter-Fatter (also diffusion) effect # values - dark_exptime: 300 # Exposure time for dark current frames [seconds] - flat_exptime: 150 # Exposure time for flat-fielding frames [seconds] - readout_time: 40 # The read-out time for each channel [seconds] - df_strength: 2.3 # Sillicon sensor diffusion strength - bias_level: 500 # bias level [e-/pixel] - gain: 1.1 # Gain - full_well: 90000 # Full well depth [e-] + # dark_exptime: 300 # Exposure time for dark current frames [seconds] + # flat_exptime: 150 # Exposure time for flat-fielding frames [seconds] + # readout_time: 40 # The read-out time for each channel [seconds] + # df_strength: 2.3 # Sillicon sensor diffusion strength + # bias_level: 500 # bias level [e-/pixel] + # gain: 1.1 # Gain + # full_well: 90000 # Full well depth [e-] ############################################### # Random seeds diff --git a/config/default.config b/config/default.config new file mode 100644 index 0000000000000000000000000000000000000000..cb2d0f91b7ded9b67299dab175c5db448a1cfddf --- /dev/null +++ b/config/default.config @@ -0,0 +1,90 @@ +# Default configuration file for SExtractor 2.25.0 +# EB 2019-10-03 +# + +#-------------------------------- Catalog ------------------------------------ + +CATALOG_NAME test.cat # name of the output catalog +CATALOG_TYPE FITS_1.0 # NONE,ASCII,ASCII_HEAD, ASCII_SKYCAT, + # ASCII_VOTABLE, FITS_1.0 or FITS_LDAC +PARAMETERS_NAME default.param # name of the file containing catalog contents + +#------------------------------- Extraction ---------------------------------- + +DETECT_TYPE CCD # CCD (linear) or PHOTO (with gamma correction) +DETECT_MINAREA 3 # min. # of pixels above threshold +DETECT_THRESH 1.5 # or , in mag.arcsec-2 +ANALYSIS_THRESH 1.5 # or , in mag.arcsec-2 +THRESH_TYPE RELATIVE + +FILTER Y # apply filter for detection (Y or N)? +FILTER_NAME ../measurement_pipeline/data/default.conv # name of the file containing the filter + +DEBLEND_NTHRESH 64 # Number of deblending sub-thresholds +DEBLEND_MINCONT 0.0005 # Minimum contrast parameter for deblending + +CLEAN Y # Clean spurious detections? (Y or N)? +CLEAN_PARAM 1.0 # Cleaning efficiency + +MASK_TYPE CORRECT # type of detection MASKing: can be one of + # NONE, BLANK or CORRECT + +#------------------------------ Flagging ----------------------------------- +#FLAG_TYPE OR + +#------------------------------ Photometry ----------------------------------- + +PHOT_APERTURES 5 # MAG_APER aperture diameter(s) in pixels +PHOT_AUTOPARAMS 2.5, 3.5 # MAG_AUTO parameters: , +PHOT_PETROPARAMS 2.0, 3.5 # MAG_PETRO parameters: , + # + +SATUR_LEVEL 50000.0 # level (in ADUs) at which arises saturation +SATUR_KEY SATURATE # keyword for saturation level (in ADUs) + +MAG_ZEROPOINT 0.0 # magnitude zero-point +#MAG_GAMMA 4.0 # gamma of emulsion (for photographic scans) +GAIN 1.0 # detector gain in e-/ADU +#GAIN_KEY GAIN # keyword for detector gain in e-/ADU +PIXEL_SCALE 0 # size of pixel in arcsec (0=use FITS WCS info) + +#------------------------- Star/Galaxy Separation ---------------------------- + +SEEING_FWHM 0.15 # stellar FWHM in arcsec +STARNNW_NAME ../measurement_pipeline/data/default.nnw # Neural-Network_Weight table filename + +#------------------------------ Background ----------------------------------- + +BACK_TYPE AUTO +BACK_SIZE 400 # Background mesh: or , +BACK_FILTERSIZE 3 # Background filter: or , + +BACKPHOTO_TYPE GLOBAL # can be GLOBAL or LOCAL + +#------------------------------ Check Image ---------------------------------- + +CHECKIMAGE_TYPE NONE # can be NONE, BACKGROUND, BACKGROUND_RMS, + # MINIBACKGROUND, MINIBACK_RMS, -BACKGROUND, + # FILTERED, OBJECTS, -OBJECTS, SEGMENTATION, + # or APERTURES +CHECKIMAGE_NAME ../check.fits # Filename for the check-image + +#--------------------- Memory (change with caution!) ------------------------- + +MEMORY_OBJSTACK 3000 # number of objects in stack +MEMORY_PIXSTACK 300000 # number of pixels in stack +MEMORY_BUFSIZE 1024 # number of lines in buffer + +#----------------------------- Miscellaneous --------------------------------- + +VERBOSE_TYPE NORMAL # can be QUIET, NORMAL or FULL +HEADER_SUFFIX .head # Filename extension for additional headers +WRITE_XML N # Write XML file (Y/N)? +XML_NAME sex.xml # Filename for XML output + +#------------------------------ Weighting ----------------------------------- +#WEIGHT_TYPE MAP_WEIGHT +#RESCALE_WEIGHTS Y +#WEIGHT_IMAGE weight.fits +#WEIGHT_GAIN N +#WEIGHT_THRESH 1e-7 diff --git a/config/default.param b/config/default.param new file mode 100644 index 0000000000000000000000000000000000000000..02de5fc47ac52b1773864227383ebf4cf8c67610 --- /dev/null +++ b/config/default.param @@ -0,0 +1,67 @@ +# ID and flags +NUMBER +FLAGS +# Basic coordinates +X_IMAGE +Y_IMAGE +XMIN_IMAGE +XMAX_IMAGE +YMIN_IMAGE +YMAX_IMAGE +# Accurate coordinates +XWIN_IMAGE +YWIN_IMAGE +ERRAWIN_IMAGE +ERRBWIN_IMAGE +ERRTHETAWIN_IMAGE +ALPHAWIN_J2000 +DELTAWIN_J2000 +ERRAWIN_WORLD +ERRBWIN_WORLD +ERRTHETAWIN_J2000 +# Peak value +XPEAK_IMAGE +YPEAK_IMAGE +ALPHAPEAK_J2000 +DELTAPEAK_J2000 +# Basic shape info +A_IMAGE +B_IMAGE +THETA_IMAGE +A_WORLD +B_WORLD +THETA_J2000 +ELONGATION +FLUX_RADIUS +# Isophotal photometry +#FLUX_ISO +#FLUXERR_ISO +MAG_ISO +MAGERR_ISO +ISOAREA_IMAGE +ISOAREAF_IMAGE +ISOAREA_WORLD +ISOAREAF_WORLD +# Aperture photometry +FLUX_APER(1) +FLUXERR_APER(1) +MAG_APER(1) +MAGERR_APER(1) +# Kron photometry +FLUX_AUTO +FLUXERR_AUTO +MAG_AUTO +MAGERR_AUTO +KRON_RADIUS +# Petrosian photometry +#FLUX_PETRO +#FLUXERR_PETRO +MAG_PETRO +MAGERR_PETRO +PETRO_RADIUS +# Basic surface brightnesses +BACKGROUND +THRESHOLD +MU_THRESHOLD +FLUX_MAX +MU_MAX \ No newline at end of file diff --git a/config/sex.config b/config/sex.config new file mode 100644 index 0000000000000000000000000000000000000000..edc7d11efed2d27885b7cb22265237b3b63b870e --- /dev/null +++ b/config/sex.config @@ -0,0 +1,80 @@ +# Default configuration file for SExtractor 2.25.0 +# EB 2019-10-03 +# + +#-------------------------------- Catalog ------------------------------------ + +CATALOG_NAME test.cat # name of the output catalog +CATALOG_TYPE ASCII_HEAD # NONE,ASCII,ASCII_HEAD, ASCII_SKYCAT, + # ASCII_VOTABLE, FITS_1.0 or FITS_LDAC +PARAMETERS_NAME ./sex.param_sersic # name of the file containing catalog contents + +#------------------------------- Extraction ---------------------------------- + +DETECT_TYPE CCD # CCD (linear) or PHOTO (with gamma correction) +DETECT_MINAREA 5 # min. # of pixels above threshold +DETECT_THRESH 1.5 # or , in mag.arcsec-2 +ANALYSIS_THRESH 1.5 # or , in mag.arcsec-2 + +FILTER Y # apply filter for detection (Y or N)? +FILTER_NAME ./default.conv # name of the file containing the filter + +DEBLEND_NTHRESH 32 # Number of deblending sub-thresholds +DEBLEND_MINCONT 0.005 # Minimum contrast parameter for deblending + +CLEAN Y # Clean spurious detections? (Y or N)? +CLEAN_PARAM 1.0 # Cleaning efficiency + +MASK_TYPE CORRECT # type of detection MASKing: can be one of + # NONE, BLANK or CORRECT + +#------------------------------ Photometry ----------------------------------- +PHOT_APERTURES 1.85 3.70 5.55 7.41 11.11 14.81 18.52 22.22 25.93 31.00 44.44 66.67 # MAG_APER aperture diameter(s) in pixels +#PHOT_APERTURES 5 # MAG_APER aperture diameter(s) in pixels +PHOT_AUTOPARAMS 2.5, 3.5 # MAG_AUTO parameters: , +PHOT_PETROPARAMS 2.0, 3.5 # MAG_PETRO parameters: , + # + +SATUR_LEVEL 50000.0 # level (in ADUs) at which arises saturation +SATUR_KEY SATURATE # keyword for saturation level (in ADUs) + +MAG_ZEROPOINT 0.0 # magnitude zero-point +MAG_GAMMA 4.0 # gamma of emulsion (for photographic scans) +GAIN 1.0 # detector gain in e-/ADU +GAIN_KEY GAIN # keyword for detector gain in e-/ADU +PIXEL_SCALE 1.0 # size of pixel in arcsec (0=use FITS WCS info) + +#-----------------Model-Fitting Photometry------------------------------------- +# PSF_NMAX 1 + +#------------------------- Star/Galaxy Separation ---------------------------- + +SEEING_FWHM 0.15 # stellar FWHM in arcsec +STARNNW_NAME ./default.nnw # Neural-Network_Weight table filename + +#------------------------------ Background ----------------------------------- + +BACK_SIZE 256 # Background mesh: or , +BACK_FILTERSIZE 3 # Background filter: or , + +BACKPHOTO_TYPE GLOBAL # can be GLOBAL or LOCAL + +#------------------------------ Check Image ---------------------------------- + +CHECKIMAGE_TYPE BACKGROUND # can be NONE, BACKGROUND, BACKGROUND_RMS, + # MINIBACKGROUND, MINIBACK_RMS, -BACKGROUND, + # FILTERED, OBJECTS, -OBJECTS, SEGMENTATION, + # or APERTURES +CHECKIMAGE_NAME check.fits # Filename for the check-image + +#--------------------- Memory (change with caution!) ------------------------- + +MEMORY_OBJSTACK 3000 # number of objects in stack +MEMORY_PIXSTACK 300000 # number of pixels in stack +MEMORY_BUFSIZE 1024 # number of lines in buffer + +#----------------------------- Miscellaneous --------------------------------- + +VERBOSE_TYPE NORMAL # can be QUIET, NORMAL or FULL +HEADER_SUFFIX .head # Filename extension for additional headers +WRITE_XML N # Write XML file (Y/N)? diff --git a/config/sex.param_sersic b/config/sex.param_sersic new file mode 100644 index 0000000000000000000000000000000000000000..3113a4dace9d778fa79858b48b02063473b6ee38 --- /dev/null +++ b/config/sex.param_sersic @@ -0,0 +1,174 @@ +# ID and flags +NUMBER +FLAGS +# Basic coordinates +X_IMAGE +Y_IMAGE +XMIN_IMAGE +XMAX_IMAGE +YMIN_IMAGE +YMAX_IMAGE +# Accurate coordinates +XWIN_IMAGE +YWIN_IMAGE +ERRAWIN_IMAGE +ERRBWIN_IMAGE +ERRTHETAWIN_IMAGE +ALPHAWIN_J2000 +DELTAWIN_J2000 +ERRAWIN_WORLD +ERRBWIN_WORLD +ERRTHETAWIN_J2000 +# Peak value +XPEAK_IMAGE +YPEAK_IMAGE +ALPHAPEAK_J2000 +DELTAPEAK_J2000 +# Basic shape info +A_IMAGE +B_IMAGE +THETA_IMAGE +A_WORLD +B_WORLD +THETA_J2000 +ELONGATION +FLUX_RADIUS +# Isophotal photometry +#FLUX_ISO +#FLUXERR_ISO +MAG_ISO +MAGERR_ISO +ISOAREA_IMAGE +ISOAREAF_IMAGE +ISOAREA_WORLD +ISOAREAF_WORLD +# Aperture photometry +FLUX_APER(12) +FLUXERR_APER(12) +MAG_APER(12) +MAGERR_APER(12) +# Kron photometry +FLUX_AUTO +FLUXERR_AUTO +MAG_AUTO +MAGERR_AUTO +KRON_RADIUS +# Petrosian photometry +#FLUX_PETRO +#FLUXERR_PETRO +MAG_PETRO +MAGERR_PETRO +PETRO_RADIUS +#hybrid magnitudes +MAG_HYBRID +MAGERR_HYBRID +# Basic surface brightnesses +BACKGROUND +THRESHOLD +MU_THRESHOLD +FLUX_MAX +MU_MAX +# PSF fitting +#XPSF_IMAGE +#YPSF_IMAGE +#ERRAPSF_IMAGE +#ERRBPSF_IMAGE +#ERRTHETAPSF_IMAGE +#ALPHAPSF_J2000 +#DELTAPSF_J2000 +#ERRAPSF_WORLD +#ERRBPSF_WORLD +#ERRTHETAPSF_J2000 +#FLUX_PSF +#FLUXERR_PSF +#MAG_PSF +#MAGERR_PSF +#NITER_PSF +#CHI2_PSF +# Model fitting coordinates +XMODEL_IMAGE +YMODEL_IMAGE +ERRAMODEL_IMAGE +ERRBMODEL_IMAGE +ERRTHETAMODEL_IMAGE +ALPHAMODEL_J2000 +DELTAMODEL_J2000 +ERRAMODEL_WORLD +ERRBMODEL_WORLD +ERRTHETAMODEL_J2000 +# Global shape measurements from model fitting +AMODEL_IMAGE +BMODEL_IMAGE +THETAMODEL_IMAGE +AMODEL_WORLD +BMODEL_WORLD +THETAMODEL_J2000 +# Shear measurements from model fitting +ELLIP1MODEL_IMAGE +ELLIP2MODEL_IMAGE +ELLIP1MODEL_WORLD +ELLIP2MODEL_WORLD +# Global model-fitting photometry +FLUX_MODEL +FLUXERR_MODEL +MAG_MODEL +MAGERR_MODEL +#FLUX_MAX_MODEL +#FLUX_EFF_MODEL +#FLUX_MEAN_MODEL +MU_MAX_MODEL +MU_EFF_MODEL +MU_MEAN_MODEL +# Spheroid model component +#FLUX_SPHEROID +#FLUXERR_SPHEROID +MAG_SPHEROID +MAGERR_SPHEROID +SPHEROID_REFF_IMAGE +SPHEROID_REFFERR_IMAGE +SPHEROID_REFF_WORLD +SPHEROID_REFFERR_WORLD +SPHEROID_ASPECT_IMAGE +SPHEROID_ASPECTERR_IMAGE +SPHEROID_ASPECT_WORLD +SPHEROID_ASPECTERR_WORLD +SPHEROID_THETA_IMAGE +SPHEROID_THETAERR_IMAGE +SPHEROID_THETA_J2000 +SPHEROID_THETAERR_WORLD +SPREAD_MODEL +SPREADERR_MODEL +CLASS_STAR +# Model fitting info +CHI2_MODEL +NITER_MODEL +#new ones +FLAGS_WEIGHT +NLOWWEIGHT_ISO +NLOWDWEIGHT_ISO +# +SPHEROID_SERSICN +SPHEROID_SERSICNERR +#FWHMPSF_IMAGE +#FWHMPSF_WORLD + + +# added 08/30/2011 per new coadd_objects table def +ELLIP1ERRMODEL_WORLD +ELLIP2ERRMODEL_WORLD +ELLIPCORRMODEL_WORLD +ELLIPTICITY +ERRA_IMAGE +ERRB_IMAGE +ERRTHETA_IMAGE +ERRX2_WORLD +ERRXY_WORLD +ERRY2_WORLD +FLAGS_MODEL +FWHM_WORLD +X2_WORLD +XY_WORLD +Y2_WORLD +# added on feb 27 2015 after SE cataloging is also done like in dual image mode +MAG_DETMODEL +MAGERR_DETMODEL \ No newline at end of file diff --git a/evaluation/cross_match_catalogs.py b/evaluation/cross_match_catalogs.py new file mode 100644 index 0000000000000000000000000000000000000000..b00dd2941309953f6fbc2e557e24a686e24f5092 --- /dev/null +++ b/evaluation/cross_match_catalogs.py @@ -0,0 +1,77 @@ +import numpy as np +import astropy.units as u +import matplotlib.pyplot as plt +from astropy.coordinates import SkyCoord +from astropy.io import fits +from astropy.io import ascii +from sklearn.neighbors import BallTree + +# TU_catalog = "test_RectGrid_20220628.cat" +# source_catalog = "extracted_test_RectGrid_20220628.fits" +TU_catalog = "injected_bkgsub_img.cat" +source_catalog = "extracted_injected_bkgsub_img.fits" + +def convert_catalog(catname): + text_file = ascii.read(catname) + text_file.write('test_ascii_to_fits.fits', overwrite=True) + +def read_catalog(catname, ext_num=1, ra_name='ra', dec_name='dec', col_list=[]): + hdu = fits.open(catname) + hdr = hdu[ext_num].header + # print(hdr) + data = hdu[ext_num].data + ra = data[ra_name] + dec = data[dec_name] + col_other = [] + if len(col_list) > 0: + for col in col_list: + col_other.append(data[col]) + # print(ra, dec) + return ra, dec, col_other + +def match_catalogs_sky(ra1, dec1, ra2, dec2, max_dist=0.6, others1=[], others2=[], thresh=[]): + cat1 = SkyCoord(ra=ra1*u.degree, dec=dec1*u.degree) + cat2 = SkyCoord(ra=ra2*u.degree, dec=dec2*u.degree) + idx1, idx2, d2d, d3d = cat2.search_around_sky(cat1, 1*u.deg) + # print(idx1) + # print(idx2) + # print(np.shape(idx1)) + # print(np.shape(idx2)) + +def match_catalogs_img(x1, y1, x2, y2, max_dist=0.5, others1=[], others2=[], thresh=[]): + cat1 = np.array([(x, y) for x,y in zip(x1, y1)]) + cat2 = np.array([(x, y) for x,y in zip(x2, y2)]) + print(np.shape(cat1)) + print(np.shape(cat2)) + tree = BallTree(cat2) + idx1 = tree.query_radius(cat1, r = max_dist) + tree = BallTree(cat1) + idx2 = tree.query_radius(cat2, r = max_dist) + # print(np.shape(idx1)) + tot = 0 + print(idx1) + for idx in idx1: + if len(idx) == 0: + continue + tot += 1 + print(tot) + return idx1, idx2 + +def validation_hist(val1, idx1, name="val1", nbins=10): + counts, bins = np.histogram(val1) + plt.stairs(bins, counts) + plt.xlabel(name, size='x-large') + plt.savefig("detection_completeness.png") + # plt.show() + +if __name__=="__main__": + convert_catalog(TU_catalog) + ra_TU, dec_TU, _ = read_catalog('test_ascii_to_fits.fits', ext_num=1, ra_name="ra", dec_name="dec") + x_TU, y_TU, col_list = read_catalog('test_ascii_to_fits.fits', ext_num=1, ra_name="xImage", dec_name="yImage", col_list=["mag"]) + mag_TU = col_list[0] + # ra_source, dec_source, _ = read_catalog(source_catalog, ext_num=2, ra_name="ALPHAPEAK_J2000", dec_name="DELTAPEAK_J2000") + x_source, y_source, _ = read_catalog(source_catalog, ext_num=1, ra_name="X_IMAGE", dec_name="Y_IMAGE") + # match_catalogs_sky(ra1=ra_TU, dec1=dec_TU, ra2=ra_source, dec2=dec_source) + idx1, idx2, = match_catalogs_img(x1=x_TU, y1=y_TU, x2=x_source, y2=y_source) + # print(ra_TU, dec_TU) + validation_hist(mag_TU, idx1, name="mag_injected") \ No newline at end of file diff --git a/injection_pipeline.py b/injection_pipeline.py deleted file mode 100644 index bd692510f7b999e5171ce5daf7ddcb4c6211ba9e..0000000000000000000000000000000000000000 --- a/injection_pipeline.py +++ /dev/null @@ -1,37 +0,0 @@ -from astropy.io import fits -from astropy import wcs -import galsim -import os -import yaml - -from SingleEpochImage import SingleEpochImage -from InjectionCatalog import InjectionCatalog -from InputCatalogs import SimCat -from Grid import RectGrid -from config import parse_args - -# img_file = 'CSST_MSC_MS_SCI_20240617065639_20240617065909_100000000_24_L0_1.fits' -img_file = 'CSST_MSC_MS_SCI_20240617065639_20240617065909_100000000_23_L0_1.fits' # null-weight test image - -args = parse_args() -if args.config_dir is None: - args.config_dir = '' -args.config_dir = os.path.abspath(args.config_dir) -args.config_file = os.path.join(args.config_dir, args.config_file) -print(args.config_file) -with open(args.config_file, "r") as stream: - try: - config = yaml.safe_load(stream) - for key, value in config.items(): - print (key + " : " + str(value)) - except yaml.YAMLError as exc: - print(exc) - -image = SingleEpochImage(config=config, filepath=img_file) -# print(image.ramin, image.ramax, image.u_area, image.ra_boundary_cross) -inject_cat = InjectionCatalog(image=image) -inject_cat.generate_positions(config=config) -input_cat = SimCat(config=config, chip=image.chip, nobjects=inject_cat.nobjects) -print(inject_cat.pos, inject_cat.nobjects) -image.inject_objects(pos=inject_cat.pos, cat=input_cat) -image.save_injected_img() \ No newline at end of file diff --git a/InputCatalogs.py b/injection_pipeline/Catalog/C5_SimCat.py similarity index 96% rename from InputCatalogs.py rename to injection_pipeline/Catalog/C5_SimCat.py index 35f69a22945f077fc7224acbab3aa3ab1c354d97..4e90b828ef306d8dc528e34bbcbd13a144de5540 100644 --- a/InputCatalogs.py +++ b/injection_pipeline/Catalog/C5_SimCat.py @@ -58,23 +58,25 @@ class SimCat(CatalogBase): def _load_gals(self, gals, pix_id=None, nobjects=None): # Load how mnay objects? + max_ngals = len(gals) if nobjects is None: - ngals = 5000 + ngals = max_ngals else: ngals = nobjects self.rng_sedGal = random.Random() self.rng_sedGal.seed(pix_id) # Use healpix index as the random seed self.ud = galsim.UniformDeviate(pix_id) - for igals in range(ngals): + for i in range(ngals): param = self.initialize_param() + igals = ngals % max_ngals param['ra'] = gals['ra_true'][igals] param['dec'] = gals['dec_true'][igals] - # param['mag_use_normal'] = gals['mag_true_g_lsst'][igals] + param['mag_use_normal'] = gals['mag_true_g_lsst'][igals] # (TEST) use same magnitude # (there will be slight difference due to randomness in SED) - param['mag_use_normal'] = 18 + # param['mag_use_normal'] = 21 param['z'] = gals['redshift_true'][igals] param['model_tag'] = 'None' diff --git a/Grid.py b/injection_pipeline/Grid.py similarity index 100% rename from Grid.py rename to injection_pipeline/Grid.py diff --git a/InjectionCatalog.py b/injection_pipeline/InjectionCatalog.py similarity index 97% rename from InjectionCatalog.py rename to injection_pipeline/InjectionCatalog.py index 8010065548c9174db07d7ecb84ebda94367d2784..74d61d4152d54f62c024acc1001663a35d49f6f7 100644 --- a/InjectionCatalog.py +++ b/injection_pipeline/InjectionCatalog.py @@ -7,12 +7,13 @@ import mathutil as util class InjectionCatalog(object): def __init__(self, image): - self.rmin, self.rmax = image.ramin, image.ramax + self.ramin, self.ramax = image.ramin, image.ramax self.decmin, self.decmax = image.decmin, image.decmax self.ra_boundary_cross = image.ra_boundary_cross self.Npix_x, self.Npix_y = image.Npix_x, image.Npix_y self.pixel_scale = image.pixel_scale self.wcs = image.wcs + print(self.wcs) # This is also set for a given image, as it may depend on its area self.objs_per_real = image.objs_per_real @@ -119,6 +120,3 @@ class InjectionCatalog(object): angle_unit=self.angle_unit, pos_offset=self.grid_offset) return grid_kwargs - - def get_truth_outfile(self): - pass diff --git a/Injector.py b/injection_pipeline/Injector.py similarity index 100% rename from Injector.py rename to injection_pipeline/Injector.py diff --git a/injection_pipeline/SingleEpochImage.py b/injection_pipeline/SingleEpochImage.py new file mode 100644 index 0000000000000000000000000000000000000000..4a003ad1b63fcf7a5c8e195dba6228e8a7a0afd7 --- /dev/null +++ b/injection_pipeline/SingleEpochImage.py @@ -0,0 +1,237 @@ +import numpy as np +import copy +import os +import galsim +import traceback +from astropy import wcs +from astropy.io import fits + +from ObservationSim.Config.Header import generatePrimaryHeader, generateExtensionHeader +from ObservationSim.Instrument import Chip, Filter, FilterParam, FocalPlane, Telescope +from ObservationSim.PSF import PSFGauss, PSFInterp, FieldDistortion +from ObservationSim.Config import ChipOutput + +class SingleEpochImage(object): + + def __init__(self, config, input_img_path, output_img_path): + # Read the origianl image file + self.config = config + self.read_initial_image(input_img_path) + self._get_wcs(self.header_img) + self._determine_unique_area(config) + self.output_img_fname = output_img_path + self.output_dir = os.path.dirname(output_img_path) + + if 'n_objects' in self.config["pos_sampling"] and self.config["pos_sampling"]['n_objects'] is not None: + # Fixed number of objects per image + self.objs_per_real = self.config["pos_sampling"]['n_objects'] + elif 'object_density' in self.config["pos_sampling"] and self.config["pos_sampling"]['object_density'] is not None: + # Fixed number density of objects + self.objs_per_real = round(self.u_area * self.config["pos_sampling"]['object_density']) + else: + # Grid types: calculate nobjects later + self.objs_per_real = None + + self.tel = Telescope() + + # Setup field distortion model: + if ("field_dist" in self.config) and (self.config["ins_effects"]["field_dist"] == True): + self.fd_model = FieldDistortion(chip=chip) + else: + self.fd_model = None + + # Load PSF model + if self.config["psf_setting"]["psf_model"] == "Gauss": + self.psf_model = PSFGauss(chip=self.chip, psfRa=self.config["psf_setting"]["psf_rcont"]) + elif self.config["psf_setting"]["psf_model"] == "Interp": + self.psf_model = PSFInterp(chip=self.chip, npsf=self.chip.n_psf_samples, PSF_data_file=self.config["psf_setting"]["psf_dir"]) + + # Setup Filter + filter_id, filter_type = self.chip.getChipFilter() + filter_param = FilterParam() + self.filt = Filter(filter_id=filter_id, + filter_type=filter_type, + filter_param=filter_param) + self.focal_plane = FocalPlane() + + self.setup_image_for_injection() + + self.header_ext = generateExtensionHeader( + chip=self.chip, + xlen=self.chip.npix_x, + ylen=self.chip.npix_y, + ra=self.ra_cen, + dec=self.dec_cen, + pa=self.pos_ang, + gain=self.chip.gain, # {TODO} + readout=self.chip.read_noise, + dark=self.chip.dark_noise, + saturation=90000, + pixel_scale=self.chip.pix_scale, + pixel_size=self.chip.pix_size, + xcen=self.chip.x_cen, + ycen=self.chip.y_cen, + extName = 'raw') + + # (TODO) specify sub-directory + self.chip_output = ChipOutput( + config = config, + focal_plane = self.focal_plane, + chip = self.chip, + filt = self.filt, + ra_cen = self.ra_cen, + dec_cen = self.dec_cen, + exptime = self.exp_time, + subdir = self.output_dir, + ) + # temp_str = config["output_img_name"].split('.')[0] + ".cat" + temp_str = self.output_img_fname.split('/')[-1].split('.')[0] + '.cat' + self.chip_output.cat_name = temp_str + self.chip_output.create_output_file() + + def setup_image_for_injection(self): + self.ra_cen = self.wcs.wcs.crval[0] + self.dec_cen = self.wcs.wcs.crval[1] + self.wcs_fp = self.focal_plane.getTanWCS(self.ra_cen, self.dec_cen, self.pos_ang*galsim.degrees, self.pixel_scale) + self.chip.img = galsim.Image(self.image, copy=True) + self.chip.img.setOrigin(self.chip.bound.xmin, self.chip.bound.ymin) + self.chip.img.wcs = self.wcs_fp + + def read_initial_image(self, filepath): + data_dir = os.path.dirname(filepath) + img_name = os.path.basename(filepath) + data = fits.open(filepath) + self.header0 = data[0].header + self.header_img = data[1].header + self.image = fits.getdata(filepath) + + # Determine which CCD + self.chip_ID = int(self.header0['DETECTOR'][-2:]) + # Construnct Chip object + self.chip = Chip(chipID=self.chip_ID, config=self.config) + self.exp_time = float(self.header0 ['EXPTIME']) + + # Process L1 image + self.image = self.image * self.exp_time / self.chip.gain + + # Process L1 SKY image + # [TODO] + # sky_img_path = "CSST_MSC_MS_SCI_20240617065639_20240617065909_100000020_08_sky.fits" + # sky_img = fits.getdata(sky_img_path) + # sky_img = sky_img * self.exp_time / self.chip.gain + # image -= sky_img + + # Process L1 FLAG image + flag_img_path = os.path.join(data_dir, img_name.replace("img_L1", "flg_L1")) + flag_img = fits.getdata(flag_img_path) + self.image[flag_img > 0] = 0. + + # Process L1 WEIGHT image + # [TODO] + + # Save null weight image + # hdu1 = fits.PrimaryHDU(header=header0) + # hdu2 = fits.ImageHDU(image, header=header1) + # hdu1 = fits.HDUList([hdu1, hdu2]) + # fname = "nullwt_image_for_injection.fits" + # hdu1.writeto(fname, output_verify='ignore', overwrite=True) + + def _get_wcs(self, header): + self.pos_ang = float(header['POS_ANG']) + self.wcs = wcs.WCS(header) + + self.pixel_scale = 0.074 + self.Npix_x = int(header['NAXIS1']) + self.Npix_y = int(header['NAXIS2']) + + def _determine_unique_area(self, config): + coners = np.array([(1, 1), (1, self.Npix_y), (self.Npix_x, 1), (self.Npix_x, self.Npix_y)]) + coners = self.wcs.wcs_pix2world(coners, 1) + ra_coners = coners[:, 0] + dec_coners = coners[:, 1] + self.ramin, self.ramax = min(ra_coners), max(ra_coners) + self.decmin, self.decmax = min(dec_coners), max(dec_coners) + + if self.ramax - self.ramin > 1.: + self.ra_boundary_cross = True + else: + self.ra_boundary_cross = False + + d1, d2 = np.deg2rad([self.decmin, self.decmax]) + r1, r2 = self.ramin, self.ramax + + if self.ra_boundary_cross: + r2 = r2 + 360. + + # In deg^2 + a = (180. / np.pi) * (r2 - r1) * (np.sin(d2) - np.sin(d1)) + # Save in arcmin^2 + self.u_area = 3600. * a + + def inject_objects(self, pos, cat): + nobj = len(pos) + # Make sure we have enough objects to inject + assert nobj <= len(cat.objs) + + for i in range(nobj): + obj = cat.objs[i] + try: + sed_data = cat.load_sed(obj) + norm_filt = cat.load_norm_filt(obj) + obj.sed, obj.param["mag_%s"%self.filt.filter_type], obj.param["flux_%s"%self.filt.filter_type] = cat.convert_sed( + mag=obj.param["mag_use_normal"], + sed=sed_data, + target_filt=self.filt, + norm_filt=norm_filt) + except Exception as e: + traceback.print_exc() + continue + + # Update object position to a point on grid + obj.param['ra'], obj.param['dec'] = pos[i][0], pos[i][1] + self.chip_output.Log_info("ra = %.3f, dec = %.3f"%(obj.param['ra'], obj.param['dec'])) + pos_img, offset, local_wcs, real_wcs, fd_shear = obj.getPosImg_Offset_WCS(img=self.chip.img, fdmodel=self.fd_model, chip=self.chip, verbose=False, img_header=self.header_ext) + self.chip_output.Log_info("pos_img_x = %.3f, pos_img_y = %.3f"%(pos_img.x, pos_img.y)) + try: + isUpdated, pos_shear = obj.drawObj_multiband( + tel=self.tel, + pos_img=pos_img, + psf_model=self.psf_model, + bandpass_list=self.filt.bandpass_sub_list, + filt=self.filt, + chip=self.chip, + g1=obj.g1, + g2=obj.g2, + exptime=self.exp_time) + if isUpdated: + # TODO: add up stats + # self.chip_output.Log_info("updating output catalog...") + self.chip_output.cat_add_obj(obj, pos_img, pos_shear) + pass + else: + self.chip_output.Log_info("object omitted") + continue + except Exception as e: + traceback.print_exc() + pass + # Unload SED: + obj.unload_SED() + del obj + + def add_to_truth_cat(self): + pass + + def save_injected_img(self): + self.chip.img = galsim.Image(self.chip.img.array, dtype=np.float32) + + # [TODO] TEST + self.chip.img *= self.gain + self.chip.img /= self.exp_time + + hdu1 = fits.PrimaryHDU(header=self.header0) + hdu2 = fits.ImageHDU(self.chip.img.array, header=self.header_img) + hdu1 = fits.HDUList([hdu1, hdu2]) + fname = self.output_img_fname + hdu1.writeto(fname, output_verify='ignore', overwrite=True) + + diff --git a/injection_pipeline/__init__.py b/injection_pipeline/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/config.py b/injection_pipeline/config.py similarity index 100% rename from config.py rename to injection_pipeline/config.py diff --git a/injection_pipeline/injection_pipeline.py b/injection_pipeline/injection_pipeline.py new file mode 100644 index 0000000000000000000000000000000000000000..5e04f9815171ee73dabb9a6ed2ddf4f0de899321 --- /dev/null +++ b/injection_pipeline/injection_pipeline.py @@ -0,0 +1,68 @@ +from astropy.io import fits +from astropy import wcs +import mpi4py.MPI as MPI +import galsim +import os +import yaml + +from SingleEpochImage import SingleEpochImage +from InjectionCatalog import InjectionCatalog +from Catalog.C5_SimCat import SimCat +from Grid import RectGrid +from config import parse_args + +class InjectionPipeline(object): + + def __init__(self): + # Load configuration + args = parse_args() + if args.config_dir is None: + args.config_dir = '' + args.config_dir = os.path.abspath(args.config_dir) + args.config_file = os.path.join(args.config_dir, args.config_file) + with open(args.config_file, "r") as stream: + try: + self.config = yaml.safe_load(stream) + for key, value in self.config.items(): + print (key + " : " + str(value)) + except yaml.YAMLError as exc: + print(exc) + # Read the input image paths + with open(self.config["input_img_list"]) as input_list: + self.img_list = [line.rstrip() for line in input_list] + + # Prepare the output directory + if not os.path.exists(self.config["output_img_dir"]): + os.makedirs(self.config["output_img_dir"]) + + self.output_dir = os.path.join(self.config["output_img_dir"], self.config["run_name"]) + if not os.path.exists(self.output_dir): + os.makedirs(self.output_dir) + + def run_injection_img_list(self, Catalog): + if self.config["use_mpi"]: + comm = MPI.COMM_WORLD + ind_thread = comm.Get_rank() + num_thread = comm.Get_size() + + for i in range(len(self.img_list)): + if self.config["use_mpi"]: + if i % num_thread != ind_thread: + continue + img_path = self.img_list[i] + # Prepare output image path + img_name = img_path.split('/')[-1].split('.')[0] + output_name = img_name + '_injected.fits' + output_path = os.path.join(self.output_dir, output_name) + + image = SingleEpochImage(config=self.config, input_img_path=img_path, output_img_path=output_path) + inject_cat = InjectionCatalog(image=image) + inject_cat.generate_positions(config=self.config) + print("number of galaxies to be injected: %d"%(inject_cat.nobjects)) + input_cat = Catalog(config=self.config, chip=image.chip, nobjects=inject_cat.nobjects) + image.inject_objects(pos=inject_cat.pos, cat=input_cat) + image.save_injected_img() + +if __name__ == "__main__": + pipeline = InjectionPipeline() + pipeline.run_injection_img_list(Catalog=SimCat) \ No newline at end of file diff --git a/mathutil.py b/injection_pipeline/mathutil.py similarity index 96% rename from mathutil.py rename to injection_pipeline/mathutil.py index 729fa98fa39feccb3a91338f2091c85c5cad399e..c8cba759d6b6ff16093d041a4f504d2a006d3597 100644 --- a/mathutil.py +++ b/injection_pipeline/mathutil.py @@ -48,9 +48,9 @@ def sample_uniform_dec(d1, d2, N=None, unit='deg'): delta = np.arcsin(P * (np.sin(d2) - np.sin(d1)) +np.sin(d1)) # Return correct unit - if unit is 'deg' or unit is 'degree': + if unit == 'deg' or unit == 'degree': return np.rad2deg(delta) - elif unit is 'rad' or unit is 'radian': + elif unit == 'rad' or unit == 'radian': return delta else: raise TypeError('Only deg/degree or rad/radian are allowed as inputs!') diff --git a/measurement_pipeline/data/default.conv b/measurement_pipeline/data/default.conv new file mode 100644 index 0000000000000000000000000000000000000000..2590b9cba71399a05c5487e7a7441843f0fdb10b --- /dev/null +++ b/measurement_pipeline/data/default.conv @@ -0,0 +1,5 @@ +CONV NORM +# 3x3 ``all-ground'' convolution mask with FWHM = 2 pixels. +1 2 1 +2 4 2 +1 2 1 diff --git a/measurement_pipeline/data/default.nnw b/measurement_pipeline/data/default.nnw new file mode 100644 index 0000000000000000000000000000000000000000..4b521bd432f70b333331b2c88b11b63cf38dc5b4 --- /dev/null +++ b/measurement_pipeline/data/default.nnw @@ -0,0 +1,28 @@ +NNW +# Neural Network Weights for the SExtractor star/galaxy classifier (V1.3) +# inputs: 9 for profile parameters + 1 for seeing. +# outputs: ``Stellarity index'' (0.0 to 1.0) +# Seeing FWHM range: from 0.025 to 5.5'' (images must have 1.5 < FWHM < 5 pixels) +# Optimized for Moffat profiles with 2<= beta <= 4. + + 3 10 10 1 + +-1.56604e+00 -2.48265e+00 -1.44564e+00 -1.24675e+00 -9.44913e-01 -5.22453e-01 4.61342e-02 8.31957e-01 2.15505e+00 2.64769e-01 + 3.03477e+00 2.69561e+00 3.16188e+00 3.34497e+00 3.51885e+00 3.65570e+00 3.74856e+00 3.84541e+00 4.22811e+00 3.27734e+00 + +-3.22480e-01 -2.12804e+00 6.50750e-01 -1.11242e+00 -1.40683e+00 -1.55944e+00 -1.84558e+00 -1.18946e-01 5.52395e-01 -4.36564e-01 -5.30052e+00 + 4.62594e-01 -3.29127e+00 1.10950e+00 -6.01857e-01 1.29492e-01 1.42290e+00 2.90741e+00 2.44058e+00 -9.19118e-01 8.42851e-01 -4.69824e+00 +-2.57424e+00 8.96469e-01 8.34775e-01 2.18845e+00 2.46526e+00 8.60878e-02 -6.88080e-01 -1.33623e-02 9.30403e-02 1.64942e+00 -1.01231e+00 + 4.81041e+00 1.53747e+00 -1.12216e+00 -3.16008e+00 -1.67404e+00 -1.75767e+00 -1.29310e+00 5.59549e-01 8.08468e-01 -1.01592e-02 -7.54052e+00 + 1.01933e+01 -2.09484e+01 -1.07426e+00 9.87912e-01 6.05210e-01 -6.04535e-02 -5.87826e-01 -7.94117e-01 -4.89190e-01 -8.12710e-02 -2.07067e+01 +-5.31793e+00 7.94240e+00 -4.64165e+00 -4.37436e+00 -1.55417e+00 7.54368e-01 1.09608e+00 1.45967e+00 1.62946e+00 -1.01301e+00 1.13514e-01 + 2.20336e-01 1.70056e+00 -5.20105e-01 -4.28330e-01 1.57258e-03 -3.36502e-01 -8.18568e-02 -7.16163e+00 8.23195e+00 -1.71561e-02 -1.13749e+01 + 3.75075e+00 7.25399e+00 -1.75325e+00 -2.68814e+00 -3.71128e+00 -4.62933e+00 -2.13747e+00 -1.89186e-01 1.29122e+00 -7.49380e-01 6.71712e-01 +-8.41923e-01 4.64997e+00 5.65808e-01 -3.08277e-01 -1.01687e+00 1.73127e-01 -8.92130e-01 1.89044e+00 -2.75543e-01 -7.72828e-01 5.36745e-01 +-3.65598e+00 7.56997e+00 -3.76373e+00 -1.74542e+00 -1.37540e-01 -5.55400e-01 -1.59195e-01 1.27910e-01 1.91906e+00 1.42119e+00 -4.35502e+00 + +-1.70059e+00 -3.65695e+00 1.22367e+00 -5.74367e-01 -3.29571e+00 2.46316e+00 5.22353e+00 2.42038e+00 1.22919e+00 -9.22250e-01 -2.32028e+00 + + + 0.00000e+00 + 1.00000e+00 diff --git a/run.sh b/run.sh index e5d34339ce530a42b65f023d7b94d1e6b699da7e..e0924c11f093e5323a42d67850cb9f59fb0f3cd7 100755 --- a/run.sh +++ b/run.sh @@ -1,3 +1,3 @@ #!/bin/bash -python /public/home/fangyuedong/test/injection_pipeline/injection_pipeline.py config_injection.yaml -c /public/home/fangyuedong/test/injection_pipeline/ \ No newline at end of file +python /share/home/fangyuedong/injection_pipeline/injection_pipeline/injection_pipeline.py config_injection.yaml -c /share/home/fangyuedong/injection_pipeline/config \ No newline at end of file diff --git a/run_injection.pbs b/run_injection.pbs new file mode 100755 index 0000000000000000000000000000000000000000..be239d1439549721f08ef212b2ff3702a9caf9c7 --- /dev/null +++ b/run_injection.pbs @@ -0,0 +1,13 @@ +#!/bin/bash + +#PBS -N INJ +#PBS -l nodes=wcl-1:ppn=60 +#PBS -u fangyuedong +#PBS -j oe + +cd $PBS_O_WORKDIR + +NP=20 +date + +mpirun -np $NP python /share/home/fangyuedong/injection_pipeline/injection_pipeline/injection_pipeline.py config_injection.yaml -c /share/home/fangyuedong/injection_pipeline/config \ No newline at end of file diff --git a/run_sextractor.sh b/run_sextractor.sh new file mode 100755 index 0000000000000000000000000000000000000000..9f883cf7a446f1b3ce24790b6be046107b0a5cef --- /dev/null +++ b/run_sextractor.sh @@ -0,0 +1,12 @@ +#sex ./test_HexGrid_20221012.fits, ./test_HexGrid_20221012.fits \ +sex ./injected_bkgsub_img.fits, ./injected_bkgsub_img.fits \ +-c ./config/default.config \ +-INTERP_TYPE VAR_ONLY \ +-CATALOG_NAME extracted_injected_bkgsub_img.fits \ +-SATUR_LEVEL 30000.0000 \ +-DETECT_THRESH 1.5000 \ +-VERBOSE_TYPE NORMAL \ +-WEIGHT_IMAGE CSST_MSC_MS_SCI_20240617065639_20240617065909_100000020_08_wht_L1.fits \ +-FLAG_IMAGE CSST_MSC_MS_SCI_20240617065639_20240617065909_100000020_08_flg_L1.fits \ +-PSF_NAME CSST_MSC_MS_SCI_20240617065639_20240617065909_100000020_08_psf.fits \ +# -WEIGHT_IMAGE CSST_MSC_MS_SCI_20240617065639_20240617065909_100000020_08_wht_L1.fits \ \ No newline at end of file