sunpy / ndcube

A base package for multi-dimensional contiguous and non-contiguous coordinate-aware arrays. "Maintainers": @danryanirish & @Cadair
http://docs.sunpy.org/projects/ndcube/
BSD 2-Clause "Simplified" License
44 stars 45 forks source link

Add custom function to calculate error after ndcube rebin #702

Open andyto1234 opened 1 month ago

andyto1234 commented 1 month ago

Describe the feature

I was trying to rebin some EIS spectral data with propagate_uncertainties=True. I think because the error array is UnknownUncertainty with intensity measurement, it gave the following warning: "UserWarning: self.uncertainty is of type UnknownUncertainty which does not support uncertainty propagation."

I got away by propagating the rebinned error myself and setting it externally. Would be great to allow custom operation on the uncertainty within NDCube rebin.

Proposed solution

Add custom operation on the uncertainty within NDCube rebin

Cadair commented 1 month ago

What form do your uncertainties take? NDCube in theory delegates all the uncertainty propagation to Astropy's NDData.

From a quick skim of the Astropy docs, they directly support StdDevUncertainty and VarianceUncertainty.

If neither of those work, you could implement your own uncertainty class, I think a subclass of NDUncertainty with a custom propagate_<operation> method should do it?

DanRyanIrish commented 1 month ago

Yes, in principle that's right. If it turns out it doesn't work as expected, we should look into that.

DanRyanIrish commented 2 days ago

@andyto1234 Did this resolve your issue?