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

update

parent aa97d21f
Loading
Loading
Loading
Loading
+253 KiB

File added.

No diff preview for this file type.

+93 −93
Original line number Original line Diff line number Diff line
@@ -821,16 +821,16 @@ def psfMaker_IDW(px, py, PSFMat, cen_col, cen_row, dn=5, IDWindex=3, OnlyNeighbo
        dist = np.sqrt((ref_col - cen_col[idx])
        dist = np.sqrt((ref_col - cen_col[idx])
                       ** 2 + (ref_row - cen_row[idx])**2)
                       ** 2 + (ref_row - cen_row[idx])**2)


        if IDWindex == 1:
        #if IDWindex == 1:
            psfWeight[ipsf] = dist
        psfWeight[ipsf] = dist**IDWindex
        if IDWindex == 2:
        # if IDWindex == 2:
            psfWeight[ipsf] = dist**2
        #     psfWeight[ipsf] = dist**2
        if IDWindex == 3:
        # if IDWindex == 3:
            psfWeight[ipsf] = dist**3
        #     psfWeight[ipsf] = dist**3
        if IDWindex == 4:
        # if IDWindex == 4:
            psfWeight[ipsf] = dist**4
        #     psfWeight[ipsf] = dist**4
        if IDWindex == 5:
        # if IDWindex == 5:
            psfWeight[ipsf] = dist**5
        #     psfWeight[ipsf] = dist**5


        psfWeight[ipsf] = max(psfWeight[ipsf], minimum_psf_weight)
        psfWeight[ipsf] = max(psfWeight[ipsf], minimum_psf_weight)
        psfWeight[ipsf] = 1./psfWeight[ipsf]
        psfWeight[ipsf] = 1./psfWeight[ipsf]
@@ -1051,7 +1051,7 @@ class MCIsimulator():
            (self.information['ysize'], self.information['xsize']), dtype=float)
            (self.information['ysize'], self.information['xsize']), dtype=float)
        return
        return


###############################################################################
##########################################IDWindex#####################################
##############################################################################
##############################################################################
    def _loadGhostModel(self):
    def _loadGhostModel(self):
        """
        """
@@ -1822,11 +1822,11 @@ class MCIsimulator():


            # ###### use  SED_code to generate star SED   #######
            # ###### use  SED_code to generate star SED   #######
            if get_file_extension(starcat) == '.fits':
            if get_file_extension(starcat) == '.fits':
                umag = self.star['gmag'][j]
                umag = self.star['gmag'][j]; gmag = self.star['gmag'][j]; rmag = self.star['rmag'][j]; imag = self.star['imag'][j]; zmag = self.star['zmag'][j];
                gmag = self.star['gmag'][j]

                rmag = self.star['rmag'][j]

                imag = self.star['imag'][j]

                zmag = self.star['zmag'][j]



            # SED of j-th star
            # SED of j-th star
            else:
            else:
@@ -1926,7 +1926,7 @@ class MCIsimulator():
                    psf[ch] = ndimage.rotate(
                    psf[ch] = ndimage.rotate(
                        temp, theta.deg, order=1, reshape=True)
                        temp, theta.deg, order=1, reshape=True)
                else:
                else:
                    psf[ch] = temp
                    psf[ch] = tempIDWindex


                conv = psf[ch]
                conv = psf[ch]
                conv = conv/conv.sum()
                conv = conv/conv.sum()
@@ -2205,7 +2205,7 @@ class MCIsimulator():
        #                    'earthshine': earthshine_ifs})
        #                    'earthshine': earthshine_ifs})


        self.zodiacal_wave = wave_mci            # in A
        self.zodiacal_wave = wave_mci            # in A
        self.zodiacal_flux = zodi_mci
        self.zodiacal_flux = zodi_mciIDWindex


        self.earthshine_wave = wave_mci          # A
        self.earthshine_wave = wave_mci          # A
        self.earthshine_flux = earthshine_mci
        self.earthshine_flux = earthshine_mci
@@ -3312,42 +3312,42 @@ class MCIsimulator():
        return
        return


##############################################################################
##############################################################################
    def img_fits_save(self, data, filename):
    # def img_fits_save(self, data, filename):
        ####
    #     ####

        ofd_g = fits.PrimaryHDU()
        # World coordinate system and related parameters  #####
        hdu_g = fits.ImageHDU(data)

        hdu_g.header['WCSAXES'] = (np.int16(2),    'number of WCS axes')
        hdu_g.header['CRPIX1'] = (
            round(float(self.information['CRPIX1']), 1), 'x-coordinate of reference pixel')
        hdu_g.header['CRPIX2'] = (
            round(float(self.information['CRPIX2']), 1), 'y-coordinate of reference pixel')

        hdu_g.header['CRVAL1'] = (
            float(self.information['CRVAL1']), 'first axis value at reference pixel')
        hdu_g.header['CRVAL2'] = (
            float(self.information['CRVAL2']), 'second axis value at reference pixel')
        hdu_g.header['CTYPE1'] = (
            'RA---TAN', 'the coordinate type for the first axis')
        hdu_g.header['CTYPE2'] = (
            'DEC--TAN', 'the coordinate type for the second axis')
        hdu_g.header['CD1_1'] = (
            float(self.information['CD1_1']), 'partial of first axis coordinate w.r.t. x')
        hdu_g.header['CD1_2'] = (
            float(self.information['CD1_2']), 'partial of first axis coordinate w.r.t. y')
        hdu_g.header['CD2_1'] = (
            float(self.information['CD2_1']), 'partial of second axis coordinate w.r.t. x')
        hdu_g.header['CD2_2'] = (
            float(self.information['CD2_2']), 'partial of second axis coordinate w.r.t. y')

        hdulist_g = fits.HDUList([ofd_g, hdu_g])

        file_g = self.result_path+'/ori_Sky/'+filename + '.fits'


        hdulist_g.writeto(file_g, overwrite=True)
    #     ofd_g = fits.PrimaryHDU()
        return
    #     # World coordinate system and related parameters  #####
    #     hdu_g = fits.ImageHDU(data)

    #     hdu_g.header['WCSAXES'] = (np.int16(2),    'number of WCS axes')
    #     hdu_g.header['CRPIX1'] = (
    #         round(float(self.information['CRPIX1']), 1), 'x-coordinate of reference pixel')
    #     hdu_g.header['CRPIX2'] = (
    #         round(float(self.information['CRPIX2']), 1), 'y-coordinate of reference pixel')

    #     hdu_g.header['CRVAL1'] = (
    #         float(self.information['CRVAL1']), 'first axis value at reference pixel')
    #     hdu_g.header['CRVAL2'] = (
    #         float(self.information['CRVAL2']), 'second axis value at reference pixel')
    #     hdu_g.header['CTYPE1'] = (
    #         'RA---TAN', 'the coordinate type for the first axis')
    #     hdu_g.header['CTYPE2'] = (
    #         'DEC--TAN', 'the coordinate type for the second axis')
    #     hdu_g.header['CD1_1'] = (
    #         float(self.information['CD1_1']), 'partial of first axis coordinate w.r.t. x')
    #     hdu_g.header['CD1_2'] = (
    #         float(self.information['CD1_2']), 'partial of first axis coordinate w.r.t. y')
    #     hdu_g.header['CD2_1'] = (
    #         float(self.information['CD2_1']), 'partial of second axis coordinate w.r.t. x')
    #     hdu_g.header['CD2_2'] = (
    #         float(self.information['CD2_2']), 'partial of second axis coordinate w.r.t. y')

    #     hdulist_g = fits.HDUList([ofd_g, hdu_g])

    #     file_g = self.result_path+'/ori_Sky/'+filename + '.fits'

    #     hdulist_g.writeto(file_g, overwrite=True)
    #     return
###########
###########
########
########
##############################################################################
##############################################################################
@@ -3370,46 +3370,46 @@ class MCIsimulator():
        else:
        else:


            if direction == 'horizon':
            if direction == 'horizon':

                self.information['bleding_direction']='Not_horizon'
                # loop over each column, as bleeding is modelled column-wise
                # loop over each column, as bleeding is modelled column-wise
                for i, column in enumerate(data):  # select one solumnn
                # for i, column in enumerate(data):  # select one solumnn
                    if column.max() <= self.information['fullwellcapacity']:
                #     if column.max() <= self.information['fullwellcapacity']:
                        continue
                #         continue
                    sum = 0.
                #     sum = 0.
                    for j, value in enumerate(column):
                #     for j, value in enumerate(column):
                        # first round - from bottom to top (need to half the bleeding)
                #         # first round - from bottom to top (need to half the bleeding)
                        overload = value - self.information['fullwellcapacity']
                #         overload = value - self.information['fullwellcapacity']
                        if overload > 0.:
                #         if overload > 0.:
                            overload /= 2.
                #             overload /= 2.
                            # self.image[j, i] -= overload
                #             # self.image[j, i] -= overload
                            data[i, j] -= overload
                #             data[i, j] -= overload
                            sum += overload
                #             sum += overload


                        elif sum > 0.:
                #         elif sum > 0.:
                            if -overload > sum:
                #             if -overload > sum:
                                overload = -sum
                #                 overload = -sum
                            # self.image[j, i] -= overload
                #             # self.image[j, i] -= overload
                            data[i, j] -= overload
                #             data[i, j] -= overload
                            sum += overload
                #             sum += overload
                ######################################################
                # ######################################################
                for i, column in enumerate(data):
                # for i, column in enumerate(data):
                    if column.max() <= self.information['fullwellcapacity']:
                #     if column.max() <= self.information['fullwellcapacity']:
                        continue
                #         continue
                    sum = 0.
                #     sum = 0.
                    for j, value in enumerate(column[::-1]):
                #     for j, value in enumerate(column[::-1]):
                        # second round - from top to bottom (bleeding was half'd already, so now full)
                #         # second round - from top to bottom (bleeding was half'd already, so now full)
                        overload = value - self.information['fullwellcapacity']
                #         overload = value - self.information['fullwellcapacity']
                        if overload > 0.:
                #         if overload > 0.:
                            # self.image[-j-1, i] -= overload
                #             # self.image[-j-1, i] -= overload
                            data[i, -j-1] -= overload
                #             data[i, -j-1] -= overload
                            sum += overload
                #             sum += overload


                        elif sum > 0.:
                #         elif sum > 0.:
                            if -overload > sum:
                #             if -overload > sum:
                                overload = -sum
                #                 overload = -sum
                            # self.image[-j-1, i] -= overload
                #             # self.image[-j-1, i] -= overload
                            data[i, -j-1,] -= overload
                #             data[i, -j-1,] -= overload
                            sum += overload
                #             sum += overload


            else:
            else:


+187 B

File added.

No diff preview for this file type.

+1.72 KiB

File added.

No diff preview for this file type.

+188 B

File added.

No diff preview for this file type.

Loading