Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zero-size array when running imager_func #33

Closed
lmorabit opened this issue Jul 22, 2018 · 3 comments
Closed

zero-size array when running imager_func #33

lmorabit opened this issue Jul 22, 2018 · 3 comments

Comments

@lmorabit
Copy link

I'm calling the imager_func like this:
zbl = 0.28
cfloor = 0.0028
niter = 300
conv_criteria = 0.0001
out = eh.imager_func( obs, gaussprior, gaussprior, zbl, d1='cphase', d2='camp', s1='gs', s2='gs', alpha_d1=50, alpha_d2=50, clipfloor=cfloor, maxit=niter, stop=conv_criteria )

The gaussprior is a single gaussian.

I get the following error and traceback:

/home/lmorabit/.local/lib/python2.7/site-packages/ehtim/imaging/imager_utils.pyc in imager_func(Obsdata, InitIm, Prior, flux, d1, d2, d3, alpha_d1, alpha_d2, alpha_d3, s1, s2, s3, alpha_s1, alpha_s2, alpha_s3, alpha_flux, alpha_cm, **kwargs)
294 # Print stats
295 print("Initial S_1: %f S_2: %f S_3: %f" % (reg1(ninit), reg2(ninit), reg3(ninit)))
--> 296 print("Initial Chi^2_1: %f Chi^2_2: %f Chi^2_3: %f" % (chisq1(ninit), chisq2(ninit), chisq3(ninit)))
297 print("Initial Objective Function: %f" % (objfunc(xinit)))
298

/home/lmorabit/.local/lib/python2.7/site-packages/ehtim/imaging/imager_utils.pyc in chisq2(imvec)
199
200 def chisq2(imvec):
--> 201 return chisq(imvec, A2, data2, sigma2, d2, ttype=ttype, mask=embed_mask)
202
203 def chisq2grad(imvec):

/home/lmorabit/.local/lib/python2.7/site-packages/ehtim/imaging/imager_utils.pyc in chisq(imvec, A, data, sigma, dtype, ttype, mask)
373 chisq = chisq_cphase(imvec, A, data, sigma)
374 elif dtype == 'camp':
--> 375 chisq = chisq_camp(imvec, A, data, sigma)
376 elif dtype == 'logcamp':
377 chisq = chisq_logcamp(imvec, A, data, sigma)

/home/lmorabit/.local/lib/python2.7/site-packages/ehtim/imaging/imager_utils.pyc in chisq_camp(imvec, Amatrices, clamp, sigma)
739 def chisq_camp(imvec, Amatrices, clamp, sigma):
740 """Closure Amplitudes (normalized) chi-squared"""
--> 741 print( np.min(imvec) )
742 print( np.min(Amatrices[1] ) )
743 clamp_samples = np.abs(np.dot(Amatrices[0], imvec) * np.dot(Amatrices[1], imvec) / (np.dot(Amatrices[2], imvec) * np.dot(Amatrices[3], imvec)))

/usr/lib64/python2.7/site-packages/numpy/core/fromnumeric.pyc in amin(a, axis, out, keepdims)
2370
2371 return _methods._amin(a, axis=axis,
-> 2372 out=out, **kwargs)
2373
2374

/usr/lib64/python2.7/site-packages/numpy/core/_methods.pyc in _amin(a, axis, out, keepdims)
27
28 def _amin(a, axis=None, out=None, keepdims=False):
---> 29 return umr_minimum(a, axis, None, out, keepdims)
30
31 def _sum(a, axis=None, dtype=None, out=None, keepdims=False):

ValueError: zero-size array to reduction operation minimum which has no identity

@klbouman
Copy link
Collaborator

Hi Leah, Could you try lowering cfloor to 0 and see what happens? Maybe it is masking out all the pixels in the image.

@lmorabit
Copy link
Author

That seems to have worked, thanks. Is there a way to see before running the imager_func what the clipfloor will mask?

@klbouman
Copy link
Collaborator

clipfloor in the imager will only optimize pixels in the Prior that initially have an intensity greater than the value you specify. I don't think there is a function right now that will return this mask region. We can add one if you'd like. To see the masked region you could do

mask = gaussprior.copy()
mask.imvec = mask.imvec > clipfloor
mask.display()

This will show the pixels you are asking the imager to optimize as 1.

@achael achael closed this as completed Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants