cta-observatory/pycorsikaio

Event end block gained new fields in recent versions

Closed this issue · 11 comments

The event end block gained additional fields in recent versions (need to check which versions introduced which fields).

In SWGO we encountered this problem: we need to access fields related to the lateral distribution fit

Fixing this issue should be as easy as writing the event end subblock module in the same way as e.g. the run header one

the annoying part is reviewing the data model changelog

is there a way to access the docs of the older versions?

maxnoe commented

By asking the maintainers for them via email. But I think first adding support for the versions where we definitely know these fields are contained in is fine I think. I think they were introduced with 7.x, but not sure.

There is actually a problem in adding this solution. From what I can understand, the EVTE subblock does not have a version field, so it is not possible to read the CORSIKA version from the block as done for the other blocks in which dtypes are different for different versions of CORSIKA.

Hi @AndreaNegro953, that's not really an issue: the version is known from the run header block. We don't need to be able to read the version from an event end block in isolation I think.

I.e. here:

self.parse_blocks = parse_blocks
self._buffer_size = read_buffer_size(path)
self._f = open_compressed(path)
self._block_iter = iter_blocks(self._f)
runh_bytes = next(self._block_iter)
if not runh_bytes[:4] == b'RUNH':
raise ValueError('File does not start with b"RUNH"')
self.run_header = parse_run_header(runh_bytes)[0]
self.version = round(float(self.run_header['version']), 4)

We get the version and store it, which means it can later be used to parse the rund end block.

Thank you, I was trying to do something similar to the other block and in those cases the version was read from the file. I think I can try to open a branch then

@AndreaNegro953 Thank you very much.

I would change the function parse_run_end to have the signature:

def parse_run_end(run_end_bytes, version):
    ...

and then call in CorsikaFile like this:

self._run_end = parse_run_end(block, self.version)[0]

Thank you, but I think there has been a misunderstanding it is the event end datablock not the run end

Ah, right, but the same principle applies, right?

Yeah, I think so. Still testing the changes.

Addressed in #37