diff options
author | Aaron LI <aly@aaronly.me> | 2017-08-14 21:35:46 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-08-14 21:35:46 +0800 |
commit | 6f626998c7523f5948ce0e00acf4f2cb00f1bdc4 (patch) | |
tree | 92e69953f8530184f909e0af3b95913a819ec359 /fg21sim/extragalactic | |
parent | cc71b0bc70b5602dcdc9bdeffdfdc3632f92029f (diff) | |
download | fg21sim-6f626998c7523f5948ce0e00acf4f2cb00f1bdc4.tar.bz2 |
clusters/main.py: Use OrderedDict to easy keys manipulation
Also avoid forgetting to add the newly added item for DataFrame
conversion.
Signed-off-by: Aaron LI <aly@aaronly.me>
Diffstat (limited to 'fg21sim/extragalactic')
-rw-r--r-- | fg21sim/extragalactic/clusters/main.py | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py index b515d59..4990505 100644 --- a/fg21sim/extragalactic/clusters/main.py +++ b/fg21sim/extragalactic/clusters/main.py @@ -19,6 +19,7 @@ References import os import logging +from collections import OrderedDict import numpy as np import pandas as pd @@ -254,39 +255,39 @@ class GalaxyClusters: flux = halo.calc_flux(emissivity) Tb_mean = halo.calc_brightness_mean(emissivity, self.frequencies, pixelsize=self.sky.pixelsize) - data = { - "z0": halo.z_obs, - "M0": halo.M_obs, # [Msun] - "lon": row.lon, # [deg] longitude - "lat": row.lat, # [deg] longitude - "felong": row.felong, # Fraction of elongation - "rotation": row.rotation, # [deg] ellipse rotation angle - "z_merger": halo.z_merger, - "M_main": halo.M_main, # [Msun] - "M_sub": halo.M_sub, # [Msun] - "time_crossing": halo.time_crossing, # [Gyr] - "gamma": halo.gamma, # Lorentz factors - "radius": halo.radius, # [kpc] - "angular_radius": halo.angular_radius, # [arcsec] - "volume": halo.volume, # [kpc^3] - "B": halo.magnetic_field, # [uG] - "Ke": halo.injection_rate, # [cm^-3 Gyr^-1] - "n_e": n_e, # [cm^-3] - "frequency": self.frequencies, # [MHz] - "emissivity": emissivity, # [erg/s/cm^3/Hz] - "power": power, # [W/Hz] - "flux": flux, # [Jy] - "Tb_mean": Tb_mean, # [K] - } + data = OrderedDict([ + ("z0", halo.z_obs), + ("M0", halo.M_obs), # [Msun] + ("lon", row.lon), # [deg] longitude + ("lat", row.lat), # [deg] longitude + ("felong", row.felong), # Fraction of elongation + ("rotation", row.rotation), # [deg] ellipse rotation angle + ("z_merger", halo.z_merger), + ("M_main", halo.M_main), # [Msun] + ("M_sub", halo.M_sub), # [Msun] + ("time_crossing", halo.time_crossing), # [Gyr] + ("gamma", halo.gamma), # Lorentz factors + ("radius", halo.radius), # [kpc] + ("angular_radius", halo.angular_radius), # [arcsec] + ("volume", halo.volume), # [kpc^3] + ("B", halo.magnetic_field), # [uG] + ("Ke", halo.injection_rate), # [cm^-3 Gyr^-1] + ("n_e", n_e), # [cm^-3] + ("frequency", self.frequencies), # [MHz] + ("emissivity", emissivity), # [erg/s/cm^3/Hz] + ("power", power), # [W/Hz] + ("flux", flux), # [Jy] + ("Tb_mean", Tb_mean), # [K] + ]) self.halos.append(data) + logger.info("Simulated radio halos for merging cluster.") - # + logger.info("Converting halos data to be a Pandas DataFrame ...") + keys = list(self.halos[0].keys()) # Ignore the ``gamma`` and ``n_e`` items - keys = ["z0", "M0", "lon", "lat", "felong", "rotation", - "z_merger", "M_main", "M_sub", "time_crossing", - "radius", "angular_radius", "volume", "B", "frequency", - "emissivity", "power", "flux", "Tb_mean"] + for k in ["gamma", "n_e"]: + keys.remove(k) self.halos_df = dictlist_to_dataframe(self.halos, keys=keys) logger.info("Done halos data conversion.") @@ -390,6 +391,7 @@ class GalaxyClusters: Timg = Tmean * template # [K] sky.add(Timg, center=center) + logger.info("Done Simulate map at %.2f [MHz]." % freq) return sky def simulate(self): |