Using API to search criteria for FOF halos rather than subhalos

Sophia Nasr
  • 2
  • 14 Nov '19

Hello,

I'm trying to modify the help files on using the API to search for group halos with a specified mass range instead of subhalos with specified mass range, as in the example. I'm not getting it to work successfully. Here's what I do:

mass_min = 10**12.9 / 1e10 * 0.6774
mass_max = 10**13.1 / 1e10 * 0.6774

# form the search_query string by hand for once
search_query = "?mass__gt=" + str(mass_min) + "&mass__lt=" + str(mass_max)
print(search_query)
# '?mass__gt=55.9207077246&mass__lt=88.6283489903'

# form the url and make the request
url = "http://www.tng-project.org/api/TNG100-1/snapshots/z=0.2/halos/" + search_query
halos = get(url)
print(halos['count'])

ids = [ halos['results'][i]['id'] for i in range(20) ]
print(ids)

At "print(halo['count'])", I get an error saying the object halo is not subscriptable, If I comment that out, "print(ids)" gives the same error. Can you help with what I'm doing wrong?? What I really want is a range on M200 for the group halos, then within one group that fits, to find subhalos that fit a specific mass range. I really think using the API would be more feasible so I'm not always downloading huge files, particularly since I want to look at the halo trees as well.

Thanks!

Dylan Nelson
  • 14 Nov '19

Hi Sophia,

Unfortunately it isn't possible to search over halos using the API, only subhalos.

I would suggest to download the group catalog for this field only: it's a small, ~25MB file:

https://www.tng-project.org/api/TNG100-1/files/groupcat-84/?Group=Group_M_Crit200

I'm assuming above that the mass you want to search over is the M200 spherical overdensity value.

You could also add in the GroupFirstSub field, so that you know the central subhalo of each halo after you select those of interest:

https://www.tng-project.org/api/TNG100-1/files/groupcat-84/?Group=Group_M_Crit200,GroupFirstSub
Sophia Nasr
  • 15 Nov '19

Thank you so much Dylan!! This is very helpful!

Sophia Nasr
  • 1
  • 15 Nov '19

Hi Dylan, I actually figured my previous question out so I am editing to instead ask, once I find a central subhalo in a mass range that I want, how can I search for subhalos within the same FOF group that central is in that have yet another specified mass range? Thank you again!

Dylan Nelson
  • 16 Nov '19

For a given group, all its subhalos can be located by combining GroupFirstSub and GroupNsubs.

Sophia Nasr
  • 1
  • 19 Nov '19

So, just to be clear, I'd need to modify the following search query:

search_query = "?mass__gt=" + str(mass_min) + "&mass__lt=" + str(mass_max)

I'm guessing I need to somehow include the group number so that it's searching for subhalos that are part of that particular group, but I do't really know how to do this... I know how to find the group ID (I use subhalo['grnr'] for the primary subhalo ID), but that's as far as I can go. Is this something you can help with??

Dylan Nelson
  • 19 Nov '19

Hi Sophia,

You can add &grnr=N as well. These and any other details you might need are available in the API reference.

Sophia Nasr
  • 19 Nov '19

Ah! Thank you very much Dylan. I couldn't figure it out in the API reference so I had to ask to make sure, but thank you!

Sophia Nasr
  • 10 Dec '19

Hi Dylan,

I'm having trouble figuring out the syntax, or if it is at all possible, to search for subhalos that are within a specific distance of the center of the group position (ie, say, subhalos within 100 kpc of 'GroupPos'). I know these are x, y, and z values, so even if I could do a query that's +/- 50 kpc along either direction would be fine. My issue was, how would I do this given that the GroupPos could have any value within the box, and I don't think I could set the range to, say, ?GroupPos[0]__gt + str( GroupPos[0] - 50) (for example) for x, and so on for y and z as well. Is this even possible to do, even if it's with the primary subhalo instead of the center of the group?? I hope that makes sense, and that it is possible. Otherwise my queries are just finding as many subhalos as possible (like a very large number, which takes extremely long), followed by finding subhalos within that distance.

Thanks again for your help!

Dylan Nelson
  • 10 Dec '19

Hi Sophia,

No I'm afraid there is no spatial searching available - if you want to do this, I would again suggest to just download the group catalog and use python (following the "Example Scripts" page).

Sophia Nasr
  • 10 Dec '19

Okay, I suppose it's not too bad to just get all subhalos that are part of a group, and then work from there. Thank you again!

  • Page 1 of 1