Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify leakage variable names #455

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lstchain/data/lstchain_src_dep_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"length": [0, Infinity],
"wl": [0, 1],
"r": [0, 1],
"intensity_width_2": [0, 1]
"leakage_intensity_width_2": [0, 1]
},

"tailcut": {
Expand Down Expand Up @@ -62,7 +62,7 @@
"skewness_from_source",
"kurtosis",
"time_gradient_from_source",
"intensity_width_2",
"leakage_intensity_width_2",
"n_islands",
"dist"
],
Expand All @@ -75,7 +75,7 @@
"skewness_from_source",
"kurtosis",
"time_gradient_from_source",
"intensity_width_2",
"leakage_intensity_width_2",
"n_islands",
"log_reco_energy",
"dist"
Expand Down
6 changes: 3 additions & 3 deletions lstchain/data/lstchain_standard_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"length": [0, Infinity],
"wl": [0, 1],
"r": [0, 1],
"intensity_width_2": [0, 1]
"leakage_intensity_width_2": [0, 1]
},

"tailcut": {
Expand Down Expand Up @@ -67,7 +67,7 @@
"kurtosis",
"r",
"time_gradient",
"intensity_width_2",
"leakage_intensity_width_2",
"n_islands"
],

Expand All @@ -84,7 +84,7 @@
"kurtosis",
"r",
"time_gradient",
"intensity_width_2",
"leakage_intensity_width_2",
"n_islands",
"log_reco_energy",
"reco_disp_dx",
Expand Down
6 changes: 3 additions & 3 deletions lstchain/data/soft_cut_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
0,
1
],
"intensity_width_2": [
"leakage_intensity_width_2": [
0,
0.4
]
Expand Down Expand Up @@ -81,7 +81,7 @@
"kurtosis",
"r",
"time_gradient",
"intensity_width_2",
"leakage_intensity_width_2",
"n_islands"
],
"classification_features": [
Expand All @@ -97,7 +97,7 @@
"kurtosis",
"r",
"time_gradient",
"intensity_width_2",
"leakage_intensity_width_2",
"n_islands",
"log_reco_energy",
"reco_disp_dx",
Expand Down
26 changes: 13 additions & 13 deletions lstchain/io/lstcontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
"""

import astropy.units as u
from astropy.units import Quantity
import numpy as np
from astropy.units import Quantity
from ctapipe.core import Container, Field
from ctapipe.image import timing_parameters as time
from ctapipe.image import leakage, concentration
from ctapipe.image import timing_parameters as time
from ctapipe.image.morphology import number_of_islands
from numpy import nan

from ..reco import utils
from numpy import nan

__all__ = [
'DL1MonitoringEventIndexContainer',
'DL1ParametersContainer',
'DispContainer',
'LSTEventType'
'MetaData',
'ThrownEventsHistogram',
'DL1MonitoringEventIndexContainer',
'LSTEventType'
]


Expand Down Expand Up @@ -50,10 +50,10 @@ class DL1ParametersContainer(Container):
src_y = Field(None, 'source y coordinate in camera frame', unit=u.m)
time_gradient = Field(None, 'Time gradient in the camera')
intercept = Field(None, 'Intercept')
intensity_width_2 = Field(None, 'Fraction of intensity in outermost pixels')
intensity_width_2 = Field(None, 'Fraction of intensity in two outermost rings of pixels')
pixels_width_1 = Field(None, 'Fraction of signal pixels that are border pixels')
pixels_width_2 = Field(None, 'Fraction of signal pixels that are in the two outermost rings of pixels')
leakage_intensity_width_1 = Field(None, 'Fraction of intensity in outermost pixels')
leakage_intensity_width_2 = Field(None, 'Fraction of intensity in two outermost rings of pixels')
leakage_pixels_width_1 = Field(None, 'Fraction of signal pixels that are border pixels')
leakage_pixels_width_2 = Field(None, 'Fraction of signal pixels that are in the two outermost rings of pixels')
n_pixels = Field(None, 'Number of pixels after cleaning')
concentration_cog = Field(None, 'Fraction of intensity in three pixels closest to the cog')
concentration_core = Field(None, 'Fraction of intensity inside hillas ellipse')
Expand Down Expand Up @@ -172,10 +172,10 @@ def set_timing_features(self, geom, image, pulse_time, hillas):

def set_leakage(self, geom, image, clean):
leakage_c = leakage(geom, image, clean)
self.intensity_width_1 = leakage_c.intensity_width_1
self.intensity_width_2 = leakage_c.intensity_width_2
self.pixels_width_1 = leakage_c.pixels_width_1
self.pixels_width_2 = leakage_c.pixels_width_2
self.leakage_intensity_width_1 = leakage_c.intensity_width_1
self.leakage_intensity_width_2 = leakage_c.intensity_width_2
self.leakage_pixels_width_1 = leakage_c.pixels_width_1
self.leakage_pixels_width_2 = leakage_c.pixels_width_2

def set_concentration(self, geom, image, hillas_parameters):
conc = concentration(geom, image, hillas_parameters)
Expand Down
24 changes: 12 additions & 12 deletions lstchain/mc/sensitivity.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import astropy.units as u
import numpy as np
import pandas as pd
import astropy.units as u
from .plot_utils import sensitivity_minimization_plot, plot_positions_survived_events
from .mc import rate, weight
from lstchain.spectra.crab import crab_hegra,crab_magic
from lstchain.spectra.proton import proton_bess
from gammapy.stats import WStatCountsStatistic
from lstchain.reco.utils import reco_source_position_sky
from astropy.coordinates.angle_utilities import angular_separation
from gammapy.stats import WStatCountsStatistic

from lstchain.io import read_simu_info_merged_hdf5
from lstchain.io.io import dl2_params_lstcam_key
from lstchain.reco.utils import reco_source_position_sky
from lstchain.spectra.crab import crab_hegra
from lstchain.spectra.proton import proton_bess
from .mc import rate, weight

__all__ = [
'read_sim_par',
'process_mc',
'bin_definition',
'calculate_sensitivity',
'calculate_sensitivity_lima',
'calculate_sensitivity_lima_ebin',
'bin_definition',
'ring_containment',
'find_best_cuts_sensitivity',
'process_mc',
'read_sim_par',
'ring_containment',
'sensitivity',
]

Expand Down Expand Up @@ -83,7 +83,7 @@ def process_mc(dl1_file, dl2_file, mc_type):
# by the number of LSTs in the simulation)

filter_good_events = (
(events.intensity_width_2 < 0.2)
(events.leakage_intensity_width_2 < 0.2)
& (events.intensity > 50)
# & (events.tel_id==1)
# & (events.wl > 0.1)
Expand Down
36 changes: 19 additions & 17 deletions lstchain/reco/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,38 @@
"import utils"
"""

import numpy as np
from ctapipe.coordinates import CameraFrame
import logging
from warnings import warn

import astropy.units as u
from astropy.utils import deprecated
import numpy as np
import pandas as pd
from astropy.coordinates import AltAz, SkyCoord, EarthLocation
from astropy.time import Time
from astropy.utils import deprecated
from ctapipe.coordinates import CameraFrame

from . import disp
from warnings import warn
import pandas as pd
import logging

__all__ = [
'alt_to_theta',
'az_to_phi',
'cal_cam_source_pos',
'get_event_pos_in_camera',
'reco_source_position_sky',
'camera_to_altaz',
'sky_to_camera',
'radec_to_camera',
'source_side',
'source_dx_dy',
'polar_to_cartesian',
'cartesian_to_polar',
'predict_source_position_in_camera',
'clip_alt',
'expand_tel_list',
'filter_events',
'linear_imputer',
'get_event_pos_in_camera',
'impute_pointing',
'clip_alt',
'linear_imputer',
'polar_to_cartesian',
'predict_source_position_in_camera',
'radec_to_camera',
'reco_source_position_sky',
'sky_to_camera',
'source_dx_dy',
'source_side',
'unix_tai_to_time',
]

Expand Down Expand Up @@ -423,7 +425,7 @@ def filter_events(events,
length=[0, np.inf],
wl=[0, np.inf],
r=[0, np.inf],
intensity_width_2=[0, 1],
leakage_intensity_width_2=[0, 1],
),
dropna=True,
):
Expand Down
36 changes: 19 additions & 17 deletions lstchain/scripts/lstchain_mc_dl1ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@

"""

import tables
import numpy as np
import argparse
from lstchain.io.io import dl1_params_lstcam_key, dl1_images_lstcam_key
from distutils.util import strtobool

import numpy as np
import tables
from astropy.table import Table
from astropy.units import Quantity
from ctapipe.containers import HillasParametersContainer
from ctapipe.image import hillas_parameters
from ctapipe.image.cleaning import tailcuts_clean
from ctapipe.image.morphology import number_of_islands
from ctapipe.image import hillas_parameters
from lstchain.io.config import read_configuration_file, replace_config
from lstchain.io.config import get_standard_config
from ctapipe.instrument import CameraGeometry, OpticsDescription
from lstchain.io.lstcontainers import DL1ParametersContainer
from ctapipe.containers import HillasParametersContainer
from astropy.units import Quantity
from distutils.util import strtobool

from lstchain.io import get_dataset_keys, auto_merge_h5files
from astropy.table import Table
from lstchain.io.config import get_standard_config
from lstchain.io.config import read_configuration_file, replace_config
from lstchain.io.io import dl1_params_lstcam_key, dl1_images_lstcam_key
from lstchain.io.lstcontainers import DL1ParametersContainer

parser = argparse.ArgumentParser(
description="Recompute DL1b parameters from a DL1a file")
Expand Down Expand Up @@ -80,16 +82,16 @@ def main():
dl1_container = DL1ParametersContainer()
parameters_to_update = list(HillasParametersContainer().keys())
parameters_to_update.extend([
'wl', 'r',
'intensity_width_1',
'intensity_width_2',
'pixel_width_1',
'pixel_width_2',
'concentration_cog',
'concentration_core',
'concentration_pixel',
'n_pixels',
'leakage_intensity_width_1',
'leakage_intensity_width_2',
'leakage_pixel_width_1',
'leakage_pixel_width_2',
'n_islands', 'intercept', 'time_gradient'
'n_pixels',
'wl', 'r',
])

nodes_keys = get_dataset_keys(args.input_file)
Expand Down