Open keflavich opened 11 years ago
Sorry for taking so long to review this. I tested it and it does work, but I think there are a couple changes we should make to the code before merging it.
.items
property that contains its immediate children, and using that will be much more efficient than using [d for d in item.descendants if d.level==item.level++]
Here's an example. I think this is working (please test) for the 'brightest' plot mode; I haven't implemented the other version.
def _build_lines(self, items, brightest=True):
for item in items:
color = self._color_lambda(item)
if brightest:
### Changes start here ########
brightest_children = []
def add_brightest_children(current_item):
brightest_children.append(current_item)
if type(current_item)==Branch:
brightest_child = max(current_item.items, key=lambda i: i.f_sum)
add_brightest_children(brightest_child)
add_brightest_children(item)
xvalues, yvalues = zip(*[ (i.npix, i.f_sum) for i in brightest_children ])
else:
# TODO: normal (non-brightest) mode
self._plot_values[item.idx] = { 'color': color, 'values': [[xvalues,yvalues],] }
one could also implement this as follows:
xvalues, yvalues = [],[]
if brightest:
def add_brightest_children(current_item):
xvalues.append(current_item.npix)
yvalues.append(current_item.f_sum)
if type(current_item)==Branch:
brightest_child = max(current_item.items, key=lambda i: i.f_sum)
add_brightest_children(brightest_child)
add_brightest_children(item)
else: ...
For making the style of plots Jens Kauffmann likes, e.g. Kauffmann 2013 comparing Orion with the Brick. Same as previous pull request onto dendro-core, but this time with the right target.
https://github.com/bradenmacdonald/dendro-core/pull/1#issuecomment-12450895
Thanks for clarifying the split @bradenmacdonald. Might be worth referencing that comment - or copying it - in the docs.