Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from tractor import sdss as st
def tractor_render_patch(run, camcol, field, roi, celeste_src=None, bandname='r'):
""" ROI = (x0, x1, y0, y1), zero indexed pixel coordinates """
# set up tractor
sdss = DR9()
getim = st.get_tractor_image_dr9
getsrc = st.get_tractor_sources_dr9
imkw = dict(zrange=[-3,100], sdss=sdss)
# get images
tim,tinf = getim(run, camcol, field, bandname, curl=True, roi=roi, **imkw)
tim.zr = tinf['zr']
# get corresponding sources
sources = getsrc(run, camcol, field, bandname, bands=[bandname], curl=True, roi=roi)
# set the first source to have the same parameters as dustin's
if celeste_src is not None:
print "setting source parameters"
ts = sources[0]
ts_pos = ts.getPosition()
ts_pos.ra, ts_pos.dec = celeste_src.params.u
from import nanomaggies2mags
band_mag = nanomaggies2mags(celeste_src.params.flux_dict[bandname])
ts_bright = ts.getBrightness()
ts_bright.setMag(bandname, band_mag)
# create a tractor object, get a model image
tractor = Tractor(images = [tim], catalog=[ts])
mod = tractor.getModelImage(tim, srcs=sources)
chi = tractor.getChiImage(imgi=0, srcs=sources)
return mod, tim, chi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment