Skip to content

Conversation

@keflavich
Copy link
Contributor

@keflavich keflavich commented Feb 18, 2023

I've got this most of the way working, I think, but there are still problems:

  • Do the x,y conventions map properly?
  • Is my use of squeeze correct? (I think no; next thing to test)
  • Why is this happening?
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/scratch/local/56668455/ipykernel_19160/2221476826.py in <module>
----> 1 results2  = fit_im(data, wrapmod, weight=np.ones_like(data)*5,
     2                    #psfderiv=np.gradient(-psf_initial[0].data),
     3                    nskyx=0, nskyy=0, refit_psf=False, verbose=True)
     4 stars, modsky, skymsky, psf = results

/blue/adamginsburg/adamginsburg/repos/crowdsource/crowdsource/crowdsource_base.py in fit_im(im, psf, weight, dq, psfderiv, nskyx, nskyy, refit_psf, verbose, miniter, maxiter, blist, maxstars, derivcentroids, ntilex, ntiley, fewstars, threshold, ccd, plot, titer_thresh, blendthreshu, psfvalsharpcutfac, psfsharpsat)
   828             mbd = in_bounds(xa, ya, [bdxf-0.5, bdxl-0.5],
   829                             [bdyf-0.5, bdyl-0.5])
--> 830             psfsbda = build_psf_list(xa[mbda], ya[mbda], psf, sz[mbda],
   831                                      psfderiv=tpsfderiv)
   832             sall = numpy.s_[bdxaf:bdxal, bdyaf:bdyal]

/blue/adamginsburg/adamginsburg/repos/crowdsource/crowdsource/crowdsource_base.py in build_psf_list(x, y, psf, sz, psfderiv)
   231     for i in range(len(x)):
   232         for j in range(len(out)):
--> 233             out[j].append(psflist[sz[i]][j][counts[sz[i]]])
   234         counts[sz[i]] += 1
   235     return out

IndexError: index 19 is out of bounds for axis 0 with size 19

@andrew-saydjari
Copy link
Collaborator

This error IndexError: index 19 is out of bounds for axis 0 with size 19 is because crowdsource expects axis 0 to be the nstamp axis. Changing to axis 0 being the nstamp dimension solved this problem for me.

@keflavich
Copy link
Contributor Author

Current version fails as noted by @andrew-saydjari because of a regression in photutils (astropy/photutils#1660); photutils==1.6.0 will work.

the workaround:

        stamps = []
        for i in range(len(col)):
            stamps.append(self.psfgridmodel.evaluate(cols[:,:,i], rows[:,:,i], 1, col[i], row[i]))
        stampsS = np.stack(stamps,axis=0)
        stamps = np.transpose(stampsS,axes=(0,2,1))

works because it circumvents the cache-related bug introduced.

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

Successfully merging this pull request may close these issues.

2 participants