Package: eventio
A Python (read-only) implementation of the EventIO data format invented
by Konrad Bernloehr as used for example by the IACT extension for
CORSIKA:https://www.ikp.kit.edu/corsikaDocumentation of the file format:https://www.mpi-hd.mpg.de/hfm/~bernlohr/sim_telarray/Documentation/eventio_en.pdfMost blocks of the IACT extension and SimTel are implemented.
The following blocks are known, but reading their data is not (yet)
implemented, because we do not have any test files containing
these objects.If you want support for these objects,
please open anissue.CodeDescription1206IACT Camera Layout1207IACT Trigger Time2017SimTel Pixel Calibriation2024SimTel Run Statistics2025SimTel MC Run Statisitics2029SimTel Auxiliary Digital Traces2030SimTel Auxiliary Analog Traces2031SimTel FSPhotinstall withpip install eventioOpen a file produced by the IACT CORSIKA extensionFirst ExampleOne may iterate over an instance ofIACTFileclass in order to retrieve events.
Events have a small number of fields.
The most important one is thephoton_bunchesfield,
which is dictionary mapping telescope ids to a simple structurednp.array,
containing the typical parameters Cherenkov photon bunches in CORSIKA have, like:x,ycoordinate in the observation plane (in cm)direction cosinecx,cyin x and y direction of the incident
angle of the photonwavelengthlambdaof the photon (in nm)number ofphotonsassociated with this bunchthetimesince the first interaction (in ns, I believe)the production height of the photon bunch (calledzem)a bool flag, whether the photon was scattered in the atmosphereAn event has the following attributes: *header: anamedtuplecontaining the Corsika Event Header data *end_block: a numpy array
containing the Corsika Event End data *time_offset,x_offset,y_offsett, the offset of the arrayThis prints energy and the number of photons for the first telescope in every
event:importeventiowitheventio.IACTFile('eventio/resources/one_shower.dat')asf:foreventinf:print(event.header.total_energy)print(event.photon_bunches[0]['photons'].sum())Second ExampleIf you like to plot the origin of the Cherenkov photons of the first
event in fileeventio/resources/one_shower.datafor the first telescope,
have a look intothis exampleIt might look similar to this picture:an example showerOpen a file produced by simtel_arrayimporteventiowitheventio.SimTelFile('eventio/resources/gamma_test.simtel.gz')asf:print(len(f.telescope_descriptions))forarray_eventinf:print(array_event['mc_shower']['energy'])Commandline ToolsWe provide a few commandline tools to look into eventio files.eventio_print_structureTo get an overview over the structure of a file, useeventio_print_structure,
for larger files, you might want to pipe its output into e.g.less:$eventio_print_structureeventio/resources/gamma_test.simtel.gzHistory[70]HistoryCommandLine[71]HistoryConfig[72]HistoryConfig[72]And127objectsmoreofthesametype...RunHeader[2000](run_id=31964)MCRunHeader[2001]MCRunHeader[2001]InputCard[1212]InputCard[1212]CameraSettings[2002](telescope_id=1)CameraOrganization[2003](telescope_id=1)PixelSettings[2004](telescope_id=1)DisabledPixels[2005](telescope_id=1)CameraSoftwareSettings[2006](telescope_id=1)DriveSettings[2008](telescope_id=1)PointingCorrection[2007](telescope_id=1)CameraSettings[2002](telescope_id=2)CameraOrganization[2003](telescope_id=2)eventio_print_object_informationTo get table of all object versions and counts in a file,
useeventio_print_object_information, it can also print json if given the--jsonoption$eventio_print_object_informationeventio/resources/gamma_test.simtel.gzType|Version|Level|#Objects | eventio-class------------------------------------------------------------70|1|0|3|simtel.objects.History71|1|1|3|simtel.objects.HistoryCommandLine72|1|1|32840|simtel.objects.HistoryConfig1212|0|0|2|iact.objects.InputCard2000|2|0|1|simtel.objects.RunHeader2001|4|0|2|simtel.objects.MCRunHeader2002|2|0|98|simtel.objects.CameraSettings2002|3|0|28|simtel.objects.CameraSettings2003|1|0|126|simtel.objects.CameraOrganization2004|2|0|126|simtel.objects.PixelSettings2005|0|0|126|simtel.objects.DisabledPixels2006|0|0|126|simtel.objects.CameraSoftwareSettings2007|0|0|126|simtel.objects.PointingCorrection2008|0|0|126|simtel.objects.DriveSettings2009|2|1|10|simtel.objects.TriggerInformation2010|0|0|10|simtel.objects.ArrayEvent2011|1|2|50|simtel.objects.TelescopeEventHeader2013|3|2|50|simtel.objects.ADCSamples2014|5|2|44|simtel.objects.ImageParameters2016|1|2|49|simtel.objects.PixelTiming2020|1|0|122|simtel.objects.MCShower2021|1|0|1214|simtel.objects.MCEvent2022|0|0|126|simtel.objects.CameraMonitoring2023|2|0|126|simtel.objects.LaserCalibration2026|2|0|21|simtel.objects.MCPhotoelectronSum2027|0|2|93|simtel.objects.PixelList2100|0|1|42|simtel.objects.TrackingPosition2200|1|1|50|simtel.objects.TelescopeEvent------------------------------------------------------------eventio_plot_histogramsTo plot histograms stored in an eventio file (Type 100),
useeventio_plot_histograms.$eventio_plot_histogramsgamma_20deg_180deg_run99___cta-prod3_desert-2150m-Paranal-merged_cone10.simtel.gzHistogram of Impact distance vs log10(E / TeV)eventio_print_simtel_metaparamsTo print the metaparameters stored in an eventio file (the values of the parameters used in the simulation),
useeventio_print_simtel_metaparams.$eventio_print_simtel_metaparamstests/resources/history_meta_75.simtel.zstGlobalMETAPARAMs-----------------CONFIG_RELEASE=Release"2021-12-16 (development beyond prod-5)"from2021-12-25T19:33:19UTC.CONFIG_VERSION=ARRAY_CONFIG_NAME=LaPalma-baseline-prod5ARRAY_CONFIG_VARIANT=LST/MST-NectarCam(includingotherMSTcameratype)atCTANorthprod-5/prod-5b(extended)ARRAY_CONFIG_VERSION=2020-11-20RANDOM_GENERATOR=mt19937RANDOM_STATE=autoRANDOM_SEED=autoSIMTEL_VERSION=2021-12-1618:31:13CET(konrad@wizard4)SIMTEL_RELEASE=2021-12-16(developmentbeyondprod-5)SIMTEL_BASE_RELEASE=2021-12-16(developmentbeyondprod-5)METAPARAMsfortelescope=1--------------------------OPTICS_CONFIG_NAME=LSTOPTICS_CONFIG_VARIANT=LST-1prototypeOPTICS_CONFIG_VERSION=2020-04-29CAMERA_CONFIG_NAME=LSTCAMERA_CONFIG_VARIANT=LST-1prototype,withnsb_autoscale_airmassCAMERA_CONFIG_VERSION=2020-11-24METAPARAMsfortelescope=2--------------------------OPTICS_CONFIG_NAME=LSTOPTICS_CONFIG_VARIANT=OPTICS_CONFIG_VERSION=2020-04-29CAMERA_CONFIG_NAME=LSTCAMERA_CONFIG_VARIANT=LSTcamera,withnsb_autoscale_airmassCAMERA_CONFIG_VERSION=2020-11-24METAPARAMsfortelescope=3--------------------------OPTICS_CONFIG_NAME=LSTOPTICS_CONFIG_VARIANT=OPTICS_CONFIG_VERSION=2020-04-29CAMERA_CONFIG_NAME=LSTCAMERA_CONFIG_VARIANT=LSTcamera,withnsb_autoscale_airmassCAMERA_CONFIG_VERSION=2020-11-24...Low level accessFor more low level access to the items of anEventIOfile (or to
implement a higher level abstraction likeIACTFile) one can use theEventIOFileclass which gives access to theobjectsandsubobjectsinEventIOfiles.This is how our test file looks like in the low level view:In [3]: with EventIOFile('eventio/resources/one_shower.dat') as f:
   ...:     for obj in f:
   ...:         print(obj)
   ...:         if obj.header.only_subobjects:
   ...:             for subobj in obj:
   ...:                 print('   ', subobj)
CORSIKARunHeader[1200](size=1096, only_subobjects=False, first_byte=16)
CORSIKAInputCard[1212](size=448, only_subobjects=False, first_byte=1128)
CORSIKATelescopeDefinition[1201](size=20, only_subobjects=False, first_byte=1592)
CORSIKAEventHeader[1202](size=1096, only_subobjects=False, first_byte=1628)
CORSIKAArrayOffsets[1203](size=16, only_subobjects=False, first_byte=2740)
CORSIKATelescopeData[1204](size=6136, only_subobjects=True, first_byte=2772)
    IACTPhotons(length=6124, n_bunches=382)
CORSIKAEventEndBlock[1209](size=1096, only_subobjects=False, first_byte=8924)
CORSIKARunEndBlock[1210](size=16, only_subobjects=False, first_byte=10036)