Retrieve particles' refinement level

22 views
Skip to first unread message

Thor Tepper García

unread,
Jan 14, 2021, 9:39:50 PM1/14/21
to ramses_users
Hi guys,

Is there any tool around that can be used to retrieve the refinement level of particles (from a pure N-body run)? Are Pynbody or YT able to plot the (projected) refinement map, e.g. the maximum level along the sightline?

I noticed that, e.g. part2map.f90 actually skips over levels, and it wouldn't be hard to hack into the code and adapt it, but I thought I asked before I reinvent the wheel...

Cheers

Thor

Corentin CADIOU

unread,
Jan 15, 2021, 6:59:52 AM1/15/21
to ramses...@googlegroups.com

Hi Thor,

You can achieve this with yt:

import yt
# Load a sample dataset. You can load whatever dataset you want using yt.load instead
ds = yt.load_sample("output_00080", "info_00080.txt")
ad = ds.all_data()

# Required to define DM as the above dataset doesn't use the new particle family
@yt.particle_filter(name="DM")
def DM_filter(pfilter, data):
    return data['io', 'particle_identity'] > 0
ds.add_particle_filter("DM")

# Max ref. level of the cell containing each particle is given by
ad['DM', 'particle_refinement_level']

# Ref. level of the AMR grids is given by
ad['index', 'grid_level']   # NOTE: this is 0-indexed, i.e. the actual ref. level is levelmin + ad['index', 'grid_level']

# To make a l.o.s. plot
p = yt.ProjectionPlot(ds, 'x', ('index', 'grid_level'), method='mip')
p.set_log(('index', 'grid_level'), False)  # deactivate log as it goes from 0 to N
p.save("/tmp/")

# Alternatively you can also project the particle's ref. level onto the grid using
fname = ds.add_deposited_particle_field(('DM', 'particle_refinement_level'), method='nearest')
fname == ('deposit', 'DM_nn_refinement_level')

p = yt.ProjectionPlot(ds, 'x', ('deposit', 'DM_nn_refinement_level'), method='mip')
p.set_log(('deposit', 'DM_nn_refinement_level'), False)  # deactivate log as it goes from 0 to N
p.set_zlim(('deposit', 'DM_nn_refinement_level'), ds.parameters['levelmin'], ds.parameters['levelmax'])  # otherwise there will be "hole" in AMR cells with no DM particles

p.save("/tmp/")

I attached the two plots I obtain from this to the email, hope this helps!

Cheers,
Corentin

--
You received this message because you are subscribed to the Google Groups "ramses_users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ramses_users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ramses_users/1a3b95c0-ba6b-4919-8aa8-84d290568d11n%40googlegroups.com.
-- 
Dr. Corentin Cadiou
Post Doctoral Research Assistant
Cosmoparticle Initiative Hub, desk 27
University College London (UCL)
Gower St, Bloomsbury, London WC1E 6BT

mobile: +33.6.43.18.66.83
info_00080_Projection_x_DM_nn_refinement_level.png
info_00080_Projection_x_grid_level.png
OpenPGP_signature
Reply all
Reply to author
Forward
0 new messages