import yt12# Load the dataset.3ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")45# You can create a derived field by manipulating any existing derived fields6# in any way you choose. In this case, let's just make a simple one:7# thermal_energy_density = 3/2 nkT8910# First create a function which yields your new derived field11def thermal_energy_dens(field, data):12return (3 / 2) * data["gas", "number_density"] * data["gas", "kT"]131415# Then add it to your dataset and define the units16ds.add_field(17("gas", "thermal_energy_density"),18units="erg/cm**3",19function=thermal_energy_dens,20sampling_type="cell",21)2223# It will now show up in your derived_field_list24for i in sorted(ds.derived_field_list):25print(i)2627# Let's use it to make a projection28ad = ds.all_data()29yt.ProjectionPlot(30ds,31"x",32("gas", "thermal_energy_density"),33weight_field=("gas", "density"),34width=(200, "kpc"),35).save()363738