Commit 5c4a3a79 authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

update

parent 0b24318d
Loading
Loading
Loading
Loading
Loading
+94 −94
Original line number Diff line number Diff line
@@ -2407,8 +2407,8 @@ class IFSsimulator():

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


#
#
    def applyDarkCurrent(self):
        """
        Returns
@@ -2507,13 +2507,12 @@ class IFSsimulator():
            self.information['dark4_r']


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

    def applyPoissonNoise(self):
        """

    def applyPoissonNoise(self):

        """
        Returns
        -------
        None.
@@ -2542,8 +2541,8 @@ class IFSsimulator():
        self.log.info('Added Poisson noise on channel red')
        self.image_r += residual


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

    def applyCosmetics(self):
        """
@@ -3096,7 +3095,8 @@ class IFSsimulator():
        else:
            self.log.error(
                'Cannot include pre- and overscan because of an unknown quadrant!')

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

        canvas = np.zeros((self.information['redsize'],
@@ -3324,14 +3324,11 @@ class IFSsimulator():

    def CCDreadout(self):
        """


        Returns
        -------
        None.

        """

        imgb = self.image_b.copy()
        prescan = int(self.information['prescan'])
        overscan = int(self.information['overscan'])
@@ -3385,7 +3382,9 @@ class IFSsimulator():
        y1 = 2418+prescan
        y2 = y1+2048
        temp[x1:x2, y1:y2] = imgb[0:1024, 0:2048]
        
        #
        #
        #
        # ## third part, old OSE,  down to up   ###################
        x1 = 0
        x2 = x1+1024
@@ -4362,7 +4361,7 @@ class IFSsimulator():
            '========================================================================', before='EXPT0_1')

        hdulist_b.writeto(self.file_b, output_verify='ignore', checksum=True)
     #########################################################################
        # ##################################################################
        hdulist_r = fits.HDUList([hdu2, hdu_r])

        hdu_r.header.add_comment(
@@ -4399,7 +4398,7 @@ class IFSsimulator():
        """

        # read solar template
        solar_template = pd.read_csv(self.information['dir_path']+'IFS_inputdata/refs/solar_spec.dat', sep='\s+',
        solar_template = pd.read_csv(self.information['dir_path']+'IFS_inputdata/refs/solar_spec.dat', sep='\\s+',
                                     header=None, comment='#')
        template_wave = solar_template[0].values
        template_flux = solar_template[1].values
@@ -4411,7 +4410,7 @@ class IFSsimulator():
        surface_brightness = earthshine_curve[1].values

        # read V-band throughtput
        cat_filter_V = pd.read_csv(self.information['dir_path']+'IFS_inputdata/refs/filter_Bessell_V.dat', sep='\s+',
        cat_filter_V = pd.read_csv(self.information['dir_path']+'IFS_inputdata/refs/filter_Bessell_V.dat', sep='\\s+',
                                   header=None, comment='#')
        filter_wave = cat_filter_V[0].values
        filter_response = cat_filter_V[1].values
@@ -4510,7 +4509,7 @@ class IFSsimulator():
        """

        sizeout = 1000  # here image has the pixelscale =0.01 arcsec
        ################# create the slicer and slit file for high resolution 0.01arcsec simulation ###################
        # create the slicer and slit file for high resolution 0.01arcsec simulation ###################

        maskSlice = dict()
        maskSlit = dict()
@@ -4526,7 +4525,8 @@ class IFSsimulator():

        self.maskSliceHole = maskSlice
        self.maskSlitHole = maskSlit
        #########################################################################
        ################################################################
        # ########
        # #### load slicer_Qe1K.fits  ####
        slicerfile = self.information['dir_path'] + \
            'IFS_inputdata/Flatfield/slicer_QE_1K_230625.fits'
@@ -4822,7 +4822,7 @@ class IFSsimulator():
            newd.writeto(filename, overwrite=True)

        return
    ##################################################################################
    # ########################################################################

    def sim_sky_img(self, skyfitsfilename, skyRa, skyDec, sky_rot, telRa, telDec,  exposuretime, simnumber):
        """
@@ -4885,7 +4885,7 @@ class IFSsimulator():

        self.information['dec_pnt0'] = a[0].header['DEC'] + disDec

        ###############   calculate the earthshine and zodiacal noise  ,new code 2023.11.1  ############
        # calculate the earthshine and zodiacal noise  ,new code 2023.11.1  ############
        ###############

        self.log.info('Real telescope pointing in Ra = %f, Dec = %f' % (
@@ -4959,7 +4959,7 @@ class IFSsimulator():
        Wave = 0.1*a[2].data
        # print('Wave data header', hdr)

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

        exptime = self.information['exptime']  # exposure time

@@ -5340,7 +5340,7 @@ class IFSsimulator():

                # print('covtime =', t2-t1)

               ########################   get subimage                   #####################
                # ###   get subimage                   #####################
                subimage = galsim.Image(80, 80)
                subimage.array[:, :] = img3[int(
                    sizeout/2)-40:int(sizeout/2)+40, int(sizeout/2)-40:int(sizeout/2)+40]
@@ -5355,17 +5355,17 @@ class IFSsimulator():
                photons = galsim.PhotonArray.makeFromImage(
                    subimage, max_flux=max(img3.max()/10000.0, 1))

                #############################################################################
                ############################################################
                # do something for each photons;
                ##############################################################################
                #############################################################
                idx0 = np.where(photons.flux > 1e-3)
                # totla energy for slice image
                energy = energy+sum(photons.flux[idx0])
                p_num = len(idx0[0])

                ###############################################################################################
                ####################### code for test slice is right or not ###################################
                ###############################################################################################
                ##############################################################
                # ######### code for test slice is right or not ##############
                ##############################################################
                # photons_2=galsim.PhotonArray(N=p_num, x=photons.x[idx0], y=photons.y[idx0], flux = photons.flux[idx0], wavelength=lam)
                # if k==0:
                #     sliceimage = galsim.Image(100,100)
@@ -5425,8 +5425,8 @@ class IFSsimulator():

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

            ########################### test code ################################
            ######################################################################
            # ##################### test code ################################
            # ################################################################
            # fits.writeto('originalImg.fits',Nimg,overwrite=True)
            # fits.writeto('PSFedImg.fits',temp,overwrite=True)
            # fits.writeto('rotedphotonsImg.fits',image.array,overwrite=True)
@@ -5434,10 +5434,10 @@ class IFSsimulator():
            # fits.writeto('slicephotonsImg.fits',sliceimage.array,overwrite=True)

            # pause()
            ######################################################################
            ###################### finish test code   ###########################
            # #############################################################
            # ############## finish test code   ###########################

        ####################################################################################
        #####################################################################
        # stray light will cover 2% of input total light;
        if self.sky_noise:

@@ -5696,14 +5696,14 @@ class IFSsimulator():

                img3 = conv

                ########################   get subimage                   #####################
                # # ##   get subimage                   #####################
                subimage = galsim.Image(80, 80)
                subimage.array[:, :] = img3[int(
                    sizeout/2)-40:int(sizeout/2)+40, int(sizeout/2)-40:int(sizeout/2)+40]

                # fits.writeto('subimage.fits',subimage.array,overwrite=True)

                ########################   get photons from sub-image     #####################
                # #####   get photons from sub-image     #####################
                subimage.scale = self.pixelscale

                subimage.setOrigin(0, 0)
@@ -5711,16 +5711,16 @@ class IFSsimulator():
                photons = galsim.PhotonArray.makeFromImage(
                    subimage, max_flux=max(img3.max()/10000.0, 1))

                #############################################################################
                #  ###########################################################
                # do something for each photons;
                ##############################################################################
                # ############################################################
                idx0 = np.where(photons.flux > 1e-2)
                # energy=energy+sum(photons.flux[idx0])     ### totla energy for slice image
                p_num = len(idx0[0])

                ###############################################################################################
                ####################### code for test slice is right or not ###################################
                ###############################################################################################
                # #############################################################
                # ##### code for test slice is right or not ##################
                #########################################################
                # photons_2=galsim.PhotonArray(N=p_num, x=photons.x[idx0], y=photons.y[idx0], flux = photons.flux[idx0], wavelength=lam)
                # if k==0:
                #     sliceimage = galsim.Image(100,100)
@@ -5829,7 +5829,7 @@ class IFSsimulator():

    #         fits.writeto(bluefile, self.image_b, overwrite=True)
    #         fits.writeto(redfile,  self.image_r, overwrite=True)
#################################################################################################
# #############################################################################

    def simulate(self, sourcein, simnumber):
        """
@@ -5902,7 +5902,7 @@ class IFSsimulator():
                df = pd.read_csv(
                    self.information['dir_path']+'IFS_inputdata/TianCe/'+starcat)

                ###################################################################
                ##############################################################
                sn = self.simnumber-1
                arr = np.array(df['time'][sn*5:sn*5+5])
                self.exptime_start_jd, self.exptime_start_index = find_min(arr)
@@ -5911,7 +5911,7 @@ class IFSsimulator():
                # self.earthshine_theta=df['earth_angle'][sn*5+index]      # in degree
                self.dt = jd2time(self.exptime_start_jd)
                self.bianpai_data = df
                ##################################################################
                # ############################################################
            else:

                # ### load orbit parameters  #####
@@ -5937,7 +5937,7 @@ class IFSsimulator():
                    if flag == 1:
                        break

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

                if kk + self.dt_num < len(d[:, 0]):

@@ -6040,7 +6040,7 @@ class IFSsimulator():
        else:
            print('Souce is not correct and programe will return')
            raise ValueError('Souce is not correct and programe will return')
###############################################################################
#  ########################################################################
        # save the original image firstly;
        self.image_b_ori = self.image_b+10.0
        self.image_r_ori = self.image_r+10.0
@@ -6066,7 +6066,7 @@ class IFSsimulator():

        for idk in range(exptimes):

            ############  add some effect to images #######################################
            # ###  add some effect to images #################################

            self.image_b = self.image_b_ori-10.0
            self.image_r = self.image_r_ori-10.0
@@ -6203,4 +6203,4 @@ def runIFSsim(sourcein, configfile, dir_path, result_path, iLoop, debug, applyho

    return 1

############################## end  ##########################################
# ######################### end  ##########################################
+6 −6

File changed.

Contains only whitespace changes.