Commit 80c8efca authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

update setup.py

parent c81ef19b
Loading
Loading
Loading
Loading
Loading
+36 −40
Original line number Original line Diff line number Diff line
@@ -5017,7 +5017,7 @@ class IFSsimulator():
##############################################################################################
##############################################################################################




def runIFSsim(sourcein, skyfitsin, configfile, iLoop, CSST_unittest, applyhole='no'):
def runIFSsim(sourcein, skyfitsin, configfile, iLoop, applyhole='no'):


    opts, args = processArgs()
    opts, args = processArgs()


@@ -5031,11 +5031,7 @@ def runIFSsim(sourcein, skyfitsin, configfile, iLoop, CSST_unittest, applyhole='
    else:
    else:
        simulate[iLoop].information['holemask'] = 'no'
        simulate[iLoop].information['holemask'] = 'no'


    if CSST_unittest:
    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')
    else:
        dir_path = '../'

    simulate[iLoop].information['dir_path'] = dir_path
    simulate[iLoop].information['dir_path'] = dir_path


    ###############
    ###############
@@ -5049,53 +5045,53 @@ def runIFSsim(sourcein, skyfitsin, configfile, iLoop, CSST_unittest, applyhole='
    return 1
    return 1




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


    CSST_unittest = True
#     CSST_unittest = True


    sourcein = 'SCI'
#     sourcein = 'SCI'


    applyhole = 'no'
#     applyhole = 'no'


    if CSST_unittest:
#     if CSST_unittest:
        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/')
    else:
#     else:
        dir_path = '../'
#         dir_path = '../'


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


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


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


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


    configfile = configfile0
#     configfile = configfile0


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


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


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


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


    ############################################################################
    ############################################################################
    ############################################################################
    ############################################################################
+6 −10
Original line number Original line Diff line number Diff line
@@ -32,17 +32,13 @@ class TestDemoFunction(unittest.TestCase):
        """
        """
        # demo function test
        # demo function test
        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/')
        
        print(dir_path)
        print(dir_path)
        
        configfile = dir_path+'IFS_data/IFS_sim_C90.config'
        d=1
        skyfitsin = dir_path+'IFS_inputdata/FengshuaiData/NGC6397_S6102.fits'
        
        sourcein = 'SCI'
        subprocess.run(['csst_ifs_sim.py', dir_path])
        csst_ifs_sim.runIFSsim(sourcein, skyfitsin, configfile, 1, 'no')
        
        #csst_ifs_sim dir_path
        
        self.assertEqual(
        self.assertEqual(
            d , 1,
            1 , 1,
            "case 1: SCI sim passes.",
            "case 1: SCI sim passes.",
        )
        )