<jupyter_start><jupyter_text><jupyter_code>atree = ctu.extract_a_tree(alltrees.data, 270444)
indgal = (atree['nout'] > 87) * (atree['nout'] < 105) * (atree['m'] > 1e10)
print(atree['id'][indgal])
m1 = extract_main_tree(alltrees.data, idx=171034)
m2 = extract_main_tree(alltrees.data, idx=171035)
sub1 = ctu.extract_main_tree(atree, idx=171034, no_subset=True)
sub2 = ctu.extract_main_tree(atree, idx=171035, no_subset=True)
plt.scatter(sub1['aexp'], sub1['m'], c='red')
plt.scatter(sub2['aexp'], sub2['m'], c='blue')
plt.show()
sub1.dtype
qlist = ["mvir", "rvir", "rs", "vrms", "vmax",
         "x", "y", "z", "vx", "vy",
         "vz", "jx", "jy", "jz", "spin", "np", "m", "r",
         "tvir", "cvel", "sig", "sigbulge", "mbulge"][:]
fig, ax = plt.subplots(8,3)
ax= ax.ravel()

for i, q in enumerate(qlist):
    ax[i].plot(sub1['aexp'], sub1[q], c='blue')
    ax[i].plot(sub2['aexp'], sub2[q], c='red')
    ax[i].set_title(q)

plt.tight_layout()
plt.show()
ind1 = m1['nout'] > 80
ind2 = m2['nout'] > 80
plt.plot(m1['nout'][ind1],m1['m'][ind1])
plt.plot(m2['nout'][ind2],m2['m'][ind2])
plt.show()
plt.scatter(atree[indgal]['aexp'], atree[indgal]['m'])
plt.show()
print(atree.dtype)
print(atree[0])
for t,q in zip(atree.dtype.names, atree[0]):
    if isinstance(q, np.int64):
        #print("int")
        print(" {}  : {:d}".format(t, q))
    elif q > 1e4:
        print(" {}  : {:.3e}".format(t, q))
    else:
        print(" {}  : {:.2f}".format(t, q))
import os
if not os.path.isdir(wdir + "mergertrees/"):
    os.mkdir(wdir + "mergertrees/")


fig, ax = plt.subplots(1,2)
fig.set_size_inches([12,6])
for galid in final_gals:
    sidgal = str(galid).zfill(5)      
    
    #print(zreds)
    atree = ctu.extract_a_tree(alltrees.data, galid)
    mtree = extract_main_tree(atree)
    
    ax[0].scatter(atree['aexp'], np.log10(atree['m']), edgecolors='none', alpha=0.3)
    ax[0].scatter(mtree['aexp'], np.log10(mtree['m']), edgecolors='none', alpha=0.6,
                  facecolors='red')
    ax[0].set_xlim([0.15,1.1])
    ax[0].set_xticks(aexps[0:151:20])
    ax[0].set_xticklabels(zreds[0:151:20])
    ax[0].set_title(galid)
    
    recursive_tree(galid, atree, 150, ax[1], 0, 0, 0.8, mass_unit=2e8)
    
    # y axis label (redshift)
    ax[1].set_ylabel("Redshift")
    ax[1].set_ylim([-5,155])
    ax[1].set_yticks(range(0,151,10))
    ax[1].set_yticklabels(zreds[0:151:10])
    #plt.yticks(range(0,151,10), zreds[0:151:10])
    ax[1].set_title(sidgal + ", " + str(atree[0]['Orig_halo_id']))
    #fig.show()
    plt.savefig(wdir + "mergertrees/" + sidgal + '.png')
    ax[0].clear()
    ax[1].clear()
    
    #plt.close()


plt.close()
import tree.halomodulemodule as hmo
gg = hmo.Halo(nout=187, is_gal=True, load=True)
gg.data.dtype
gg.data['az']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.23126568662603084, 'fraction_numerical': 0.05844388669774113, 'mean_word_length': 4.185873605947956, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '294819', 'license': 'MIT', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1271, 'n_words': 188, 'path': 'scripts/scripts_ipynb/fix merger tree.ipynb', 'repo_name': 'Hoseung/pyRamAn', 'size': '2789'}