Commit b2028a91 authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

redate ifs_sim

parent c5522b44
Loading
Loading
Loading
Loading
Loading
+12.9 KiB

File added.

No diff preview for this file type.

+142 B

File added.

No diff preview for this file type.

+11 −144
Original line number Diff line number Diff line
@@ -45,8 +45,6 @@ from datetime import datetime, timedelta
import pandas as pd
from scipy.integrate import simps
import galsim
# sys.path.append('../')
from joblib import Parallel, delayed
from astropy.utils.iers import conf
conf.auto_max_age = None

@@ -1588,7 +1586,7 @@ class IFSsimulator():
        """
        self.log.info('Reading in cosmic ray information from %s and %s' % (self.information['cosmicraylengths'],
                                                                            self.information['cosmicraydistance']))
        print(self.information)
        #### print(self.information)

        crLengths = np.loadtxt(
            self.information['dir_path']+self.information['cosmicraylengths'])
@@ -1733,9 +1731,9 @@ class IFSsimulator():

            if home_path == '/home/yan':

                self.result_path = '../IFS_simData_'+self.source+ss+result_day
                self.result_path = '../IFS_simData/'+self.source+ss+result_day
            else:
                self.result_path = '/data/ifspip/CCD_ima/IFS_simData_'+self.source+ss+result_day
                self.result_path = '/data/ifspip/CCD_ima/'+self.source+ss+result_day

        if os.path.isdir(self.result_path) == False:
            os.mkdir(self.result_path)
@@ -4141,13 +4139,11 @@ class IFSsimulator():
        Wave = np.zeros(6000)

        if self.debug:

            alfa = 1000
        else:

            alfa = 1

        # 3
        #########################################

        for klam in range(6000):

@@ -4163,7 +4159,7 @@ class IFSsimulator():
                self.log.info('red image max value = %i' % red_img.array.max())

            if ilam >= 6000:
                continue
                break

            # the wavelength of the i-th frame data
            lam = 350.0+(1000-350)/6000.0 * ilam
@@ -4651,10 +4647,8 @@ class IFSsimulator():
        ########################################################################################

        if self.debug:

            alfa = 1000
        else:

            alfa = 1

        for klam in range(6000):
@@ -4662,7 +4656,7 @@ class IFSsimulator():
            ilam = klam*alfa

            if ilam >= 6000:
                continue
                break

            # print(ilam)

@@ -5051,10 +5045,8 @@ class IFSsimulator():
        ####

        if self.debug:

            alfa = 1000
        else:

            alfa = 1

        for klam in range(6000):
@@ -5072,7 +5064,7 @@ class IFSsimulator():
                self.log.info('red image max value = %i' % red_img.array.max())

            if ilam >= 6000:
                continue
                break

            # the wavelength of the i-th frame data
            lam = 350.0+(1000-350)/6000.0 * ilam
@@ -5586,10 +5578,6 @@ class IFSsimulator():

            if self.source == 'SCI' or self.source == 'COMP':

                # if self.debug:
                #     print('Debug mode, no cosmicrays')
                # else:

                if self.cosmicRays:
                    self.addCosmicRays(idk)
                    print('Applying cosmicRays finished.......')
@@ -5662,7 +5650,7 @@ class IFSsimulator():
############################################################################


def runIFSsim(sourcein, configfile, iLoop, applyhole='no'):
def runIFSsim(sourcein, configfile, dir_path, iLoop, applyhole='no'):
    """
    

@@ -5692,132 +5680,11 @@ def runIFSsim(sourcein, configfile, iLoop, applyhole='no'):
    else:
        simulate[iLoop].information['holemask'] = 'no'

    dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'], 'ifs_sim/')
    ### dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'], 'ifs_sim/')
    simulate[iLoop].information['dir_path'] = dir_path
    
    simulate[iLoop].simulate(sourcein, iLoop)

    return 1


# ##########################   begin   main fucntion     #######################################
# ##############################################################################################
# ##############################################################################################
# if __name__ == "__main__":

#     CSST_unittest = True

#     sourcein = 'SCI'

#     applyhole = 'no'

#     if CSST_unittest:
#         dir_path = os.path.join(os.environ['UNIT_TEST_DATA_ROOT'], 'ifs_sim/')
#     else:
#         dir_path = '../'

#     configfile0 = dir_path+'IFS_data/IFS_sim_C90.config'

#     skyfitsin = dir_path+'IFS_inputdata/FengshuaiData/NGC6397_S6102.fits'

#     if len(sys.argv[:]) < 2:
#         configfile = configfile0

#     if len(sys.argv[:]) >= 2:
#         configfile = sys.argv[1]+'IFS_inputdata/configData/IFS_sim_C90.config'
#         if not os.path.exists(configfile):
#             print('The given input fonfigfile path is wrong......')
#             sys.exit(1)

#     configfile = configfile0

#     if len(sys.argv[:]) >= 3:
#         sourcein = sys.argv[2]CSST_unittest

#         if sourcein not in ['BIAS', 'DARK', 'LAMP', 'FLAT', 'SCI']:
#             print('The input sourcein parameter input is wrong......')
#             sys.exit(1)

#     if len(sys.argv[:]) >= 4:
#         applyhole = sys.argv[3]
#         if sourcein not in ['yes', 'no']:
#             print('The input applyhole parameter should be yes or no!')
#             sys.exit(1)
#     #############################################################
#     ##################        sky  test    ############################

#     runIFSsim(sourcein, skyfitsin, configfile, 1, CSST_unittest, applyhole)

    ############################################################################
    ############################################################################
    # it=range(1, exposureNum+1,1)

    # if exposureNum>1:
    #     Parallel(n_jobs=min(5,exposureNum))(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole)    for iLoop in it)
    # else:
    #     runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)

    # pause
    # # ############################################################
    # # ###############          bias , no mask      ###############
    # sourcein ='BIAS'
    # applyhole='no'
    # exposureNum=5
    # it=range(1,exposureNum+1,1)

    # if exposureNum>1:
    #     Parallel(n_jobs=exposureNum)(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole)    for iLoop in it)
    # else:
    #     runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)

    # pause()

    # # # ##########################################################
    # # ###############         dark , no mask          ###########
    # sourcein ='DARK'
    # applyhole='no'
    # exposureNum=5
    # it=range(1,exposureNum+1,1)

    # if exposureNum>1:
    #     Parallel(n_jobs=exposureNum)(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole)    for iLoop in it)
    # else:
    #     runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)
    # # ###############################################################################

    #################        lamp ,    no mask     #############

    # sourcein ='LAMP'
    # applyhole='no'
    # exposureNum=5
    # it=range(1,exposureNum+1,1)

    # if exposureNum>1:
    #     Parallel(n_jobs=exposureNum)(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole)    for iLoop in it)
    # else:
    #     runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)

    ############################################################

    ###########################################################
    # # ###############      flat,  no mask        ################
    # sourcein ='FLAT'
    # applyhole='no'
    # exposureNum=5
    # it=range(1,exposureNum+1,1)

    # if exposureNum>1:
    #     Parallel(n_jobs=exposureNum)(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole)    for iLoop in it)
    # else:
    #     runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)

    # ############################################################
    # ##################     hole Mask simulation  ###############
    # sourcein ='LAMP'
    # applyhole='yes'
    # exposureNum=2
    # it=range(1,exposureNum+1,1)

    # if exposureNum>1:
    #     Parallel(n_jobs=exposureNum)(delayed(runIFSsim)(sourcein, skyfitsin, configfile, iLoop, applyhole)    for iLoop in it)
    # else:
    #     runIFSsim(sourcein, skyfitsin, configfile, 1, applyhole)
############################## end  ##########################################
 No newline at end of file
+1.47 KiB

File added.

No diff preview for this file type.

Loading