In [1]:
import holoviews as hv
hv.notebook_extension('bokeh')



In [2]:
import dask
import dask.dataframe as dd
import pandas as pd
from distributed import Client
client = Client(scheduler_file='/scratch/tmorton/dask/scheduler.json')

In [3]:
from lsst.daf.persistence import Butler

butler = Butler('/datasets/hsc/repo/rerun/RC/w_2018_04/DM-13256/')

In [4]:
from explorer.utils import get_tracts
get_tracts(butler)


Out[4]:
[9615, 9697, 9813]

In [5]:
from explorer.rc2 import get_coadd, get_matched, get_color

fields = ['COSMOS', 'WIDE_VVDS', 'WIDE_GAMA15H']
filters = ['HSC-G', 'HSC-R', 'HSC-I', 'HSC-Z', 'HSC-Y']#, 'NB9021']
catalog = {field : {filt : get_coadd(butler, field, filt, name=filt) for filt in filters} for field in fields}

In [6]:
field = 'COSMOS'

In [7]:
from explorer.functors import (Functor, Mag, MagDiff, CustomFunctor, DeconvolvedMoments, Column,
                            SdssTraceSize, PsfSdssTraceSizeDiff, HsmTraceSize, Seeing, HsmTraceSize,
                            PsfHsmTraceSizeDiff, CompositeFunctor, StarGalaxyLabeller, NumStarLabeller)

psfmag = Mag('base_PsfFlux')
cmodel = Mag('modelfit_CModel')
kron = Mag('ext_photometryKron_KronFlux')

funcs = {'psf':psfmag, 'cmodel':cmodel, 'kron':kron}

In [8]:
from explorer.catalog import MultiBandCatalog

filts = ['HSC-G', 'HSC-R', 'HSC-I', 'HSC-Z', 'HSC-Y']
grizy = MultiBandCatalog({filt: catalog[field][filt] for filt in filts}, short_filters='GRIZY', reference_filt='HSC-I')

In [9]:
from explorer.dataset import QADataset

flags = ['calib_psfUsed', 'qaBad_flag',
#  'merge_measurement_i',
#  'merge_measurement_r',
#  'merge_measurement_z',
#  'merge_measurement_y',
#  'merge_measurement_g',
#  'base_Footprint_nPix_flag',
 'base_PixelFlags_flag_inexact_psf']

grizy_data = QADataset(grizy, funcs, client=client, flags=flags)

In [10]:
%time grizy_data.df.head()


CPU times: user 57.5 s, sys: 9.54 s, total: 1min 7s
Wall time: 1min 26s
Out[10]:
base_PixelFlags_flag_inexact_psf calib_psfUsed ... psf_color cmodel_color kron_color
HSC-G HSC-R HSC-I HSC-Z HSC-Y HSC-G HSC-R HSC-I HSC-Z HSC-Y ... R_I Z_Y G_R I_Z R_I Z_Y G_R I_Z R_I Z_Y
id
43158034708430849 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
43158034708430850 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
43158034708430851 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
43158034708430852 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
43158034708430853 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

5 rows × 59 columns


In [15]:
grizy_data.color_explore()


/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:247: RuntimeWarning: invalid value encountered in greater_equal
  mask &= k.start <= arr
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:249: RuntimeWarning: invalid value encountered in less
  mask &= arr < k.stop
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:247: RuntimeWarning: invalid value encountered in greater_equal
  mask &= k.start <= arr
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:249: RuntimeWarning: invalid value encountered in less
  mask &= arr < k.stop
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:247: RuntimeWarning: invalid value encountered in greater_equal
  mask &= k.start <= arr
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:249: RuntimeWarning: invalid value encountered in less
  mask &= arr < k.stop
Out[15]:

In [16]:
%%opts Points [width=600, height=600]
grizy_data.color_fit_explore()


/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:247: RuntimeWarning: invalid value encountered in greater_equal
  mask &= k.start <= arr
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:249: RuntimeWarning: invalid value encountered in less
  mask &= arr < k.stop
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:247: RuntimeWarning: invalid value encountered in greater_equal
  mask &= k.start <= arr
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:249: RuntimeWarning: invalid value encountered in less
  mask &= arr < k.stop
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:247: RuntimeWarning: invalid value encountered in greater_equal
  mask &= k.start <= arr
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:249: RuntimeWarning: invalid value encountered in less
  mask &= arr < k.stop
Out[16]:

In [15]:
from explorer.plots import FlagSetter
import parambokeh

flag_setter = FlagSetter(filter_stream=filter_stream, flags=grizy_data.flags, bad_flags=grizy_data.flags)
parambokeh.Widgets(flag_setter, callback=flag_setter.event, push=False, on_init=True)



In [97]:
bounds.event(bounds=(0.22892597443466878, -0.14964022550496975, 1.3908525799392557, 0.7309904051256608))


:Curve   [x]   (y)
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:247: RuntimeWarning: invalid value encountered in greater_equal
  mask &= k.start <= arr
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:249: RuntimeWarning: invalid value encountered in less
  mask &= arr < k.stop

In [32]:
def color_fit_explore(self, xmax_range=np.arange(18,26.1,0.5), filter_stream=None):
    streams = [hv.streams.RangeXY(), hv.streams.BoundsXY()]
    if filter_stream is not None:
        streams += [filter_stream]
    dmap = hv.DynamicMap(partial(color_points_fit, self=self), kdims=['colors','mag', 'xmax', 'label'], 
                         streams=streams)
    dmap = dmap.redim.values(mag=self.mag_names, xmax=xmax_range, 
                             label=['star', 'maybe', 'noStar'],
                            colors=['{}{}{}'.format(c1[0],c1[-1],c2[-1]) for c1, c2 in zip(self.catalog.colors[0:-1], self.catalog.colors[1:])])
    return dmap

In [36]:
%%opts Points [width=600, height=600] (alpha=0.2)
color_fit_explore(grizy_data)


/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:247: RuntimeWarning: invalid value encountered in greater_equal
  mask &= k.start <= arr
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:249: RuntimeWarning: invalid value encountered in less
  mask &= arr < k.stop
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:247: RuntimeWarning: invalid value encountered in greater_equal
  mask &= k.start <= arr
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:249: RuntimeWarning: invalid value encountered in less
  mask &= arr < k.stop
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:247: RuntimeWarning: invalid value encountered in greater_equal
  mask &= k.start <= arr
/home/tmorton/repositories/holoviews/holoviews/core/data/interface.py:249: RuntimeWarning: invalid value encountered in less
  mask &= arr < k.stop
Out[36]:

In [ ]: