<jupyter_start><jupyter_text>This is notebook to low level calibration R0->R1 Fill the R1 container ```event.r1.tel[0].waveform```.Following function exist:1. to subtraction pedestal ```subtract_pedestal(event)```2. to dt correction ```time_lapse_corr(event)```3. to interpolate spikes ```interpolate_spikes(event)```or you can call method ```calibrate(event)```, then baseline value will be around 0To subtraction pedestal you need pedestal file from cta-lstchain-extra or you can create pedestal file yourself using scirpt ```create_pedestal_file.py```In ```config``` you can set how many samples in waveform keep to R1 container (first two and last two samples in waveform are noisy)<jupyter_code># Give path to real LST data
# We have to use LSTEventSource: LST-1.1.Run00xxx.xxx.fits.fz
# because for dt correction and interpolate spikes events must be in turn (event_id = 0,1,2, ...)
reader = LSTEventSource(input_url="/media/pawel1/ADATA HD330/20190215/LST-1.1.Run00097.0001.fits.fz",
                        max_events=5)
offset_value = 400
# Give path to pedestal file and set offset to baseline
config = Config({
    "LSTR0Corrections": {
        "pedestal_path": "/media/pawel1/ADATA HD330/20190215/pedestal_run97_new.fits",
        "offset":  offset_value,
        "tel_id": 0, # for EVB3 will be 1
        "r1_sample_start": None,
        "r1_sample_end": None
    }
})
# Give path to pedestal file
lst_r0 = LSTR0Corrections(config=config)

t = np.linspace(2, 37, 36)

for ev in reader:
    plt.figure(figsize=(12, 7))
    plt.step(t,  ev.r0.tel[0].waveform[0, 7, 2:38], color="blue", label="raw waveform")
    
    lst_r0.subtract_pedestal(ev)
    
    plt.step(t,  ev.r1.tel[0].waveform[0, 7, 2:38], color="red", label="after pedestal substraction ")
    
    lst_r0.time_lapse_corr(ev)
    lst_r0.interpolate_spikes(ev)
    
    plt.step(t,  ev.r1.tel[0].waveform[0, 7, 2:38], color="green", label="after pedestal substraction + dt corr + interpolate spikes")
    plt.plot([0, 40], [offset_value, offset_value], 'k--', label="offset")
    plt.xlabel("time sample [ns]")
    plt.ylabel("counts [ADC]")
    plt.legend()
    plt.ylim([-50, 500])
    plt.show()<jupyter_output><empty_output><jupyter_text>Call ```calibrate``` method<jupyter_code># Give path to real LST data
reader = LSTEventSource(
    input_url="/media/pawel1/ADATA HD330/20190215/LST-1.1.Run00097.0001.fits.fz",
    max_events=5)

# Give path to pedestal file and set offset to baseline
config = Config({
    "LSTR0Corrections": {
        "pedestal_path": "/home/pawel1/Pulpit/Astrophysics/CTA/cta-lstchain-extra/calib/camera/pedestal_run97_new.fits",
        "offset":  300,
        "tel_id": 0, # for EVB3 will be 1
        "r1_sample_start": 2,
        "r1_sample_end": 38
    }
})

lst_r0 = LSTR0Corrections(config=config)

t = np.linspace(2, 37, 36)

for ev in reader:
    print(ev.r0.event_id)
    plt.figure(figsize=(12, 7))
    plt.step(t,  ev.r0.tel[0].waveform[0, 7, 2:38], color="blue", label="raw waveform")
    
    lst_r0.calibrate(ev)

    plt.step(t,  ev.r1.tel[0].waveform[0, 7, :], color="red", label="after calib")
    
    plt.xlabel("time sample [ns]")
    plt.ylabel("counts [ADC]")
    plt.legend()
    plt.ylim([-50, 500])
    plt.show()<jupyter_output>53005
{'fraction_non_alphanumeric': 0.14434569414649095, 'fraction_numerical': 0.054551026662580444, 'mean_word_length': 3.821270310192024, 'pattern_counts': {'":': 12, '<': 8, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '136634', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1221, 'n_words': 280, 'path': 'notebooks/low_level_corrections.ipynb', 'repo_name': 'thomasgas/cta-lstchain', 'size': '3263'}