"""
画出指定PSF image
"""
import sys,os,math
import time
from IPython import display
import numpy as np
import matplotlib.pyplot as plt
import mpi4py.MPI as MPI

sys.path.append("/public/home/weichengliang/lnData/CSST_new_framwork/csstPSF")
import PSFConfig as myConfig
import PSFUtil as myUtil


def plotPSFMat(iccd, iwave, ipsf, psfPath):
    print('ipsf:', ipsf)
    psfInfo = myConfig.LoadPSF(iccd, iwave, ipsf, psfPath, InputMaxPixelPos=True, PSFCentroidWgt=True)
    imx = psfInfo['psfMat']    

    plt.close()
    fig = plt.figure(figsize=(8,8))
    cpp = 128
    dcpp= 10
    plt.imshow(imx[cpp-dcpp:cpp+dcpp, cpp-dcpp:cpp+dcpp])
    plt.annotate('iccd-{:} ipsf-{:}'.format(iccd, ipsf), (0.1, 0.9), xycoords='axes fraction',color='w')
    plt.savefig('figs/psfMatPlot_iccd{:}_ipsf{:}.pdf'.format(iccd, ipsf))
    

iccd = 28  #[1, 30]
iwave= 1  #[1, 4]
ipsf = 1  #[1, 100]
#psfPath = '/data/simudata/CSSOSDataProductsSims/data/csstPSFdata/CSSOS_psf_ciomp'
psfPath = '/data/simudata/CSSOSDataProductsSims/data/csstPSFdata/CSSOS_psf_ciomp_30X30'

for ipsf in range(12, 21):
    plotPSFMat(iccd, iwave, ipsf, psfPath)
for ipsf in range(12, 21):
    plotPSFMat(iccd, iwave, ipsf+30, psfPath)
for ipsf in range(12, 21):
    plotPSFMat(iccd, iwave, ipsf+60, psfPath)




