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

Migration to Stage1 format #100

Merged
merged 93 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
10cd2af
Update reader for the new format
LucaRomanato Nov 26, 2020
91d5688
Streamline filters and reader code
LucaRomanato Nov 26, 2020
2feff94
fix morphology value
LucaRomanato Nov 26, 2020
5cd36b5
Add all the DataContainer filters
LucaRomanato Nov 26, 2020
7a04564
Streamline code + image_selection for new format
LucaRomanato Nov 26, 2020
9542607
Merge pull request #1 from cta-observatory/hillas
LucaRomanato Nov 26, 2020
29e3781
support only new format
LucaRomanato Nov 30, 2020
fa4ebbe
Streamline filters
LucaRomanato Nov 30, 2020
6ee3058
Update filters.py
LucaRomanato Nov 30, 2020
21e2853
read selected parameters
LucaRomanato Dec 1, 2020
e13ef08
streamline _select_image_from_file code
LucaRomanato Dec 1, 2020
23b558c
adding parameters to example_description
LucaRomanato Dec 1, 2020
f1ee830
update __getitem__ for parameters
LucaRomanato Dec 1, 2020
5246a4a
fix bug if image_selection_from_file or training_parameters are not p…
LucaRomanato Dec 1, 2020
d9d9def
Update parameter string name
LucaRomanato Dec 2, 2020
e993e91
Update reader.py
LucaRomanato Dec 2, 2020
5c745fa
update path event_intensity_filter
LucaRomanato Dec 4, 2020
4929d83
Add legend informations
LucaRomanato Dec 5, 2020
7cd3078
exlude algorithms for filter_function
LucaRomanato Dec 6, 2020
c4e3a36
Preparing reader.py for future works
LucaRomanato Dec 7, 2020
1697589
Improving Reader performance
LucaRomanato Jan 2, 2021
b4975e9
Update log in writer
LucaRomanato Jan 4, 2021
9196f96
Update reader.py
LucaRomanato Jan 14, 2021
4cadbfc
fix reader.py
LucaRomanato Jan 14, 2021
72a7b77
fix np.log10 Hillas_log_intensity
LucaRomanato Jan 16, 2021
b27c253
notebook for reader demo
LucaRomanato Jan 20, 2021
0fab6af
update event_intensity_filter to new format
TjarkMiener Jan 21, 2021
bade4a1
subclassing current dl1dh reader
TjarkMiener Jan 21, 2021
d806423
added Dl1 event-wise reading from stage1 format
TjarkMiener Feb 1, 2021
544bcc0
adopted ctapipe functionality to construct the reader
TjarkMiener Feb 17, 2021
64bca8b
fix travis
TjarkMiener Feb 17, 2021
4a25928
store pix and cam rotation in file
TjarkMiener Dec 1, 2020
99ed21e
store inverted image masks
TjarkMiener Dec 1, 2020
bd7b6a1
store angular distance in rad and energy in log(TeV) in Events table
TjarkMiener Dec 2, 2020
2152303
make image_extractor configurable
TjarkMiener Dec 2, 2020
0211541
prepare for dl1dh v0.9.0
TjarkMiener Dec 2, 2020
fa6814c
added configurable gain selector
TjarkMiener Dec 7, 2020
377de34
apply gain selector only for simtel files
TjarkMiener Dec 7, 2020
6b7a358
add gain selector to example config
TjarkMiener Dec 7, 2020
2479cea
fixed array pointing for MAGIC data
TjarkMiener Dec 7, 2020
c99fdee
clean up
TjarkMiener Dec 9, 2020
1bccd5f
added MAGIC superstar files
TjarkMiener Dec 9, 2020
e219583
only store mc information for selected tels
TjarkMiener Dec 15, 2020
5b44092
bug fixed
TjarkMiener Dec 17, 2020
4d56969
added electrons to the particle transformation
TjarkMiener Dec 3, 2020
0e380bf
adjusted example config file
TjarkMiener Jan 4, 2021
0fc2227
prepare v0.9.0
TjarkMiener Jan 4, 2021
e82752d
change default values for cleaning settings
TjarkMiener Jan 14, 2021
cef1864
add uproot to setup
TjarkMiener Jan 14, 2021
e53eeef
initialize float values with nan
TjarkMiener Jan 14, 2021
f5a152d
read image tables from new format
TjarkMiener Jan 18, 2021
dcc3447
add jupyter to setup
TjarkMiener Jan 18, 2021
3191e9a
update MAGIC demo
TjarkMiener Jan 18, 2021
269be06
README fix - activate source with 'conda activate X'
TjarkMiener Jan 18, 2021
3123b58
add noarch to conda meta.yml
TjarkMiener Jan 20, 2021
a1fc462
update event_intensity_filter to new format
TjarkMiener Jan 21, 2021
15872f2
subclassing current dl1dh reader
TjarkMiener Jan 21, 2021
d2b23fa
added Dl1 event-wise reading from stage1 format
TjarkMiener Feb 1, 2021
cc4b471
adopted ctapipe functionality to construct the reader
TjarkMiener Feb 17, 2021
9fef2e7
fix travis
TjarkMiener Feb 17, 2021
145dd1c
Merge branch 'stage1' of https://github.com/cta-observatory/dl1-data-…
TjarkMiener Feb 24, 2021
6d000f3
fix subclass DL1DataReaderDL1DH
TjarkMiener Mar 1, 2021
9b1ca6e
add run information for GammaBoard (closses #64)
TjarkMiener Mar 2, 2021
53f782a
added MAGIC superstar files to generate_runlist script
TjarkMiener Mar 15, 2021
150ff03
add MAGIC protons in transforms
TjarkMiener Mar 15, 2021
06710ad
update example config
TjarkMiener Mar 15, 2021
cf8e353
add particle ID and image mask from the MARS software
TjarkMiener Mar 15, 2021
7cb4f76
Merge branch 'master' into stage1
TjarkMiener Mar 16, 2021
03bda2d
update ctapipe versio v0.10.5
TjarkMiener Apr 9, 2021
9cc6238
convert back to floating point
TjarkMiener Apr 9, 2021
bb33e5f
adjusted the transforms functions
TjarkMiener Apr 9, 2021
ec98582
moved ctapipe imports in DL1ReaderStage1 class
TjarkMiener Apr 9, 2021
d31c7f2
removed try except from ctapipe import
TjarkMiener Apr 9, 2021
90a1784
Add bool self.mc
astrojarred Mar 5, 2021
a687f70
Read run number directly from root file
astrojarred Mar 8, 2021
94b8850
Add a continer for real MAGIC data
astrojarred Mar 11, 2021
32ad9c4
Change the name of mcheader to just header
astrojarred Mar 11, 2021
0a874d8
Put superstar MC data behind and if statement
astrojarred Mar 11, 2021
736034e
Update _parse_header() to work with real data
astrojarred Mar 11, 2021
7c6c78f
Add a decoder for uproot ASCII arrays
astrojarred Mar 11, 2021
6303bfa
Comment out MC/real_data print statements.
astrojarred Apr 14, 2021
20e0d14
added energy range to meta data
TjarkMiener Apr 21, 2021
f36d564
Merge pull request #101 from astrojarred/stage-1-PR
TjarkMiener Apr 23, 2021
a1d410f
Merge branch 'stage1' into magic_data
TjarkMiener Apr 23, 2021
97ae825
Merge pull request #102 from cta-observatory/magic_data
TjarkMiener Apr 23, 2021
4f2b249
updated transform function to stage1
TjarkMiener Apr 26, 2021
985c8a5
Merge branch 'stage1' of https://github.com/cta-observatory/dl1-data-…
TjarkMiener Apr 26, 2021
f72fecd
update notebooks
TjarkMiener May 9, 2021
a21bce0
reconstruct the SrcPosX/Y in the camera for the arrival direction reg…
TjarkMiener May 9, 2021
6f7eb5f
added ability to read from files with split_datasets_by tel_type
TjarkMiener May 27, 2021
0ecd83e
bug fixed
TjarkMiener May 29, 2021
e8e958f
close example identifiers file
TjarkMiener Jun 7, 2021
8690b57
fix the sorting of the images
TjarkMiener Jun 7, 2021
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ install:
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
- conda create -n test python=3.7
- conda create -n test python=3.7 cython
- conda activate test
- python setup.py develop
script:
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ python setup_light.py install

To install it as a conda package, first install Anaconda by following the instructions here: https://www.anaconda.com/distribution/.

Then, create and enter a new Python 3.7 environment with:
Then, create and enter a new Python 3.7 (with cython) environment with:

```bash
conda create -n [ENVIRONMENT_NAME] python=3.7
conda create -n [ENVIRONMENT_NAME] python=3.7 cython
conda activate [ENVIRONMENT_NAME]
```

Expand Down Expand Up @@ -83,7 +83,7 @@ The main dependencies are:

* PyTables >= 3.4.4
* NumPy >= 1.15.0
* ctapipe == 0.9.1
* ctapipe == 0.10.3

Also see setup.py.

Expand All @@ -96,14 +96,14 @@ Also see setup.py.
To process data files into a desired format:

```bash
scripts/write_data.py [runlist] [--config_file CONFIG_FILE_PATH] [--output_dir OUTPUT_DIR] [--debug]
dl1dh-write_data [runlist] [--config_file,-c CONFIG_FILE_PATH] [--output_dir,-o OUTPUT_DIR] [--debug]
```
on the command line.

ex:

```bash
scripts/write_data.py runlist.yml --config_file example_config.yml --debug
dl1dh-write_data runlist.yml -c example_config.yml --debug
```

* runlist - A YAML file containing groups of input files to load data from and output files to write to. See example runlist for format.
Expand Down Expand Up @@ -148,17 +148,18 @@ data_writer.process_data(run_list)
```
#### Generating a run list

If processing data from simtel.gz files, as long as their filenames have the format ``[particle_type]_[ze]deg_[az]deg_run[run_number]___[production info].simtel.gz`` or ``[particle_type]_[ze]deg_[az]deg_run[run_number]___[production info]_cone[cone_num].simtel.gz`` the scripts/generate_runlist.py can be used to automatically generate a runlist in the correct format.
If processing data from simtel.gz files, as long as their filenames have the format ``[particle_type]_[ze]deg_[az]deg_run[run_number]___[production info].simtel.gz`` or ``[particle_type]_[ze]deg_[az]deg_run[run_number]___[production info]_cone[cone_num].simtel.gz`` the 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:

```bash
scripts/generate_runlist.py [file_dir] [--num_inputs_per_run NUM_INPUTS_PER_RUN] [--output_file OUTPUT_FILE]
dl1dh-generate_runlist [file_dir] [--num_inputs_per_run,-n NUM_INPUTS_PER_RUN] [--output_file_name,-f OUTPUT_FILE_NAME] [--output_dir,-o OUTPUT_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. Defaults to ./runlist.yml
* output_file - Path/filename of output runlist file without a postfix. Defaults to ./runlist
* output_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]___[production info].h5``. The output YAML file will be written to output_file.

Expand Down
2 changes: 1 addition & 1 deletion config/example_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Data Writer:
# Boolean flag indicating whether to save non-triggered Monte Carlo events in a separate MC_Events table.
save_mc_events: False
# Telescope ids dumped to file. Specify the telescopes to write to the the output file.
selected_telescope_ids: [1]
selected_telescope_ids: [1,2]
#selected_telescope_ids: [1,2,3,4]
# Settinigs for the GainSelector
gain_selector_settings:
Expand Down
45 changes: 44 additions & 1 deletion dl1_data_handler/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class MAGICMCHeaderContainer(Container):
prod_site = Field(nan, "Production site")
date_run_mmcs = Field(nan, "Date Run MMCs")
date_run_cam = Field(nan, "Date Run Camera")
energy_range_max = Field(nan * u.GeV, "Energy range Maximum", unit = u.GeV)
energy_range_min = Field(nan * u.GeV, "Energy range Minimum", unit = u.GeV)
shower_theta_max = Field(nan * u.deg, "Shower Theta Maximum", unit = u.deg)
shower_theta_min = Field(nan * u.deg, "Shower Theta Minimum", unit = u.deg)
shower_phi_max = Field(nan * u.deg, "Shower Phi Maximum", unit = u.deg)
Expand All @@ -20,7 +22,7 @@ class MAGICMCHeaderContainer(Container):
height_lev = Field([], "Height Level")
slope_spec = Field(nan, "Slope Spec")
rand_pointing_cone_semi_angle = Field(nan * u.deg, "Random Pointing Cone Semi Angle", unit = u.deg)
impact_max = Field(nan, "Imapact Maximum")
impact_max = Field(nan, "Impact Maximum")
star_field_rotate = Field(nan, "Star Field Rotate")
star_field_ra_h = Field(nan, "Star Field RA H")
star_field_ra_m = Field(nan, "Star Field RA M")
Expand All @@ -41,3 +43,44 @@ class MAGICMCHeaderContainer(Container):
num_phe_from_dnsb = Field(nan, "Number Phe from DNSB")
elec_noise = Field(nan, "Elec Noise")
optic_links_noise = Field(nan, "Optic Links Noise")

class MAGICHeaderContainer(Container):
camera_version = Field(nan, "Camera Version")
fadc_type = Field(nan, "FADC type")
fadc_resolution = Field(nan, "FADC resolution")
format_version = Field(nan, "Format version")
magic_number = Field(nan, "MAGIC number")
num_bytes_per_sample = Field(nan, "Number of bytes per sample")
num_crates = Field(nan, "Number of crates")
num_pix_in_crate = Field(nan, "Number of pixels per crate")
num_samples_hi_gain = Field(nan, "Number of High gain samples")
num_samples_lo_gain = Field(nan, "Number of Low gain samples")
num_samples_removed_head = Field(nan, "Number of samples removed from the head")
num_samples_removed_tail = Field(nan, "Number of samples removed from the tail")
run_type = Field(nan, "Run type")
online_domino_calib = Field(nan, "Online domino calibration")
sample_frequency = Field(nan, "Sample frequency")
soft_version = Field(nan, "Soft version")
source_epoch_date = Field(nan, "Source epoch date")
num_events = Field(nan, "Number of events")
num_events_read = Field(nan, "Number of events read")
channel_header_size = Field(nan, "Channel header size")
event_header_size = Field(nan, "Event header size")
run_header_size = Field(nan, "Run header size")
run_number = Field(nan, "Run number")
subrun_index = Field(nan, "Subrun index")
source_dec = Field(nan, "Source Dec")
source_ra = Field(nan, "Source RA")
telescope_dec = Field(nan, "Telescope Dec")
telescope_ra = Field(nan, "Telescope RA")
observation_mode = Field(nan, "Observation mode")
project_name = Field(nan, "Project name")
source_epoch_char = Field(nan, "Source epoch char")
source_name = Field(nan, "Source name")
calib_coeff_filename = Field(nan, "Calibration coefficient filename")
run_start_mjd = Field(nan, "Start date MJD")
run_start_ms = Field(nan, "Start time in ms")
run_start_ns = Field(nan, "Start time in ns")
run_stop_mjd = Field(nan, "Stop date MJD")
run_stop_ms = Field(nan, "Stop time in ms")
run_stop_ns = Field(nan, "Stop time in ns")
Loading