<commit_before>import jet as _jet
import environments.makino as _NFW
from astropy.convolution import convolve as _convolve
from astropy.convolution import Box2DKernel as _Box2DKernel
from contextlib2 import ExitStack as _ExitStack
from contextlib import contextmanager as _contextmanager
from helpers import suppress_stdout as _suppress_stdout
import pyPLUTO as _pp
import numpy as _np

def LoadSimulationData(ids, directory, suppress_output = None):
    data = []
    with _ExitStack() as stack:
        if suppress_output in [None, True]:
            stack.enter_context(_suppress_stdout())
        for i in ids:
            data.append(_pp.pload(i, w_dir=directory))
    return data

def load_timestep_data(timestep, directory, suppress_output = None):
    with _ExitStack() as stack:
        if suppress_output in [None, True]:
            stack.enter_context(_suppress_stdout())
            return _pp.pload(timestep, w_dir=directory)

def load_simulation_variables(ids, directory, var_list, suppress_output = None):
    data = {}
    for v in var_list:
        data[v] = []
    for i in ids:
        current_run_data = LoadSimulationData([i], directory, suppress_output)[0]
        for v in var_list:
            data[v].append(getattr(current_run_data, v))
    return data

def LoadSimulationTimes(run_directory, run_timesteps):
    times = []
    for i in run_timesteps:
        with _suppress_stdout():
            energy_data = _pp.pload(i, w_dir=run_directory)
        times.append(energy_data.SimTime)
    return times

def sphericaltocartesian(run_data):
    # generate the spherical polar grid
    R, Theta = _np.meshgrid(run_data.x1, run_data.x2)
    # rotate theta so that jet is pointing upwards - not necessarily needed
    Theta = Theta - _np.pi/2

    # convert spherical polar grid to cartesian<commit_msg>add rotation parameter to coordinate conversions<commit_after>import jet as _jet
import environments.makino as _NFW
from astropy.convolution import convolve as _convolve
from astropy.convolution import Box2DKernel as _Box2DKernel
from contextlib2 import ExitStack as _ExitStack
from contextlib import contextmanager as _contextmanager
from helpers import suppress_stdout as _suppress_stdout
import pyPLUTO as _pp
import numpy as _np

def LoadSimulationData(ids, directory, suppress_output = None):
    data = []
    with _ExitStack() as stack:
        if suppress_output in [None, True]:
            stack.enter_context(_suppress_stdout())
        for i in ids:
            data.append(_pp.pload(i, w_dir=directory))
    return data

def load_timestep_data(timestep, directory, suppress_output = None):
    with _ExitStack() as stack:
        if suppress_output in [None, True]:
            stack.enter_context(_suppress_stdout())
            return _pp.pload(timestep, w_dir=directory)

def load_simulation_variables(ids, directory, var_list, suppress_output = None):
    data = {}
    for v in var_list:
        data[v] = []
    for i in ids:
        current_run_data = LoadSimulationData([i], directory, suppress_output)[0]
        for v in var_list:
            data[v].append(getattr(current_run_data, v))
    return data

def LoadSimulationTimes(run_directory, run_timesteps):
    times = []
    for i in run_timesteps:
        with _suppress_stdout():
            energy_data = _pp.pload(i, w_dir=run_directory)
        times.append(energy_data.SimTime)
    return times

def sphericaltocartesian(run_data, rotation=None):

    # default rotation is pi / 2 
    # (results in jet pointing up for certain simulations)
    if rotation is None:
        rotation = _np.pi / 2
    # generate the spherical polar grid
    R, Theta = _np.meshgrid(run_data.x1, run_data.x2)
    # rotate theta so that jet is pointing upwards - not necessarily needed
    Theta = Theta - rotation

    # convert spherical polar grid to cartesian
{'fraction_non_alphanumeric': 0.07189203218271477, 'fraction_numerical': 0.003893070334804049, 'mean_word_length': 3.434982738780207, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3340726', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1131, 'n_words': 351}