Commit 18bdecdb authored by Fang Yuedong's avatar Fang Yuedong
Browse files

encapsulate instrumental data

parent 72f88213
import sys
from itertools import islice
import mpi4py.MPI as MPI
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.use('Agg')
import scipy.io
#import xlrd
from scipy import ndimage
sys.path.append("/public/home/weichengliang/lnData/CSST_new_framwork/csstPSF_20210108")
import PSFConfig as myConfig
import PSFUtil as myUtil
NPSF = 900
##############################
##############################
##############################
def test_psfPlot(iccd, ipsf, psfPath):
plt.cla()
plt.close('all')
#psf质心位置检查,图像切片程序检查
fig = plt.figure(figsize=(4,16))
plt.subplots_adjust(wspace=0.1, hspace=0.1)
psfSet = []
psfSetX= []
for iwave in range(1, 5):
psfInfo = myConfig.LoadPSF(iccd, iwave, ipsf, psfPath, InputMaxPixelPos=True, PSFCentroidWgt=False)
psfSet.append(psfInfo)
psfInfo = myConfig.LoadPSF(iccd, iwave, ipsf, psfPath, InputMaxPixelPos=True, PSFCentroidWgt=True)
psfSetX.append(psfInfo)
ax = plt.subplot(4,1,iwave)
psfMat = psfSet[iwave-1]['psfMat']
pixsize = psfSet[iwave-1]['pixsize']*1e-3 #microns -> mm
print('psfMat-shape:', psfMat.shape)
npix = psfMat.shape[0]
pixCutEdge= int(npix/2-15)
plt.imshow((psfMat[pixCutEdge:npix-pixCutEdge, pixCutEdge:npix-pixCutEdge]), origin='lower')
plt.plot([npix/2-pixCutEdge, npix/2-pixCutEdge],[0, (npix/2-pixCutEdge)*2-1],'w--')
plt.plot([0, (npix/2-pixCutEdge)*2-1],[npix/2-pixCutEdge, npix/2-pixCutEdge],'w--')
imgX = psfSet[iwave-1]['image_x'] #in mm
imgY = psfSet[iwave-1]['image_y'] #in mm
#cenX = imgX +deltX
#cenY = imgY -deltY
deltX= psfSet[iwave-1]['centroid_x'] #in mm
deltY= psfSet[iwave-1]['centroid_y'] #in mm
cenPix_X = npix/2 + deltX/pixsize
cenPix_Y = npix/2 + deltY/pixsize
plt.plot([cenPix_X-pixCutEdge],[cenPix_Y-pixCutEdge], 'rx', ms = 20)
deltX= psfSetX[iwave-1]['centroid_x'] #in mm
deltY= psfSetX[iwave-1]['centroid_y'] #in mm
cenPix_X = npix/2 + deltX/pixsize
cenPix_Y = npix/2 + deltY/pixsize
plt.plot([cenPix_X-pixCutEdge],[cenPix_Y-pixCutEdge], 'bx', ms = 10, mew=2)
maxX = psfSet[iwave-1]['max_x']
maxY = psfSet[iwave-1]['max_y']
maxPix_X = npix/2 + maxX/pixsize
maxPix_Y = npix/2 + maxY/pixsize
plt.plot([maxPix_X-pixCutEdge],[maxPix_Y-pixCutEdge], 'r+', ms = 20)
img = psfMat/np.sum(psfMat)
y, x = ndimage.center_of_mass(img)
print(x, y)
print(cenPix_X, cenPix_Y)
plt.plot([x-pixCutEdge],[y-pixCutEdge], 'wx', ms = 5, mew=1)
plt.annotate('iccd={:}, iwave={:}, ipsf={:}'.format(iccd, iwave, ipsf), [0,(npix/2-pixCutEdge)*2-5], c='w', size=15)
plt.savefig('figs/psf_{:}_{:}.pdf'.format(iccd, ipsf))
print('psfSet has been loaded.')
print('Usage: psfSet[i][keys]')
print('psfSet.keys:', psfSet[0].keys())
##############################
##############################
##############################
if __name__=='__main__':
iccd = 2 #[1, 30]
iwave= 2 #[1, 4]
ipsf = 46 #[1, 100]
psfPath = '/data/simudata/CSSOSDataProductsSims/data/csstPSFdata/CSSOS_psf_20210108/CSST_psf_ciomp_2p5um_cycle3_ccr90'
iipsf = [1, 15, 30, 450, 465, 480, 870, 885, 900]
for iccd in range(1, 31):
for ipsf in iipsf:
test_psfPlot(iccd, ipsf, psfPath)
import sys
from itertools import islice
import mpi4py.MPI as MPI
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.use('Agg')
import scipy.io
#import xlrd
from scipy import ndimage
sys.path.append("/public/home/weichengliang/lnData/CSST_new_framwork/csstPSF_20210108")
import PSFConfig as myConfig
import PSFUtil as myUtil
NPSF = 900
##############################
##############################
##############################
def test_psfPlot(iccd, iwave, ipsf, psfPath, r50):
#psf质心位置检查,图像切片程序检查
plt.cla()
plt.close("all")
fig = plt.figure(figsize=(4,8))
plt.subplots_adjust(wspace=0.1, hspace=0.1)
#psfSet = []
#psfSetX= []
#for iwave in range(1, 5):
psfInfo = myConfig.LoadPSF(iccd, iwave, ipsf, psfPath, InputMaxPixelPos=True, PSFCentroidWgt=False)
#psfSet.append(psfInfo)
psfInfoX = myConfig.LoadPSF(iccd, iwave, ipsf, psfPath, InputMaxPixelPos=True, PSFCentroidWgt=True)
#psfSetX.append(psfInfo)
ax = plt.subplot(2,1,1)
psfMat = psfInfo['psfMat']
pixsize = psfInfo['pixsize']*1e-3 #microns -> mm
print('psfMat-shape:', psfMat.shape)
npix = psfMat.shape[0]
pixCutEdge= int(npix/2-15)
plt.imshow(np.log10(1e-6+psfMat[pixCutEdge:npix-pixCutEdge, pixCutEdge:npix-pixCutEdge]), origin='lower')
plt.plot([npix/2-pixCutEdge, npix/2-pixCutEdge],[0, (npix/2-pixCutEdge)*2-1],'w--')
plt.plot([0, (npix/2-pixCutEdge)*2-1],[npix/2-pixCutEdge, npix/2-pixCutEdge],'w--')
imgX = psfInfo['image_x'] #in mm
imgY = psfInfo['image_y'] #in mm
#cenX = imgX +deltX
#cenY = imgY -deltY
#deltX= psfSet[iwave-1]['centroid_x'] #in mm
#deltY= psfSet[iwave-1]['centroid_y'] #in mm
#cenPix_X = npix/2 + deltX/pixsize
#cenPix_Y = npix/2-1 + deltY/pixsize
#plt.plot([cenPix_X-pixCutEdge],[cenPix_Y-pixCutEdge], 'rx', ms = 20)
deltX= psfInfoX['centroid_x'] #in mm
deltY= psfInfoX['centroid_y'] #in mm
cenPix_X = npix/2 + deltX/pixsize
cenPix_Y = npix/2 + deltY/pixsize
plt.plot([cenPix_X-pixCutEdge],[cenPix_Y-pixCutEdge], 'bx', ms = 10, mew=2)
#maxX = psfSet[iwave-1]['max_x']
#maxY = psfSet[iwave-1]['max_y']
#maxPix_X = npix/2 + maxX/pixsize
#maxPix_Y = npix/2-1 + maxY/pixsize
#plt.plot([maxPix_X-pixCutEdge],[maxPix_Y-pixCutEdge], 'r+', ms = 20)
#img = psfMat/np.sum(psfMat)
#y, x = ndimage.center_of_mass(img)
#print(x, y)
#print(cenPix_X, cenPix_Y)
#plt.plot([x-pixCutEdge],[y-pixCutEdge], 'wx', ms = 5, mew=1)
plt.annotate('iccd={:}, iwave={:}, ipsf={:}'.format(iccd, iwave, ipsf), [0,(npix/2-pixCutEdge)*2-5], c='w', size=15)
ax = plt.subplot(2,1,2)
cenPix = [cenPix_X, cenPix_Y]
img = myUtil.psfTailor(psfMat, apSizeInArcsec=2*r50, psfSampleSizeInMicrons=2.5, cenPix=cenPix)
plt.imshow(np.log10(1e-6+img[pixCutEdge:npix-pixCutEdge, pixCutEdge:npix-pixCutEdge]), origin='lower')
plt.plot([npix/2-pixCutEdge, npix/2-pixCutEdge],[0, (npix/2-pixCutEdge)*2-1],'w--')
plt.plot([0, (npix/2-pixCutEdge)*2-1],[npix/2-pixCutEdge, npix/2-pixCutEdge],'w--')
plt.savefig('figs/psf_{:}_{:}_2r50_log.pdf'.format(iccd, ipsf))
#print('psfSet has been loaded.')
#print('Usage: psfSet[i][keys]')
#print('psfSet.keys:', psfSet[0].keys())
##############################
##############################
##############################
if __name__=='__main__':
iccd = 2 #[1, 30]
iwave= 2 #[1, 4]
ipsf = 46 #[1, 100]
psfPath = '/data/simudata/CSSOSDataProductsSims/data/csstPSFdata/CSSOS_psf_20210108/CSST_psf_ciomp_2p5um_cycle3'
REE50 = np.loadtxt('REE50_w{:}.txt'.format(iwave))
iipsf = [1, 15, 30, 450, 465, 480, 870, 885, 900]
for iccd in range(1, 31):
r50 = REE50[iccd-1]
print(r50)
for ipsf in iipsf:
test_psfPlot(iccd, iwave, ipsf, psfPath, r50)
import sys
from itertools import islice
import mpi4py.MPI as MPI
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.use('Agg')
import scipy.io
#import xlrd
from scipy import ndimage
sys.path.append("/public/home/weichengliang/lnData/CSST_new_framwork/csstPSF_20210108")
import PSFConfig as myConfig
import PSFUtil as myUtil
NPSF = 900
##############################
##############################
##############################
def test_psfPlot(iccd, ipsf, psfPath):
plt.cla()
plt.close('all')
#psf质心位置检查,图像切片程序检查
fig = plt.figure(figsize=(4,16))
plt.subplots_adjust(wspace=0.1, hspace=0.1)
psfSet = []
psfSetX= []
for iwave in range(1, 5):
psfInfo = myConfig.LoadPSF(iccd, iwave, ipsf, psfPath, InputMaxPixelPos=True, PSFCentroidWgt=False)
psfSet.append(psfInfo)
psfInfo = myConfig.LoadPSF(iccd, iwave, ipsf, psfPath, InputMaxPixelPos=True, PSFCentroidWgt=True)
psfSetX.append(psfInfo)
ax = plt.subplot(4,1,iwave)
psfMat = psfSetX[iwave-1]['psfMat']
pixsize = psfSet[iwave-1]['pixsize']*1e-3 #microns -> mm
print('psfMat-shape:', psfMat.shape)
npix = psfMat.shape[0]
pixCutEdge= int(npix/2-15)
plt.imshow((psfMat[pixCutEdge:npix-pixCutEdge, pixCutEdge:npix-pixCutEdge]), origin='lower')
plt.plot([npix/2-pixCutEdge, npix/2-pixCutEdge],[0, (npix/2-pixCutEdge)*2-1],'w--')
plt.plot([0, (npix/2-pixCutEdge)*2-1],[npix/2-pixCutEdge, npix/2-pixCutEdge],'w--')
imgX = psfSet[iwave-1]['image_x'] #in mm
imgY = psfSet[iwave-1]['image_y'] #in mm
#cenX = imgX +deltX
#cenY = imgY -deltY
deltX= psfSet[iwave-1]['centroid_x'] #in mm
deltY= psfSet[iwave-1]['centroid_y'] #in mm
cenPix_X = npix/2 + deltX/pixsize
cenPix_Y = npix/2 + deltY/pixsize
plt.plot([cenPix_X-pixCutEdge],[cenPix_Y-pixCutEdge], 'rx', ms = 20)
deltX= psfSetX[iwave-1]['centroid_x'] #in mm
deltY= psfSetX[iwave-1]['centroid_y'] #in mm
cenPix_X = npix/2 + deltX/pixsize
cenPix_Y = npix/2 + deltY/pixsize
plt.plot([cenPix_X-pixCutEdge],[cenPix_Y-pixCutEdge], 'bx', ms = 10, mew=2)
maxX = psfSet[iwave-1]['max_x']
maxY = psfSet[iwave-1]['max_y']
maxPix_X = npix/2 + maxX/pixsize
maxPix_Y = npix/2 + maxY/pixsize
plt.plot([maxPix_X-pixCutEdge],[maxPix_Y-pixCutEdge], 'r+', ms = 20)
img = psfMat/np.sum(psfMat)
y, x = ndimage.center_of_mass(img)
print(x, y)
print(cenPix_X, cenPix_Y)
plt.plot([x-pixCutEdge],[y-pixCutEdge], 'wx', ms = 5, mew=1)
plt.annotate('iccd={:}, iwave={:}, ipsf={:}'.format(iccd, iwave, ipsf), [0,(npix/2-pixCutEdge)*2-5], c='w', size=15)
plt.savefig('figs/psf_{:}_{:}.pdf'.format(iccd, ipsf))
print('psfSet has been loaded.')
print('Usage: psfSet[i][keys]')
print('psfSet.keys:', psfSet[0].keys())
##############################
##############################
##############################
if __name__=='__main__':
iccd = 2 #[1, 30]
iwave= 2 #[1, 4]
ipsf = 46 #[1, 100]
psfPath = '/data/simudata/CSSOSDataProductsSims/data/csstPSFdata/CSSOS_psf_20210108/CSST_psf_ciomp_2p5um_cycle3_ccr90'
iipsf = [1, 15, 30, 450, 465, 480, 870, 885, 900]
for iccd in range(1, 31):
for ipsf in iipsf:
test_psfPlot(iccd, ipsf, psfPath)
from .PSFModel import PSFModel from .PSFModel import PSFModel
from .PSFGauss import PSFGauss from .PSFGauss import PSFGauss
from .PSFInterp.PSFInterp import PSFInterp # from .PSFInterp.PSFInterp import PSFInterp
from .PSFInterp import PSFInterp
from .FieldDistortion import FieldDistortion from .FieldDistortion import FieldDistortion
\ No newline at end of file
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
# Can add some of the command-line arguments here as well; # Can add some of the command-line arguments here as well;
# OK to pass either way or both, as long as they are consistent # OK to pass either way or both, as long as they are consistent
# work_dir: "/public/home/fangyuedong/sim_code_release/CSST/test/" # work_dir: "/public/home/fangyuedong/sim_code_release/CSST/test/"
work_dir: "/public/home/fangyuedong/test/CSST/workplace/" work_dir: "/public/home/fangyuedong/current_csst/CSST/workplace/"
data_dir: "/data/simudata/CSSOSDataProductsSims/data/" data_dir: "/data/simudata/CSSOSDataProductsSims/data/"
run_name: "TEST_astrometry_FD_30s" run_name: "TEST_importlib"
# (Optional) a file of point list # (Optional) a file of point list
# if you just want to run default pointing: # if you just want to run default pointing:
...@@ -35,7 +35,7 @@ run_option: ...@@ -35,7 +35,7 @@ run_option:
out_cat_only: NO out_cat_only: NO
# Only simulate stars? # Only simulate stars?
star_only: NO star_only: YES
# Only simulate galaxies? # Only simulate galaxies?
galaxy_only: NO galaxy_only: NO
...@@ -52,7 +52,7 @@ obs_setting: ...@@ -52,7 +52,7 @@ obs_setting:
survey_type: "All" survey_type: "All"
# Exposure time [seconds] # Exposure time [seconds]
exp_time: 30. exp_time: 150.
# Observation starting date & time # Observation starting date & time
# (Subject to change) # (Subject to change)
...@@ -75,7 +75,7 @@ obs_setting: ...@@ -75,7 +75,7 @@ obs_setting:
# - give a list of indexes of pointings: [ip_1, ip_2...] # - give a list of indexes of pointings: [ip_1, ip_2...]
# - run all pointings: null # - run all pointings: null
# Note: only valid when a pointing list is specified # Note: only valid when a pointing list is specified
run_pointings: [1, 2, 3] run_pointings: [1]
# Run specific chip(s): # Run specific chip(s):
# - give a list of indexes of chips: [ip_1, ip_2...] # - give a list of indexes of chips: [ip_1, ip_2...]
...@@ -84,7 +84,7 @@ obs_setting: ...@@ -84,7 +84,7 @@ obs_setting:
run_chips: [1, 26, 29, 6, 7, 22, 23, 19, 20] run_chips: [1, 26, 29, 6, 7, 22, 23, 19, 20]
# Whether to enable astrometric modeling # Whether to enable astrometric modeling
astrometric_lib: "libshao.so" # astrometric_lib: "libshao.so"
enable_astrometric_model: True enable_astrometric_model: True
############################################### ###############################################
...@@ -102,17 +102,17 @@ SED_templates_path: ...@@ -102,17 +102,17 @@ SED_templates_path:
galaxy_SED: "Templates/Galaxy/" galaxy_SED: "Templates/Galaxy/"
# TODO: should the following path settings be made hidden from user? # TODO: should the following path settings be made hidden from user?
Efficiency_curve_path: # Efficiency_curve_path:
filter_eff: "Filters/" # filter_eff: "Filters/"
ccd_eff: "Filter_CCD_Mirror/ccd/" # ccd_eff: "Filter_CCD_Mirror/ccd/"
mirror_eff: "Filter_CCD_Mirror/mirror_ccdnote.txt" # mirror_eff: "Filter_CCD_Mirror/mirror_ccdnote.txt"
CR_data_path: "CRdata/" # CR_data_path: "CRdata/"
sky_data_path: "skybackground/sky_emiss_hubble_50_50_A.dat" # sky_data_path: "skybackground/sky_emiss_hubble_50_50_A.dat"
SLS_path: # SLS_path:
SLS_conf: "CONF" # SLS_conf: "CONF"
SLS_norm: "normalize_filter" # SLS_norm: "normalize_filter"
############################################### ###############################################
...@@ -132,7 +132,8 @@ psf_setting: ...@@ -132,7 +132,8 @@ psf_setting:
# path to PSF data # path to PSF data
# NOTE: only valid for "Interp" PSF # NOTE: only valid for "Interp" PSF
psf_dir: "csstPSFdata/CSSOS_psf_20210108/CSST_psf_ciomp_2p5um_cycle3_ccr90" # psf_dir: "csstPSFdata/CSSOS_psf_20210108/CSST_psf_ciomp_2p5um_cycle3_ccr90"
psf_dir: "/data/simudata/CSSOSDataProductsSims/data/csstPSFdata/psfCube"
# path to field-distortion model # path to field-distortion model
# Note: only valid when ins_effects: field_dist is "ON" # Note: only valid when ins_effects: field_dist is "ON"
......
...@@ -16,4 +16,4 @@ NP=80 ...@@ -16,4 +16,4 @@ NP=80
date date
echo $NP echo $NP
mpirun -np $NP python /public/home/fangyuedong/test/CSST/run_sim.py config_C3.yaml -c /public/home/fangyuedong/test/CSST/config mpirun -np $NP python /public/home/fangyuedong/current_csst/CSST/run_sim.py config_C3.yaml -c /public/home/fangyuedong/current_csst/CSST/config
...@@ -41,5 +41,14 @@ setup(name='CSSTSim', ...@@ -41,5 +41,14 @@ setup(name='CSSTSim',
# 'Cython>=0.29.21' # 'Cython>=0.29.21'
# 'numba>=0.50.1' # 'numba>=0.50.1'
# ] # ]
package_data = {
'ObservationSim.Astrometry.lib': ['libshao.so'],
'ObservationSim.MockObject.data': ['*.dat'],
'ObservationSim.Instrument.data': ['*.txt', '*.dat'],
'ObservationSim.Instrument.data.ccd': ['*.txt'],
'ObservationSim.Instrument.data.filters': ['*.txt', '*.list', '*.dat'],
'ObservationSim.Instrument.data.sls_conf': ['*.conf', '*.fits'],
'Catalog.data': ['*.fits'],
},
ext_modules = cythonize(extensions), ext_modules = cythonize(extensions),
) )
\ No newline at end of file
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