Created
June 6, 2019 01:20
-
-
Save johnarban/24ff502f56281210d7f6f51f0e284955 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from glue.core import Data, DataCollection | |
from glue.core.component_link import ComponentLink | |
for i,d1 in enumerate(dc): | |
for j,d2 in enumerate(dc): | |
if j>i:#d1.label != d2.label: | |
print('\n',d1.label,' <---> ',d2.label,'\n') | |
comp1 = d1.components | |
comp2 = d2.components | |
for c1 in comp1: | |
for c2 in comp2: | |
if (c1.label==c2.label): | |
cord1 = 'Coord' in str(type(d1.get_component(c1))) | |
cord2 = 'Coord' in str(type(d2.get_component(c2))) | |
if not (cord1 or cord2): | |
print(c2.label,' <> ',c1.label) | |
link=ComponentLink([d2.id[c2]],d1.id[c1]) | |
dc.add_link(link) | |
else: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This little piece of code will link together all components with identical names from every data collection currently loaded. It's purpose is to link columns of catalogs. It will ignore coordinate components because those might use special linkers and I didn't feel like thinking about that. In any case, there are usually only a few coordinate components and those can be done manually 😄