Package: dl1-data-handler
A package of utilities for writing (deprecated), reading, and applying image processing toCherenkov Telescope Array (CTA)DL1 data (calibrated images) in a standardized format. Created primarily for testing machine learning image analysis techniques on IACT data.Currently supports data in the CTA pyhessio sim_telarray format, with the possibility of supporting other IACT data formats in the future. Built using ctapipe and PyTables.Previously named image-extractor (v0.1.0 - v0.6.0). Currently under development, intended for internal use only.Data Format[Deprecated] DL1DataWriter implements a standardized format for storing simulated CTA DL1 event data into Pytables files. CTAMLDataDumper is the class which implements the conversion from ctapipe containers to the CTA ML data format. See the wiki pageherefor a full description of this data format and an FAQ.ctapipe process tool should be used instead.InstallationThe following installation method (for Linux) is recommended:Installing as a conda packageTo install dl1-data-handler as a conda package, first install Anaconda by following the instructions here:https://www.anaconda.com/distribution/.The following command will set up a conda virtual environment, add the
necessary package channels, and install dl1-data-handler specified version and its dependencies:DL1DH_VER=0.10.11wgethttps://raw.githubusercontent.com/cta-observatory/dl1-data-handler/v$DL1DH_VER/environment.ymlcondaenvcreate-n[ENVIRONMENT_NAME]-fenvironment.ymlcondaactivate[ENVIRONMENT_NAME]condainstall-cctlearn-projectdl1_data_handler=$DL1DH_VERThis should automatically install all dependencies (NOTE: this may take some time, as by default MKL is included as a dependency of NumPy and it is very large).If you want to import any functionality from dl1-data-handler into your own Python scripts, then you are all set. However, if you wish to make use of any of the scripts in dl1-data-handler/scripts (like write_data.py), you should also clone the repository locally and checkout the corresponding tag (i.e. for version v0.10.11):gitclonehttps://github.com/cta-observatory/dl1-data-handler.gitgitcheckoutv0.10.11dl1-data-handler should already have been installed in your environment by Conda, so no further installation steps (i.e. with setuptools or pip) are necessary and you should be able to run scripts/write_data.py directly.DependenciesThe main dependencies are:PyTables >= 3.7NumPy >= 1.16.0ctapipe == 0.19Also see setup.py.Usage[Deprecated] DL1DataWriterThe DL1DataWriter is not supported by the default installation. Please follow the custom installation instructions:gitclonehttps://github.com/cta-observatory/dl1-data-handler.gitgitcheckoutmagic# for MAGIC datacondaenvcreate-n[ENVIRONMENT_NAME]-fenvironment-magic.ymlcondaactivate[ENVIRONMENT_NAME]pythonsetup_magic.pyinstallFrom the Command Line:To process data files into a desired format:dl1dh-write_data[runlist][--config_file,-cCONFIG_FILE_PATH][--output_dir,-oOUTPUT_DIR][--debug]on the command line.ex:dl1dh-write_datarunlist.yml-cexample_config.yml--debugrunlist - A YAML file containing groups of input files to load data from and output files to write to. See example runlist for format.config_file - The path to a YAML configuration file specifying all of the settings for data loading and writing. See example config file and documentation for details on each setting. If none is provided, default settings are used for everything.output_dir - Path to directory to write all output files to. If not provided, defaults to the current directory.debug - Optional flag to print additional debug information from the logger.In a Python script:If the package was installed with pip as described above, you can import and use it in Python like:ex:fromdl1_data_handlerimportdl1_data_writerevent_source_class=MyEventSourceClassevent_source_settings={'setting1':'value1'}data_dumper_class=MyDataDumperClassdata_dumper_settings={'setting2':'value2'}defmy_cut_function(event):# custom cut logic herereturnTruedata_writer=dl1_data_writer.DL1DataWriter(event_source_class=event_source_class,event_source_settings=event_source_settings,data_dumper_class=data_dumper_class,data_dumper_settings=dumper_settings,preselection_cut_function=my_cut_function,output_file_size=10737418240,events_per_file=500)run_list=[{'inputs':['file1.simtel.gz','file2.simtel.gz'],'target':'output.h5'}]data_writer.process_data(run_list)Generating a run listIf processing data from simtel.gz files, as long as their filenames have the format[particle_type]_[ze]deg_[az]deg_run[run_number]___[productioninfo].simtel.gzor[particle_type]_[ze]deg_[az]deg_run[run_number]___[productioninfo]_cone[cone_num].simtel.gzthe dl1dh-generate_runlist can be used to automatically generate a runlist in the correct format. The script can also generate a run list with the MAGIC-MARS superstar files.It can be called as:dl1dh-generate_runlist[file_dir][--num_inputs_per_run,-nNUM_INPUTS_PER_RUN][--output_file_name,-fOUTPUT_FILE_NAME][--output_dir,-oOUTPUT_DIR]file_dir - Path to a directory containing simtel.gz files with the filename format specified above.num_inputs_per_run - Number of input files with the same particle type, ze, az, and production info to group together into each run (defaults to 10).output_file - Path/filename of output runlist file without a postfix. Defaults to ./runlistoutput_dir - Path where to save generated files. By default, the input directory is used.It will automatically sort the simtel files in the file_dir directory into groups with matching particle_type, zenith, azimuth, and production parameters. Within each of these groups, it will group together input files in sequential order into runs of size NUM_INPUTS_PER_RUN. The output filename for each run will be automatically generated as[particle_type]_[ze]deg_[az]deg_runs[run_number_range]___[productioninfo].h5. The output YAML file will be written to output_file.ImageMapperThe ImageMapper class transforms the hexagonal input pixels into a 2D Cartesian output image. The basic usage is demonstrated in theImageMapper tutorial. It requiresctapipe-extraoutside of the dl1-data-handler. See this publication for a detailed description:arXiv:1912.09898Other scriptsAll other scripts located in the scripts/deprecated directory are not currently updated to be compatible with dl1-data-handler >= 0.7.0 and should not be used.Examples/TipsVitables is very helpful for viewing and debugging PyTables-style HDF5 files. Installation/download instructions can be found in the link below.Known Issues/TroubleshootingLinksCherenkov Telescope Array (CTA)- Homepage of the CTA collaborationCTLearnandGammaLearn- Repository of code for studies on applying deep learning to IACT analysis tasks. Maintained by groups at Columbia University, Universidad Complutense de Madrid, Barnard College (CTLearn) and LAPP (GammaLearn).ctapipe- Official documentation for the ctapipe analysis package (in development)ViTables- Homepage for ViTables application for Pytables HDF5 file visualization