From 72ee59d141af74cdf4f0801ace4ba5e5597c7587 Mon Sep 17 00:00:00 2001 From: fangyuedong Date: Mon, 22 Apr 2024 10:05:43 +0800 Subject: [PATCH] add wrapper for photometry calls --- .../csst_photometry.py | 35 +++-- .../run_csst_msc_mbi_photometry | 129 ++++++++++++++++++ 2 files changed, 153 insertions(+), 11 deletions(-) create mode 100644 measurement_pipeline/run_csst_msc_mbi_photometry diff --git a/measurement_pipeline/L1_pipeline/csst_msc_mbi_photometry/csst_photometry.py b/measurement_pipeline/L1_pipeline/csst_msc_mbi_photometry/csst_photometry.py index e968dde..91c2efd 100644 --- a/measurement_pipeline/L1_pipeline/csst_msc_mbi_photometry/csst_photometry.py +++ b/measurement_pipeline/L1_pipeline/csst_msc_mbi_photometry/csst_photometry.py @@ -84,6 +84,10 @@ prog_dir = os.path.dirname(__file__) config_path = os.path.join(prog_dir, 'data/') __version__ = "1.4.3" +# [TODO] +zero_points = {'NUV': 24.8, 'u': 25.22, 'g': 26.23, + 'r': 26.04, 'i': 25.85, 'z': 25.27, 'y': 23.92} + def pick_psfstars(psffile, remove_polution=False, min_nstar=10, max_nstar=1500, class_star=0.7, match_dist=10, min_sn=20, max_elp=0.3, fwhm_range=[1.5, 20]): @@ -134,12 +138,15 @@ def pick_psfstars(psffile, remove_polution=False, min_nstar=10, max_nstar=1500, cat = cat[index] print("selecting isolated stars:", len(cat)) - mask = (cat['flags'] == 0) & (cat['nimaflags_iso'] < 3) & (cat['CLASS_STAR'] > class_star) & (cat['ELLIPTICITY'] < max_elp) & ( + # mask = (cat['flags'] == 0) & (cat['nimaflags_iso'] < 3) & (cat['CLASS_STAR'] > class_star) & (cat['ELLIPTICITY'] < max_elp) & ( + # cat['SNR_WIN'] > min_sn) & (cat['FWHM_IMAGE'] > fwhm_range[0]) & (cat['FWHM_IMAGE'] < fwhm_range[1]) + # [TODO] + mask = (cat['flags'] == 0) & (cat['CLASS_STAR'] > class_star) & (cat['ELLIPTICITY'] < max_elp) & ( cat['SNR_WIN'] > min_sn) & (cat['FWHM_IMAGE'] > fwhm_range[0]) & (cat['FWHM_IMAGE'] < fwhm_range[1]) cat = cat[mask] if len(cat) < min_nstar: - print("too few psf stars...") + print("too few psf stars... , got %d" % (len(cat))) hdulist.close() return False @@ -224,7 +231,8 @@ def get_psf(imgfile, whtfile, flgfile, psffile, psf_size=101, degree=3, variabil # fitsname = dm.l1_detector(detector=detector, post="") head = fits.getheader(imgfile, 0) - gain = head['exptime'] + # gain = head['exptime'] + gain = head['EXPTIME'] saturate = 50000.0 / gain # fitsname,_=os.path.splitext(imgfile) @@ -324,7 +332,9 @@ def photometry(imgfile, whtfile, flgfile, psffile, fluxfile, catfile, skyfile, s if zp_name not in head or head[zp_name] <= 0: print("No zeropoint in the header or bad zeropoint") - return False + # return False + # [TODO] + # date=head['date-obs'] # ccd=head['ccd_no'] @@ -335,7 +345,8 @@ def photometry(imgfile, whtfile, flgfile, psffile, fluxfile, catfile, skyfile, s # flagfile=rootname[:indpos]+'_flg.fits' # weightfile=rootname[:indpos]+'_wht.fits' - gain = head['exptime'] + # gain = head['exptime'] + gain = head['EXPTIME'] saturate = 50000.0 / gain # types = {'sky': 'BACKGROUND', 'seg': 'SEGMENTATION', 'mod': 'MODELS', 'res': '-MODELS'} @@ -655,12 +666,12 @@ def clean_catalog(cat, head, sep=2.0, star_thresh=0.005): # add IDs bits = 6 objid = np.array(cat['ObjID']) - if 'ccdchip' in head: - ccdno = int(str.strip(head['ccdchip'])[3:]) + if 'CCDCHIP' in head: + ccdno = int(str.strip(head['CCDCHIP'])[3:]) else: - ccdno = int(str.strip(head['chipid'])) + ccdno = int(str.strip(head['CHIPID'])) - obsid = int(head['obsid']) + obsid = int(head['OBSID']) ids = np.array(cat['ObjID'], dtype=int) + ccdno * \ 10 ** bits + obsid * 10 ** (bits + 2) col = Table.Column( @@ -670,7 +681,7 @@ def clean_catalog(cat, head, sep=2.0, star_thresh=0.005): cat.add_column(col, index=0) col = Table.Column(ids, name='ID') cat.add_column(col, index=0) - filt = head['filter'] + filt = head['FILTER'] ff = np.zeros(len(cat), dtype='