Saving cutouts from TNG50-2 subhalos

Avinash Chaturvedi
  • 2
  • 30 Dec '21

Dear Dylan,

I am to save full cutouts from the few subhalos in a given mass range from the TNG50-2 subhalos. I am following the API cookbook to save the cutouts, however, I am getting errors like this : HTTPError: 404 Client Error: Not Found for url:

Here is what I am doing.

## Mass search ##
mass_min = 10**13.5/1e10*0.6774
mass_max = 10**14.5/1e10*0.6774
search_query = "?mass__gt=" + str(mass_min) + "&mass__lt=" + str(mass_max)  ## Making the mass search option ###

### printing the subhalos id ###
ids_tgn50 = [ subhalos['results'][i]['id'] for i in range(subhalos['count'])]
print (ids_tgn50)
[0, 10482, 16110, 19546, 24112, 31028, 33290]

### get function from AIP page ###

def get(path, params=None):
# make HTTP GET request to path
    headers = {"api-key":"my_key here"}
    r = requests.get(path, params=params, headers=headers)
    # raise exception if response code is not HTTP SUCCESS (200)

    if r.headers['content-type'] == 'application/json':
        return r.json() # parse json responses automatically

    if 'content-disposition' in r.headers:
        filename = r.headers['content-disposition'].split("filename=")[1]
        with open(filename, 'wb') as f:
        return filename # return the filename string

    return r

for id in ids_tgn50:
    url = ""+str(id)+"/cutout.hdf5"
    print (url)
    saved_filename = get(url)

Here it is not working. Could you please check it once? Thank you.


Dylan Nelson
  • 2 Jan '22

Potentially this is an issue that the cutouts you are requesting are simply extremely large.

Can you try to add a specific particle type/field you want (this is called a cutout_query in the API documentation).

e.g. if you add ?gas=Density to the end of your URL, to only request the gas cell densities, then this works for me.

Avinash Chaturvedi
  • 2 Jan '22

Dear Dylan,

Thanks for the response. Yes, it's working for me as well. :)
Thank you.


  • Page 1 of 1