Closed Mikea1985 closed 8 years ago
Um, that condition should never be met as far as I was concerned. Looks like you have found something fancy, or are doing something silly. :)
What is the value of the background used in that line? What is the value of trimHighPix?
On Jan 15, 2016, at 9:24 AM, Mike Alexandersen notifications@github.com wrote:
I'm getting catastrophic failures on some images (while everything works perfectly for others) The phot function fails occasionally, like so:
phot(xt,yt,radius=fwhm_14,l=(EXPTIME/3600)_rate/pxscale,a=angle, skyRadius=4_fwhm,width=6_fwhm, zpt=260,exptime=EXPTIME,enableBGSelection=True,display=True, mode="smart",trimBGHighPix=3) Traceback (most recent call last): File "
", line 4, in File "/usr/local/lib/python27/dist-packages/trippy/pillpy", line 184, in call bg=bgfsmartBackground(display=display) File "/usr/local/lib/python27/dist-packages/trippy/bgFinderpy", line 118, in smartBackground pylhist(selfdata,bins=min(100,len(selfdata/10))) File "/usr/local/lib/python27/dist-packages/matplotlib/pyplotpy", line 2896, in hist stacked=stacked, **kwargs) File "/usr/local/lib/python27/dist-packages/matplotlib/axes/_axespy", line 5597, in hist raise ValueError("x must have at least one data point") ValueError: x must have at least one data point I think this is caused by the numwhere on line 182 of pillpy I think that if there where statement returns an empty array, then line 184 will fail This is a short-coming of where that I also forget to take precautions against fairly often myself Given that I think you are just trimming high background pixels, I think the easiest fix is to add: if (len(W[0]>0):
Do the stuff you're already doing
else:
Don't do anything
— Reply to this email directly or view it on GitHub https://github.com/fraserw/trippy/issues/7.
Hmmm, odd. trimBGHighPix=3 as in the tutorial. The background level is about -10.
I can get the error to stop by wiggling xt and yt about by a few tenths of a pixel...
I can't really comment on your situation without seeing what it is you are doing.... But I suspect you are using a silly background region with lots of sources in it. On 15 Jan 2016 9:54 am, "Mike Alexandersen" notifications@github.com wrote:
Hmmm, odd. trimBGHighPix=3 as in the tutorial. The background level is about -10.
I can get the error to stop by wiggling xt and yt about by a few tenths of a pixel...
— Reply to this email directly or view it on GitHub https://github.com/fraserw/trippy/issues/7#issuecomment-171916598.
For posterity, let's also put the solution here. The problem was line 182 of pill.py:
W=num.where(rebinnedSkyImage[w]<bg+trimBGHighPix*bg**0.5)
Because my images have been dark-subtracted and what-not, their average background fluctuates around 0. For the images with bg slightly possitive (0 to 5), the above line works, but does inforce a very brutal trim. For the images where bg is negative, the above line fails, so phot fails.
An easy fix is to use the standard deviation in place of bg**0.5
(which is only the standard deviation in un-reduced images). The standard deviation bgstd
is already calculated on line 178, so just replace line 182 with:
W=num.where(rebinnedSkyImage[w]<bg+trimBGHighPix*bgstd)
Cheers
I'm getting catastrophic failures on some images (while everything works perfectly for others). The phot function fails occasionally, like so:
I think this is caused by the
num.where
on line 182 of pill.py. I think that if there where statement returns an empty array, then line 184 will fail. This is a short-coming ofwhere
that I also forget to take precautions against fairly often myself. Given that I think you are just trimming high background pixels, I think the easiest fix is to add:EDIT: The
[0]
is of course needed, aslen(where(something))
always returns 1, whilelen(where(something))[0]
gives what you actually want.