Commit 5fd170d7 authored by Wei Chengliang's avatar Wei Chengliang
Browse files

update codestyle-PEP8

parent c326c535
Loading
Loading
Loading
Loading
Loading
+43 −4
Original line number Diff line number Diff line
@@ -17,13 +17,52 @@ def add_prescan_overscan(self, chip, filt, tel, pointing, catalog, obs_param):
                                     over1=chip.overscan_x,
                                     over2=chip.overscan_y)

    if obs_param["add_dark"] == True:
    if obs_param["add_dark"] is True:
        ny = int(chip.npix_y/2)
        base_dark = (ny-1)*(chip.readout_time/ny)*chip.dark_noise
        chip.img.array[(chip.prescan_y+ny):-(chip.prescan_y+ny), :] = base_dark
    return chip, filt, tel, pointing


def add_crosstalk(self, chip, filt, tel, pointing, catalog, obs_param):
    crosstalk=np.zeros([16,16])
    crosstalk[0,:] = np.array([1., 1e-4, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
    crosstalk[1,:] = np.array([1e-4, 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
    crosstalk[2,:] = np.array([0., 0., 1., 1e-4, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
    crosstalk[3,:] = np.array([0., 0., 1e-4, 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
    crosstalk[4,:] = np.array([0., 0., 0., 0., 1., 1e-4, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
    crosstalk[5,:] = np.array([0., 0., 0., 0., 1e-4, 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
    crosstalk[6,:] = np.array([0., 0., 0., 0., 0., 0., 1., 1e-4, 0., 0., 0., 0., 0., 0., 0., 0.])
    crosstalk[7,:] = np.array([0., 0., 0., 0., 0., 0., 1e-4, 1., 0., 0., 0., 0., 0., 0., 0., 0.])
    crosstalk[8,:] = np.array([0., 0., 0., 0., 0., 0., 0., 0., 1., 1e-4, 0., 0., 0., 0., 0., 0.])
    crosstalk[9,:] = np.array([0., 0., 0., 0., 0., 0., 0., 0., 1e-4, 1., 0., 0., 0., 0., 0., 0.])
    crosstalk[10,:]= np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1e-4, 0., 0., 0., 0.])
    crosstalk[11,:]= np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1e-4, 1., 0., 0., 0., 0.])
    crosstalk[12,:]= np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1e-4, 0., 0.])
    crosstalk[13,:]= np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1e-4, 1., 0., 0.])
    crosstalk[14,:]= np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1e-4])
    crosstalk[15,:]= np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1e-4, 1.])

    # 2*8 -> 1*16
    img = formatOutput(chip.img)
    ny, nx = img.array.shape
    nsecy=1
    nsecx=16
    dy = int(ny/nsecy)
    dx = int(nx/nsecx)

    newimg = galsim.Image(nx, ny, init_value=0)
    for i in range(16):
        for j in range(16):
            newimg.array[:, int(i*dx):int(i*dx+dx)] += crosstalk[i,j]*img.array[:, int(j*dx):int(j*dx+dx)]

    # 1*16 -> 2*8
    newimg = formatRevert(newimg)
    chip.img.array[:, :] = newimg.array[:, :]

    return chip, filt, tel, pointing


def add_readout_noise(self, chip, filt, tel, pointing, catalog, obs_param):
    seed = int(self.overall_config["random_seeds"]
               ["seed_readout"]) + pointing.id*30 + chip.chipID
@@ -36,13 +75,13 @@ def add_readout_noise(self, chip, filt, tel, pointing, catalog, obs_param):

def apply_gain(self, chip, filt, tel, pointing, catalog, obs_param):
    self.chip_output.Log_info("  Applying Gain")
    if obs_param["gain_16channel"] == True:
    if obs_param["gain_16channel"] is True:
        chip.img, chip.gain_channel = effects.ApplyGainNonUniform16(chip.img,
                                                                    gain=chip.gain,
                                                                    nsecy=chip.nsecy,
                                                                    nsecx=chip.nsecx,
                                                                    seed=self.overall_config["random_seeds"]["seed_gainNonUniform"]+chip.chipID)
    elif obs_param["gain_16channel"] == False:
    elif obs_param["gain_16channel"] is False:
        chip.img /= chip.gain
        chip.gain_channel = np.ones(chip.nsecy*chip.nsecx)*chip.gain
    return chip, filt, tel, pointing
@@ -74,7 +113,7 @@ def quantization_and_output(self, chip, filt, tel, pointing, catalog, obs_param)
    self.updateHeaderInfo(header_flag='ext', keys=['GAIN01', 'GAIN02', 'GAIN03', 'GAIN04', 'GAIN05', 'GAIN06', 'GAIN07',
                          'GAIN08', 'GAIN09', 'GAIN10', 'GAIN11', 'GAIN12', 'GAIN13', 'GAIN14', 'GAIN15', 'GAIN16'], values=gains)

    if obs_param["format_output"] == True:
    if obs_param["format_output"] is True:
        self.chip_output.Log_info("  Apply 1*16 format")
        chip.img = chip_utils.formatOutput(GSImage=chip.img)
        chip.nsecy = 1