Compare commits

..

2 Commits

Author SHA1 Message Date
Noe Brucy
a7284a6f99 add loader for osyris 2025-03-21 14:13:06 +01:00
Noe Brucy
55d09c691c solve a bug whith binning 2025-03-21 14:12:49 +01:00
2 changed files with 57 additions and 2 deletions

View File

@@ -565,8 +565,8 @@ class Galsec(GalsecAnalysis):
if binning_mode == "delta":
delta = bins[name]
elif binning_mode == "number":
bin_min = filter_bounds[name][0].value
bin_max = filter_bounds[name][1].value
bin_min = filter_bounds[name][0]
bin_max = filter_bounds[name][1]
delta = (bin_max - bin_min) / bins[name]
if delta is not None:

View 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