Commit 1f233449 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

add entry points in setup.py to make executables

parent 72c543f5
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* This step removes all the instrumental related effects as well as cosmoic rays * This step removes all the instrumental related effects as well as cosmoic rays
* modify the corresponding ```config_detrending.yaml``` file to configure all running options * modify the corresponding ```config_detrending.yaml``` file to configure all running options
``` ```
python ./measurement_pipeline/run_csst_msc_instrument.py /path/to/config_detrending.yaml run_csst_detrending /path/to/config_detrending.yaml
``` ```
* Products: * Products:
* L1 calibrated images (detrended + cosmic rays removed) * L1 calibrated images (detrended + cosmic rays removed)
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* Modify the corresponding ```config_injection.yaml``` file to configure all running options * Modify the corresponding ```config_injection.yaml``` file to configure all running options
* An object catalog class which inherits from ```observation_sim.mock_objects.CatalogBase``` needs to be implemented and imported in ```injection.injection_pipeline.py```. This is to construct a list of to be injected ```observation_sim.mock_objects.MockObject```. * An object catalog class which inherits from ```observation_sim.mock_objects.CatalogBase``` needs to be implemented and imported in ```injection.injection_pipeline.py```. This is to construct a list of to be injected ```observation_sim.mock_objects.MockObject```.
``` ```
python ./injection_pipeline/injection_pipeline.py /path/to/config_injection.yaml run_csst_injection /path/to/config_injection.yaml
``` ```
* Products: * Products:
* L1 calibrated images with synthetic sources injected * L1 calibrated images with synthetic sources injected
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* Re-detect and redo photometry measurements on the injected images * Re-detect and redo photometry measurements on the injected images
* modify the corresponding ```config_photometry.yaml``` file to configure all running options * modify the corresponding ```config_photometry.yaml``` file to configure all running options
``` ```
python ./measurement_pipeline/run_csst_msc_mbi_photometry.py /path/to/config_photometry.yaml run_csst_photometry /path/to/config_photometry.yaml
``` ```
* Products: * Products:
* Detection catalogs with photometric information * Detection catalogs with photometric information
......
input_dir: "/public/share/yangxuliu/CSSOSDataProductsSims/outputs_50sqDeg/50sqDeg_Photo_W2/" input_dir: "/public/share/yangxuliu/CSSOSDataProductsSims/outputs_50sqDeg/50sqDeg_Photo_W2/"
output_dir: "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/" output_dir: "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/"
calib_data_path: "/public/home/fangyuedong/project/calib_data/"
pointing_label_list: ["MSC_0000000"] pointing_label_list: ["MSC_0000000"]
chip_label_list: ["07"] chip_label_list: ["07"]
\ No newline at end of file
...@@ -20,7 +20,7 @@ pos_sampling: ...@@ -20,7 +20,7 @@ pos_sampling:
# object_density: 37 # arcmin^-2 # object_density: 37 # arcmin^-2
input_dir: "/public/home/fangyuedong/project/50sqDeg_L1_outputs/50sqDeg_Photo_W2/" input_dir: "/public/home/fangyuedong/project/50sqDeg_L1_outputs/50sqDeg_Photo_W2/"
output_dir: "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/" output_dir: "/public/home/fangyuedong/project/demo_csst_injection/test/"
pointing_label_list: ["MSC_0000000"] pointing_label_list: ["MSC_0000000"]
chip_label_list: ["07"] chip_label_list: ["07"]
......
input_dir: "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/" # input_dir: "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/"
input_dir: "/public/home/fangyuedong/project/demo_csst_injection/test/"
flag_weight_dir: "/public/home/fangyuedong/project/demo_csst_injection/L1_products/50sqDeg_Photo_W2/" flag_weight_dir: "/public/home/fangyuedong/project/demo_csst_injection/L1_products/50sqDeg_Photo_W2/"
output_dir: "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/" output_dir: "/public/home/fangyuedong/project/demo_csst_injection/test/"
pointing_label_list: ["MSC_0000000"] pointing_label_list: ["MSC_0000000"]
chip_label_list: ["07"] chip_label_list: ["07"]
calib_data_path: "/public/home/fangyuedong/project/calib_data/" calib_data_path: "/public/home/fangyuedong/project/calib_data/"
\ No newline at end of file
%% Cell type:code id:dc2c5d8e tags: %% Cell type:code id:809b5d07 tags:
   
``` python ``` python
import os import os
import warnings import warnings
import importlib import importlib
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from pathlib import Path from pathlib import Path
from glob import glob from glob import glob
from astropy.io import ascii, fits from astropy.io import ascii, fits
from astropy.utils.exceptions import AstropyWarning from astropy.utils.exceptions import AstropyWarning
warnings.simplefilter('ignore', category=AstropyWarning) warnings.simplefilter('ignore', category=AstropyWarning)
   
import evaluation.evaluation_utils as evaluation_utils import evaluation.evaluation_utils as evaluation_utils
from evaluation.calculate_completeness_fraction import validation_hist from evaluation.calculate_completeness_fraction import validation_hist
from evaluation.cross_match_catalogs import read_catalog, match_catalogs_img from evaluation.cross_match_catalogs import read_catalog, match_catalogs_img
   
importlib.reload(evaluation_utils) importlib.reload(evaluation_utils)
%matplotlib inline %matplotlib inline
``` ```
   
%% Cell type:code id:92d0ff48 tags: %% Cell type:code id:212a642a tags:
   
``` python ``` python
chip_label = "07" chip_label = "07"
pointing_label = "MSC_0000000" pointing_label = "MSC_0000000"
   
fig_root_dir = "./fig_for_demonstration" fig_root_dir = "./fig_for_demonstration"
if not os.path.exists(fig_root_dir): if not os.path.exists(fig_root_dir):
os.makedirs(fig_root_dir) os.makedirs(fig_root_dir)
   
l1_img_dir = "/public/home/fangyuedong/project/demo_csst_injection/L1_products/50sqDeg_Photo_W2/%s/"%(pointing_label) l1_img_dir = "/public/home/fangyuedong/project/demo_csst_injection/L1_products/50sqDeg_Photo_W2/%s/"%(pointing_label)
l1_injected_dir = "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/%s"%(pointing_label) l1_injected_dir = "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/%s"%(pointing_label)
``` ```
   
%% Cell type:markdown id:1d59e962 tags: %% Cell type:markdown id:45201a01 tags:
   
# Visualize the injection # Visualize the injection
Use evaluation.evaluation_utils.plot_injection_comparison to plot before vs after injection, and the difference Use evaluation.evaluation_utils.plot_injection_comparison to plot before vs after injection, and the difference
   
%% Cell type:code id:74f801a0 tags: %% Cell type:code id:230134ea tags:
   
``` python ``` python
l1_img = glob(l1_img_dir + "/*_%s_img*.fits"%(chip_label))[0] l1_img = glob(l1_img_dir + "/*_%s_img*.fits"%(chip_label))[0]
l1_flg = glob(l1_img_dir + "/*_%s_flg*.fits"%(chip_label))[0] l1_flg = glob(l1_img_dir + "/*_%s_flg*.fits"%(chip_label))[0]
injected_img = glob(l1_injected_dir + "/*_%s_img_*.fits"%(chip_label))[0] injected_img = glob(l1_injected_dir + "/*_%s_img_*.fits"%(chip_label))[0]
   
evaluation_utils.plot_injection_comparison(orig_img=l1_img, evaluation_utils.plot_injection_comparison(orig_img=l1_img,
injected_img=injected_img, injected_img=injected_img,
flg_img=l1_flg, flg_img=l1_flg,
save_fig_dir=fig_root_dir, save_fig_dir=fig_root_dir,
fig_prefix="%s_%s_%s_"%("demo", pointing_label, chip_label), fig_prefix="%s_%s_%s_"%("demo", pointing_label, chip_label),
figsize=(8, 8)) figsize=(8, 8))
``` ```
   
%% Output %% Output
   
   
   
   
%% Cell type:markdown id:1202b0bb tags: %% Cell type:markdown id:a97854f7 tags:
   
# Matching catalogs and check detection completeness # Matching catalogs and check detection completeness
* For each pair of ground truth and detected catalogs from an injected image, use ```evaluation.cross_match_catalogs.match_catalogs_img``` to match the source by image coordinate * For each pair of ground truth and detected catalogs from an injected image, use ```evaluation.cross_match_catalogs.match_catalogs_img``` to match the source by image coordinate
* Use ```evaluation.evaluation_utils.validation_hist``` to make a histogram for each pair. Accumulate the counts * Use ```evaluation.evaluation_utils.validation_hist``` to make a histogram for each pair. Accumulate the counts
* Use ```evaluation.evaluation_utils.create_fraction_figure``` to generate the final detection fraction histogram * Use ```evaluation.evaluation_utils.create_fraction_figure``` to generate the final detection fraction histogram
   
%% Cell type:code id:6ebebcef tags: %% Cell type:code id:508205b5 tags:
   
``` python ``` python
injected_truth_dir = "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/" injected_truth_dir = "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/"
injected_l1_output_dir = "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/" injected_l1_output_dir = "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/"
   
nbins = 50 nbins = 50
bins = np.linspace(16., 28., nbins+1) bins = np.linspace(16., 28., nbins+1)
   
counts = np.zeros(nbins) counts = np.zeros(nbins)
counts_detected = np.zeros(nbins) counts_detected = np.zeros(nbins)
   
cat_path_list_injected_truth = glob(injected_truth_dir + "*/*_%s_*.cat*"%(chip_label)) cat_path_list_injected_truth = glob(injected_truth_dir + "*/*_%s_*.cat*"%(chip_label))
cat_path_list_injected_l1 = glob(injected_l1_output_dir + "*/*%s_cat*"%(chip_label)) cat_path_list_injected_l1 = glob(injected_l1_output_dir + "*/*%s_cat*"%(chip_label))
   
for cat_path_injected_truth in cat_path_list_injected_truth: for cat_path_injected_truth in cat_path_list_injected_truth:
print("Injected truth catalog: ", os.path.basename(cat_path_injected_truth)) print("Injected truth catalog: ", os.path.basename(cat_path_injected_truth))
obs_id = cat_path_injected_truth.split('/')[-2] obs_id = cat_path_injected_truth.split('/')[-2]
data = ascii.read(cat_path_injected_truth) data = ascii.read(cat_path_injected_truth)
x_truth = data["xImage"] x_truth = data["xImage"]
y_truth = data["yImage"] y_truth = data["yImage"]
mag_truth = data["mag"] mag_truth = data["mag"]
   
cat_path_injected_l1 = os.path.join(injected_l1_output_dir, cat_path_injected_l1 = os.path.join(injected_l1_output_dir,
obs_id, obs_id,
os.path.basename(cat_path_injected_truth).replace("img", "cat").replace(".cat", ".fits")) os.path.basename(cat_path_injected_truth).replace("img", "cat").replace(".cat", ".fits"))
print("L1 processed photometry catalog: ", os.path.basename(cat_path_injected_l1)) print("L1 processed photometry catalog: ", os.path.basename(cat_path_injected_l1))
hdu = fits.open(cat_path_injected_l1) hdu = fits.open(cat_path_injected_l1)
x_measure = hdu[1].data["X"] x_measure = hdu[1].data["X"]
y_measure = hdu[1].data["Y"] y_measure = hdu[1].data["Y"]
mag_measure = hdu[1].data["Mag_Kron"] mag_measure = hdu[1].data["Mag_Kron"]
   
idx1, _, = match_catalogs_img(x1=x_truth, y1=y_truth, x2=x_measure, y2=y_measure) idx1, _, = match_catalogs_img(x1=x_truth, y1=y_truth, x2=x_measure, y2=y_measure)
   
counts_temp, counts_detected_temp, _ = evaluation_utils.validation_hist(val=mag_truth, counts_temp, counts_detected_temp, _ = evaluation_utils.validation_hist(val=mag_truth,
idx=idx1, idx=idx1,
name="mag_injected", name="mag_injected",
bins=bins, bins=bins,
output_dir='./', output_dir='./',
create_figure=False) create_figure=False)
counts += counts_temp counts += counts_temp
counts_detected += counts_detected_temp counts_detected += counts_detected_temp
   
fig1, ax1 = evaluation_utils.create_hist_figure(counts, counts_detected, bins, "mag_injected", './') fig1, ax1 = evaluation_utils.create_hist_figure(counts, counts_detected, bins, "mag_injected", './')
fig1.savefig(os.path.join(fig_root_dir, "detection_recovered_W2.png")) fig1.savefig(os.path.join(fig_root_dir, "detection_recovered_W2.png"))
fig1 fig1
fig2, ax2, fraction = evaluation_utils.create_fraction_figure(counts, counts_detected, bins, 'mag_injected', './', label="W2") fig2, ax2, fraction = evaluation_utils.create_fraction_figure(counts, counts_detected, bins, 'mag_injected', './', label="W2")
``` ```
   
%% Output %% Output
   
Injected truth catalog: CSST_MSC_MS_SCIE_20220708044845_20220708045115_10160000000_07_img_L1_injected.cat Injected truth catalog: CSST_MSC_MS_SCIE_20220708044845_20220708045115_10160000000_07_img_L1_injected.cat
L1 processed photometry catalog: CSST_MSC_MS_SCIE_20220708044845_20220708045115_10160000000_07_cat_L1_injected.fits L1 processed photometry catalog: CSST_MSC_MS_SCIE_20220708044845_20220708045115_10160000000_07_cat_L1_injected.fits
number of matched sources = 389 number of matched sources = 389
   
/public/home/fangyuedong/.local/lib/python3.11/site-packages/csst_source_injection-1.0.0-py3.11.egg/evaluation/evaluation_utils.py:109: RuntimeWarning: invalid value encountered in divide /public/home/fangyuedong/.local/lib/python3.11/site-packages/csst_source_injection-1.0.0-py3.11.egg/evaluation/evaluation_utils.py:109: RuntimeWarning: invalid value encountered in divide
fraction = counts_detected / counts fraction = counts_detected / counts
   
   
   
%% Cell type:markdown id:13b2c150 tags: %% Cell type:markdown id:0eb991ca tags:
   
# Evaluate recovered photometry # Evaluate recovered photometry
* Use ```evaluation.evaluation_utils.plot_mag_comparison``` to make diff(mag) vs true_mag plot * Use ```evaluation.evaluation_utils.plot_mag_comparison``` to make diff(mag) vs true_mag plot
   
%% Cell type:code id:d4738454 tags: %% Cell type:code id:2c5648aa tags:
   
``` python ``` python
importlib.reload(evaluation_utils) importlib.reload(evaluation_utils)
injected_truth_dir = "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/" injected_truth_dir = "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/"
injected_l1_output_dir = "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/" injected_l1_output_dir = "/public/home/fangyuedong/project/demo_csst_injection/50sqDeg_Photo_W2/"
   
cat_path_list_injected_truth = glob(injected_truth_dir + "*/*_%s_*.cat*"%(chip_label)) cat_path_list_injected_truth = glob(injected_truth_dir + "*/*_%s_*.cat*"%(chip_label))
evaluation_utils.plot_mag_comparison(truth_cat_list=cat_path_list_injected_truth, evaluation_utils.plot_mag_comparison(truth_cat_list=cat_path_list_injected_truth,
measured_cat_root_dir=injected_l1_output_dir, measured_cat_root_dir=injected_l1_output_dir,
save_fig_dir=fig_root_dir, save_fig_dir=fig_root_dir,
fig_prefix="%s_%s_"%("demo", chip_label), fig_prefix="%s_%s_"%("demo", chip_label),
title="%s, chip: %s"%("demo", chip_label)) title="%s, chip: %s"%("demo", chip_label))
``` ```
   
%% Output %% Output
   
Injected truth catalog: CSST_MSC_MS_SCIE_20220708044845_20220708045115_10160000000_07_img_L1_injected.cat Injected truth catalog: CSST_MSC_MS_SCIE_20220708044845_20220708045115_10160000000_07_img_L1_injected.cat
L1 processed photometry catalog: CSST_MSC_MS_SCIE_20220708044845_20220708045115_10160000000_07_img_L1_injected.cat L1 processed photometry catalog: CSST_MSC_MS_SCIE_20220708044845_20220708045115_10160000000_07_img_L1_injected.cat
number of matched sources = 389 number of matched sources = 389
   
import numpy as np import numpy as np
import galsim import galsim
import Grid import injection_pipeline.Grid as Grid
import mathutil as util import injection_pipeline.mathutil as util
class InjectionCatalog(object): class InjectionCatalog(object):
......
...@@ -4,7 +4,7 @@ import logging ...@@ -4,7 +4,7 @@ import logging
import os import os
import numpy as np import numpy as np
import grid import injection_pipeline.Grid as grid
class AddOnImageBuilder(galsim.config.image_scattered.ScatteredImageBuilder): class AddOnImageBuilder(galsim.config.image_scattered.ScatteredImageBuilder):
......
...@@ -3,10 +3,10 @@ import os ...@@ -3,10 +3,10 @@ import os
import yaml import yaml
from glob import glob from glob import glob
from SingleEpochImage import SingleEpochImage from injection_pipeline.SingleEpochImage import SingleEpochImage
from InjectionCatalog import InjectionCatalog from injection_pipeline.InjectionCatalog import InjectionCatalog
from Catalog.C6_SimCat import SimCat from injection_pipeline.Catalog.C6_SimCat import SimCat
from config import parse_args from injection_pipeline.config import parse_args
class InjectionPipeline(object): class InjectionPipeline(object):
...@@ -118,6 +118,10 @@ class InjectionPipeline(object): ...@@ -118,6 +118,10 @@ class InjectionPipeline(object):
image.inject_objects(pos=inject_cat.pos, cat=input_cat) image.inject_objects(pos=inject_cat.pos, cat=input_cat)
image.save_injected_img() image.save_injected_img()
def main():
pipeline = InjectionPipeline()
pipeline.run_pointing_list(Catalog=SimCat)
if __name__ == "__main__": if __name__ == "__main__":
# input_dir = "/public/home/fangyuedong/project/50sqDeg_L1_outputs/50sqDeg_Photo_W2/" # input_dir = "/public/home/fangyuedong/project/50sqDeg_L1_outputs/50sqDeg_Photo_W2/"
...@@ -130,11 +134,6 @@ if __name__ == "__main__": ...@@ -130,11 +134,6 @@ if __name__ == "__main__":
# output_dir = "/public/home/fangyuedong/project/test_photometry/50sqDeg_Photo_W2/" # output_dir = "/public/home/fangyuedong/project/test_photometry/50sqDeg_Photo_W2/"
# config_file = "/public/home/fangyuedong/project/injection_pipeline/config/config_injection.yaml" # config_file = "/public/home/fangyuedong/project/injection_pipeline/config/config_injection.yaml"
# pipeline = InjectionPipeline(config_file=config_file) # pipeline = InjectionPipeline()
pipeline = InjectionPipeline() # pipeline.run_pointing_list(Catalog=SimCat)
# pipeline.run_pointing_list(input_dir=input_dir, main()
# pointing_label_list=pointing_label_list,
# output_dir=output_dir,
# chip_label_list=chip_label_list,
# Catalog=SimCat)
pipeline.run_pointing_list(Catalog=SimCat)
...@@ -23,7 +23,7 @@ from astropy.stats import sigma_clipped_stats ...@@ -23,7 +23,7 @@ from astropy.stats import sigma_clipped_stats
# subtract_dark, # subtract_dark,
# FlagConfig, # FlagConfig,
# ) # )
from L1_pipeline.csst_msc_instrument.image import ( from measurement_pipeline.L1_pipeline.csst_msc_instrument.image import (
remove_cr_deepcr, remove_cr_deepcr,
subtract_bias, subtract_bias,
subtract_dark, subtract_dark,
......
...@@ -14,12 +14,14 @@ import os ...@@ -14,12 +14,14 @@ import os
import numpy as np import numpy as np
import deepCR import deepCR
from ..config import FlagConfig from measurement_pipeline.L1_pipeline.csst_msc_instrument.image.config import FlagConfig
import importlib.resources as pkg_resources
__all__ = ["remove_cr_deepcr", ] __all__ = ["remove_cr_deepcr", ]
MODEL_DIR = os.path.join(os.path.dirname( # MODEL_DIR = os.path.join(os.path.dirname(
os.path.abspath(__file__)), 'cr_model') # os.path.abspath(__file__)), 'cr_model')
DEEPCR_MODEL_PATH = { DEEPCR_MODEL_PATH = {
'01': '2022-04-26_15_samples_32_layers_epoch30.pth', '01': '2022-04-26_15_samples_32_layers_epoch30.pth',
...@@ -86,7 +88,9 @@ def remove_cr_deepcr(image: np.ndarray, ...@@ -86,7 +88,9 @@ def remove_cr_deepcr(image: np.ndarray,
""" """
inpaint = False inpaint = False
inpaint_model = 'ACS-WFC-F606W-2-32' inpaint_model = 'ACS-WFC-F606W-2-32'
model_path = os.path.join(MODEL_DIR, DEEPCR_MODEL_PATH[chipid]) # model_path = os.path.join(MODEL_DIR, DEEPCR_MODEL_PATH[chipid])
with pkg_resources.path('measurement_pipeline.L1_pipeline.csst_msc_instrument.image.cosmicray.cr_model', DEEPCR_MODEL_PATH[chipid]) as p:
model_path = p
model = deepCR.deepCR( model = deepCR.deepCR(
model_path, model_path,
inpaint_model, inpaint_model,
......
...@@ -18,7 +18,7 @@ from scipy.special import erf ...@@ -18,7 +18,7 @@ from scipy.special import erf
from scipy.stats import trim_mean, t, sigmaclip from scipy.stats import trim_mean, t, sigmaclip
from astropy.stats import mad_std, sigma_clip from astropy.stats import mad_std, sigma_clip
from .config import get_array_config from measurement_pipeline.L1_pipeline.csst_msc_instrument.image.config import get_array_config
__all__ = ["average_overscan", "smooth_overscan", "correct_overscan", ] __all__ = ["average_overscan", "smooth_overscan", "correct_overscan", ]
......
...@@ -75,8 +75,8 @@ from scipy.interpolate import UnivariateSpline ...@@ -75,8 +75,8 @@ from scipy.interpolate import UnivariateSpline
from astropy.coordinates import SkyCoord from astropy.coordinates import SkyCoord
from shutil import which from shutil import which
import astropy.units as u import astropy.units as u
from .stats import sigmaclip_limitsig, weighted_mean, closest_match from measurement_pipeline.L1_pipeline.csst_msc_mbi_photometry.stats import sigmaclip_limitsig, weighted_mean, closest_match
from .mag_flux_convert import fluxerr2magerr from measurement_pipeline.L1_pipeline.csst_msc_mbi_photometry.mag_flux_convert import fluxerr2magerr
# from csst_common import CsstResult, CsstStatus # from csst_common import CsstResult, CsstStatus
from typing import Optional from typing import Optional
......
...@@ -5,8 +5,8 @@ import yaml ...@@ -5,8 +5,8 @@ import yaml
from glob import glob from glob import glob
import mpi4py.MPI as MPI import mpi4py.MPI as MPI
# from .L1_pipeline.csst_msc_instrument.csst_msc_mbi_instrument import core_msc_l1_mbi_instrument # from .L1_pipeline.csst_msc_instrument.csst_msc_mbi_instrument import core_msc_l1_mbi_instrument
from L1_pipeline.csst_msc_instrument.csst_msc_mbi_instrument import core_msc_l1_mbi_instrument from measurement_pipeline.L1_pipeline.csst_msc_instrument.csst_msc_mbi_instrument import core_msc_l1_mbi_instrument
from config import parse_args from measurement_pipeline.config import parse_args
def run_csst_msc_instrument(image_path, def run_csst_msc_instrument(image_path,
...@@ -121,19 +121,7 @@ def run_pointing_list(input_dir, ...@@ -121,19 +121,7 @@ def run_pointing_list(input_dir,
calib_data_path=calib_data_path) calib_data_path=calib_data_path)
if __name__ == "__main__": def main():
# input_dir = "/public/share/yangxuliu/CSSOSDataProductsSims/outputs_50sqDeg/50sqDeg_Photo_W1/"
# pointing_label_list = ["MSC_0000000"]
# chip_label_list = ["08"]
# output_dir = "/public/home/fangyuedong/project/test_deepcr"
# input_dir = "/public/share/yangxuliu/CSSOSDataProductsSims/outputs_50sqDeg/50sqDeg_Photo_W2/"
# output_dir = "/public/home/fangyuedong/project/50sqDeg_L1_outputs/50sqDeg_Photo_W2/"
# input_dir = "/public/share/yangxuliu/CSSOSDataProductsSims/outputs_50sqDeg/50sqDeg_Photo_W3/"
# output_dir = "/public/home/fangyuedong/project/50sqDeg_L1_outputs/50sqDeg_Photo_W3/"
# pointing_label_list = ["MSC_0000000", "MSC_0000001",
# "MSC_0000002", "MSC_0000003", "MSC_0000004", "MSC_0000005", "MSC_0000006", "MSC_0000007", "MSC_0000008", "MSC_0000009"]
# chip_label_list = None
args = parse_args() args = parse_args()
config_file = args.config_file config_file = args.config_file
with open(config_file, "r") as stream: with open(config_file, "r") as stream:
...@@ -149,3 +137,19 @@ if __name__ == "__main__": ...@@ -149,3 +137,19 @@ if __name__ == "__main__":
output_dir=config["output_dir"], output_dir=config["output_dir"],
chip_label_list=config["chip_label_list"], chip_label_list=config["chip_label_list"],
calib_data_path=config["calib_data_path"]) calib_data_path=config["calib_data_path"])
if __name__ == "__main__":
# input_dir = "/public/share/yangxuliu/CSSOSDataProductsSims/outputs_50sqDeg/50sqDeg_Photo_W1/"
# pointing_label_list = ["MSC_0000000"]
# chip_label_list = ["08"]
# output_dir = "/public/home/fangyuedong/project/test_deepcr"
# input_dir = "/public/share/yangxuliu/CSSOSDataProductsSims/outputs_50sqDeg/50sqDeg_Photo_W2/"
# output_dir = "/public/home/fangyuedong/project/50sqDeg_L1_outputs/50sqDeg_Photo_W2/"
# input_dir = "/public/share/yangxuliu/CSSOSDataProductsSims/outputs_50sqDeg/50sqDeg_Photo_W3/"
# output_dir = "/public/home/fangyuedong/project/50sqDeg_L1_outputs/50sqDeg_Photo_W3/"
# pointing_label_list = ["MSC_0000000", "MSC_0000001",
# "MSC_0000002", "MSC_0000003", "MSC_0000004", "MSC_0000005", "MSC_0000006", "MSC_0000007", "MSC_0000008", "MSC_0000009"]
# chip_label_list = None
main()
...@@ -4,9 +4,9 @@ import os ...@@ -4,9 +4,9 @@ import os
import yaml import yaml
from glob import glob from glob import glob
import mpi4py.MPI as MPI import mpi4py.MPI as MPI
from L1_pipeline.csst_msc_mbi_photometry.csst_photometry import core_msc_l1_mbi_phot from measurement_pipeline.L1_pipeline.csst_msc_mbi_photometry.csst_photometry import core_msc_l1_mbi_phot
from typing import Optional from typing import Optional
from config import parse_args from measurement_pipeline.config import parse_args
def run_csst_msc_mbi_photometry(image_path, def run_csst_msc_mbi_photometry(image_path,
output_dir, output_dir,
...@@ -128,6 +128,23 @@ def run_pointing_list(input_dir, ...@@ -128,6 +128,23 @@ def run_pointing_list(input_dir,
output_dir=output_path, output_dir=output_path,
flag_weight_dir=fw_dir) flag_weight_dir=fw_dir)
def main():
args = parse_args()
config_file = args.config_file
with open(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)
run_pointing_list(input_dir=config["input_dir"],
flag_weight_dir=config["flag_weight_dir"],
pointing_label_list=config["pointing_label_list"],
output_dir=config["output_dir"],
chip_label_list=config["chip_label_list"])
if __name__ == "__main__": if __name__ == "__main__":
# input_dir = "/public/home/fangyuedong/project/injected_50sqDeg_L1_outputs" # input_dir = "/public/home/fangyuedong/project/injected_50sqDeg_L1_outputs"
...@@ -146,18 +163,4 @@ if __name__ == "__main__": ...@@ -146,18 +163,4 @@ if __name__ == "__main__":
# # output_dir = "/public/home/fangyuedong/project/50sqDeg_L1_outputs/50sqDeg_Photo_W3/" # # output_dir = "/public/home/fangyuedong/project/50sqDeg_L1_outputs/50sqDeg_Photo_W3/"
# output_dir = "/public/home/fangyuedong/project/processed_injected_50sqDeg_L1_outputs/50sqDeg_Photo_W3/" # output_dir = "/public/home/fangyuedong/project/processed_injected_50sqDeg_L1_outputs/50sqDeg_Photo_W3/"
args = parse_args() main()
config_file = args.config_file
with open(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)
run_pointing_list(input_dir=config["input_dir"],
flag_weight_dir=config["flag_weight_dir"],
pointing_label_list=config["pointing_label_list"],
output_dir=config["output_dir"],
chip_label_list=config["chip_label_list"])
...@@ -10,8 +10,18 @@ with open("requirements.txt", "r") as f: ...@@ -10,8 +10,18 @@ with open("requirements.txt", "r") as f:
setup(name='csst_source_injection', setup(name='csst_source_injection',
version='1.0.0', version='1.0.0',
packages=find_packages(), packages=find_packages(),
entry_points={
'console_scripts': [
'run_csst_injection=injection_pipeline.injection_pipeline:main',
'run_csst_detrending=measurement_pipeline.run_csst_msc_instrument:main',
'run_csst_photometry=measurement_pipeline.run_csst_msc_mbi_photometry:main'
]
},
package_data={ package_data={
'injection_pipeline.Catalog.data': ["*.fits"], 'injection_pipeline.Catalog.data': ["*.fits"],
'measurement_pipeline.L1_pipeline.csst_msc_mbi_photometry.data': ["*.config", "*.conv", "*.nnw", "*.param", "*.sex", "*.psfex"],
'measurement_pipeline.L1_pipeline.csst_msc_instrument': ["instrument_cor_demo.head"],
'measurement_pipeline.L1_pipeline.csst_msc_instrument.image.cosmicray.cr_model': ["*.pth"]
}, },
python_requires=">=3.11", python_requires=">=3.11",
install_requires=requirements, install_requires=requirements,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment