In [ ]:
import numpy as np
import util
import matplotlib
matplotlib.rcParams['savefig.dpi'] = 150
import matplotlib.pyplot as plt
import yt
import logging
logging.getLogger('yt').setLevel(logging.WARNING)
from yt.utilities.logger import ytLogger as mylog
print (yt.__version__)

In [ ]:
from particle_filters import *

def setup_part_file(ds):
    filename = os.path.join(ds.directory,ds.basename)
    ds._particle_handle = HDF5FileHandler(filename.replace('plt_cnt', 'part')+'_updated')
    ds.particle_filename = filename.replace('plt_cnt', 'part')+'_updated'
    mylog.info('Changed particle files to:' + ds.particle_filename)

fname = '/home/ychen/d9/FLASH4/2015_production_runs/0529_L45_M10_b1_h1/MHD_Jet_hdf5_plt_cnt_0010'
ds = yt.load(fname, particle_filename=fname.replace('plt_cnt', 'part'))

ptype = 'jetp'
ds.add_particle_filter(ptype)

#ad = ds.all_data()

In [ ]:
deposited_field = ds.add_deposited_particle_field((ptype, 'particle_dens'), \
                                                  method='nearest', extend_cells=16)

In [ ]:
print grid.LeftEdge
print ds.domain_left_edge
print np.maximum(grid.LeftEdge, ds.domain_left_edge)

In [ ]:
n = 2
grid = ds.index.grids[1000]
level = grid.Level
print 
LeftEdge = grid.LeftEdge - grid.dds*n
print LeftEdge
dims = grid.ActiveDimensions + np.array([n,n,n])*2
print dims

In [ ]:
plot = yt.SlicePlot(ds, 'x', deposited_field, center=(0,0,0), width=(4, 'kpc'))
#plot.zoom(64)
plot.annotate_clear()
plot.annotate_grids(linewidth=0.5, alpha=0.3, edgecolors='grey')
plot.set_cmap(deposited_field, 'algae')
plot.set_zlim(deposited_field, 1E-28, 1E-26)
plot.annotate_particles(width=(0.25, 'kpc'), ptype=ptype)
#ds.add_particle_filter('fast')
#plot.annotate_particles(width=(0.25, 'kpc'), ptype='fast', col='b')
plot.show()

In [ ]:
plot = yt.SlicePlot(ds, 'x', deposited_field, center=(0,0,0), width=(4, 'kpc'))
plot.annotate_clear()
plot.annotate_grids(linewidth=0.5, alpha=0.3, edgecolors='grey')
plot.set_cmap(deposited_field, 'algae')
plot.set_zlim(deposited_field, 1E-28, 1E-26)
plot.annotate_particles(width=(0.25, 'kpc'), ptype=ptype)
#ds.add_particle_filter('fast')
#plot.annotate_particles(width=(0.25, 'kpc'), ptype='fast', col='b')
plot.show()

In [ ]:
plot.annotate_clear()
plot.annotate_grids(linewidth=0.5, alpha=0.3, edgecolors='white')
plot.annotate_particles(width=(0.25, 'kpc'), ptype='lobe')
ds.add_particle_filter('fast')
plot.annotate_particles(width=(0.25, 'kpc'), ptype='fast', col='b')
plot.show()

In [ ]:
plot = yt.SlicePlot(ds, 'x', deposited_field, center=(0,0,0))
plot.zoom(16)
plot.annotate_clear()
plot.annotate_grids(linewidth=0.5, alpha=0.3, edgecolors='white')
plot.set_cmap(deposited_field, 'algae')
plot.set_zlim(deposited_field, 1E-28, 1E-26)
plot.set_log(deposited_field, True)

In [ ]:
plot.annotate_clear()
plot.annotate_grids(linewidth=0.5, alpha=0.3, edgecolors='white')
plot.annotate_particles(width=(0.25, 'kpc'), ptype='fast', )
plot.show()

In [ ]:
plot = yt.SlicePlot(ds, 'x', 'density', center=(0,0,0))
plot.zoom(64)
plot.annotate_clear()
plot.annotate_grids(linewidth=0.5, alpha=0.3, edgecolors='white')
plot.set_cmap('density', 'algae')
plot.set_zlim('density', 1E-28, 1E-26)
plot.show()

In [ ]:
deposited_field = ds.add_deposited_particle_field(('jetp', 'particle_dens'), \
                                                  method='cic',\
                                                 weight_field='particle_one')

In [ ]:
plot = yt.SlicePlot(ds, 'x', deposited_field, center=(0,0,0))
plot.zoom(16)
plot.annotate_clear()
plot.annotate_grids(linewidth=0.5, alpha=0.3, edgecolors='white')
plot.set_cmap(deposited_field, 'algae')
plot.set_zlim(deposited_field, 1E-28, 1E-26)
plot.set_log(deposited_field, True)
#plot.annotate_particles(width=(0.5, 'kpc'), ptype='jetp')
plot.show()

In [ ]:
g = ds.index.grids[5000].Parent.Parent

In [ ]:
from yt_synchrotron_emissivity import *
from yt.utilities.file_handler import HDF5FileHandler

filename = ds.particle_filename
ds._particle_handle = HDF5FileHandler(filename.replace('plt_cnt', 'part')+'_updated')
ds.particle_filename = filename.replace('plt_cnt', 'part')+'_updated'

print ds

In [ ]:
ds.field_list

In [ ]:
add_synchrotron_dtau_emissivity(ds, ptype='jetp', nu =(1400, 'MHz'), proj_axis='x')

In [ ]:
lobe = ds.known_filters['lobe']

In [ ]:
ds.derived_field_list

In [ ]:
g.RightEdge.in_units('kpc')

In [ ]: