From 2f40f984a44c393b72a62b36cf054171dabf169d Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Thu, 27 Oct 2016 12:13:07 +0800 Subject: extragalactic/pointsource (#3) Merge PR#3: Add new simulation component "extragalactic/pointsources", including SF, SB, RQ, FRI and FRII. * extragalactic/pointsource: add point source simulation module * extracgalactic/pointsource: add point source simulation module * Add configurating spec to extragalgactic point sources. * Modified some variables * base.py: modified * flux.py: modified * fr1.py: modified * fr2.py: modified * pointsources.py: modified * psparams.py: modified * radioquiet.py: modified * starforming.py: modified * starbursting.py: modified * Rewritten the comments. * base.py: modified * flux.py: modified * fr1.py: modified * fr2.py: modified * Modified * psparams.py: modified * radioquiet.py: modified * starforming.py: modified * starbursting.py: modified * Modified * Modified * Modified * Modified * Modified * MOdified * Modified * Modified * Modified * Modified * Modified * Modified * Modified * Modified * Modified * Changed pointsource to pointsources * Fixed some config keywords * Fixed some config keywords * Fixed some config keywords * Fixed some config keywords * Fixed some config keywords * Fixed some config keywords * Fixed some config keywords * base.py:rewrited * fr1.py:rewritten * pointsources.py: rewritten * radioquiet.py: rewritten * Rewritten * Rewritten * base.py: modified * fr1.py: modified * fr2.py: modified * radioquiet.py: modified * starbursting.py: modified * starforming.py: modified * Fix conflicts * fg21sim: fixed conflicts * base.py: modified frequencies loading in _get_configs() * Rewritten as forground.py * fg21sim: fixed conflicts * base.py: deteled loading for frequencies configurations. * fr1.py: modified * fr2.py: modified * pointsources.py: modified * radioquiet.py: modified * starbursting.py: modified * starforming.py: modified * Add new methods to calculate Tb. * Add new methods to calculate Tb. * Add new methods to calculate Tb. * Add new methods to calculate Tb. * Add new methods to calculate Tb. * Add new methods to calculate Tb. * Deleted useless comments. * Add pscomps to deal with multi-type PS problem. * Add a new key. * Fixed permission to 755. * Rejusted PS subsections. * Add methods to calcualte luminosity function and redshift distribution. * Rejusted generation of samples redshift and luminosity. * Fixed mistakes on FRII structure, added hotspots and offsets. * Reajusted generation of samples redshift and luminosity. * Readujsted generation of samples radii, redshifts and luminosity. * Readujsted generation of samples radii, redshifts and luminosity. * Fixed conflicts. * Fixed conficts. * Combined configurations of pointsources. * Removed the older extragalactic configuration file. * Fixed some mistakes. * Fixed mistakes of drawing PS. * Fixed mistakes of drawing PS. * Fixed code style by pep8 checking. * Fixed code style by pep8 checking. * Fixed code style by pep8 checking. * Fixed some coding style. * Reconfigured default redshift interval. * Reconfigured default redshift interval. * Reconfigured default redshift interval. * Fixed mistakes in method calc_single_Tb and changed resolution of grid. * Fixed mistakes in method calc_single_Tb and changed resolution of grid. * Deleted astropy.units style code to accelerate. * Deleted astropy.units style code to accelerate. * Deleted astropy.units style code to accelerate. * Deleted astropy.units style code to accelerate. * Deleted astropy.units style code to accelerate. * Deleted astropy.units style code to accelerate. * Deleted astropy.units style code to accelerate. * Fixed some mistakes. * Fixed some mistakes. * Changed dA from au.Mpc to float64. * Fixed some mistakes. * Fixed some mistakes. * Fixed some mistakes. * Reajusted grid resolution to generate discs. * Reajusted grid resolution to generate discs. * Reajusted loading strategy of parameter resolution. * Reajusted code style of configuration loading. * Reajusted code style of configuration loading. * Reajusted code style of configuration loading. * Reajusted code style of configuration loading. * Reajusted code style of configuration loading. --- fg21sim/extragalactic/pointsources/psparams.py | 77 ++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 fg21sim/extragalactic/pointsources/psparams.py (limited to 'fg21sim/extragalactic/pointsources/psparams.py') diff --git a/fg21sim/extragalactic/pointsources/psparams.py b/fg21sim/extragalactic/pointsources/psparams.py new file mode 100644 index 0000000..7c3a93a --- /dev/null +++ b/fg21sim/extragalactic/pointsources/psparams.py @@ -0,0 +1,77 @@ +# Copyright (c) 2016 Zhixian MA +# MIT license + +""" +Basic parameters to be used in point sources simulation. + +References +---------- +[1] Angular diameter distance, + https://en.wikipedia.org/wiki/Angular_diameter_distance +[2] FlatLambdaCDM, + {http://docs.astropy.org/en/stable/api/astropy.cosmology. + FlatLambdaCDM.html#astropy.cosmology.FlatLambdaCDM} +""" + +from astropy.cosmology import FlatLambdaCDM + + +class PixelParams(): + """ + A class to transform cosmology distance to angles or pixels. + Parameters + ------------ + H0: float + The hubble constant at z = 0, whose unit is km/s/Mpc + Om0: float + The total matter density. + ang_res: float + Angular resolution, i.e. degree per pixel. (May be useless) + ang_total: list + Total angles of the simulated sky region,whose unit is degree (\deg) + z : float + Redshift + scale: float + The real object scale. + Example + ------------ + >>> PixelParams = PixelParams(img_size=(1024,1024),ang_total=(5,5)) + """ + + # Hubble constant at z = 0 + H0 = 71.0 + # Omega0, total matter density + Om0 = 0.27 + # Redshift + z = 0.0 + # Cosmology calculator + cosmo = 0.0 + # angular diameter distance, [Mpc] + dA = 0.0 + # angular resolution + ang_res = 0.0 + + def __init__(self, z=0.0): + self.z = z + self.cosmo = FlatLambdaCDM(H0=self.H0, Om0=self.Om0) + + # angular diameter distance, [Mpc] + self.dA = self.cosmo.angular_diameter_distance(self.z).value + + def get_angle(self, scale=1.0): + """ + Input real object scale, and output the respect observed + angle, and pixels. + """ + ang = scale / self.dA # [rac] + + return ang + + def get_scale(self, ang=1.0): + """ + Input real observed scale, and output the respect + real object scale, and pixels. + """ + scale = ang * self.dA # [Mpc] + + return scale -- cgit v1.2.2