SIRF icon indicating copy to clipboard operation
SIRF copied to clipboard

Python: modify some DataContainer methods to fall back to numpy

Open KrisThielemans opened this issue 5 months ago • 4 comments

I suggest to modify https://github.com/SyneRBI/SIRF/blob/8fbfe5294e4efd57d12ae15d87b97f64e96d09d4/src/common/SIRF.py#L268-L276 to something like this

def norm(self):
   if (self.supports_array_view):
      return numpy.linalg.norm(self.asarray())
   # original code

@evgueni-ovtchinnikov @casperdcl good idea?

KrisThielemans avatar Jul 24 '25 13:07 KrisThielemans

Yes, though as @ckolbPTB mentioned there may be cases where self.norm() should not be calculated over the whole self.asarray() 🤷.

Also related: https://github.com/SyneRBI/SIRF/pull/1332#pullrequestreview-3051782870

casperdcl avatar Jul 24 '25 14:07 casperdcl

Yes, though as @ckolbPTB mentioned there may be cases where self.norm() should not be calculated over the whole self.asarray() 🤷.

sure, but I don't think that's we should worry about this here. The current norm() would then be inappropriate already anyway.

KrisThielemans avatar Jul 24 '25 15:07 KrisThielemans

@KrisThielemans I am afraid your suggestion will only work for DataContainer objects, but views may be numpy arrays.

evgueni-ovtchinnikov avatar Jul 24 '25 15:07 evgueni-ovtchinnikov

re Christoph remark: if he meant ignoring some acquisitions then this is already covered by the ignore mask, but it is easy to extend this feature to any subset by adding optional list argument in the constructor of AcquisitionDataView - will ask him next time we meet.

evgueni-ovtchinnikov avatar Jul 24 '25 16:07 evgueni-ovtchinnikov