[yt-users] halos

Irina Dvorkin irina at wise.tau.ac.il
Fri Mar 4 03:17:40 PST 2011


Hi All,

If I understood correctly, what Molly wants is to read the HopAnalysis  
file to get the halo information, since everything you know is in that  
file. But isn't it already implemented in _read_halo_list in  
HaloProfiler.py (from an older version of yt)?

I hope this helps, but maybe I just didn't understand the problem.

Irina

P.S.
For reference, here is a slightly modified form of this function that  
I'm using:

def read_halos(pf, filename='VHaloList.out', format={'id':0, 'mass':1,  
'npart':2, 'center':[7, 8, 9], 'velocity':[10, 11, 12], 'r_max':13}):
	""" Read a list of halos found earlier.
	A variation on _read_halo_list from HaloProfiler.py """

	def __isE(arg):
             parts = arg.lower().split('e')
             if len(parts) != 2: return False
             return not (True in [q.isalpha() for q in ''.join(parts)])

         def __get_num(arg):
             if __isE(arg):
                 return float(arg)
             if arg != arg.swapcase():
                 return arg
             return float(arg)

	mylog.info("Reading halo information from %s." % filename)

	haloList = []
         listLines = file(filename)
	fields = format.keys()
         getID = not 'id' in fields
         getR_max = not 'r_max' in fields

	for line in listLines:
             line = line.strip()
             if not(line.startswith('#')):
                 halo = {}
                 onLine = line.split()
                 for field in fields:
                     if isinstance(format[field], types.ListType):
                         halo[field] = [__get_num(onLine[q]) for q in  
format[field]]
                     else:
                         halo[field] = __get_num(onLine[format[field]])
                 halo['r_max'] *= pf.units['mpc']
                 haloList.append(halo)

         mylog.info("Loaded %d halos." % (len(haloList)))
         return haloList


Quoting "Matthew Turk" <matthewturk at gmail.com>:

> Hi Stephen,
>
> On Thu, Mar 3, 2011 at 7:49 PM, Stephen Skory <stephenskory at yahoo.com> wrote:
>> Molly,
>>
>> I can help you with the halos, but I'll leave the halo profiler for  
>> Britton who knows it better than I do.
>>
>>> First, I'm able to find halos and print information about them out to
>>> an, e.g., HopAnalysis.out file.  Is there a way to read this kind of
>>> information back in?  So far I have to re-run the halo finder every
>>> time I want to get new information, which is rather inefficient.  (The
>>> kludge of only looking for halos in a subvolume where I know there is
>>> one kind of works but isn't ideal.)
>>
>>
>> This is not currently possible. This is something that I've thought  
>> about, and should be possible, but I haven't done it because I  
>> haven't needed it. If there is enough interest in this, I can add  
>> it to my list of to-dos.
>
> This would unquestionably be extremely useful.  If you could implement
> a __reduce__ function that works, we should be able to pickle the
> halos; note that if you go the __reduce__ route, the particle data can
> be dumped to, for instance, HDF5 files.  If you were to just let
> Pickle handle it, the particle membership would just be pickled right
> along with it.
>
> -Matt
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>





More information about the yt-users mailing list