cta-observatory / pycorsikaio

Python reader for CORSIKA binary file format
MIT License
9 stars 2 forks source link

pycorsikaio to astropy Qtable #14

Open HealthyPear opened 1 year ago

HealthyPear commented 1 year ago

I have developed an initial version of a CorsikaNPOReader class which uses pycorsikaio to load the content of 1 or multiple files in astropy QTables.

This class behaves similarly to ctapipe.io.TableLoader, meaning that it can load each file block separately if enabled and joins each table using all common 1D fields. A couple functions (not methods at the moment) have been indeed taken from TableLoader.

If this can be of interest for this project I could preemptively open a pull request for early feedback. The code is definitely not final but it's working and it could be tested with a very small corsika file with say 10 showers.

maxnoe commented 1 year ago

As discussed in slack: I'd propose to add unit to Field, so that we can just do something like this:

table = Table(data, units={field.name: field.unit for field in fields})
HealthyPear commented 1 year ago

A minor update on this: I have used #23 to simplify the way units are treated in my development class, so now they don't use any more astropy structured units, but just dictionaries built from the subblock fields.

Also, the class now supports the identical Corsika versions as native pycorsikaio.

HealthyPear commented 1 year ago

I have copied corsika757_particle for my unit tests which are satisfactory for the moment.

The only issues are now perhaps the possibly low-quality design of the class...