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

update

parent d851b140
Loading
Loading
Loading
Loading
Loading
+135 −135
Original line number Diff line number Diff line
@@ -105,10 +105,10 @@ def get_file_extension(filename):
    return extension
##########################################################


"""
Charge Transfer Inefficiency
============================

This file contains a simple class to run a CDM03 CTI model developed by Alex Short (ESA).

This now contains both the official CDM03 and a new version that allows different trap
@@ -237,7 +237,7 @@ class CDM03bidir():

        :return: image that has been run through the CDM03 model
        :rtype: ndarray  """""
        
        #
        # return data

        iflip = iquadrant / 2
@@ -293,7 +293,7 @@ def ill2flux(E, path):

    # use template from sky_bkg (background_spec_hst.dat)
    filename = path+'MCI_inputData/refs/background_spec_hst.dat'
    cat_spec = pd.read_csv(filename, sep='\s+', header=None, comment='#')
    cat_spec = pd.read_csv(filename, sep='\\s+', header=None, comment='#')
    wave0 = cat_spec[0].values       # A
    spec0 = cat_spec[2].values      # erg/s/cm^2/A/arcsec^2

@@ -351,7 +351,7 @@ def earth_angle(time_jd, x_sat, y_sat, z_sat, ra_obj, dec_obj):

def CCDnonLinearityModel(data, beta=6e-7):
    """

    ##
    The non-linearity is modelled based on the results presented.
    :param data: data to which the non-linearity model is being applied to
    :type data: ndarray
@@ -522,7 +522,7 @@ def jd2mjd(jd):


def dt2hmd(dt):
    ## dt is datetime
    # dt is datetime
    hour = dt.hour
    minute = dt.minute
    second = dt.second
@@ -758,7 +758,7 @@ PSF interpolation for MCI_sim
'''


###find neighbors-KDtree  ###
# find neighbors-KDtree  ###

def findNeighbors(tx, ty, px, py, dn=5):
    """
@@ -782,7 +782,7 @@ def findNeighbors(tx, ty, px, py, dn=5):
    return indexq

###############################################################################
###PSF-IDW###
# PSF-IDW###


def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, dn=5, IDWindex=3, OnlyNeighbors=True):
@@ -807,10 +807,10 @@ def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, dn=5, IDWindex=3, OnlyNeighbo
    ngy, ngx = PSFMat[:, :, 0, 0].shape  # PSF data size

    ####################################
    #######   my code  ######
    #   my code  ######
    psfWeight = np.zeros([dn])

    if OnlyNeighbors == True:
    if OnlyNeighbors:

        neigh = findNeighbors(px, py, cen_col, cen_row, dn)

@@ -929,10 +929,10 @@ class MCIsimulator():
        # self.config.readfp(open(self.configfile))
        self.config.read_file(open(self.configfile))


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


#######
#######
    def processConfigs(self):
        """
        Processes configuration information and save the information to a dictionary self.information.
@@ -998,7 +998,7 @@ class MCIsimulator():
            self.section, 'save_cosmicrays')
        self.lensing = self.config.getboolean(self.section, 'lensing')

        ###############################################3#################################
        # #################################
        self.booleans = dict(cosmicRays=self.cosmicRays,
                             darknoise=self.darknoise,
                             cosmetics=self.cosmetics,
@@ -1026,8 +1026,8 @@ class MCIsimulator():

        return

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

    def _createEmpty(self):
        """
@@ -1035,8 +1035,8 @@ class MCIsimulator():
        add g r i channel images;

        Creates lensing parameters;

        """
        
        self.image_g = np.zeros(
            (self.information['ysize'], self.information['xsize']), dtype=float)
        self.image_r = np.zeros(
@@ -1103,7 +1103,7 @@ class MCIsimulator():

        self.source = sourcein

        ##print('print information:', self.information)
        # print('print information:', self.information)

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

@@ -1128,7 +1128,7 @@ class MCIsimulator():
        self.result_path = self.information['result_path'] + \
            self.source+"_"+result_day

        if os.path.isdir(self.result_path) == False:
        if os.path.isdir(self.result_path) is False:
            os.mkdir(self.result_path)
            os.mkdir(self.result_path+'/cali_Data')
            os.mkdir(self.result_path+'/log_Data')
@@ -1810,7 +1810,7 @@ class MCIsimulator():
            flag = (umag > 0 and gmag > 0 and rmag >
                    0 and imag > 0 and zmag > 0)

            if flag == False:
            if flag is False:
                continue

            wave = np.linspace(2500, 11000, 8501)
@@ -2067,7 +2067,7 @@ class MCIsimulator():

        # interpolated zodical surface brightness at 0.5 um
        zodi = pd.read_csv(
            self.information['dir_path']+'MCI_inputData/refs/zodi_map.dat', sep='\s+', header=None, comment='#')
            self.information['dir_path']+'MCI_inputData/refs/zodi_map.dat', sep='\\s+', header=None, comment='#')
        beta_angle = np.array([0, 5, 10, 15, 20, 25, 30, 45, 60, 75])
        lamda_angle = np.array([0, 5, 10, 15, 20, 25, 30, 35, 40, 45,
                                60, 75, 90, 105, 120, 135, 150, 165, 180])
@@ -2077,7 +2077,7 @@ class MCIsimulator():

        # read the zodical spectrum in the ecliptic
        cat_spec = pd.read_csv(
            self.information['dir_path']+'MCI_inputData/refs/solar_spec.dat', sep='\s+', header=None, comment='#')
            self.information['dir_path']+'MCI_inputData/refs/solar_spec.dat', sep='\\s+', header=None, comment='#')
        wave = cat_spec[0].values       # A
        spec0 = cat_spec[1].values      # 10^-8 W m^�? sr^�? μm^�?
        zodi_norm = 252                 # 10^-8 W m^�? sr^�? μm^�?
@@ -2115,7 +2115,7 @@ class MCIsimulator():
        dec = -34.155241212932374

        # halo_id = 229600100382
        if self.sim_star == False:
        if self.sim_star is False:
            self.information['star_ra'] = ra
            self.information['star_dec'] = dec

@@ -2138,7 +2138,7 @@ class MCIsimulator():
        self.information['ra_pnt0'] = center_ra
        self.information['dec_pnt0'] = center_dec
        ####################################################################
        ##################################################################################
        # ###################################################################

        time_jd = time2jd(self.dt)

@@ -2663,12 +2663,12 @@ class MCIsimulator():
        fullimg['i'] = final_image['i'].array

        return fullimg


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

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

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

    def generatePRNU(self, ave=1.0, sigma=0.01):
        """
@@ -2744,8 +2744,8 @@ class MCIsimulator():

        Because the pixel-to-pixel non-uniformity effect (i.e. multiplicative) flat fielding takes place
        before CTI and other effects, the flat field file must be the same size as the pixels that see
        the sky. 
        """
        the sky."""
        
        # generate flatfiledfile, with
        flatsigma = self.information['flatsigma']

@@ -3192,7 +3192,7 @@ class MCIsimulator():
            # end for
            return

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

    def applyBias(self):
        """
@@ -3271,10 +3271,10 @@ class MCIsimulator():

        hdulist_g.writeto(file_g, overwrite=True)
        return


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

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

    def applyBleeding(self, img, direction='not_horizon'):
        """
@@ -5452,10 +5452,10 @@ class MCIsimulator():

            self.log.info('dis_ra(in pixel)=%f, dis_dec(in pixel)=%f, sky_rot(in deg)=%f' % (
                dis_ra*3600/0.05, dis_dec*3600/0.05, theta.deg))
           #######################################################################################################
###################################################################

           #############################################################################
           #########   simulate star images from star SED data       ##################
##################################################################
# ########   simulate star images from star SED data   ###########

            if self.sim_star:
                ###########################
@@ -5659,8 +5659,8 @@ class MCIsimulator():
            print('Souce is not correct and programe will return')
            sys.exit(1)

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

        # Apply flat-field large scale structure for one chip
        if self.flatfieldM: