Different float precision for the subhalo catalogue from API or hdf5 files
Yan Xiang Lai
16 Dec
Hi. I am trying to select spiral galaxies from the TNG50-1 simulation. I was testing my code by loading the data through the API first. Once I finished debugging, I downloaded the TNG catalogue to the local supercomputer and loaded the data directly from the HDF5 file. However, I discovered that data from the API is in float64 format, whereas the same data from the HDF5 file is in float32 format. Strangely, for gas and stellar particles, both API and the HDF5 files return the float32 precision. I have attached my code below. For galaxy_id = 8 (starts from 0), the outputs for "SubhaloPos", "SubhaloVel", and "SubhaloHalfmassRadStars" are [11914.14230883 36004.42869796 30827.13315619], [-913.312 435.268 270.353], 4.8027753173900205 for API, and [11914.136 36004.395 30827.182], [-913.3116 435.26785 270.35333], 4.8027377 for reading in the HDF5 file. The data from the API has higher float precision than that from the HDF5 file. I guess I should use the ones from the HDF5 file since the documentation states all data is saved with the float32 precision, but I am not quite sure what caused the difference here. The small offset between the API and HDF5 files can significantly impact the inclination calculation by more than 10 degrees using the formulae from sections III.C and III.D in this paper.
Code for loading in API data:
def get_api_data(self, endpoint, params=None):
"""
General method to get data from TNG API
Hi. I am trying to select spiral galaxies from the TNG50-1 simulation. I was testing my code by loading the data through the API first. Once I finished debugging, I downloaded the TNG catalogue to the local supercomputer and loaded the data directly from the HDF5 file. However, I discovered that data from the API is in float64 format, whereas the same data from the HDF5 file is in float32 format. Strangely, for gas and stellar particles, both API and the HDF5 files return the float32 precision. I have attached my code below. For galaxy_id = 8 (starts from 0), the outputs for "SubhaloPos", "SubhaloVel", and "SubhaloHalfmassRadStars" are [11914.14230883 36004.42869796 30827.13315619], [-913.312 435.268 270.353], 4.8027753173900205 for API, and [11914.136 36004.395 30827.182], [-913.3116 435.26785 270.35333], 4.8027377 for reading in the HDF5 file. The data from the API has higher float precision than that from the HDF5 file. I guess I should use the ones from the HDF5 file since the documentation states all data is saved with the float32 precision, but I am not quite sure what caused the difference here. The small offset between the API and HDF5 files can significantly impact the inclination calculation by more than 10 degrees using the formulae from sections III.C and III.D in this paper.
Code for loading in API data:
def get_api_data(self, endpoint, params=None):
"""
General method to get data from TNG API
Code for loading in HDF5 files: