Make gas density map with Python

16 views
Skip to first unread message

Thor Tepper García

unread,
Dec 7, 2020, 6:18:22 PM12/7/20
to ramses_users
Hi guys,

I was wondering whether somebody can provide a simple Python script to extract AMR data and plot, e.g the projected gas density of a snapshot (assuming it is possible)?

I'm aware that Ramses ships with a number of utils, among them some Python routines, but I have no clue about how to use them. I could not find any info about these on the Ramses wiki either.

I'm also aware of the existence of Pymses, which however requires Python2x and is thus outdated for my purposes. I also know about the existence of Pynbody, but when it comes to Ramses AMR data it does not seem to do a good job (or I'm using it wrong...)

Any help would be highly appreciated!

Thor.

Romain Teyssier

unread,
Dec 7, 2020, 6:24:48 PM12/7/20
to Thor Tepper García, ramses_users
You can try OSYRIS ?

Romain

Le 8 déc. 2020 à 00:18, Thor Tepper García <ttep...@gmail.com> a écrit :

Hi guys,
--
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/03c313d9-9d35-4432-b5c3-7f1769d4cd2en%40googlegroups.com.

Asger Gronnow

unread,
Dec 7, 2020, 6:49:28 PM12/7/20
to Romain Teyssier, Thorsten Tepper García, ramses_users
Hi Thor,
The yt package (yt-project.org) works great for this, and for analysing Ramses data in general. E.g. to make a projection plot of the initial density along the x axis:

import yt
ds = yt.load("output_00001/info_00001.txt")
sl = yt.ProjectionPlot(ds, "x", "density")
sl.save()


Cheers,
Asger

Tepper

unread,
Dec 7, 2020, 6:52:42 PM12/7/20
to Asger Gronnow, Romain Teyssier, ramses_users
Hi Asger,

I did try that, but it crashes at import, specifically at the internal:

import matplotlib._png as _png

Apparently, matplotlib 3.3+ got rid of the _png module in favour of Pillows.
YT (or at least the latest version I could get my hands on) has not addressed
this incompatibility yet...

Thanks for the hint anyways though

Cheers

Thor.

____________________________
Dr. Thorsten Tepper García
Astrophysicist
www.thorsten.mx
@thorsten_mx

Luke Conaboy

unread,
Dec 8, 2020, 3:44:02 AM12/8/20
to Tepper, Asger Gronnow, Romain Teyssier, ramses_users
Hi Thor,

I think they fixed this in the master branch (https://github.com/yt-project/yt/issues/2752). Have you tried installing directly from the git repository?

Thanks,
Luke

Thor Tepper-Garcia

unread,
Dec 8, 2020, 4:52:03 AM12/8/20
to Luke Conaboy, Asger Gronnow, Romain Teyssier, ramses_users
Hi Luke,

They actually did fix it. The issue in my case was that I was installing yt via MacPorts; their version is not yet up to date, apparently. But installing it via pip did the trick.

Cheers

Thor.

Corentin CADIOU

unread,
Dec 8, 2020, 4:57:10 AM12/8/20
to Tepper, Asger Gronnow, Romain Teyssier, ramses_users

Hi Thor,

This has now been fixed as of yt 3.6.1 (and later). You can install yt 3.6.1 using

    pip install yt==3.6.1

You can also try the new yt 4 version (not released yet), which is the current development branch (and so is fixed more often than the yt 3.x.x branch) with

    pip install git+https://github.com/yt-project/yt.git@master

Here is the link to the pull request modifying the code (https://github.com/yt-project/yt/pull/2754) and the one implementing it for yt 3.6.1 (https://github.com/yt-project/yt/pull/2800). I'd be happy to help should if you have more issues with yt!

Cheers,
Corentin

To view this discussion on the web visit https://groups.google.com/d/msgid/ramses_users/CEFB8561-AECD-4F3A-833C-29B620869D90%40gmail.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
OpenPGP_signature
Reply all
Reply to author
Forward
0 new messages