samuelyeewl / specmatch-emp

Empirical SpecMatch
9 stars 8 forks source link

Expected None Empty Vector for x when shifting #38

Closed JackActon96 closed 5 years ago

JackActon96 commented 5 years ago

Hi,

I've just started using specmatch. I managed to run the code on the examples Hires spectra fine, however now I'm attemtping it on a target of my own and having some issues.

Here's what Im running

lib = specmatchemp.library.read_hdf()

data=np.loadtxt('input_spec.dat', delimiter=' ')

w=data[:,0] s=data[:,1]

Target_Spectrum=specmatchemp.spectrum.Spectrum(w, s, serr=None, mask=None, name=None, header=None) sm = SpecMatch(Target_Spectrum, lib) sm.shift()

sm.match()

sm.lincomb()

print('Derived Parameters: ') print('Teff: {0:.0f}, Radius: {1:.2f}, [Fe/H]: {2:.2f}'.format( sm_G.results['Teff'], sm_G.results['radius'], sm_G.results['feh']))

My input spectra is in the format of a simple data file with 2 columns (wavelength & spectrum) so I assumed reading it like that would be ok?

But the sm.shift() part throws up an error-

Shifting spectrum Shifting spectrum Spectrum 1 Attempting shift to spectrum NSO, median cross-correlation peak = 0.27 Attempting shift to spectrum 123239, median cross-correlation peak = 0.34 Attempting shift to spectrum 222368, median cross-correlation peak = 0.17 Attempting shift to spectrum 216899, median cross-correlation peak = 0.41 Best reference for shifting: 216899 Shifting entire spectrum Traceback (most recent call last): File "", line 1, in File "specmatch.py", line 20, in sm.shift() File "build/bdist.linux-x86_64/egg/specmatchemp/specmatch.py", line 150, in shift

File "build/bdist.linux-x86_64/egg/specmatchemp/shift.py", line 84, in bootstrap_shift File "build/bdist.linux-x86_64/egg/specmatchemp/shift.py", line 216, in shift File "build/bdist.linux-x86_64/egg/specmatchemp/shift.py", line 524, in solve_for_shifts File "/usr/lib64/python2.7/site-packages/numpy/lib/polynomial.py", line 555, in polyfit raise TypeError("expected non-empty vector for x") TypeError: expected non-empty vector for x

So there seems to be some issue with the shifting itself, which I assume may be to do with my input, any ideas?

Cheers,

samuelyeewl commented 5 years ago

Hi,

I think this might be related to the wavelength range of the input - could I know the range and length of your wavelength array? Alternatively, are there large contiguous gaps in your input spectrum?

Cheers, Sam

JackActon96 commented 5 years ago

Hi.

Thanks for your response. After reading it I looked at my input and realised that I had a few gaps in the spectrum that hadn't been removed. I cut those out and now it all runs fine.

Thankyou very much for your assistance!

samuelyeewl commented 5 years ago

Great to hear that!