We need modules from the Bokeh library, Datashader, NumPy, and Pandas, as well as the Data Lab modules to connect to and query the database.

In [1]:

print"Start"fromcStringIOimportStringIOfromdlimportauthClientfromdlimportqueryClientimportpandasaspdimportdatashaderasdsimportdatashader.glyphsimportdatashader.transfer_functionsastfimportbokeh.plottingasbpfromdatashader.bokeh_extimportInteractiveImage# Get the security token for the datalab demo usertoken=authClient.login('anonymous')print"Got token",token

We will query the SMASH catalog over a range of fields to sample a variety of field properties. We set a constraint on the depthflag parameter to insist on detection in the deep exposures. To make the query go faster, one can restrict the range of fieldid in the query. The default field range will return roughly 6 million objects.

We will first make a single cut on the sharp parameter, and classify objects with sharp>0.7 as galaxies. Pandas allows us to add a Class column to the dataframe and specify that it should be considered a category. We will also add a g_r column to the Pandas dataframe.

We now use Datashader and Bokeh to make an interactive plot of g magnitude vs. chi. Datashader assigns different colors to each category, in this case blue for objects labeled stars, and red for objects labeled galaxies. The plot shows that the sharp cut separates two sequences in the magnitude-chi plane, with galaxies having larger chi values. One might be tempted to use chi as an additional constraint. However, at bright magnitudes the chi for stars clearly increases, while at bright magnitudes the sequences overlap in chi. The sharp cut likely confuses some stars and galaxies, especially at faint magnitudes. One could increase the sharp threshold for a more complete star sample, or decrease it for a more pure one.