Skip to content

DataIO refactoring #344

@israelmcmc

Description

@israelmcmc

This issue superseeds #249 and #338, closed by #342.

This is meant to start the discussion on how DataIO will look like longer term. None of this is critical, it's only refactoring, and therefore it's low priotirity

I'll start with my thoughts. I propose:

  • UnbinnedData and BinnedData should both derive from DataIO. DataIO should contain all common functions and properties (currently UnbinnedData derived from DataIO, and BinnedData from UnbinnedData)
  • Both UnbinnedData and BinnedData should have the methods open(), write() and plot(). For BinnedData, these will mostly call histpy methods, instead of duplicating the IO code (tagging @jdbuhler since he had thoughts about this)
  • Methods like get_raw_spectrum and get_raw_lightcurve should return another BinnedData object (with a reduced number of axes). They'll now how to open(), write() and plot() themselves already. Similarly for other axes --e.g. psichi, phi.
  • BinnedData should have a classmethod from_unbinned() which takes an UnbinnedData object and bins it.
  • UnbinnedData should have a method called to_binned() which internally calls BinnedData.from_unbinned(). This is a convenience method, but doesn't duplicate code.
  • config file should become optional, only if the user finds them convenient. There should be a way to use DataIO programatically without config files.
  • (Done in Interfaces refactoring #369 )~We should create an e.g. EventSelection class. This will take an event (or event list), and output True of False (or an array that works as a mask) depending on whether an event passed a cut or not. Derived classes from EventSelection can implement different types of cuts --e.g. energy, time, if it's in the SAA, if it's a GTI, number of hits, hit location, etc. Multiple event EventSelection objects can be concatenated. The UnbinnedData object should be able to take these as an input to filter out events. This mechanism should replace specific methods like select_data_energy, select_data_time, filter_good_data, cut_SAA_events, etc.
  • The binning information should come from a histpy Axes, which can in turn from from a response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions