<commit_before>import galaxy_analysis as ga
from galaxy_analysis.static_data\
     import IMAGE_COLORBAR_LIMITS as cbar_lim

from galaxy_analysis.static_data\
     import PLOT_LIMITS as plim

from galaxy_analysis.static_data\
     import FIELD_UNITS as field_units

from galaxy_analysis.static_data\
     import LABELS as axis_label

import yt
import glob
import os
import numpy as np
import sys

from joblib import Parallel, delayed
import multiprocessing

#
# move to yt field defines
# 
def main_sequence(pfilter,data):
    filter = data[(pfilter.filtered_type, "particle_type")] == 11
    return filter

yt.add_particle_filter("main_sequence", function=main_sequence, filtered_type="all", requires=["particle_type"])


def phase_plots(ds, to_plot = 'all', region = None):

    # construct a list of phase diagrams here. List contains list of tuples, where each
    # list is the following set of 4 items:  [ x-axis field, y-axis field, cbar field, weight_field ]
    #
    pp_def    = { 'T_n' :  [ ('gas','number_density'), ('enzo','Temperature'), ('gas','cell_mass'), None],
                  'P_T' :  [ ('enzo','Temperature'), ('gas','pressure'), ('gas', 'cell_mass'), None],
                  'Go_n' : [ ('gas','number_density'), ('gas','G_o'), ('gas','cell_mass'), None],
                  'Go_r' : [ ('index','magnitude_cylindrical_radius'), ('gas','G_o'), ('gas','cell_mass'), None]
                 }

    pdict = {}
    if to_plot == 'all':
        for n in ['T_n','P_T','Go_n']:
            pdict[n] = pp_def[n]

    if region is None:
        region = ds.all_data()

    for name in pdict:
        pdef = pdict[name]

        pp = yt.PhasePlot( region, pdef[0], pdef[1], pdef[2],
                           weight_field = pdef[3])

        if pdef[0] == ('gas','magnitude_cylindrical_radius'):
            pp.set_log('magnitude_cylindrical_radius', False)

        # set units on each axis
        for f in pdef[0:2]:
            pp.set_unit(f[1], field_units[f].units)

        # set plot limits for horizonatal and vertical axes
        if not plim[pdef[0]] is None:
            pp.set_xlim(plim[pdef[0]][0], plim[pdef[0]][1])
        if not plim[pdef[1]] is None:
            pp.set_ylim(plim[pdef[1]][0], plim[pdef[1]][1])

        # set color map limits
        if not cbar_lim[pdef[2]] is None:
            pp.set_zlim( pdef[2], cbar_lim[pdef[2]][0], cbar_lim[pdef[2]][1])
        pp.set_cmap( pdef[2], 'cubehelix')

        pp.save('./phase_plots/')

        del(pp)


    return

def projection_plots(ds, fields, axis=['x','z'], has_particles = None):<commit_msg>added phase plots and fixed axis labelling and zlim<commit_after>import galaxy_analysis as ga
from galaxy_analysis.static_data\
     import IMAGE_COLORBAR_LIMITS as cbar_lim

from galaxy_analysis.static_data\
     import PLOT_LIMITS as plim

from galaxy_analysis.static_data\
     import FIELD_UNITS as field_units

from galaxy_analysis.static_data\
     import LABELS as axis_label

import yt
import glob
import os
import numpy as np
import sys

from joblib import Parallel, delayed
import multiprocessing

#
# move to yt field defines
# 
def main_sequence(pfilter,data):
    filter = data[(pfilter.filtered_type, "particle_type")] == 11
    return filter

yt.add_particle_filter("main_sequence", function=main_sequence, filtered_type="all", requires=["particle_type"])


def phase_plots(ds, to_plot = 'all', region = None):

    # construct a list of phase diagrams here. List contains list of tuples, where each
    # list is the following set of 4 items:  [ x-axis field, y-axis field, cbar field, weight_field ]
    #
    pp_def    = { 'T_n' :  [ ('gas','number_density'), ('enzo','Temperature'), ('gas','cell_mass'), None],
                  'T_n_Fe' :  [ ('gas','number_density'), ('enzo','Temperature'), ('gas','Fe_Mass'), None],
                  'T_n_O'  :  [ ('gas','number_density'), ('enzo','Temperature'), ('gas','O_Mass'), None],
                  'T_n_C'  :  [ ('gas','number_density'), ('enzo','Temperature'), ('gas','C_Mass'), None],
                  'P_T' :  [ ('enzo','Temperature'), ('gas','pressure'), ('gas', 'cell_mass'), None],
                  'Go_n' : [ ('gas','number_density'), ('gas','G_o'), ('gas','cell_mass'), None],
                  'Go_r' : [ ('index','magnitude_cylindrical_radius'), ('gas','G_o'), ('gas','cell_mass'), None]
                 }

    pdict = {}
    if to_plot == 'all':
        for n in ['T_n_Fe','T_n_O','T_n','P_T','Go_n','T_n_C']:
            pdict[n] = pp_def[n]

    if region is None:
        region = ds.all_data()

    print cbar_lim

    for name in pdict:
        pdef = pdict[name]

        pp = yt.PhasePlot( region, pdef[0], pdef[1], pdef[2],
                           weight_field = pdef[3])

        if pdef[0] == ('gas','magnitude_cylindrical_radius'):
            pp.set_log('magnitude_cylindrical_radius', False)

        # set units on each axis
        for f in pdef[:3]:
            pp.set_unit(f[1], field_units[f].units)

        # set plot limits for horizonatal and vertical axes
        if not plim[pdef[0]] is None:
            pp.set_xlim(plim[pdef[0]][0], plim[pdef[0]][1])
        if not plim[pdef[1]] is None:
            pp.set_ylim(plim[pdef[1]][0], plim[pdef[1]][1])

        # set color map limits
        print cbar_lim[pdef[2]], pdef[2]
        if not (cbar_lim[pdef[2]] is None):
            pp.set_zlim( pdef[2], cbar_lim[pdef[2]][0], cbar_lim[pdef[2]][1])

        pp.set_cmap( pdef[2], 'cubehelix')

        pp.save('./phase_plots/')

        del(pp)


    return

def projection_plots(ds, fields, axis=['x','z'], has_particles = None):
{'fraction_non_alphanumeric': 0.15236739053043788, 'fraction_numerical': 0.010145959416162335, 'mean_word_length': 2.94039270687237, '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': '635550', 'n_tokens_mistral': 1998, 'n_tokens_neox': 1912, 'n_words': 455}