@@ -60,8 +60,9 @@ def make_faceon(cop, this_g_cood, this_g_mass, this_g_vel):
60
60
def extract_subfind_info (fname = 'data/flares.hdf5' , inp = 'FLARES' ,
61
61
properties = {'properties' : ['MassType' ],
62
62
'conv_factor' : [1e10 ],
63
+ 'arr_idx' : [None ],
63
64
'save_str' : ['MassType' ]},
64
- overwrite = False , threads = 8 , verbose = False ):
65
+ overwrite = False , threads = 8 , write_out = True , verbose = False ):
65
66
66
67
fl = flares .flares (fname ,inp )
67
68
indices = fl .load_dataset ('Indices' )
@@ -81,24 +82,121 @@ def extract_subfind_info(fname='data/flares.hdf5', inp='FLARES',
81
82
82
83
halodir = fl .directory + '/GEAGLE_' + halo + '/data/'
83
84
84
- props = properties ['properties' ]
85
- conv_factor = properties ['conv_factor' ]
86
- save_str = properties ['save_str' ]
87
-
88
- for _prop ,_conv ,_save in zip (props ,conv_factor ,save_str ):
85
+ for _prop ,_conv ,_save ,_arr_idx in \
86
+ zip (properties ['properties' ],
87
+ properties ['conv_factor' ],
88
+ properties ['save_str' ],
89
+ properties ['arr_idx' ]):
90
+
89
91
90
92
if (fl ._check_hdf5 ('%s/%s/Subhalo/%s' % (halo ,tag ,_prop )) is False ) | \
91
93
(overwrite == True ):
92
94
93
95
_arr = E .read_array ("SUBFIND" , halodir , tag ,
94
96
"/Subhalo/%s" % _prop ,
95
97
numThreads = threads , noH = True ) * _conv
96
-
97
98
98
- fl .create_dataset (_arr [indices [halo ][tag ].astype (int )], _save ,
99
- '%s/%s/Galaxy/' % (halo ,tag ), overwrite = True , verbose = verbose )
99
+ if arr_idx is not None :
100
+ _arr [:arr_idx ]
101
+
102
+
103
+ if write_out is False :
104
+ # return array WITHOUT indices filtering (be careful)
105
+ return _arr
106
+ else :
107
+ fl .create_dataset (_arr [indices [halo ][tag ].astype (int )], _save ,
108
+ '%s/%s/Galaxy/' % (halo ,tag ), overwrite = True , verbose = verbose )
109
+
110
+
111
+
112
+ def initialise_master_file ():
113
+ """
114
+ Run the initial subfind download and create the indices array
115
+ """
116
+
117
+ print (F"Extracing information from { inp } { num } { tag } " )
118
+
119
+ if inp == 'FLARES' :
120
+ sim_type = 'FLARES'
121
+ fl = flares .flares (fname = './data2/' ,sim_type = sim_type )
122
+ num = str (num )
123
+ if len (num ) == 1 :
124
+ num = '0' + num
125
+ dir = fl .directory
126
+ sim = F"{ dir } GEAGLE_{ num } /data/"
127
+
128
+ elif inp == 'REF' :
129
+ sim_type = 'PERIODIC'
130
+ fl = flares .flares (fname = './data/' ,sim_type = sim_type )
131
+ sim = fl .ref_directory
100
132
133
+ elif inp == 'AGNdT9' :
134
+ sim_type = 'PERIODIC'
135
+ fl = flares .flares (fname = './data/' ,sim_type = sim_type )
136
+ sim = fl .agn_directory
137
+
138
+ else :
139
+ ValueError ("Type of input simulation not recognized" )
101
140
141
+ if rank == 0 :
142
+ print (F"Sim location: { sim } , tag: { tag } " )
143
+
144
+ #Simulation properties
145
+ z = E .read_header ('SUBFIND' , sim , tag , 'Redshift' )
146
+ a = E .read_header ('SUBFIND' , sim , tag , 'ExpansionFactor' )
147
+
148
+ if inp == 'FLARES' :
149
+ ## Selecting the subhalos within our region
150
+
151
+ for halo in fl .halos :
152
+ print (halo )
153
+ fl .create_group (halo )
154
+ for tag in fl .tags :
155
+ cop = E .read_array ('SUBFIND' , halo , tag , '/Subhalo/CentreOfPotential' , noH = False , physicalUnits = False , numThreads = 4 ) #units of cMpc/h
156
+ cen , r , min_dist = fl .spherical_region (halo , tag ) #units of cMpc/h
157
+ indices = np .where (np .logical_and (mstar >= 10 ** 7. , np .sqrt (np .sum ((cop - cen )** 2 , axis = 1 ))<= fl .radius ) == True )[0 ]
158
+ fl .create_dataset (indices .astype (int ), 'Indices' , '%s/%s/Galaxy/' % (halo ,tag ), overwrite = True , verbose = verbose )
159
+
160
+ else :
161
+ indices = np .where (mstar >= 10 ** 7. )[0 ]
162
+
163
+ ## Galaxy global properties
164
+ properties = {'properties' : ['FOF/Group_M_Crit200' ,'FOF/Group_M_Crit500' ,'FOF/Group_M_Crit2500' ,
165
+ 'Subhalo/Mass' ,'/Subhalo/ApertureMeasurements/Mass/030kpc' ,'Subhalo/SubGroupNumber' ,
166
+ 'Subhalo/GroupNumber' ,'Subhalo/Velocity' ],
167
+ 'conv_factor' : [1e10 , 1e10 , 1e10 , 1e10 , 1e10 , 1 , 1 , 1 ],
168
+ 'arr_idx' : [None , None , None , None , 4 , None , None , None ],
169
+ 'save_str' : []
170
+ }
171
+
172
+ extract_subfind_info (properties )
173
+
174
+
175
+ # M200 = E.read_array('SUBFIND', sim, tag, 'FOF/Group_M_Crit200', numThreads=4, noH=True, physicalUnits=True)*1e10
176
+ # M500 = E.read_array('SUBFIND', sim, tag, '/FOF/Group_M_Crit500', numThreads=4, noH=True, physicalUnits=True)*1e10
177
+ # M2500 = E.read_array('SUBFIND', sim, tag, '/FOF/Group_M_Crit2500', numThreads=4, noH=True, physicalUnits=True)*1e10
178
+ # SubhaloMass = E.read_array('SUBFIND', sim, tag, '/Subhalo/Mass', numThreads=4, noH=True, physicalUnits=True)*1e10
179
+ # mstar = E.read_array('SUBFIND', sim, tag, '/Subhalo/ApertureMeasurements/Mass/030kpc', numThreads=4, noH=True, physicalUnits=True)[:,4]*1e10
180
+ # sgrpno = E.read_array('SUBFIND', sim, tag, '/Subhalo/SubGroupNumber', numThreads=4)
181
+ # grpno = E.read_array('SUBFIND', sim, tag, '/Subhalo/GroupNumber', numThreads=4)
182
+ # vel = E.read_array('SUBFIND', sim, tag, '/Subhalo/Velocity', noH=True, physicalUnits=True, numThreads=4)
183
+
184
+
185
+
186
+
187
+
188
+ cop = E .read_array ('SUBFIND' , sim , tag , '/Subhalo/CentreOfPotential' , noH = True , physicalUnits = True , numThreads = 4 )
189
+ sfr_inst = E .read_array ('SUBFIND' , sim , tag , '/Subhalo/ApertureMeasurements/SFR/030kpc' , numThreads = 4 , noH = True , physicalUnits = True )
190
+
191
+
192
+ return None
193
+
194
+
195
+ def extract_particle_array ():
196
+ """
197
+ Extract a particle array
198
+ """
199
+ return None
102
200
103
201
def extract_info (num , tag , kernel = 'sph-anarchy' , inp = 'FLARES' ):
104
202
"""
0 commit comments