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: https://data-eu.tng-project.org/cutout/subhalo/L35n1080TNG/99/0/67108863.255.0.7.262143.16777215/?token=60d32c7227a3bfe83127.

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)
    r.raise_for_status()

    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:
            f.write(r.content)
        return filename # return the filename string

    return r

for id in ids_tgn50:
    url = "http://www.tng-project.org/api/TNG50-2/snapshots/99/subhalos/"+str(id)+"/cutout.hdf5"
    print (url)
    saved_filename = get(url)

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

Regards
Avinash

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.

Regards
Avinash

  • Page 1 of 1