SWIFTSIM / swiftsimio

Python library for reading SWIFT data. Uses unyt and h5py.
GNU Lesser General Public License v3.0
15 stars 12 forks source link

Read in the physical constants? #158

Closed MatthieuSchaller closed 1 year ago

MatthieuSchaller commented 1 year ago

We don't read in the physical constants as part of the meta-data. Should we?

JBorrow commented 1 year ago

Instead of using the built-in ones in unyt?

JBorrow commented 1 year ago

If you can let me know what use cases we have for this it will make it easier to evaluate this change.

MatthieuSchaller commented 1 year ago

@JegerBroxterman what was your case?

JegerBroxterman commented 1 year ago

It had to do with the neutrino corrections. I think in my case unyt also works but it is nice to directly read the constants in the internal units (for me G in Mpc/(1E10 Msun) km/s). Not sure if this is possible already with swiftsimio, I used h5py in the end.

JBorrow commented 1 year ago

You can just use unyt.G, this comes with the symbolic units attached. Is there a reason that this is not viable?

JegerBroxterman commented 1 year ago

It should work but you need to know the units you want to convert to. At first, I wasn't sure what the exact internal units of the simulation were.

JBorrow commented 1 year ago

Why do you need to know the units? The arrays themselves have symbolic units. So to calculate something like gravitational force I would just do unyt.G data.gas.masses[0] data.gas.masses[1] / np.sum(data.gas.coordinates[0] * data.gas.coordinates[1]).

JegerBroxterman commented 1 year ago

I didn't need the units in the end.

MatthieuSchaller commented 1 year ago

ah so we can close?

Using swiftsimio and unyt throughout is the recommended way to go.

JegerBroxterman commented 1 year ago

I think so, yes.