I was wondering if there is a simple way to access a specific halo ID's black hole info like BH_Mass. Coordinates. I tried to access a snapshot's black hole information through web API but I am getting an error using the following code retrieved from this TNG website. This code works fine if instead of 'black holes', I write 'stars' or 'gas'. I wonder why this is the case.
baseUrl = 'https://www.tng-project.org/api/'
headers = {"api-key":"MYKEY"}
def get(path, params=None):
headers = {"api-key":"MYKEY"}
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
base_url = 'https://www.tng-project.org/api/TNG300-1/'
sim_metadata = get(base_url)
params = {'black holes':'Coordinates, BH_Mass,BH_Mdot, ParticleIDs'}
for i in range(sim_metadata['num_files_snapshot']):
file_url = base_url + "files/snapshot-99." + str(i) + ".hdf5"
saved_filename = get(file_url, params)
print(saved_filename)
Dylan Nelson
11 Sep
On the API documentation under "Search and Cutout Requests" you find some important details for the query you are trying.
In particular, all you need to do is change "black holes" to "bhs", this is the recognized name for the particle type.
I was wondering if there is a simple way to access a specific halo ID's black hole info like BH_Mass. Coordinates. I tried to access a snapshot's black hole information through web API but I am getting an error using the following code retrieved from this TNG website. This code works fine if instead of 'black holes', I write 'stars' or 'gas'. I wonder why this is the case.
On the API documentation under "Search and Cutout Requests" you find some important details for the query you are trying.
In particular, all you need to do is change "black holes" to "bhs", this is the recognized name for the particle type.