STAR FORMATION RATE FOR RAMSES DATASET
Hi, I am trying to get a plot of Star formation rate in yt for RAMSES Data set and I am using the sample code given for Enzo instead
import yt import numpy as np from yt.data_objects.particle_filters import add_particle_filter from matplotlib import pyplot as plt def formed_star(pfilter, data): filter = data["io", "creation_time"] > 0 return filter add_particle_filter("formed_star", function=formed_star, filtered_type='io', requires=["creation_time"]) filename = "/Users/xxxxxx/Desktop/out/info_00014.txt" ds = yt.load(filename) ds.add_particle_filter('formed_star') ad = ds.all_data() masses = ad['formed_star', 'particle_mass'].in_units('Msun') formation_time = ad['formed_star', 'creation_time'].in_units('yr') time_range = [0, 5e9] # years n_bins = 1000 hist, bins = np.histogram(formation_time, bins=n_bins, range=time_range,) inds = np.digitize(formation_time, bins=bins)
time = (bins[:-1] + bins[1:])/2
sfr = np.array([masses[inds == j+1].sum()/(bins[j+1]-bins[j]) for j in range(len(time))]) sfr[sfr == 0] = np.nan plt.plot(time/1e6, sfr) plt.xlabel('Time [Myr]')
However, I am ending up with this error:
The fields
('io', 'creation_time'),
required by the "formed_star" particle filter, are not defined for this dataset.
Could anyone please suggest how I could access this "formed_star"/ an equivalent field for RAMSES. Thanks!
An update: I tried replacing creation time with particle_age and I still get the same error. On Mon, 5 Mar 2018 at 8:20 PM, Vadlamani Samhitha < vadlamani.samhitha@gmail.com> wrote:
Hi,
I am trying to get a plot of Star formation rate in yt for RAMSES Data set and I am using the sample code given for Enzo instead
import yt import numpy as np from yt.data_objects.particle_filters import add_particle_filter from matplotlib import pyplot as plt def formed_star(pfilter, data): filter = data["io", "creation_time"] > 0 return filter add_particle_filter("formed_star", function=formed_star, filtered_type='io', requires=["creation_time"]) filename = "/Users/xxxxxx/Desktop/out/info_00014.txt" ds = yt.load(filename) ds.add_particle_filter('formed_star') ad = ds.all_data() masses = ad['formed_star', 'particle_mass'].in_units('Msun') formation_time = ad['formed_star', 'creation_time'].in_units('yr') time_range = [0, 5e9] # years n_bins = 1000 hist, bins = np.histogram(formation_time, bins=n_bins, range=time_range,) inds = np.digitize(formation_time, bins=bins)
time = (bins[:-1] + bins[1:])/2
sfr = np.array([masses[inds == j+1].sum()/(bins[j+1]-bins[j]) for j in range(len(time))]) sfr[sfr == 0] = np.nan plt.plot(time/1e6, sfr) plt.xlabel('Time [Myr]')
However, I am ending up with this error:
The fields
('io', 'creation_time'),
required by the "formed_star" particle filter, are not defined for this dataset.
Could anyone please suggest how I could access this "formed_star"/ an equivalent field for RAMSES. Thanks!
participants (1)
-
Vadlamani Samhitha