{"action":"created","comment":{"url":"https://api.github.com/repos/liweitianux/fg21sim/pulls/comments/83170355","pull_request_review_id":4023637,"id":83170355,"diff_hunk":"@@ -0,0 +1,362 @@\n+# Copyright (c) 2016 Zhixian MA <zxma_sjtu@qq.com>\n+# MIT license\n+\n+import os\n+import numpy as np\n+import pandas as pd\n+\n+import astropy.units as au\n+import healpy as hp\n+\n+from .flux import Flux\n+from .starforming import StarForming\n+from .starbursting import StarBursting\n+from .radioquiet import RadioQuiet\n+from .fr1 import FRI\n+from .fr2 import FRII\n+\n+class PointSources:\n+    \"\"\"\n+    This class namely pointsource is designed to generate PS catelogues,\n+    read csv format PS lists, calculate the flux and surface brightness\n+    of the sources at different frequencies, and then ouput hpmaps\n+\n+    functions\n+    ---------\n+    read_csv\n+        read the csv format files, judge the PS type and\n+        transformed to be iterable numpy.ndarray.\n+\n+    calc_flux\n+        calculate the flux and surface brightness of the PS.\n+\n+    draw_elp\n+        processing on the elliptical and circular core or lobes.\n+\n+    draw_cir\n+        processing on the circular star forming or bursting galaxies\n+\n+    draw_ps\n+        generate hpmap with respect the imput PS catelogue\n+\"\"\"\n+\n+    def __init__(self, configs):\n+        self.configs = configs\n+        self._get_configs()\n+        self.files = []\n+\n+    def _get_configs(self):\n+        \"\"\"Load configs and set the attributes\"\"\"\n+        # nside of the healpix cell\n+        self.nside = self.configs.getn(\"common/nside\")\n+        # frequencies\n+        self.freq = self.configs.getn(\"frequency/frequencies\")\n+        # save flag\n+        self.save = self.configs.getn(\"extragalactic/pointsource/save\")\n+\n+    def gen_catelogue(self):\n+        \"\"\"Generate the catelogues\"\"\"\n+        # Init\n+        sf = StarForming(self.configs)\n+        sb = StarBursting(self.configs)\n+        rq = RadioQuiet(self.configs)\n+        fr1 = FRI(self.configs)\n+        fr2 = FRII(self.configs)\n+\n+        # Save\n+        if self.save:\n+            self.files.append(sf.save_as_csv()[1])\n+            self.files.append(sb.save_as_csv()[1])\n+            self.files.append(rq.save_as_csv()[1])\n+            self.files.append(fr1.save_as_csv()[1])\n+            self.files.append(fr2.save_as_csv()[1])\n+\n+    def read_csv(self,filepath):\n+        \"\"\"\n+        Read csv format point source files,judge its class\n+        type according to its name.\n+        For example, 'PS_Num_YYYYMMDD_HHMMSS.csv'\n+        Split it by '_'\n+\n+        Parameters\n+        ----------\n+        filepath: str\n+            Name of the file.\n+        \"\"\"\n+        # Split to folder name and file name\n+        filename = os.path.basename(filepath)\n+        # Split and judge point source type\n+        class_list = ['SF', 'SB', 'RQ', 'FRI', 'FRII']\n+        class_name = filename.split('.')[0]\n+        class_type = class_list.index(class_name) + 1\n+        # Read csv\n+        ps_data = pd.read_csv(filepath)\n+\n+        return class_type, ps_data\n+\n+\n+    def calc_flux(self,class_type, freq, ps_data):\n+        \"\"\"\n+        Calculate the flux and surface brightness of the point source.\n+\n+        Parameters\n+        ----------\n+        class_type: int\n+            Type of point source\n+        freq: float\n+            frequency\n+        ps_data: pandas.core.frame.DataFrame\n+            Data of the point sources\n+        \"\"\"\n+        # init flux\n+        ps_flux = Flux(freq, class_type)\n+        # ps_flux_list\n+        num_ps = ps_data.shape[0]\n+        if class_type <= 3:\n+            ps_flux_list = np.zeros((num_ps,))\n+            # Iteratively calculate flux\n+            for i in range(num_ps):\n+                ps_area = ps_data['Area (sr)'][i]\n+                ps_flux_list[i] = ps_flux.calc_Tb(ps_area)\n+        else:\n+            ps_flux_list = np.zeros((num_ps, 2))\n+            # Iteratively calculate flux\n+            for i in range(num_ps):\n+                ps_area = ps_data['Area (sr)'][i]\n+                ps_flux_list[i, :] = ps_flux.calc_Tb(ps_area)[0:2]\n+\n+        return ps_flux_list\n+\n+    def draw_rq(self, ps_data, freq):\n+        \"\"\"\n+        Designed to draw the radio quiet AGN\n+\n+        Parameters\n+        ----------\n+        ImgMat: np.ndarray\n+            Two dimensional matrix, to describe the image\n+        ps_data: pandas.core.frame.DataFrame\n+            Data of the point sources\n+        freq: float\n+            frequency\n+        \"\"\"\n+        # Init\n+        npix = hp.nside2npix(self.nside)\n+        hpmap = np.zeros((npix,))\n+        # Gen flux list\n+        ps_flux_list = self.calc_flux(3, freq, ps_data)\n+        # Angle to pix\n+        theta = ps_data['Theta (deg)'] / 180 * np.pi\n+        phi = ps_data['Phi (deg)'] / 180 * np.pi\n+        pix = hp.ang2pix(self.nside, theta, phi)\n+        # Gen hpmap\n+        hpmap[pix] += ps_flux_list\n+\n+        return hpmap\n+\n+    def draw_cir(self, ps_data, class_type, freq):","path":"fg21sim/extragalactic/pointsources/pointsources.py","position":157,"original_position":157,"commit_id":"c68c8810ce46d56d56ef4e56f719921c79ca54ae","original_commit_id":"c68c8810ce46d56d56ef4e56f719921c79ca54ae","user":{"login":"liweitianux","id":686169,"avatar_url":"https://avatars.githubusercontent.com/u/686169?v=3","gravatar_id":"","url":"https://api.github.com/users/liweitianux","html_url":"https://github.com/liweitianux","followers_url":"https://api.github.com/users/liweitianux/followers","following_url":"https://api.github.com/users/liweitianux/following{/other_user}","gists_url":"https://api.github.com/users/liweitianux/gists{/gist_id}","starred_url":"https://api.github.com/users/liweitianux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liweitianux/subscriptions","organizations_url":"https://api.github.com/users/liweitianux/orgs","repos_url":"https://api.github.com/users/liweitianux/repos","events_url":"https://api.github.com/users/liweitianux/events{/privacy}","received_events_url":"https://api.github.com/users/liweitianux/received_events","type":"User","site_admin":false},"body":"Change function name to ``draw_circle``.","created_at":"2016-10-13T08:55:36Z","updated_at":"2016-10-13T09:01:51Z","html_url":"https://github.com/liweitianux/fg21sim/pull/3#discussion_r83170355","pull_request_url":"https://api.github.com/repos/liweitianux/fg21sim/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/liweitianux/fg21sim/pulls/comments/83170355"},"html":{"href":"https://github.com/liweitianux/fg21sim/pull/3#discussion_r83170355"},"pull_request":{"href":"https://api.github.com/repos/liweitianux/fg21sim/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/liweitianux/fg21sim/pulls/3","id":88763676,"html_url":"https://github.com/liweitianux/fg21sim/pull/3","diff_url":"https://github.com/liweitianux/fg21sim/pull/3.diff","patch_url":"https://github.com/liweitianux/fg21sim/pull/3.patch","issue_url":"https://api.github.com/repos/liweitianux/fg21sim/issues/3","number":3,"state":"open","locked":false,"title":"extragalactic/pointsource","user":{"login":"myinxd","id":11346940,"avatar_url":"https://avatars.githubusercontent.com/u/11346940?v=3","gravatar_id":"","url":"https://api.github.com/users/myinxd","html_url":"https://github.com/myinxd","followers_url":"https://api.github.com/users/myinxd/followers","following_url":"https://api.github.com/users/myinxd/following{/other_user}","gists_url":"https://api.github.com/users/myinxd/gists{/gist_id}","starred_url":"https://api.github.com/users/myinxd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myinxd/subscriptions","organizations_url":"https://api.github.com/users/myinxd/orgs","repos_url":"https://api.github.com/users/myinxd/repos","events_url":"https://api.github.com/users/myinxd/events{/privacy}","received_events_url":"https://api.github.com/users/myinxd/received_events","type":"User","site_admin":false},"body":"The module to simulate point sources, including SF, SB, RQ, FRI and FRII. ","created_at":"2016-10-11T02:58:14Z","updated_at":"2016-10-13T09:01:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c6de188d2aec58c7862a32fd21bb72066f73e3c8","assignee":{"login":"myinxd","id":11346940,"avatar_url":"https://avatars.githubusercontent.com/u/11346940?v=3","gravatar_id":"","url":"https://api.github.com/users/myinxd","html_url":"https://github.com/myinxd","followers_url":"https://api.github.com/users/myinxd/followers","following_url":"https://api.github.com/users/myinxd/following{/other_user}","gists_url":"https://api.github.com/users/myinxd/gists{/gist_id}","starred_url":"https://api.github.com/users/myinxd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myinxd/subscriptions","organizations_url":"https://api.github.com/users/myinxd/orgs","repos_url":"https://api.github.com/users/myinxd/repos","events_url":"https://api.github.com/users/myinxd/events{/privacy}","received_events_url":"https://api.github.com/users/myinxd/received_events","type":"User","site_admin":false},"assignees":[{"login":"myinxd","id":11346940,"avatar_url":"https://avatars.githubusercontent.com/u/11346940?v=3","gravatar_id":"","url":"https://api.github.com/users/myinxd","html_url":"https://github.com/myinxd","followers_url":"https://api.github.com/users/myinxd/followers","following_url":"https://api.github.com/users/myinxd/following{/other_user}","gists_url":"https://api.github.com/users/myinxd/gists{/gist_id}","starred_url":"https://api.github.com/users/myinxd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myinxd/subscriptions","organizations_url":"https://api.github.com/users/myinxd/orgs","repos_url":"https://api.github.com/users/myinxd/repos","events_url":"https://api.github.com/users/myinxd/events{/privacy}","received_events_url":"https://api.github.com/users/myinxd/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/liweitianux/fg21sim/pulls/3/commits","review_comments_url":"https://api.github.com/repos/liweitianux/fg21sim/pulls/3/comments","review_comment_url":"https://api.github.com/repos/liweitianux/fg21sim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/liweitianux/fg21sim/issues/3/comments","statuses_url":"https://api.github.com/repos/liweitianux/fg21sim/statuses/c68c8810ce46d56d56ef4e56f719921c79ca54ae","head":{"label":"myinxd:ps","ref":"ps","sha":"c68c8810ce46d56d56ef4e56f719921c79ca54ae","user":{"login":"myinxd","id":11346940,"avatar_url":"https://avatars.githubusercontent.com/u/11346940?v=3","gravatar_id":"","url":"https://api.github.com/users/myinxd","html_url":"https://github.com/myinxd","followers_url":"https://api.github.com/users/myinxd/followers","following_url":"https://api.github.com/users/myinxd/following{/other_user}","gists_url":"https://api.github.com/users/myinxd/gists{/gist_id}","starred_url":"https://api.github.com/users/myinxd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myinxd/subscriptions","organizations_url":"https://api.github.com/users/myinxd/orgs","repos_url":"https://api.github.com/users/myinxd/repos","events_url":"https://api.github.com/users/myinxd/events{/privacy}","received_events_url":"https://api.github.com/users/myinxd/received_events","type":"User","site_admin":false},"repo":{"id":67777950,"name":"fg21sim","full_name":"myinxd/fg21sim","owner":{"login":"myinxd","id":11346940,"avatar_url":"https://avatars.githubusercontent.com/u/11346940?v=3","gravatar_id":"","url":"https://api.github.com/users/myinxd","html_url":"https://github.com/myinxd","followers_url":"https://api.github.com/users/myinxd/followers","following_url":"https://api.github.com/users/myinxd/following{/other_user}","gists_url":"https://api.github.com/users/myinxd/gists{/gist_id}","starred_url":"https://api.github.com/users/myinxd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myinxd/subscriptions","organizations_url":"https://api.github.com/users/myinxd/orgs","repos_url":"https://api.github.com/users/myinxd/repos","events_url":"https://api.github.com/users/myinxd/events{/privacy}","received_events_url":"https://api.github.com/users/myinxd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/myinxd/fg21sim","description":"WIP","fork":true,"url":"https://api.github.com/repos/myinxd/fg21sim","forks_url":"https://api.github.com/repos/myinxd/fg21sim/forks","keys_url":"https://api.github.com/repos/myinxd/fg21sim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/myinxd/fg21sim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/myinxd/fg21sim/teams","hooks_url":"https://api.github.com/repos/myinxd/fg21sim/hooks","issue_events_url":"https://api.github.com/repos/myinxd/fg21sim/issues/events{/number}","events_url":"https://api.github.com/repos/myinxd/fg21sim/events","assignees_url":"https://api.github.com/repos/myinxd/fg21sim/assignees{/user}","branches_url":"https://api.github.com/repos/myinxd/fg21sim/branches{/branch}","tags_url":"https://api.github.com/repos/myinxd/fg21sim/tags","blobs_url":"https://api.github.com/repos/myinxd/fg21sim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/myinxd/fg21sim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/myinxd/fg21sim/git/refs{/sha}","trees_url":"https://api.github.com/repos/myinxd/fg21sim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/myinxd/fg21sim/statuses/{sha}","languages_url":"https://api.github.com/repos/myinxd/fg21sim/languages","stargazers_url":"https://api.github.com/repos/myinxd/fg21sim/stargazers","contributors_url":"https://api.github.com/repos/myinxd/fg21sim/contributors","subscribers_url":"https://api.github.com/repos/myinxd/fg21sim/subscribers","subscription_url":"https://api.github.com/repos/myinxd/fg21sim/subscription","commits_url":"https://api.github.com/repos/myinxd/fg21sim/commits{/sha}","git_commits_url":"https://api.github.com/repos/myinxd/fg21sim/git/commits{/sha}","comments_url":"https://api.github.com/repos/myinxd/fg21sim/comments{/number}","issue_comment_url":"https://api.github.com/repos/myinxd/fg21sim/issues/comments{/number}","contents_url":"https://api.github.com/repos/myinxd/fg21sim/contents/{+path}","compare_url":"https://api.github.com/repos/myinxd/fg21sim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/myinxd/fg21sim/merges","archive_url":"https://api.github.com/repos/myinxd/fg21sim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/myinxd/fg21sim/downloads","issues_url":"https://api.github.com/repos/myinxd/fg21sim/issues{/number}","pulls_url":"https://api.github.com/repos/myinxd/fg21sim/pulls{/number}","milestones_url":"https://api.github.com/repos/myinxd/fg21sim/milestones{/number}","notifications_url":"https://api.github.com/repos/myinxd/fg21sim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/myinxd/fg21sim/labels{/name}","releases_url":"https://api.github.com/repos/myinxd/fg21sim/releases{/id}","deployments_url":"https://api.github.com/repos/myinxd/fg21sim/deployments","created_at":"2016-09-09T07:45:35Z","updated_at":"2016-09-28T14:12:00Z","pushed_at":"2016-10-13T05:52:58Z","git_url":"git://github.com/myinxd/fg21sim.git","ssh_url":"git@github.com:myinxd/fg21sim.git","clone_url":"https://github.com/myinxd/fg21sim.git","svn_url":"https://github.com/myinxd/fg21sim","homepage":null,"size":124,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"liweitianux:master","ref":"master","sha":"a8ed62510538b02dd415e484cf9019d9a2549839","user":{"login":"liweitianux","id":686169,"avatar_url":"https://avatars.githubusercontent.com/u/686169?v=3","gravatar_id":"","url":"https://api.github.com/users/liweitianux","html_url":"https://github.com/liweitianux","followers_url":"https://api.github.com/users/liweitianux/followers","following_url":"https://api.github.com/users/liweitianux/following{/other_user}","gists_url":"https://api.github.com/users/liweitianux/gists{/gist_id}","starred_url":"https://api.github.com/users/liweitianux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liweitianux/subscriptions","organizations_url":"https://api.github.com/users/liweitianux/orgs","repos_url":"https://api.github.com/users/liweitianux/repos","events_url":"https://api.github.com/users/liweitianux/events{/privacy}","received_events_url":"https://api.github.com/users/liweitianux/received_events","type":"User","site_admin":false},"repo":{"id":67766504,"name":"fg21sim","full_name":"liweitianux/fg21sim","owner":{"login":"liweitianux","id":686169,"avatar_url":"https://avatars.githubusercontent.com/u/686169?v=3","gravatar_id":"","url":"https://api.github.com/users/liweitianux","html_url":"https://github.com/liweitianux","followers_url":"https://api.github.com/users/liweitianux/followers","following_url":"https://api.github.com/users/liweitianux/following{/other_user}","gists_url":"https://api.github.com/users/liweitianux/gists{/gist_id}","starred_url":"https://api.github.com/users/liweitianux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liweitianux/subscriptions","organizations_url":"https://api.github.com/users/liweitianux/orgs","repos_url":"https://api.github.com/users/liweitianux/repos","events_url":"https://api.github.com/users/liweitianux/events{/privacy}","received_events_url":"https://api.github.com/users/liweitianux/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/liweitianux/fg21sim","description":"WIP","fork":false,"url":"https://api.github.com/repos/liweitianux/fg21sim","forks_url":"https://api.github.com/repos/liweitianux/fg21sim/forks","keys_url":"https://api.github.com/repos/liweitianux/fg21sim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liweitianux/fg21sim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liweitianux/fg21sim/teams","hooks_url":"https://api.github.com/repos/liweitianux/fg21sim/hooks","issue_events_url":"https://api.github.com/repos/liweitianux/fg21sim/issues/events{/number}","events_url":"https://api.github.com/repos/liweitianux/fg21sim/events","assignees_url":"https://api.github.com/repos/liweitianux/fg21sim/assignees{/user}","branches_url":"https://api.github.com/repos/liweitianux/fg21sim/branches{/branch}","tags_url":"https://api.github.com/repos/liweitianux/fg21sim/tags","blobs_url":"https://api.github.com/repos/liweitianux/fg21sim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liweitianux/fg21sim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liweitianux/fg21sim/git/refs{/sha}","trees_url":"https://api.github.com/repos/liweitianux/fg21sim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liweitianux/fg21sim/statuses/{sha}","languages_url":"https://api.github.com/repos/liweitianux/fg21sim/languages","stargazers_url":"https://api.github.com/repos/liweitianux/fg21sim/stargazers","contributors_url":"https://api.github.com/repos/liweitianux/fg21sim/contributors","subscribers_url":"https://api.github.com/repos/liweitianux/fg21sim/subscribers","subscription_url":"https://api.github.com/repos/liweitianux/fg21sim/subscription","commits_url":"https://api.github.com/repos/liweitianux/fg21sim/commits{/sha}","git_commits_url":"https://api.github.com/repos/liweitianux/fg21sim/git/commits{/sha}","comments_url":"https://api.github.com/repos/liweitianux/fg21sim/comments{/number}","issue_comment_url":"https://api.github.com/repos/liweitianux/fg21sim/issues/comments{/number}","contents_url":"https://api.github.com/repos/liweitianux/fg21sim/contents/{+path}","compare_url":"https://api.github.com/repos/liweitianux/fg21sim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liweitianux/fg21sim/merges","archive_url":"https://api.github.com/repos/liweitianux/fg21sim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liweitianux/fg21sim/downloads","issues_url":"https://api.github.com/repos/liweitianux/fg21sim/issues{/number}","pulls_url":"https://api.github.com/repos/liweitianux/fg21sim/pulls{/number}","milestones_url":"https://api.github.com/repos/liweitianux/fg21sim/milestones{/number}","notifications_url":"https://api.github.com/repos/liweitianux/fg21sim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liweitianux/fg21sim/labels{/name}","releases_url":"https://api.github.com/repos/liweitianux/fg21sim/releases{/id}","deployments_url":"https://api.github.com/repos/liweitianux/fg21sim/deployments","created_at":"2016-09-09T04:46:37Z","updated_at":"2016-09-20T09:29:09Z","pushed_at":"2016-10-13T05:52:59Z","git_url":"git://github.com/liweitianux/fg21sim.git","ssh_url":"git@github.com:liweitianux/fg21sim.git","clone_url":"https://github.com/liweitianux/fg21sim.git","svn_url":"https://github.com/liweitianux/fg21sim","homepage":null,"size":99,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/liweitianux/fg21sim/pulls/3"},"html":{"href":"https://github.com/liweitianux/fg21sim/pull/3"},"issue":{"href":"https://api.github.com/repos/liweitianux/fg21sim/issues/3"},"comments":{"href":"https://api.github.com/repos/liweitianux/fg21sim/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/liweitianux/fg21sim/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/liweitianux/fg21sim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/liweitianux/fg21sim/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/liweitianux/fg21sim/statuses/c68c8810ce46d56d56ef4e56f719921c79ca54ae"}}}}
{"actor":{"display_login":"liweitianux"}}