I am trying to use the API to download stellar particles in subhalo cutouts of the MW/M31 sample. If I download the cutout to my laptop ("http://www.tng-project.org/api/TNG50-1/snapshots/99/subhalos/388544/cutout.hdf5") I get all the PartTypes and parameters correctly. If I try to use the API, I only get PartType1, even if I specify "stars":"all" in the parameters. Can you please help so I can use the API? My code is below.
Thanks,
Bridget
def get(path, params=None):
# make HTTP GET request to path
headers = {"api-key":"bc6386f16cf0549b68ef46fc58e44751"}
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
params = {'stars':'all'}
fname = get('http://www.tng-project.org/api/TNG50-1/snapshots/99/subhalos/388544/cutout.hdf5', params)
f = h5py.File(fname, 'r')
print(f.keys()) # outputs <KeysViewHDF5 ['Header', 'PartType1']>
Dylan Nelson
25 Jul '23
Note that you will find the cutouts for the MW/M31 sample on that page. These are special cutouts, with additional information which is not available in the normal snapshots. I would suggest them.
For the subhalo 388544, its corresponding cutout is available here:
Hello,
I am trying to use the API to download stellar particles in subhalo cutouts of the MW/M31 sample. If I download the cutout to my laptop ("http://www.tng-project.org/api/TNG50-1/snapshots/99/subhalos/388544/cutout.hdf5") I get all the PartTypes and parameters correctly. If I try to use the API, I only get PartType1, even if I specify "stars":"all" in the parameters. Can you please help so I can use the API? My code is below.
Thanks,
Bridget
Note that you will find the cutouts for the MW/M31 sample on that page. These are special cutouts, with additional information which is not available in the normal snapshots. I would suggest them.
For the subhalo 388544, its corresponding cutout is available here:
If you want to download general cutouts (of any subhalo), then the syntax you give above is correct. In particular, the link:
downloads (for me) a HDF5 file with only
PartType4
.