StellarCartography / pydis

DEPRECATED: Check out PyKOSMOS!
https://github.com/jradavenport/pykosmos
MIT License
43 stars 27 forks source link

differing number of dimensions in array and kernel used in convolve() for flatcombine() #84

Open hnmartin opened 2 years ago

hnmartin commented 2 years ago

Hello!

I am new here, and have been working with images produced by the Modspec spectrograph from the MDM telescope; so to get started, I have been following the reduction guide pretty closely. As such, the code I have for making master calibration files is a line for line copy of the guide's (so hopefully this problem has a simple fix).

For the following description, I am referring to this master calibration code from the reduction guide:

import pydis
bias = pydis.biascombine('rbias.lis', trim=True)
flat, fmask_out = pydis.flatcombine('rflat.lis', bias, trim=True,
                                      mode='spline', response=True, display=True)

The main problem is arising from the flatcombine() function. The convolve() from flatcombine() is throwing an exception of "array and kernel have differing number of dimensions"; array referring to flat_stack[ok,:].mean(axis=Waxis) and kernel to Box1DKernel(5) from the following line in flatcombine():

# sum along spatial axis, smooth w/ 5pixel boxcar, take log of summed flux
        flat_1d = np.log10(convolve(flat_stack[ok,:].mean(axis=Waxis), Box1DKernel(5))) 

When I ran a debugger, these are the .shape responses I got from the array and kernel:

IPdb [1]: flat_stack.shape
(1700, 301)

IPdb [2]: flat_stack[ok,:].shape
(1, 975, 301)

IPdb [3]: flat_stack[ok,:].mean(axis=Waxis).shape
(975, 301)

IPdb [4]: Box1DKernel(5).shape
(5,)

IPdb [5]: convolve(flat_stack[ok,:].mean(axis=Waxis), Box1DKernel(5))
*** Exception: array and kernel have differing number of dimensions.

This difference in dimensions could be due to the fact that a DATASEC card was not present in the header of any of the original .fits files I am working with, and since that was keeping biascombine() from running in the master calibration code, I created DATASEC cards in the .fits files and assigned them the same values as their respective CCDSEC cards. Not sure if that could be related to the dimensions problem, but just in case it is, I thought I would mention it.

Below you will find a zipped folder of the bare minimum code and files needs to reproduce the dimensions error I have encountered, as well as a log of everything I did to try to fix the problem in the README.txt file. This .txt file also refers to corresponding screenshots of the problem or work.

issueLog.zip

Any help or suggestions would be much appreciated; thank you so much for your time and I hope you have a lovely day!

-Heather Martin