コード例 #1
0
def test_load_data():
    """
    Very basic test that either loads the data or makes sure that it exists,
    by creating it.
    """

    try:
        data = lt.read_data_from_file("lt_outputs.hdf5")
    except:
        sys.call([
            "python3", "analyse.py", "snapshot_ini.hdf5", "snapshot_end.hdf5",
            "caesar.hdf5"
        ])

        data = lt.read_data_from_file("lt_outputs.hdf5")

    return data
コード例 #2
0
#%%
# Our imports
from ltcaesar import read_data_from_file
from sphviewer.tools import QuickView
import numpy as np
import matplotlib.pyplot as plt
from pickle import load
from matplotlib.colors import LogNorm, Normalize

#%%
# Setup our favourite stylesheet
plt.style.use("mnras_flatiron")

#%%
directory = "s50j7kAHF"
data = read_data_from_file(f"{directory}/lt/lt_outputs.hdf5")

#%% [markdown]
# We want to find the largest halo in the box and make a picture of it.
# Thankfully that should be reasonably easy to find because we have
# stored everything in our 'FakeCaesar' object.

#%%
with open(f"{directory}/lt/halo_catalogue.pickle", "rb") as handle:
    halo_catalogue = load(handle)

#%%
centers = [x.center for x in halo_catalogue.halos]
r_virs = [x.rvir for x in halo_catalogue.halos]

#%%
コード例 #3
0
    """

    bin_edges = np.linspace(0, 1, 50)
    radial_bins = [[x, y] for x, y in zip(bin_edges[:-1], bin_edges[1:])]
    output, output_std = lt.analysis.radial.run_analysis_on_mass_bin(
        simulation, 1e12, 1e13, radial_bins, bin_func=mass_fraction_binned_by_feedback
    )

    bin_centers = [0.5 * (x + y) for x, y in zip(bin_edges[:-1], bin_edges[1:])]

    # Make the plot pretty
    bin_centers[0] = 0
    bin_centers[-1] = 1

    np.save("radial_distance_analysis_gas_fb.npy", output)
    np.save("radial_distance_analysis_gas_stderr_fb.npy", output_std)
    np.save("radial_distance_analysis_radial_bins_fb.npy", bin_centers)

    return


if __name__ == "__main__":
    import sys

    filename = sys.argv[1]
    print("Reading data from {}".format(filename))

    sim = lt.read_data_from_file(filename)

    run_analysis(simulation=sim)
コード例 #4
0
Makes a bunch of different plots based on distance metrics.

This is converted from a python notebook is is quite messy.
"""

import matplotlib

matplotlib.use("Agg")

import ltcaesar as lt

import matplotlib.pyplot as plt
import numpy as np


sim = lt.read_data_from_file("lt_outputs.hdf5")

dark_matter_data = lt.plot.find_distances_to_nearest_neighbours_data(sim, "dark_matter")
gas_data = lt.plot.find_distances_to_nearest_neighbours_data(sim, "gas")
star_data = lt.plot.find_distances_to_nearest_neighbours_data(sim, "stars")


# The first thing to look at is which particles have been launched by winds. To do that, we'll need some more data from the snapshot file.
#
# Note that wind launches are encoded as follows (using base 10):
#
# + SF kick, `+=1` to `NWindLaunches`
# + AGN kick, `+=1000` to `NWindLaunches`

import h5py