You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use the non-default disp_axis and crossdisp_axis, @fchabourbarra and I are getting a variety of broadcasting errors, and results that are nonsense. Our workaround right now is transposing our data, which isn't ideal. The biggest issue is the case where it apparently extracts correctly (i.e. without complaint), but extracts along the wrong axis.
I've attached a (lengthy) minimum working example that tests I think most of the failure modes
importnumpyasnpfromastropy.nddataimportCCDDataimportastropy.unitsasufromspecreduce.tracingimportArrayTracefromspecreduce.backgroundimportBackgroundfromspecreduce.extractimportBoxcarExtract# Making some fake data that is "vertical" (swapping disp/cross axes from default)data=np.zeros((300,100)) # disp_axis=0, crossdisp_axis=1data[[120,239],:] =1# put 2 lines at fixed wavelengthsimg=CCDData(data, unit=u.adu)
print('img:', img.shape)
trace_array=np.ones(300)*75# a line at crossdisp_axis = 75, has length=300tr_bad=ArrayTrace(img, trace_array)
print('bad trace:', len(tr_bad.trace)) # should = 300# if we transpose the data, ArrayTrace does it righttr=ArrayTrace(img.data.T, trace_array)
print('trace:', len(tr.trace)) # should = 300# this raises the error: # ValueError: could not broadcast input array from shape (100,) into shape (300,)# bk = Background(img, tr, disp_axis=0, crossdisp_axis=1)# this also raises the error:# ValueError: could not broadcast input array from shape (100,) into shape (300,)# bk = Background(img.data.T, tr, disp_axis=0, crossdisp_axis=1)# setting axes back to default (which is WRONG for image, and doesn't match trace)# this... works, but gives wrong length (100)bk=Background(img, tr, disp_axis=1, crossdisp_axis=0)
print('bad bkgd_spectrum:',bk.bkg_spectrum().spectral_axis.shape)
# transposing the image fixes itbk=Background(img.data.T, tr, disp_axis=1, crossdisp_axis=0)
print('bkgd_spectrum:',bk.bkg_spectrum().spectral_axis.shape)
# this appears to workextract=BoxcarExtract(img, tr, disp_axis=0, crossdisp_axis=1)
# but this raises error:# ValueError: could not broadcast input array from shape (100,) into shape (300,)# print(extract.spectrum.flux.shape)# this appears to work, with WRONG axes that don't match traceextract=BoxcarExtract(img, tr, disp_axis=1, crossdisp_axis=0)
# and gives wrong length (100)print('bad extract:', extract.spectrum.flux.shape)
# transposing worksextract=BoxcarExtract(img.data.T, tr, disp_axis=1, crossdisp_axis=0)
# and gives wrong length (100)print('extract:', extract.spectrum.flux.shape)
which outputs this:
img: (300, 100)
bad trace: 100
trace: 300
bad bkgd_spectrum: (100,)
bkgd_spectrum: (300,)
bad extract: (100,)
extract: (300,)
The text was updated successfully, but these errors were encountered:
When trying to use the non-default
disp_axis
andcrossdisp_axis
, @fchabourbarra and I are getting a variety of broadcasting errors, and results that are nonsense. Our workaround right now is transposing our data, which isn't ideal. The biggest issue is the case where it apparently extracts correctly (i.e. without complaint), but extracts along the wrong axis.I've attached a (lengthy) minimum working example that tests I think most of the failure modes
which outputs this:
The text was updated successfully, but these errors were encountered: