From 02d987ee97ac93001360a104fe263bee1fea7222 Mon Sep 17 00:00:00 2001 From: Noe Brucy Date: Wed, 8 May 2019 13:15:00 +0200 Subject: [PATCH] Cleaning --- disk_postprocess.py | 76 +++++++++------------------------------------ pipeline_disk.py | 6 ++-- 2 files changed, 17 insertions(+), 65 deletions(-) diff --git a/disk_postprocess.py b/disk_postprocess.py index 96fe87f..52dfa41 100644 --- a/disk_postprocess.py +++ b/disk_postprocess.py @@ -132,8 +132,15 @@ def make_image_aux( G = 1.0 # Gravitational constant + # Plotting parameters ntick = 6 title_ax = {"x": "x (code)", "y": "y (code)", "z": "z (code)"} + im_extent = [ + (-radius + center[0]) * lbox_units, + (radius + center[0]) * lbox_units, + (-radius + center[1]) * lbox_units, + (radius + center[1]) * lbox_units, + ] time = ro.info["time"] # time in codeunits title = "t=" + str(time)[0:5] + " (code)" @@ -161,8 +168,6 @@ def make_image_aux( ax_nb = {"x": 0, "y": 1, "z": 2} - image_names = ["coldens", "rho", "T"] - for i, ax_los in enumerate(axes_los): ax_h = axes_h[i] ax_v = axes_v[i] @@ -200,12 +205,7 @@ def make_image_aux( cont = P.contour( map_level, - extent=[ - (-radius + center[0]) * lbox_units, - (radius + center[0]) * lbox_units, - (-radius + center[1]) * lbox_units, - (radius + center[1]) * lbox_units, - ], + extent=im_extent, origin="lower", colors="k", linewidths=lw, @@ -226,16 +226,7 @@ def make_image_aux( dmap_col = datamap.map.T * lbox map_col = np.log10(dmap_col) - im = P.imshow( - map_col, - extent=[ - (-radius + center[0]) * lbox_units, - (radius + center[0]) * lbox_units, - (-radius + center[1]) * lbox_units, - (radius + center[1]) * lbox_units, - ], - origin="lower", - ) + im = P.imshow(map_col, extent=im_extent, origin="lower") P.locator_params(axis=ax_h, nbins=ntick) P.locator_params(axis=ax_v, nbins=ntick) @@ -279,16 +270,7 @@ def make_image_aux( map_vv_red = dmap_vv.map[::vel_red, ::vel_red] map_vv_red = map_vv_red.T - im = P.imshow( - map_rho, - extent=[ - (-radius + center[0]) * lbox_units, - (radius + center[0]) * lbox_units, - (-radius + center[1]) * lbox_units, - (radius + center[1]) * lbox_units, - ], - origin="lower", - ) + im = P.imshow(map_rho, extent=im_extent, origin="lower") P.locator_params(axis=ax_h, nbins=ntick) P.locator_params(axis=ax_v, nbins=ntick) nh = map_vh_red.shape[0] @@ -333,16 +315,7 @@ def make_image_aux( dmap_T = dmap_P.map.T / dmap_rho.map.T map_T = np.log10(dmap_T) - im = P.imshow( - map_T, - extent=[ - (-radius + center[0]) * lbox_units, - (radius + center[0]) * lbox_units, - (-radius + center[1]) * lbox_units, - (radius + center[1]) * lbox_units, - ], - origin="lower", - ) + im = P.imshow(map_T, extent=im_extent, origin="lower") P.locator_params(axis="x", nbins=ntick) P.locator_params(axis="y", nbins=ntick) @@ -403,15 +376,7 @@ def make_image_aux( map_Q = dmap_Q im = P.imshow( - map_Q, - extent=[ - (-radius + center[0]) * lbox_units, - (radius + center[0]) * lbox_units, - (-radius + center[1]) * lbox_units, - (radius + center[1]) * lbox_units, - ], - origin="lower", - norm=mpl.colors.LogNorm(), + map_Q, extent=im_extent, origin="lower", norm=mpl.colors.LogNorm() ) P.locator_params(axis="x", nbins=ntick) @@ -441,16 +406,7 @@ def make_image_aux( datamap = rt_cpu.process(cam, surf_qty=True) map_cpu = datamap.map.T - im = P.imshow( - map_cpu, - extent=[ - (-radius + center[0]) * lbox_units, - (radius + center[0]) * lbox_units, - (-radius + center[1]) * lbox_units, - (radius + center[1]) * lbox_units, - ], - origin="lower", - ) + im = P.imshow(map_cpu, extent=im_extent, origin="lower") P.locator_params(axis="x", nbins=ntick) P.locator_params(axis="y", nbins=ntick) @@ -670,9 +626,7 @@ def disk_prop( # Histogramm : density fluctuaction distribution function drho = np.log(rho_disk[mask_bin] / rho_rad[i]) hist, hist_edges = P.histogram( - drho, - bins=nb_bin_hist, - weights=dvol_disk[mask_bin] * 2.0 ** (3 * ro.info["levelmax"]), + drho, bins=nb_bin_hist, weights=dvol_disk[mask_bin] ) hist_drho = hist_drho + hist @@ -874,7 +828,7 @@ def plot_disk_prop(path, num, force=False, tag="", interactive=False): # Density fluctuation histogram P.grid() P.xlabel(r"$\log(\frac{\rho}{\bar{\rho}})$") - P.ylabel(r"# of cells") + P.ylabel(r"fraction of total volume") P.title(title) hist = prop_disk["hist_drho"] egdes = prop_disk["hist_edges"] diff --git a/pipeline_disk.py b/pipeline_disk.py index 737e8a5..7a2affc 100644 --- a/pipeline_disk.py +++ b/pipeline_disk.py @@ -1,11 +1,10 @@ # coding: utf-8 -import sys -import numpy as np -import pymses + import os from shutil import copy import argparse import time +import numpy as np import disk_postprocess as dp @@ -99,7 +98,6 @@ dp.out_ext = "." + args.format dp.P.rcParams["image.cmap"] = args.colormap dp.P.rcParams["savefig.dpi"] = args.dpi - for run in runs: path_suffix = project + "/" + run path_in = storage_in + path_suffix