add loader for osyris
This commit is contained in:
55
src/galaxy_ninja/loaders/load_data_osyris.py
Normal file
55
src/galaxy_ninja/loaders/load_data_osyris.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# coding: utf-8
|
||||
|
||||
import numpy as np
|
||||
import osyris
|
||||
|
||||
|
||||
def load_fields_osyris(path="", snap_id=0, data=None):
|
||||
"""
|
||||
Returns
|
||||
-------
|
||||
dict
|
||||
A dataset of cells in the following format:
|
||||
gas:
|
||||
position (Ngas, 3) [kpc], centered
|
||||
volume (Ngas) [pc^3]
|
||||
velocity (Ngas, 3) [km/s]
|
||||
mass (Ngas) [Msun]
|
||||
stars:
|
||||
position (Nstar, 3) [kpc], centered
|
||||
velocity (Nstar, 3) [km/s]
|
||||
mass (Nstar) [Msun]
|
||||
birth_time (Nstar) [Myr]
|
||||
dm:
|
||||
position (Ngas, 3) [kpc], centered
|
||||
velocity (Ngas, 3) [km/s]
|
||||
mass (Ngas) [Msun]
|
||||
maps:
|
||||
extent (xmin, xmax, ymin, ymax) Coordinates of the edges of the map, centered
|
||||
gas_coldens (Nx, Ny) [Msun/pc^2], map of column density
|
||||
"""
|
||||
|
||||
if data is None:
|
||||
data = osyris.RamsesDataset(snap_id, path=path).load(select=["mesh", "part"])
|
||||
|
||||
|
||||
time = data.meta["time"].to("Myr").magnitude
|
||||
boxlen = data.meta["boxlen"] * data.units["x"].to("kpc")
|
||||
|
||||
gas = data["mesh"]
|
||||
center = osyris.Vector(x=500, y=500, z=500, unit="pc")
|
||||
|
||||
# Create dataset
|
||||
data = {
|
||||
"header": {"time": time,
|
||||
"fluids": ["gas"],
|
||||
"box_size": boxlen },
|
||||
"gas": {
|
||||
"position": (gas["position"] - center).to("kpc").values,
|
||||
"volume": (gas["dx"]**3).to("pc^3").values,
|
||||
"velocity": gas["velocity"].to("km/s").values,
|
||||
"mass": (gas["density"] * gas["dx"]**3).to("M_sun").values
|
||||
},
|
||||
}
|
||||
return data
|
||||
|
||||
Reference in New Issue
Block a user