Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define a better API for products #122

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

samaloney
Copy link
Member

No description provided.

Copy link

codecov bot commented May 27, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 24.40%. Comparing base (8867c2d) to head (0b04ba7).

Files Patch % Lines
stixpy/product/product.py 42.85% 4 Missing ⚠️
stixpy/utils/time.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #122       +/-   ##
===========================================
- Coverage   72.53%   24.40%   -48.14%     
===========================================
  Files          31       30        -1     
  Lines        1857     1500      -357     
===========================================
- Hits         1347      366      -981     
- Misses        510     1134      +624     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

meta = self.meta.copy()
idb = self.idb_versions.copy()
ci = set(data["control_index"])
control = self.control[np.argwhere(np.isin(self.control["index"], list(ci)))].copy()
Copy link
Member Author

Choose a reason for hiding this comment

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

So this work but really need to rename and add a few more properties for this to make sense. Convert all the masks to be named _mask or _requested and then add some more props for detectors, pixels, energies which would indicate what contained in the object which would be less/different to the request as slice, rebin or crops.


"""

def __getitem__(self, item: Union[int, tuple[int, ...], slice]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def __getitem__(self, item: Union[int, tuple[int, ...], slice]):
def __getitem__(self, item: Union[int, tuple[int, slice, ...], slice]):


"""

def rebin_by_vales(self, *values, operator: Callable = np.sum):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def rebin_by_vales(self, *values, operator: Callable = np.sum):
def rebin_by_values(self, *values, operator: Callable = np.sum):


Examples
--------
cpd.rebin(None, None, None, [1, 5])
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good for this to follow the NDCube.rebin API as much as makes sense. In that case, rebin should take:

  • integers which are an integer factor of the length of the axis to which it corresponds, or:
  • a sequence of indices representing the bin edges along that axis.

In this case, the equivalent API for no rebinning should be 1, not None.

Alternatively, this method could be renamed to avoid confusion with NDCube.rebin to something like rebin_by_edges. In that case, it could take None or a sequence of indices for each axis.

"""
An `astropy.units.Quantiy` array giving the duration or integration time
"""
return self.data["timedel"]

def crop_by_value(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def crop_by_value(
def crop_by_values(

Copy link
Contributor

Choose a reason for hiding this comment

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

Would this function take high-level objects, e.g. Time, SkyCord, SpectralCoord? Or just lower level Quantity?

Copy link
Member Author

@samaloney samaloney May 27, 2024

Choose a reason for hiding this comment

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

Low level objects plus a few strings for different pixel/detector combos e.g cpd.crop_by_vales([Time(...), Time(...)], None, 'big', [4, 10]*u.keV). Since the axis have well defined should be easy to validate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants