-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgz_class.py
More file actions
750 lines (620 loc) · 32.9 KB
/
Copy pathgz_class.py
File metadata and controls
750 lines (620 loc) · 32.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
# Adapted from galaxyzoo2.gz2string
def gal_string(datarow,survey='decals'):
""" Determine a string for the consensus GZ2 classification of a
galaxy's morphology.
Parameters
----------
datarow : astropy.io.fits.fitsrec.FITS_record
Iterated element (row) of a final
GZ2 table, containing all debiased probabilities
and vote counts
survey : string indicating the survey group that defines
the workflow/decision tree. Default is 'decals'.
Possible options should be:
'candels'
'candels_2epoch'
'decals'
'ferengi'
'goods_full'
'illustris'
'sloan',
'sloan_singleband'
'ukidss'
Returns
-------
char: str
String giving the plurality classification from GZ2
eg, '
Notes
-------
"""
weights = datarow
if survey in ('decals',):
max_t1 = weights[:3].argmax()
char = ''
task_eval = [0]*12
task_eval[0] = 1
# Smooth galaxies
if max_t1 == 0:
char += 'E'
# Roundness
char += ('r','i','c')[weights[23:26].argmax()]
task_eval[8] = 1
# Features/disk galaxies
if max_t1 == 1:
char += 'S'
task_eval[1] = 1
edgeon = weights[3:5]
# Edge-on disks
if edgeon[0] >= edgeon[1]:
char += 'e'
# Bulge shape
char += ('r','b','n')[weights[20:23].argmax()]
task_eval[7] = 1
# Not edge-on disks
else:
task_eval[2] = 1
task_eval[3] = 1
task_eval[4] = 1
if weights[5] > weights[6]:
# Barred galaxies
char += 'B'
# Bulge prominence
char += ('c','b','a')[weights[9:12].argmax()]
if weights[7] > weights[8]:
# Arms number
char += ('1','2','3','4','+')[weights[15:20].argmax()]
task_eval[6] = 1
# Arms winding
char += ('t','m','l')[weights[12:15].argmax()]
task_eval[5] = 1
# Mergers/tidal debris
char += '[%s]' % ('MG','TD','MT','')[weights[26:30].argmax()]
task_eval[9] = 1
# Odd features
if max(weights[31:38]) > 0.50:
char += '(%s)' % ('n','r','l','d','i','o','v')[weights[31:38].argmax()]
task_eval[10] = 1
# Star/artifact
if max_t1 == 2:
char = 'A'
# Discuss
task_eval[11] = 1
task_ans = [0]*12
task_ans[0] = weights[ 0: 3].argmax()+0
task_ans[1] = weights[ 3: 5].argmax()+3
task_ans[2] = weights[ 5: 7].argmax()+5
task_ans[3] = weights[ 7: 9].argmax()+7
task_ans[4] = weights[ 9:12].argmax()+9
task_ans[5] = weights[12:15].argmax()+12
task_ans[6] = weights[15:20].argmax()+15
task_ans[7] = weights[20:23].argmax()+20
task_ans[8] = weights[23:26].argmax()+23
task_ans[9] = weights[26:30].argmax()+26
task_ans[10] = weights[31:38].argmax()+31
task_ans[11] = weights[38:40].argmax()+38
if survey in ('ferengi'):
# Top-level: elliptical, features/disk, artifact
max_t1 = weights[:3].argmax()
char = ''
task_eval = [0]*12
task_eval[0] = 1
# Smooth galaxies
if max_t1 == 0:
char += 'E'
# Roundness
char += ('r','i','c')[weights[23:26].argmax()]
task_eval[8] = 1
# Features/disk galaxies
if max_t1 == 1:
char += 'S'
task_eval[1] = 1
edgeon = weights[3:5]
# Edge-on disks
if edgeon[0] >= edgeon[1]:
char += 'e'
# Bulge shape
char += ('r','b','n')[weights[20:23].argmax()]
task_eval[7] = 1
# Not edge-on disks
else:
task_eval[2] = 1
task_eval[3] = 1
task_eval[4] = 1
if weights[5] > weights[6]:
# Barred galaxies
char += 'B'
# Bulge prominence
char += ('c','b','a')[weights[9:12].argmax()]
if weights[7] > weights[8]:
# Arms number
char += ('1','2','3','4','+')[weights[15:20].argmax()]
task_eval[6] = 1
# Arms winding
char += ('t','m','l')[weights[12:15].argmax()]
task_eval[5] = 1
# Mergers/tidal debris
char += '[%s]' % ('MG','TD','MT','')[weights[26:30].argmax()]
task_eval[9] = 1
# Odd features
if max(weights[31:38]) > 0.50:
char += '(%s)' % ('n','r','l','d','i','o','v')[weights[31:38].argmax()]
task_eval[10] = 1
# Star/artifact
if max_t1 == 2:
char = 'A'
# Discuss
task_eval[11] = 1
task_ans = [0]*12
task_ans[0] = weights[ 0: 3].argmax()+0
task_ans[1] = weights[ 3: 5].argmax()+3
task_ans[2] = weights[ 5: 7].argmax()+5
task_ans[3] = weights[ 7: 9].argmax()+7
task_ans[4] = weights[ 9:12].argmax()+9
task_ans[5] = weights[12:15].argmax()+12
task_ans[6] = weights[15:20].argmax()+15
task_ans[7] = weights[20:23].argmax()+20
task_ans[8] = weights[23:26].argmax()+23
task_ans[9] = weights[26:30].argmax()+26
task_ans[10] = weights[31:38].argmax()+31
task_ans[11] = weights[38:40].argmax()+38
return char,task_eval,task_ans
def plurality(datarow,survey='decals',check_threshold = 0.50):
""" Determine the plurality for the consensus GZ2 classification of a
galaxy's morphology.
Parameters
----------
datarow : astropy.io.fits.fitsrec.FITS_record
Iterated element (row) of a final
GZ2 table, containing all debiased probabilities
and vote counts
survey : string indicating the survey group that defines
the workflow/decision tree. Default is 'decals'.
Possible options should be:
'candels'
'candels_2epoch'
'decals'
'ferengi'
'goods_full'
'illustris'
'sloan',
'sloan_singleband'
'ukidss'
check_threshold: float indicating the threshold plurality level for
checkbox questions. If no questions meet this, don't select any answer.
Returns
-------
task_eval: array [N]
1 if question was answered by the plurality path through the tree; 0 if not
task_ans: array [N]
Each answer gives the index of most common answer
regardless of if it was in the plurality path or not.
Notes
-------
"""
weights = datarow
if survey in ('decals',):
d = { 0:{'idx': 0,'len':3}, # 'Shape', 'Is the galaxy simply smooth and rounded, with no sign of a disk?', ->
1:{'idx': 3,'len':2}, # 'Disk', 'Could this be a disk viewed edge-on?', ->
2:{'idx': 5,'len':2}, # 'Bar', 'Is there any sign of a bar feature through the centre of the galaxy?' ->
3:{'idx': 7,'len':2}, # "Is there any sign of a spiral arm pattern?"
4:{'idx': 9,'len':3}, # "How prominent is the central bulge, compared with the rest of the galaxy?"
5:{'idx':12,'len':3}, # "How tightly wound do the spiral arms appear?"
6:{'idx':15,'len':5}, # "How many spiral arms are there?"
7:{'idx':20,'len':3}, # "Does the galaxy have a bulge at its centre? If so, what shape?"
8:{'idx':23,'len':3}, # 'Round', 'How rounded is it?', ->
9:{'idx':26,'len':4}, # "Is the galaxy currently merging or is there any sign of tidal debris?"
10:{'idx':31,'len':7}, # "Do you see any of these odd features in the image?"
11:{'idx':38,'len':2}} # "Would you like to discuss this object?"
task_eval = [0]*len(d)
task_ans = [0]*len(d)
# Top-level: smooth/features/artifact
task_eval[0] = 1
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() < 2:
# Smooth galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 0:
# Roundness
task_eval[8] = 1
# Features/disk galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 1:
# Disk galaxies
task_eval[1] = 1
# Edge-on disks
if weights[d[1]['idx']] > weights[d[1]['idx']+1]:
# Bulge shape
task_eval[7] = 1
# Not edge-on disks
else:
task_eval[2] = 1
task_eval[3] = 1
if weights[d[3]['idx']] > weights[d[3]['idx']+1]:
# Spirals
task_eval[5] = 1
task_eval[6] = 1
task_eval[4] = 1
# Merging/tidal debris
task_eval[9] = 1
# Odd features - only count if it's above some threshold, since this is a checkbox question
if max(weights[d[10]['idx']:d[10]['idx'] + d[10]['len']]) > check_threshold:
task_eval[10] = 1
# Discuss
task_eval[11] = 1
if survey in ('ferengi','goods_full'):
d = { 0:{'idx':0 ,'len':3}, # 'Shape', 'Is the galaxy simply smooth and rounded, with no sign of a disk?', ->
1:{'idx':3 ,'len':3}, # 'Round', 'How rounded is it?', leadsTo: 'Is there anything odd?', ->
2:{'idx':6 ,'len':2}, # 'Clumps', 'Does the galaxy have a mostly clumpy appearance?', ->
3:{'idx':8 ,'len':6}, # 'Clumps', 'How many clumps are there?', leadsTo: 'Do the clumps appear in a straight line, a chain, or a cluster?', ->
4:{'idx':14 ,'len':4}, # 'Clumps', 'Do the clumps appear in a straight line, a chain, or a cluster?', leadsTo: 'Is there one clump which is clearly brighter than the others?', ->
5:{'idx':18 ,'len':2}, # 'Clumps', 'Is there one clump which is clearly brighter than the others?', ->
6:{'idx':20 ,'len':2}, # 'Clumps', 'Is the brightest clump central to the galaxy?', ->
7:{'idx':22 ,'len':2}, # 'Symmetry', 'Does the galaxy appear symmetrical?', leadsTo: 'Do the clumps appear to be embedded within a larger object?', ->
8:{'idx':24 ,'len':2}, # 'Clumps', 'Do the clumps appear to be embedded within a larger object?', leadsTo: 'Is there anything odd?', ->
9:{'idx':26 ,'len':2}, # 'Disk', 'Could this be a disk viewed edge-on?', ->
10:{'idx':28 ,'len':3}, # 'Bulge', 'Does the galaxy have a bulge at its center? If so, what shape?', leadsTo: 'Is there anything odd?', ->
11:{'idx':31 ,'len':2}, # 'Bar', 'Is there any sign of a bar feature through the centre of the galaxy?', leadsTo: 'Is there any sign of a spiral arm pattern?', ->
12:{'idx':33 ,'len':2}, # 'Spiral', 'Is there any sign of a spiral arm pattern?', ->
13:{'idx':35 ,'len':3}, # 'Spiral', 'How tightly wound do the spiral arms appear?', leadsTo: 'How many spiral arms are there?', ->
14:{'idx':38 ,'len':6}, # 'Spiral', 'How many spiral arms are there?', leadsTo: 'How prominent is the central bulge, compared with the rest of the galaxy?', ->
15:{'idx':44 ,'len':4}, # 'Bulge', 'How prominent is the central bulge, compared with the rest of the galaxy?', leadsTo: 'Is there anything odd?', ->
16:{'idx':48 ,'len':2}, # 'Discuss', 'Would you like to discuss this object?', ->
17:{'idx':50 ,'len':2}, # 'Odd', 'Is there anything odd?', ->
18:{'idx':53 ,'len':7}} # 'Odd', 'What are the odd features?', -> # Indexing here skips the a-0 answer.
task_eval = [0]*len(d)
task_ans = [0]*len(d)
# Top-level: smooth/features/artifact
task_eval[0] = 1
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() < 2:
# Smooth galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 0:
# Roundness
task_eval[1] = 1
# Features/disk galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 1:
task_eval[2] = 1
# Clumpy question
if weights[d[2]['idx']] > weights[d[2]['idx']+1]:
# Clumpy galaxies
task_eval[3] = 1
if weights[d[3]['idx']:d[3]['idx'] + d[3]['len']].argmax() > 0:
# Multiple clumps
if weights[d[3]['idx']:d[3]['idx'] + d[3]['len']].argmax() > 1:
# One bright clump
task_eval[4] = 1
task_eval[5] = 1
if weights[d[5]['idx']] > weights[d[5]['idx']+1]:
# Bright clump symmetrical
task_eval[6] = 1
if weights[d[6]['idx']] > weights[d[6]['idx']+1]:
task_eval[7] = 1
task_eval[8] = 1
else:
# Disk galaxies
task_eval[9] = 1
# Edge-on disks
if weights[d[9]['idx']] > weights[d[9]['idx']+1]:
# Bulge shape
task_eval[10] = 1
# Not edge-on disks
else:
task_eval[11] = 1
task_eval[12] = 1
if weights[d[12]['idx']] > weights[d[12]['idx']+1]:
# Spirals
task_eval[13] = 1
task_eval[14] = 1
task_eval[15] = 1
# Odd features
task_eval[17] = 1
if weights[d[17]['idx']] > weights[d[17]['idx']+1]:
# Only count if it's above some threshold, since this is a checkbox question
if max(weights[d[18]['idx']:d[18]['idx'] + d[18]['len']]) > check_threshold:
task_eval[18] = 1
# Discuss
task_eval[16] = 1
if survey in ('gzh',):
d = { 0:{'len':3}, # 'Shape', 'Is the galaxy simply smooth and rounded, with no sign of a disk?', ->
1:{'len':2}, # 'Disk', 'Could this be a disk viewed edge-on?', ->
2:{'len':2}, # 'Bar', 'Is there any sign of a bar feature through the centre of the galaxy?', leadsTo: 'Is there any sign of a spiral arm pattern?', ->
3:{'len':2}, # 'Spiral', 'Is there any sign of a spiral arm pattern?', ->
4:{'len':4}, # 'Bulge', 'How prominent is the central bulge, compared with the rest of the galaxy?', leadsTo: 'Is there anything odd?', ->
5:{'len':2}, # 'Odd', 'Is there anything odd?', ->
6:{'len':3}, # 'Round', 'How rounded is it?', leadsTo: 'Is there anything odd?', ->
7:{'len':7}, # 'Odd', 'What are the odd features?', -> Not a checkbox
8:{'len':3}, # 'Bulge', 'Does the galaxy have a bulge at its center? If so, what shape?', leadsTo: 'Is there anything odd?', ->
9:{'len':3}, # 'Spiral', 'How tightly wound do the spiral arms appear?', leadsTo: 'How many spiral arms are there?', ->
10:{'len':6}, # 'Spiral', 'How many spiral arms are there?', leadsTo: 'How prominent is the central bulge, compared with the rest of the galaxy?', ->
11:{'len':2}, # 'Clumps', 'Does the galaxy have a mostly clumpy appearance?', ->
12:{'len':6}, # 'Clumps', 'How many clumps are there?', leadsTo: 'Do the clumps appear in a straight line, a chain, or a cluster?', ->
13:{'len':2}, # 'Clumps', 'Is there one clump which is clearly brighter than the others?', ->
14:{'len':2}, # 'Clumps', 'Is the brightest clump central to the galaxy?', ->
15:{'len':4}, # 'Clumps', 'Do the clumps appear in a straight line, a chain, or a cluster?', leadsTo: 'Is there one clump which is clearly brighter than the others?', ->
16:{'len':2}, # 'Symmetry', 'Does the galaxy appear symmetrical?', leadsTo: 'Do the clumps appear to be embedded within a larger object?', ->
17:{'len':2}} # 'Clumps', 'Do the clumps appear to be embedded within a larger object?', leadsTo: 'Is there anything odd?', ->
# Don't need to skip indices since there's no checkbox question
idx = 0
for i in range(len(d)):
d[i]['idx'] = idx
idx += d[i]['len']
task_eval = [0]*len(d)
task_ans = [0]*len(d)
# Top-level: smooth/features/artifact
task_eval[0] = 1
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() < 2:
# Smooth galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 0:
# Roundness
task_eval[1] = 1
# Features/disk galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 1:
task_eval[2] = 1
# Clumpy question
if weights[d[2]['idx']] > weights[d[2]['idx']+1]:
# Clumpy galaxies
task_eval[3] = 1
if weights[d[3]['idx']:d[3]['idx'] + d[3]['len']].argmax() > 0:
# Multiple clumps
if weights[d[3]['idx']:d[3]['idx'] + d[3]['len']].argmax() > 1:
# Clump arrangement
task_eval[4] = 1
if weights[d[4]['idx']:d[4]['idx']+d[4]['len']].argmax() == 3:
# Bar
task_eval[11] = 1
# Spiral structure
task_eval[12] = 1
if weights[d[12]['idx']] > weights[d[12]['idx']+1]:
# Spiral arms
task_eval[13] = 1
task_eval[14] = 1
# Bulge prominence
task_eval[15] = 1
# One clump brighter than others
task_eval[5] = 1
if weights[d[5]['idx']] > weights[d[5]['idx']+1]:
# Bright clump central
task_eval[6] = 1
if weights[d[6]['idx']] > weights[d[6]['idx']+1]:
# Symmetrical clumps
task_eval[7] = 1
# Clumps embedded
task_eval[8] = 1
else:
# Disk galaxies
task_eval[9] = 1
# Edge-on disks
if weights[d[9]['idx']] > weights[d[9]['idx']+1]:
# Bulge shape
task_eval[10] = 1
# Not edge-on disks
else:
# Bar
task_eval[11] = 1
# Spiral
task_eval[12] = 1
if weights[d[12]['idx']] > weights[d[12]['idx']+1]:
# Spiral arm numbers and winding
task_eval[13] = 1
task_eval[14] = 1
# Bulge prominence
task_eval[15] = 1
# Odd features
task_eval[16] = 1
if weights[d[16]['idx']] > weights[d[16]['idx']+1]:
# Only count if it's above some threshold, since this is a checkbox question
if max(weights[d[17]['idx']:d[17]['idx'] + d[17]['len']]) > check_threshold:
task_eval[17] = 1
# Clumpy questions 5-8 not answered if they were organized in a spiral
if weights[d[4]['idx']:d[4]['idx']+d[4]['len']].argmax() == 3 and task_eval[4]:
task_eval[5] = 0
task_eval[6] = 0
task_eval[7] = 0
task_eval[8] = 0
if survey in ('candels','candels_2epoch'):
d = { 0:{'idx':0 ,'len':3}, # 'Shape', 'Is the galaxy simply smooth and rounded, with no sign of a disk?', ->
1:{'idx':3 ,'len':3}, # 'Round', 'How rounded is it?', leadsTo: 'Is there anything odd?', ->
2:{'idx':6 ,'len':2}, # 'Clumps', 'Does the galaxy have a mostly clumpy appearance?', ->
3:{'idx':8 ,'len':6}, # 'Clumps', 'How many clumps are there?', leadsTo: 'Do the clumps appear in a straight line, a chain, or a cluster?', ->
4:{'idx':14,'len':4}, # 'Clumps', 'Do the clumps appear in a straight line, a chain, or a cluster?', leadsTo: 'Is there one clump which is clearly brighter than the others?', ->
5:{'idx':18,'len':2}, # 'Clumps', 'Is there one clump which is clearly brighter than the others?', ->
6:{'idx':20,'len':2}, # 'Clumps', 'Is the brightest clump central to the galaxy?', ->
7:{'idx':22,'len':2}, # 'Symmetry', 'Does the galaxy appear symmetrical?', leadsTo: 'Do the clumps appear to be embedded within a larger object?', ->
8:{'idx':24,'len':2}, # 'Clumps', 'Do the clumps appear to be embedded within a larger object?', leadsTo: 'Is there anything odd?', ->
9:{'idx':26,'len':2}, # 'Disk', 'Could this be a disk viewed edge-on?', ->
10:{'idx':28,'len':2}, # 'Bulge', 'Does the galaxy have a bulge at its center?', leadsTo: 'Is there anything odd?', ->
11:{'idx':30,'len':2}, # 'Bar', 'Is there any sign of a bar feature through the centre of the galaxy?', leadsTo: 'Is there any sign of a spiral arm pattern?', ->
12:{'idx':32,'len':2}, # 'Spiral', 'Is there any sign of a spiral arm pattern?', ->
13:{'idx':34,'len':3}, # 'Spiral', 'How tightly wound do the spiral arms appear?', leadsTo: 'How many spiral arms are there?', ->
14:{'idx':37,'len':6}, # 'Spiral', 'How many spiral arms are there?', leadsTo: 'How prominent is the central bulge, compared with the rest of the galaxy?', ->
15:{'idx':43,'len':3}, # 'Bulge', 'How prominent is the central bulge, compared with the rest of the galaxy?', leadsTo: 'Is there anything odd?', ->
16:{'idx':46,'len':4}, # Merging/tidal debris
17:{'idx':50,'len':2}} # Discuss
task_eval = [0]*len(d)
task_ans = [0]*len(d)
# Top-level: smooth/features/artifact
task_eval[0] = 1
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() < 2:
# Smooth galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 0:
# Roundness
task_eval[1] = 1
# Features/disk galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 1:
task_eval[2] = 1
# Clumpy question
if weights[d[2]['idx']] > weights[d[2]['idx']+1]:
# Clumpy galaxies
task_eval[3] = 1
if weights[d[3]['idx']:d[3]['idx'] + d[3]['len']].argmax() > 0:
# Multiple clumps
if weights[d[3]['idx']:d[3]['idx'] + d[3]['len']].argmax() > 1:
# One bright clump
task_eval[4] = 1
task_eval[5] = 1
if weights[d[5]['idx']] > weights[d[5]['idx']+1]:
# Bright clump symmetrical
task_eval[6] = 1
if weights[d[6]['idx']] > weights[d[6]['idx']+1]:
task_eval[7] = 1
task_eval[8] = 1
else:
# Disk galaxies
task_eval[9] = 1
# Edge-on disks
if weights[d[9]['idx']] > weights[d[9]['idx']+1]:
# Bulge shape
task_eval[10] = 1
# Not edge-on disks
else:
task_eval[11] = 1
task_eval[12] = 1
if weights[d[12]['idx']] > weights[d[12]['idx']+1]:
# Spirals
task_eval[13] = 1
task_eval[14] = 1
task_eval[15] = 1
# Merging/tidal debris
task_eval[16] = 1
# Discuss
task_eval[17] = 1
if survey in ('illustris',):
d = { 0:{'idx': 0,'len':3}, # 'Shape', 'Is the galaxy simply smooth and rounded, with no sign of a disk?', ->
1:{'idx': 3,'len':2}, # 'Disk', 'Could this be a disk viewed edge-on?', ->
2:{'idx': 5,'len':2}, # 'Bar', 'Is there any sign of a bar feature through the centre of the galaxy?' ->
3:{'idx': 7,'len':2}, # "Is there any sign of a spiral arm pattern?"
4:{'idx': 9,'len':4}, # "How prominent is the central bulge, compared with the rest of the galaxy?"
5:{'idx':14,'len':7}, # Odd features
6:{'idx':21,'len':3}, # Round
7:{'idx':24,'len':3}, # Bulge shape
8:{'idx':27,'len':3}, # arms winding
9:{'idx':30,'len':6}, # arms number
10:{'idx':36,'len':2}, # Is there anything odd?
11:{'idx':38,'len':2}} # "Would you like to discuss this object?"
task_eval = [0]*len(d)
task_ans = [0]*len(d)
# Top-level: smooth/features/artifact
task_eval[0] = 1
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() < 2:
# Smooth galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 0:
# Roundness
task_eval[6] = 1
# Features/disk galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 1:
# Disk galaxies
task_eval[1] = 1
# Edge-on disks
if weights[d[1]['idx']] > weights[d[1]['idx']+1]:
# Bulge shape
task_eval[7] = 1
# Not edge-on disks
else:
task_eval[2] = 1
task_eval[3] = 1
if weights[d[3]['idx']] > weights[d[3]['idx']+1]:
# Spirals
task_eval[8] = 1
task_eval[9] = 1
task_eval[4] = 1
# Odd features
task_eval[10] = 1
if weights[d[10]['idx']] > weights[d[10]['idx']+1]:
# Only count if it's above some threshold, since this is a checkbox question
if max(weights[d[5]['idx']:d[5]['idx'] + d[5]['len']]) > check_threshold:
task_eval[5] = 1
# Discuss
task_eval[11] = 1
if survey in ('sloan','sloan_singleband','ukidss'):
d = { 0:{'idx': 0,'len':3}, # 'Shape', 'Is the galaxy simply smooth and rounded, with no sign of a disk?', ->
1:{'idx': 3,'len':2}, # 'Disk', 'Could this be a disk viewed edge-on?', ->
2:{'idx': 5,'len':2}, # 'Bar', 'Is there any sign of a bar feature through the centre of the galaxy?' ->
3:{'idx': 7,'len':2}, # "Is there any sign of a spiral arm pattern?"
4:{'idx': 9,'len':4}, # "How prominent is the central bulge, compared with the rest of the galaxy?"
5:{'idx':13,'len':2}, # Is there anything odd?
6:{'idx':16,'len':7}, # Odd features
7:{'idx':23,'len':3}, # Round
8:{'idx':26,'len':3}, # Bulge shape
9:{'idx':29,'len':3}, # arms winding
10:{'idx':32,'len':6}, # arms number
11:{'idx':38,'len':2}} # "Would you like to discuss this object?"
task_eval = [0]*len(d)
task_ans = [0]*len(d)
# Top-level: smooth/features/artifact
task_eval[0] = 1
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() < 2:
# Smooth galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 0:
# Roundness
task_eval[7] = 1
# Features/disk galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 1:
# Disk galaxies
task_eval[1] = 1
# Edge-on disks
if weights[d[1]['idx']] > weights[d[1]['idx']+1]:
# Bulge shape
task_eval[8] = 1
# Not edge-on disks
else:
task_eval[2] = 1
task_eval[3] = 1
if weights[d[3]['idx']] > weights[d[3]['idx']+1]:
# Spirals
task_eval[9] = 1
task_eval[10] = 1
task_eval[4] = 1
# Odd features
task_eval[5] = 1
if weights[d[5]['idx']] > weights[d[5]['idx']+1]:
# Only count if it's above some threshold, since this is a checkbox question
if max(weights[d[6]['idx']:d[6]['idx'] + d[6]['len']]) > check_threshold:
task_eval[6] = 1
# Discuss
task_eval[11] = 1
if survey in ('gz2','stripe82',):
d = { 0:{'idx': 0,'len':3}, # 'Shape', 'Is the galaxy simply smooth and rounded, with no sign of a disk?', ->
1:{'idx': 3,'len':2}, # 'Disk', 'Could this be a disk viewed edge-on?', ->
2:{'idx': 5,'len':2}, # 'Bar', 'Is there any sign of a bar feature through the centre of the galaxy?' ->
3:{'idx': 7,'len':2}, # "Is there any sign of a spiral arm pattern?"
4:{'idx': 9,'len':4}, # "How prominent is the central bulge, compared with the rest of the galaxy?"
5:{'idx':13,'len':2}, # Is there anything odd?
6:{'idx':15,'len':3}, # Round
7:{'idx':18,'len':7}, # Odd features
8:{'idx':25,'len':3}, # Bulge shape
9:{'idx':28,'len':3}, # arms winding
10:{'idx':31,'len':6}} # arms number
task_eval = [0]*len(d)
task_ans = [0]*len(d)
# Top-level: smooth/features/artifact
task_eval[0] = 1
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() < 2:
# Smooth galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 0:
# Roundness
task_eval[6] = 1
# Features/disk galaxies
if weights[d[0]['idx']:d[0]['idx']+d[0]['len']].argmax() == 1:
# Disk galaxies
task_eval[1] = 1
# Edge-on disks
if weights[d[1]['idx']] > weights[d[1]['idx']+1]:
# Bulge shape
task_eval[8] = 1
# Not edge-on disks
else:
task_eval[2] = 1
task_eval[3] = 1
if weights[d[3]['idx']] > weights[d[3]['idx']+1]:
# Spirals
task_eval[9] = 1
task_eval[10] = 1
task_eval[4] = 1
# Odd features
task_eval[5] = 1
if weights[d[5]['idx']] > weights[d[5]['idx']+1]:
task_eval[7] = 1
# Assign the plurality task numbers
for i,t in enumerate(task_ans):
try:
task_ans[i] = weights[d[i]['idx']:d[i]['idx'] + d[i]['len']].argmax() + d[i]['idx']
except ValueError:
print "ValueError in gz_class: {0:} categories, {1:} answers".format(len(weights),len(task_ans))
return task_eval,task_ans