eventio文件格式的python只读实现
eventio的Python项目详细描述
发明的eventio数据格式的python(只读)实现 由konrad bernloehr使用,例如由 科西卡语:https://www.ikp.kit.edu/corsika
文件格式文档:https://www.mpi-hd.mpg.de/hfm/~bernlohr/sim_telarray/Documentation/eventio_en.pdf
iact扩展和simtel的大部分模块都已实现。 下面的块是已知的,但是读取它们的数据(还没有) 实现,因为我们没有任何包含 这些东西。
如果你想支持这些东西, 请打开一个issue。
Code | Description |
---|---|
1206 | IACT Camera Layout |
1207 | IACT Trigger Time |
2017 | SimTel Pixel Calibriation |
2024 | SimTel Run Statistics |
2025 | SimTel MC Run Statisitics |
2029 | SimTel Auxiliary Digital Traces |
2030 | SimTel Auxiliary Analog Traces |
2031 | SimTel FSPhot |
使用
安装pip install eventio
打开iact corsika扩展名生成的文件
第一个例子
可以遍历IACTFile类的实例以检索事件。 事件有少量字段。 最重要的是photon_bunches字段, 这是字典将望远镜id映射到一个简单的结构np.array, 包含科西卡的切伦科夫光子束的典型参数,如:
- x,y观测平面坐标(cm)
- 方向余弦cx,cy在事件的x和y方向 光子的角度
- 光子的波长lambda(单位:nm)
- 与此群关联的photons个数
- 自第一次交互以来的time(我相信是ns)
- 光子束的产生高度(称为zem)
- 一个布尔标志,表示光子是否在大气中散射
事件具有以下属性:header:anamedtuple 包含corsika事件头数据*end_block:一个numpy数组 包含corsika事件结束数据*time_offset,x_offset, y_offsett,数组的偏移量
这将为每台望远镜中的第一台望远镜打印能量和光子数 事件:
importeventiowitheventio.IACTFile('eventio/resources/one_shower.dat')asf:foreventinf:print(event.header.total_energy)print(event.photon_bunches[0]['photons'].sum())
第二个例子
如果你想绘制第一个切伦科夫光子的起源 第一台望远镜的文件eventio/resources/one_shower.data中的事件, 看一看 this example
它可能与此图片类似:
淋浴示例
打开由simtel_array生成的文件
importeventiowitheventio.SimTelFile('eventio/resources/gamma_test.simtel.gz')asf:print(len(f.telescope_descriptions))forarray_eventinf:print(array_event['mc_shower']['energy'])
命令行工具
我们提供了三个命令行工具,用于查看eventio文件。
要获得文件结构的概述,请使用eventio_print_structure, 对于较大的文件,您可能需要将其输出管道化,例如less:
$ eventio_print_structure eventio/resources/gamma_test.simtel.gz History[70] HistoryCommandLine[71] HistoryConfig[72] HistoryConfig[72] And 127 objects more of the same type ... 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_information,如果给定 --json选项
$ eventio_print_object_information eventio/resources/gamma_test.simtel.gz Type | Version | Level |#Objects | eventio-class ------------------------------------------------------------ 70|1|0|3| simtel.objects.History 71|1|1|3| simtel.objects.HistoryCommandLine 72|1|1|32840| simtel.objects.HistoryConfig 1212|0|0|2| iact.objects.InputCard 2000|2|0|1| simtel.objects.RunHeader 2001|4|0|2| simtel.objects.MCRunHeader 2002|2|0|98| simtel.objects.CameraSettings 2002|3|0|28| simtel.objects.CameraSettings 2003|1|0|126| simtel.objects.CameraOrganization 2004|2|0|126| simtel.objects.PixelSettings 2005|0|0|126| simtel.objects.DisabledPixels 2006|0|0|126| simtel.objects.CameraSoftwareSettings 2007|0|0|126| simtel.objects.PointingCorrection 2008|0|0|126| simtel.objects.DriveSettings 2009|2|1|10| simtel.objects.TriggerInformation 2010|0|0|10| simtel.objects.ArrayEvent 2011|1|2|50| simtel.objects.TelescopeEventHeader 2013|3|2|50| simtel.objects.ADCSamples 2014|5|2|44| simtel.objects.ImageParameters 2016|1|2|49| simtel.objects.PixelTiming 2020|1|0|122| simtel.objects.MCShower 2021|1|0|1214| simtel.objects.MCEvent 2022|0|0|126| simtel.objects.CameraMonitoring 2023|2|0|126| simtel.objects.LaserCalibration 2026|2|0|21| simtel.objects.MCPhotoelectronSum 2027|0|2|93| simtel.objects.PixelList 2100|0|1|42| simtel.objects.TrackingPosition 2200|1|1|50| simtel.objects.TelescopeEvent ------------------------------------------------------------
要绘制存储在eventio文件(类型100)中的直方图, 使用eventio_plot_histograms。
$ eventio_plot_histograms gamma_20deg_180deg_run99___cta-prod3_desert-2150m-Paranal-merged_cone10.simtel.gz
碰撞距离与log10的直方图(e/tev)
低级访问
对于EventIO文件项的更低级访问(或 实现更高级别的抽象,如IACTFile,可以使用 EventIOFile类,该类允许访问objects和 subobjects在EventIO文件中。
这就是我们的测试文件在低级视图中的外观:
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)