API tutorial Cookbook Task 2, different returns

Rui Zhou
  • 1
  • 16 Aug

I have problems when practicing the API tutor, specially, task 2 in API Cookbook.

I paste the code to my Jupyter notebook. The first several returns are correct. However, the last one is different.

Here's the Cookbook:

>>> # first convert log solar masses into group catalog units
>>> mass_min = 10**11.9 / 1e10 * 0.704
>>> mass_max = 10**12.1 / 1e10 * 0.704

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

>>> # form the url and make the request
>>> url = "http://www.tng-project.org/api/Illustris-1/snapshots/z=2/subhalos/" + search_query
>>> subhalos = get(url)
>>> subhalos['count']
550

>>> ids = [ subhalos['results'][i]['id'] for i in range(5) ]
>>> ids
[109974, 110822, 123175, 107743, 95711]

In terms of "ids", my result is [1, 1352, 5525, 6574, 12718]. Here is my code for reference:

mass_min = 10**11.9 / 1e10 * 0.704
mass_max = 10**12.1 / 1e10 * 0.704
search_query = "?mass__gt=" + str(mass_min) + "&mass__lt=" + str(mass_max)
url = "http://www.tng-project.org/api/Illustris-1/snapshots/z=2/subhalos/" + search_query
subhalos = get(url)
subhalos['count']
ids = [ subhalos['results'][i]['id'] for i in range(5) ]
ids

The return is:
[1, 1352, 5525, 6574, 12718]

I examined these subhalos. For example, the first one with ID = 1. Its mass is indeed within the expected range, so I believe my code is correct. However, I wonder if there have been any changes in how the IDs were compiled?

Dylan Nelson
  • 23 Aug

It seems just that the order of the ID list is different?

If you look further in your list, do you see also 109974, etc?

  • Page 1 of 1