<jupyter_start><jupyter_text>Create Calibration images<jupyter_code>%matplotlib notebook

import numpy as np
import matplotlib.pyplot as plt
import os
%load_ext autoreload
%autoreload 2
# Name of output_dir. Will be used for creating folder in catalog/, images/, etc...
output_dir='Calibration/colibri'<jupyter_output><empty_output><jupyter_text>Make Offset, Vignetting and Gain maps<jupyter_code>from ImSimpy.utils.generateCalib import Offset, Vignetting, GainMap

Offset(filename=os.getenv('ImSimpy_DIR')+'/ImSimpy/data/Offset/%s/Offset_vis.fits' % output_dir,
     xsize=4096, ysize=4096, floor=1000)
Offset(filename=os.getenv('ImSimpy_DIR')+'/ImSimpy/data/Offset/%s/Offset_nir.fits' % output_dir,
     xsize=2048, ysize=2048, floor=500)

Vignetting(filename=os.getenv('ImSimpy_DIR')+'/ImSimpy/data/Vignetting/%s/Vignetting_vis.fits' % output_dir,
     floor=1,xsize=4096, ysize=4096)
Vignetting(filename=os.getenv('ImSimpy_DIR')+'/ImSimpy/data/Vignetting/%s/Vignetting_nir.fits' % output_dir,
     floor=1,xsize=2048, ysize=2048)

GainMap(filename=os.getenv('ImSimpy_DIR')+'/ImSimpy/data/GainMap/%s/Gain_vis.fits' % output_dir,
        Type='constant',mean=1.5,xsize=4096,ysize=4096)
GainMap(filename=os.getenv('ImSimpy_DIR')+'/ImSimpy/data/GainMap/%s/Gain_nir.fits' % output_dir,
        Type='random',mean=1.3, std=0.05,Nampl=32,xsize=2048,ysize=2048)<jupyter_output><empty_output><jupyter_text>Make hot and dead pixels maps<jupyter_code>from ImSimpy.utils.generateCosmetics import HotPixs, DeadPixs

HotPixs(filename=os.getenv('ImSimpy_DIR')+'/ImSimpy/data/Cosmetics/%s/HotPixs_nir.fits' % output_dir,
        xsize=2048,ysize=2048,Type='random',hotpixels=500,hotmin=5000,hotmax=40000)
HotPixs(filename=os.getenv('ImSimpy_DIR')+'/ImSimpy/data/Cosmetics/%s/HotPixs_vis.fits' % output_dir,
        xsize=4096,ysize=4096,Type='random',hotpixels=500,hotmin=70000,hotmax=300000)

DeadPixs(filename=os.getenv('ImSimpy_DIR')+'/ImSimpy/data/Cosmetics/%s/DeadPixs_nir.fits' % output_dir,
         xsize=2048,ysize=2048,Type='random',deadpixels=500)
DeadPixs(filename=os.getenv('ImSimpy_DIR')+'/ImSimpy/data/Cosmetics/%s/DeadPixs_vis.fits' % output_dir,
         xsize=4096,ysize=4096,Type='random',deadpixels=2000)<jupyter_output><empty_output><jupyter_text>Create Flat fields<jupyter_code>from ImSimpy.ImSimpy import ImageSimulator

# Configuration file used all along this notebook
configFile=os.getenv('ImSimpy_DIR')+'/ImSimpy/configFiles/Flat.hjson'

# define the telescope to use 
name_telescope='colibri'


bands=['g','r','i','z','J','H']

texp=30

colibri_IS=ImageSimulator(configFile=configFile,name_telescope=name_telescope)
#Read the configfile
colibri_IS.readConfigs()



for band in bands:
   
    if band in ['g','r','i','blue']:
        colibri_IS.config['channel']='DDRAGO-B'
        colibri_IS.config['GainMapFile']='%s/Gain_vis.fits' % output_dir
        colibri_IS.config['VignettingFile']='%s/Vignetting_vis.fits' % output_dir
        colibri_IS.config['OffsetFile']='%s/Offset_vis.fits' % output_dir
        colibri_IS.config['DeadPixFile']='%s/DeadPixs_vis.fits' % output_dir
        colibri_IS.config['HotPixFile']='%s/HotPixs_vis.fits' % output_dir


    elif band in ['z','y','red']:
        colibri_IS.config['channel']='DDRAGO-R'
        colibri_IS.config['GainMapFile']='%s/Gain_vis.fits' % output_dir
        colibri_IS.config['VignettingFile']='%s/Vignetting_vis.fits' % output_dir
        colibri_IS.config['OffsetFile']='%s/Offset_vis.fits' % output_dir
        colibri_IS.config['DeadPixFile']='%s/DeadPixs_vis.fits' % output_dir
        colibri_IS.config['HotPixFile']='%s/HotPixs_vis.fits' % output_dir


    elif band in ['J','H']:
        colibri_IS.config['channel']='CAGIRE'
        colibri_IS.config['GainMapFile']='%s/Gain_nir.fits' % output_dir
        colibri_IS.config['VignettingFile']='%s/Vignetting_nir.fits' % output_dir
        colibri_IS.config['OffsetFile']='%s/Offset_nir.fits' % output_dir
        colibri_IS.config['DeadPixFile']='%s/DeadPixs_nir.fits' % output_dir
        colibri_IS.config['HotPixFile']='%s/HotPixs_nir.fits' % output_dir

            

    colibri_IS.config['exptime']=texp
    colibri_IS.config['filter_band']=band
    colibri_IS.config['output']='%s/Flat_%s_%ss.fits' % (output_dir,band,texp)
    colibri_IS.simulate('data')<jupyter_output>Setting the random number generator seed: current time
Read config file and execute ETC
Building image: Calibration/colibri/Flat_g_30s.fits:
	Add dark current
	Add Sky background
	Add Vignetting
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Flat_r_30s.fits:
	Add dark current
	Add Sky background
	Add Vignetting
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Flat_i_30s.fits:
	Add dark current
	Add Sky background
	Add Vignetting
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Flat_z_30s.fits:
	Add dark current
	Add Sky background
	Add Vignetting
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
[...]<jupyter_text>Create Dark<jupyter_code>configFile=os.getenv('ImSimpy_DIR')+'/ImSimpy/configFiles/Dark.hjson'
bands=['g','r','i','z','J','H']

texp=30

colibri_IS=ImageSimulator(configFile=configFile,name_telescope=name_telescope)
#Read the configfile
colibri_IS.readConfigs()



for band in bands:
   
    if band in ['g','r','i','blue']:
        colibri_IS.config['channel']='DDRAGO-B'
        colibri_IS.config['GainMapFile']='%s/Gain_vis.fits' % output_dir
        colibri_IS.config['OffsetFile']='%s/Offset_vis.fits' % output_dir
        colibri_IS.config['DeadPixFile']='%s/DeadPixs_vis.fits' % output_dir
        colibri_IS.config['HotPixFile']='%s/HotPixs_vis.fits' % output_dir


    elif band in ['z','y','red']:
        colibri_IS.config['channel']='DDRAGO-R'
        colibri_IS.config['GainMapFile']='%s/Gain_vis.fits' % output_dir
        colibri_IS.config['OffsetFile']='%s/Offset_vis.fits' % output_dir
        colibri_IS.config['DeadPixFile']='%s/DeadPixs_vis.fits' % output_dir
        colibri_IS.config['HotPixFile']='%s/HotPixs_vis.fits' % output_dir


    elif band in ['J','H']:
        colibri_IS.config['channel']='CAGIRE'
        colibri_IS.config['GainMapFile']='%s/Gain_nir.fits' % output_dir
        colibri_IS.config['OffsetFile']='%s/Offset_nir.fits' % output_dir
        colibri_IS.config['DeadPixFile']='%s/DeadPixs_nir.fits' % output_dir
        colibri_IS.config['HotPixFile']='%s/HotPixs_nir.fits' % output_dir

            
    colibri_IS.config['exptime']=texp
    colibri_IS.config['filter_band']=band
    colibri_IS.config['output']='%s/Dark_%s_%ss.fits' % (output_dir,band,texp)
    colibri_IS.simulate('data')<jupyter_output>Setting the random number generator seed: current time
Read config file and execute ETC
Building image: Calibration/colibri/Dark_g_30s.fits:
	Add dark current
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Dark_r_30s.fits:
	Add dark current
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Dark_i_30s.fits:
	Add dark current
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Dark_z_30s.fits:
	Add dark current
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Dark_J_30s.fits:
	Add dark current
	[...]<jupyter_text>Create Bias (0s exposure)<jupyter_code>configFile=os.getenv('ImSimpy_DIR')+'/ImSimpy/configFiles/Bias.hjson'
bands=['g','r','i','z','J','H']

texp=0

colibri_IS=ImageSimulator(configFile=configFile,name_telescope=name_telescope)
#Read the configfile
colibri_IS.readConfigs()


for band in bands:
   
    if band in ['g','r','i','blue']:
        colibri_IS.config['channel']='DDRAGO-B'
        colibri_IS.config['GainMapFile']='%s/Gain_vis.fits' % output_dir
        colibri_IS.config['OffsetFile']='%s/Offset_vis.fits' % output_dir
        colibri_IS.config['DeadPixFile']='%s/DeadPixs_vis.fits' % output_dir
        colibri_IS.config['HotPixFile']='%s/HotPixs_vis.fits' % output_dir


    elif band in ['z','y','red']:
        colibri_IS.config['channel']='DDRAGO-R'
        colibri_IS.config['GainMapFile']='%s/Gain_vis.fits' % output_dir
        colibri_IS.config['OffsetFile']='%s/Offset_vis.fits' % output_dir
        colibri_IS.config['DeadPixFile']='%s/DeadPixs_vis.fits' % output_dir
        colibri_IS.config['HotPixFile']='%s/HotPixs_vis.fits' % output_dir


    elif band in ['J','H']:
        colibri_IS.config['channel']='CAGIRE'
        colibri_IS.config['GainMapFile']='%s/Gain_nir.fits' % output_dir
        colibri_IS.config['OffsetFile']='%s/Offset_nir.fits' % output_dir
        colibri_IS.config['DeadPixFile']='%s/DeadPixs_nir.fits' % output_dir
        colibri_IS.config['HotPixFile']='%s/HotPixs_nir.fits' % output_dir

            
    colibri_IS.config['exptime']=texp
    colibri_IS.config['filter_band']=band
    colibri_IS.config['output']='%s/Bias_%s.fits' % (output_dir,band)
    colibri_IS.simulate('data')<jupyter_output>Setting the random number generator seed: current time
Read config file and execute ETC
Building image: Calibration/colibri/Bias_g.fits:
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Bias_r.fits:
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Bias_i.fits:
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Bias_z.fits:
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read config file and execute ETC
Building image: Calibration/colibri/Bias_J.fits:
	Add cosmetics
	Apply Saturation
	Add Readout Noise
	electrons2adu
	Add offset
	Discretise
	Write outputs
Read [...]
{'fraction_non_alphanumeric': 0.12543390561966414, 'fraction_numerical': 0.015855145886105638, 'mean_word_length': 5.126436781609195, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '171729', 'license': 'MIT', 'n_tokens_mistral': 4302, 'n_tokens_neox': 4031, 'n_words': 643, 'path': 'notebooks/Create_Calibration_Images.ipynb', 'repo_name': 'mtourneur/ImSimpy', 'size': '10659'}