Commit 66d8b23f authored by GZhao's avatar GZhao
Browse files

fix 4 bugs in configration test

parent 5174c719
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -603,7 +603,6 @@ class CpicVisEmccd(object):
        bias_level = self.bias_level + np.random.randn() * self.bias_level_std
        bias_frame = vp_frame + ci_frame + hp_frame + bias_level
        bias_frame += rn_adu * np.random.randn(shape[0], shape[1]) + bias_shift

        return bias_frame

    def nonlinear_effect(self, image):
@@ -874,6 +873,7 @@ class CpicVisEmccd(object):
        bias = self.bias_frame()

        image = image / self.ph_per_adu + bias
        image = np.round(image)
        image = np.minimum(image, self.max_adu)
        image = np.maximum(image, 0)

+6 −0
Original line number Diff line number Diff line
@@ -623,4 +623,10 @@ def save_fits(images, obs_info, gnc_info, camera_dict={}, csst_format=True, outp

    full_path = f"{folder}/{filename}"
    log.debug(f'save fits file: {full_path}')

    for i in range(1, len(hdu_list)):
        # change the comment of keyword XTENSION from 'image extension' to 'extension type'
        # in order to meet the requirement of data model
        hdu_list[i].header.comments['XTENSION'] = 'extension type'

    hdu_list.writeto(full_path, overwrite=True)
+10 −3
Original line number Diff line number Diff line
@@ -10,12 +10,15 @@ from datetime import datetime
import traceback

import numpy as np
from astropy.io import fits

from .target import spectrum_generator, target_file_load
from .optics import focal_mask, focal_convolve
from .camera import CosmicRayFrameMaker, sky_frame_maker, CpicVisEmccd
from .io import save_fits, log
from .config import update_able_keys, relative_time
from .config import config as default_config
from .config import config as default_config, replace_cpism_refdata
from .psf_simulation import actuator


def vis_observation(
@@ -140,7 +143,7 @@ def vis_observation(
                platescale,
                camera.flat_shape
            )
            sky_bkg_frame = sky_bkg_frame * area * expt
            sky_bkg_frame = sky_bkg_frame * area
            sky_bkg_frame = focal_mask(sky_bkg_frame, iwa, platescale)

        cr_frame = crmaker.make_cr_frame(camera.dark_shape, expt)
@@ -313,7 +316,7 @@ def observation_simulation_from_config(obs_file, config_file):
    if config_file:
        with open(config_file) as fid:
            config = yaml.load(fid, Loader=yaml.FullLoader)

    replace_cpism_refdata(config, output='other')
    camera_config = config.get('camera', [{}])
    all_camera = []
    all_camera_name = []
@@ -323,6 +326,10 @@ def observation_simulation_from_config(obs_file, config_file):

    deduplicate_names_add_count(all_camera_name)

    if 'actuator_file' in config.keys():
        actuator_data = fits.getdata(config['actuator_file'])
        actuator[:] = actuator_data[:]

    for key in config.keys():
        if key in update_able_keys:
            default_config[key] = config[key]
+2 −2
Original line number Diff line number Diff line
band: f662
emgain: 50
emgain: 200
emset: -1
expt: 20
expt: 100
nframe: 2
obsid: '40100000005'
rotation: 30
+2 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ camera:
    nonlinear: false
    shutter: false
csst_format: true
nsample: 5
nsample: 10
check_fits_header: true
output: ./example_output/
actuator_file: ${cpism_refdata}/optics/dark_zone_0011_volt.fits
Loading