Skip to content

First step of implementing CEP-002: Change container structure#2204

Open
maxnoe wants to merge 1 commit into
mainfrom
container_structure
Open

First step of implementing CEP-002: Change container structure#2204
maxnoe wants to merge 1 commit into
mainfrom
container_structure

Conversation

@maxnoe
Copy link
Copy Markdown
Member

@maxnoe maxnoe commented Jan 10, 2023

@maxnoe
Copy link
Copy Markdown
Member Author

maxnoe commented Jan 10, 2023

Before I continue changing everything, could you review the new container structure?

I think it's already a big step in the right direction, as the structure is much simpler, we could get rid of many indirections...

@maxnoe maxnoe requested a review from kosack January 11, 2023 08:28
@nbiederbeck
Copy link
Copy Markdown
Contributor

nbiederbeck commented Jan 11, 2023

This comment just looked at ctapipe/containers.py. In general I think the structure looks fine, it makes more sense as seen in the tests, but while we're at it, some comments:

  • For the EventContainers: and why do we have count?

  • Should there be a general MuonContainer?

  • Why does the TelescopePointingContainer have no ra/dec?
    Or why does ArrayPointingContainer have it?

  • Should we rename the ParticleClassificationContainer and TelescopeImpactParameterContainer to be more consistent with ReconstructedEnergyContainer and ReconstructedGeometryContainer? E.g. ReconstructedParticleContainer, ReconstructedImpactContainer.

  • Is Reconstructed[…].telescopes sensible to be None if Mono? Or should it just hold the corresponding tel_id and be of type int?

  • Is TelescopeTriggerContainer.n_trigger_pixels with default -1 sensible? Or is 0 better to have an unsigned int?

  • SimulationConfigContainer have many nans, but str seems more appropriate given the description. Or None.

  • TelescopeSimulationContainer.impact is not called true_impact.

  • MorphologyContainer, is -1 a better default than 0? Does it make a difference of default 0 and filled 0?

  • Is CameraTimingParametersContainer still needed?

  • LeakageContainer.intensity_width_{1,2} is ambiguously documented (intensity vs. fraction of intensity, as of the docstring).

  • There are some Camera-containers, which I think we can get rid of?

@maxnoe maxnoe changed the title Start working on inverted container structure Implement CEP-002: Change container structure to ArrayEvent -> TelescopeEvent -> Data Levels Jun 2, 2023
@maxnoe
Copy link
Copy Markdown
Member Author

maxnoe commented Jun 5, 2023

Why does the TelescopePointingContainer have no ra/dec?

Because all our telescopes are alt/az mounts, so this is the actual information that is monitored.

Or why does ArrayPointingContainer have it?

Because that's the reference point the array is tracking, which might be in sky-fixed coordinates.

TelescopeSimulationContainer.impact is not called true_impact.

Isn't this accomplished by adding the true_ prefix in the data writer?

Is TelescopeTriggerContainer.n_trigger_pixels with default -1 sensible? Or is 0 better to have an unsigned int?

I think it's important to distinguish invalid from valid data, 0 trigger pixels are possible (e.g. for pedestal events which are randomly triggered), so better distinguish. Same for the other positive integers.

@maxnoe
Copy link
Copy Markdown
Member Author

maxnoe commented Jun 5, 2023

For the EventContainers: and why do we have count?

Just nice to have I guess.

@maxnoe
Copy link
Copy Markdown
Member Author

maxnoe commented Jun 5, 2023

Is CameraTimingParametersContainer still needed?

That's connected to all the other Camera... containers and to #2141, we need them as long as we still support computing image parameters in CameraFrame

@maxnoe maxnoe force-pushed the container_structure branch from ce1d8ad to 352b041 Compare July 6, 2023 08:03
@StFroese
Copy link
Copy Markdown
Member

StFroese commented Jul 7, 2023

The ArrayEventContainer contains the DL2 data (geometry, energy, classification) of the event in the ArrayDL2Container.
It also contains the telescopes as a map of TelescopeEventContainer's which contains all data levels like r0... and also dl2. dl2 in this case is a TelescopeDL2Container which is a subclass of the ArrayDL2Container again.

Why do we save the array event reconstructions at telescope level again? This is a little bit confusing to me

@maxnoe
Copy link
Copy Markdown
Member Author

maxnoe commented Jul 7, 2023

Why do we save the array event reconstructions at telescope level again? This is a little bit confusing to me

The DL2TelescopeContainer is for monoscopic predictions, not for repeating the subarray info.

The inheritance here is just to get the same fields, but I agree that it's confusing that isinstance(DL2TelescopeContainer, DL2SubarrayContainer). I had an intermediate version where both just inherited from Container and then duplicated the field definitions.

@maxnoe maxnoe force-pushed the container_structure branch from 352b041 to c522715 Compare July 7, 2023 10:25
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Comment thread ctapipe/image/image_processor.py Outdated
@StFroese
Copy link
Copy Markdown
Member

The inheritance here is just to get the same fields, but I agree that it's confusing that isinstance(DL2TelescopeContainer, DL2SubarrayContainer). I had an intermediate version where both just inherited from Container and then duplicated the field definitions.

Can we add a ReconstrucedShowerContainer which contains the fields and DL2{Telescope|Subarray}Container inherit from that?

@maxnoe maxnoe force-pushed the container_structure branch 2 times, most recently from 900249d to bd7d777 Compare October 31, 2023 16:57
@maxnoe
Copy link
Copy Markdown
Member Author

maxnoe commented Oct 31, 2023

Hi all,

I rebased this on the current main and squashed the commits into one, to ease follow-up rebases when we make updates to main.

I'd appreciate a fresh review now.

I suggest to first only review the container structure in ctapipe.containers (beware, this is collapsed by default) before reviewing any of the resulting code changes.

Once we are happy with the container structure and renaming, I'll fix up the rest of the code and we can commence the review there.

@maxnoe maxnoe requested review from Tobychev, ccossou and kosack October 31, 2023 17:01
Comment thread ctapipe/containers.py
@ccossou
Copy link
Copy Markdown
Contributor

ccossou commented Nov 6, 2023

For the EventContainers: and why do we have count?

Just nice to have I guess.

On this part. This, to me, is related to how people parse the file and shouldn't be in the container itself, or if it is, should be hidden and not publicly exposed (even if in python, private just means harder to type). But that's a minor comment and not the main purpose of CEP-002.

Comment thread ctapipe/image/image_processor.py
Comment thread ctapipe/image/image_processor.py
@ccossou
Copy link
Copy Markdown
Contributor

ccossou commented Nov 7, 2023

(Sorry, commented on file without realizing it wasn't container.py anymore, got carried away.)

@maxnoe maxnoe requested review from kosack, mexanick and moralejo April 13, 2026 16:43
@maxnoe maxnoe force-pushed the container_structure branch from 1646ac4 to c50f496 Compare April 13, 2026 16:48
@maxnoe
Copy link
Copy Markdown
Member Author

maxnoe commented Apr 13, 2026

@kosack @mexanick This is now rebased on current main (not fun!) and locally tests are passing again, but I see a lot of warnings I didn't expect, so I'll continue tomorrow.

In any case, I would be very helpful if you could already start reviewing the changes in the container definitions src/ctapipe/containers.py

and maybe play around a bit interactively with the new structure.

@maxnoe maxnoe force-pushed the container_structure branch 8 times, most recently from 40d47be to 0bdd61c Compare April 14, 2026 10:19
@maxnoe
Copy link
Copy Markdown
Member Author

maxnoe commented Apr 14, 2026

There is one change in the file format here as well, not just to the in-memory containers: to mirror the move of trigger information to dl0, this also addresses #2374 (and #2952) which better conforms with the CTAO data model.

This however should be implemented in a backwards-compatible way (reading old files with these containers stored in /dl1 is still supported).

@maxnoe maxnoe force-pushed the container_structure branch from 0bdd61c to 0221338 Compare April 14, 2026 16:59
Comment thread docs/changes/2204.api.rst

Fore more details, see :ref:`cep-002`.

With this, also the container structure itself has been largely refactored.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add migration guide details here.

@maxnoe maxnoe force-pushed the container_structure branch from 0221338 to 7a6a908 Compare April 15, 2026 08:50
Copy link
Copy Markdown
Contributor

@mexanick mexanick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the DL1 trigger table paths should be removed as that tables do not exist anymore

Comment thread src/ctapipe/io/hdf5dataformat.py
Comment thread src/ctapipe/io/hdf5dataformat.py
@maxnoe
Copy link
Copy Markdown
Member Author

maxnoe commented Apr 15, 2026

I think the DL1 trigger table paths should be removed as that tables do not exist anymore

These are crucial for backwards compatibility with older data and are used in e.g. the HDF5EventSource and TableLoader.

We do not remove compatibility with older data formats in this pull request.

@ctao-sonarqube
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

@kosack kosack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: never mind, I was looking at RandomForestRegressor_energy and not RandomForestRegressor_tel_energy

I think there is an iteration bug: I loaded an events file with TableLoader and with EventSource, and compared the first event's energy and get different results for the telescope-wise energy:

kosack
kosack previously approved these changes Apr 20, 2026
Copy link
Copy Markdown
Member

@kosack kosack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good! i don't see any major issues, and anything else can be cleaned up in future PRs. I guess you still want to add a migration guide, but I can re-approve once that is done.

@kosack
Copy link
Copy Markdown
Member

kosack commented Apr 20, 2026

Note that I opened #2997 to fix a long-standing bug, which made exploring the new structure a bit less painful interactively.

@maxnoe
Copy link
Copy Markdown
Member Author

maxnoe commented Apr 23, 2026

FYI: here is a PR in the ctapipe_io_zfits plugin working with this branch: https://github.com/cta-observatory/ctapipe_io_zfits/pull/22/changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

7 participants