{"action":"created","comment":{"url":"https://api.github.com/repos/StingraySoftware/stingray/pulls/comments/69555128","id":69555128,"diff_hunk":"@@ -0,0 +1,212 @@\n+\"\"\"\n+Definition of :class:`EventList`.\n+\n+:class:`EventList` is used to handle photon arrival times.\n+\"\"\"\n+from __future__ import (absolute_import, unicode_literals, division,\n+                        print_function)\n+\n+from stingray.simulator.events import events_to_lc, lc_to_events, assign_energies\n+\n+from .lightcurve import Lightcurve\n+import stingray.io as io\n+import stingray.utils as utils\n+\n+import numpy as np\n+\n+\n+class EventList(object):\n+    def __init__(self, times, energies=None, mjdref=0, dt=0, notes=\"\", gti=None, pi=None,\n+                 pha=None):\n+        \"\"\"\n+        Make an event list object from an array of time stamps\n+\n+        Parameters\n+        ----------\n+        times: iterable\n+            A list or array of time stamps\n+\n+        Other Parameters\n+        ----------------\n+        dt: float\n+            The time resolution of the events. Only relevant when using events\n+            to produce light curves with similar bin time.\n+\n+        energies: iterable\n+            A list of array of photon energy values\n+\n+        mjdref : float\n+            The MJD used as a reference for the time array.\n+\n+        gtis: [[gti0_0, gti0_1], [gti1_0, gti1_1], ...]\n+            Good Time Intervals\n+\n+        pi : integer, numpy.ndarray\n+            PI channels\n+\n+        pha : float, numpy.ndarray\n+            Photon energies\n+\n+        Attributes\n+        ----------\n+        time: numpy.ndarray\n+            The array of event arrival times, in seconds from the reference\n+            MJD (self.mjdref)\n+\n+        energies: numpy.ndarray\n+            The array of photon energy values\n+\n+        ncounts: int\n+            The number of data points in the event list\n+\n+        dt: float\n+            The time resolution of the events. Only relevant when using events\n+            to produce light curves with similar bin time.\n+\n+        mjdref : float\n+            The MJD used as a reference for the time array.\n+\n+        gtis: [[gti0_0, gti0_1], [gti1_0, gti1_1], ...]\n+            Good Time Intervals\n+\n+        pi : integer, numpy.ndarray\n+            PI channels\n+\n+        pha : float, numpy.ndarray\n+            Photon energies\n+\n+        \"\"\"\n+        self.time = np.array(times, dtype=np.longdouble)\n+        self.energy = np.array(energies)\n+        self.ncounts = len(times)\n+        self.notes = notes\n+        self.dt = dt\n+        self.mjdref = mjdref\n+        self.gti = gti\n+        self.pi = pi\n+        self.pha = pha\n+\n+    @staticmethod\n+    def from_fits(fname, **kwargs):\n+        from .utils import _assign_value_if_none\n+        from .io import load_events_and_gtis\n+\n+        ret = load_events_and_gtis(fname, **kwargs)\n+\n+        times = ret.ev_list\n+        gti = ret.gtis\n+\n+        pi = _assign_value_if_none(ret.additional_data, \"PI\", None)\n+        pha = _assign_value_if_none(ret.additional_data, \"PHA\", None)\n+        dt = ret.dt\n+        mjdref = ret.mjdref\n+\n+        return EventList(times, gti=gti, pi=pi, pha=pha, dt=dt, mjdref=mjdref)\n+\n+    def to_lc(self, bin_time, start_time=None, stop_time=None, center_time=True):\n+        \"\"\"\n+        Convert event list to a light curve object.\n+\n+        Parameters\n+        ----------\n+        bin_time : float\n+            Binning time of the light curve\n+\n+        Other Parameters\n+        ----------------\n+        start_time : float\n+            Initial time of the light curve\n+        stop_time : float\n+            Stop time of the light curve\n+        center_time: bool\n+            If False, time is the start of the bin. Otherwise, the center\n+\n+        Returns\n+        -------\n+        lc: `Lightcurve` object\n+        \"\"\"\n+\n+        times, counts = events_to_lc(self.time, bin_time, start_time,\n+            stop_time, center_time)\n+\n+        return Lightcurve(times, counts)\n+\n+    def set_times(self, lc):\n+        \"\"\"\n+        Assign photon arrival times to event list.\n+","path":"stingray/events.py","position":137,"original_position":137,"commit_id":"5403c885515beead8efbcb0e7909738ba974c1ba","original_commit_id":"5403c885515beead8efbcb0e7909738ba974c1ba","user":{"login":"usmanwardag","id":8848723,"avatar_url":"https://avatars.githubusercontent.com/u/8848723?v=3","gravatar_id":"","url":"https://api.github.com/users/usmanwardag","html_url":"https://github.com/usmanwardag","followers_url":"https://api.github.com/users/usmanwardag/followers","following_url":"https://api.github.com/users/usmanwardag/following{/other_user}","gists_url":"https://api.github.com/users/usmanwardag/gists{/gist_id}","starred_url":"https://api.github.com/users/usmanwardag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/usmanwardag/subscriptions","organizations_url":"https://api.github.com/users/usmanwardag/orgs","repos_url":"https://api.github.com/users/usmanwardag/repos","events_url":"https://api.github.com/users/usmanwardag/events{/privacy}","received_events_url":"https://api.github.com/users/usmanwardag/received_events","type":"User","site_admin":false},"body":"Yes, currently we are randomising by using rejection sampling. I'll add its details briefly in function description.","created_at":"2016-07-05T12:39:24Z","updated_at":"2016-07-05T12:39:24Z","html_url":"https://github.com/StingraySoftware/stingray/pull/113#discussion_r69555128","pull_request_url":"https://api.github.com/repos/StingraySoftware/stingray/pulls/113","_links":{"self":{"href":"https://api.github.com/repos/StingraySoftware/stingray/pulls/comments/69555128"},"html":{"href":"https://github.com/StingraySoftware/stingray/pull/113#discussion_r69555128"},"pull_request":{"href":"https://api.github.com/repos/StingraySoftware/stingray/pulls/113"}}},"pull_request":{"url":"https://api.github.com/repos/StingraySoftware/stingray/pulls/113","id":76258456,"html_url":"https://github.com/StingraySoftware/stingray/pull/113","diff_url":"https://github.com/StingraySoftware/stingray/pull/113.diff","patch_url":"https://github.com/StingraySoftware/stingray/pull/113.patch","issue_url":"https://api.github.com/repos/StingraySoftware/stingray/issues/113","number":113,"state":"open","locked":false,"title":"EventList Class","user":{"login":"usmanwardag","id":8848723,"avatar_url":"https://avatars.githubusercontent.com/u/8848723?v=3","gravatar_id":"","url":"https://api.github.com/users/usmanwardag","html_url":"https://github.com/usmanwardag","followers_url":"https://api.github.com/users/usmanwardag/followers","following_url":"https://api.github.com/users/usmanwardag/following{/other_user}","gists_url":"https://api.github.com/users/usmanwardag/gists{/gist_id}","starred_url":"https://api.github.com/users/usmanwardag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/usmanwardag/subscriptions","organizations_url":"https://api.github.com/users/usmanwardag/orgs","repos_url":"https://api.github.com/users/usmanwardag/repos","events_url":"https://api.github.com/users/usmanwardag/events{/privacy}","received_events_url":"https://api.github.com/users/usmanwardag/received_events","type":"User","site_admin":false},"body":"Adds an EventList class with options to:\r\n\r\n1- Set photon arrival times given a light curve\r\n2- Assign energies given a spectrum\r\n3- Export/import in ascii, pickle and hdf5 formats.\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"35\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/stingraysoftware/stingray/113)\n<!-- Reviewable:end -->\n","created_at":"2016-07-05T11:30:31Z","updated_at":"2016-07-05T12:39:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"68410141080fe56756f84cafc2db793c1aaeb66a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/StingraySoftware/stingray/pulls/113/commits","review_comments_url":"https://api.github.com/repos/StingraySoftware/stingray/pulls/113/comments","review_comment_url":"https://api.github.com/repos/StingraySoftware/stingray/pulls/comments{/number}","comments_url":"https://api.github.com/repos/StingraySoftware/stingray/issues/113/comments","statuses_url":"https://api.github.com/repos/StingraySoftware/stingray/statuses/5403c885515beead8efbcb0e7909738ba974c1ba","head":{"label":"usmanwardag:eventlist","ref":"eventlist","sha":"5403c885515beead8efbcb0e7909738ba974c1ba","user":{"login":"usmanwardag","id":8848723,"avatar_url":"https://avatars.githubusercontent.com/u/8848723?v=3","gravatar_id":"","url":"https://api.github.com/users/usmanwardag","html_url":"https://github.com/usmanwardag","followers_url":"https://api.github.com/users/usmanwardag/followers","following_url":"https://api.github.com/users/usmanwardag/following{/other_user}","gists_url":"https://api.github.com/users/usmanwardag/gists{/gist_id}","starred_url":"https://api.github.com/users/usmanwardag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/usmanwardag/subscriptions","organizations_url":"https://api.github.com/users/usmanwardag/orgs","repos_url":"https://api.github.com/users/usmanwardag/repos","events_url":"https://api.github.com/users/usmanwardag/events{/privacy}","received_events_url":"https://api.github.com/users/usmanwardag/received_events","type":"User","site_admin":false},"repo":{"id":53238697,"name":"stingray","full_name":"usmanwardag/stingray","owner":{"login":"usmanwardag","id":8848723,"avatar_url":"https://avatars.githubusercontent.com/u/8848723?v=3","gravatar_id":"","url":"https://api.github.com/users/usmanwardag","html_url":"https://github.com/usmanwardag","followers_url":"https://api.github.com/users/usmanwardag/followers","following_url":"https://api.github.com/users/usmanwardag/following{/other_user}","gists_url":"https://api.github.com/users/usmanwardag/gists{/gist_id}","starred_url":"https://api.github.com/users/usmanwardag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/usmanwardag/subscriptions","organizations_url":"https://api.github.com/users/usmanwardag/orgs","repos_url":"https://api.github.com/users/usmanwardag/repos","events_url":"https://api.github.com/users/usmanwardag/events{/privacy}","received_events_url":"https://api.github.com/users/usmanwardag/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/usmanwardag/stingray","description":"Time Series Methods For Astronomical X-ray Data That Aren''t Fishy At All!","fork":true,"url":"https://api.github.com/repos/usmanwardag/stingray","forks_url":"https://api.github.com/repos/usmanwardag/stingray/forks","keys_url":"https://api.github.com/repos/usmanwardag/stingray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/usmanwardag/stingray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/usmanwardag/stingray/teams","hooks_url":"https://api.github.com/repos/usmanwardag/stingray/hooks","issue_events_url":"https://api.github.com/repos/usmanwardag/stingray/issues/events{/number}","events_url":"https://api.github.com/repos/usmanwardag/stingray/events","assignees_url":"https://api.github.com/repos/usmanwardag/stingray/assignees{/user}","branches_url":"https://api.github.com/repos/usmanwardag/stingray/branches{/branch}","tags_url":"https://api.github.com/repos/usmanwardag/stingray/tags","blobs_url":"https://api.github.com/repos/usmanwardag/stingray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/usmanwardag/stingray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/usmanwardag/stingray/git/refs{/sha}","trees_url":"https://api.github.com/repos/usmanwardag/stingray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/usmanwardag/stingray/statuses/{sha}","languages_url":"https://api.github.com/repos/usmanwardag/stingray/languages","stargazers_url":"https://api.github.com/repos/usmanwardag/stingray/stargazers","contributors_url":"https://api.github.com/repos/usmanwardag/stingray/contributors","subscribers_url":"https://api.github.com/repos/usmanwardag/stingray/subscribers","subscription_url":"https://api.github.com/repos/usmanwardag/stingray/subscription","commits_url":"https://api.github.com/repos/usmanwardag/stingray/commits{/sha}","git_commits_url":"https://api.github.com/repos/usmanwardag/stingray/git/commits{/sha}","comments_url":"https://api.github.com/repos/usmanwardag/stingray/comments{/number}","issue_comment_url":"https://api.github.com/repos/usmanwardag/stingray/issues/comments{/number}","contents_url":"https://api.github.com/repos/usmanwardag/stingray/contents/{+path}","compare_url":"https://api.github.com/repos/usmanwardag/stingray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/usmanwardag/stingray/merges","archive_url":"https://api.github.com/repos/usmanwardag/stingray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/usmanwardag/stingray/downloads","issues_url":"https://api.github.com/repos/usmanwardag/stingray/issues{/number}","pulls_url":"https://api.github.com/repos/usmanwardag/stingray/pulls{/number}","milestones_url":"https://api.github.com/repos/usmanwardag/stingray/milestones{/number}","notifications_url":"https://api.github.com/repos/usmanwardag/stingray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/usmanwardag/stingray/labels{/name}","releases_url":"https://api.github.com/repos/usmanwardag/stingray/releases{/id}","deployments_url":"https://api.github.com/repos/usmanwardag/stingray/deployments","created_at":"2016-03-06T05:05:14Z","updated_at":"2016-03-06T05:05:15Z","pushed_at":"2016-07-05T11:27:54Z","git_url":"git://github.com/usmanwardag/stingray.git","ssh_url":"git@github.com:usmanwardag/stingray.git","clone_url":"https://github.com/usmanwardag/stingray.git","svn_url":"https://github.com/usmanwardag/stingray","homepage":null,"size":1488,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"StingraySoftware:master","ref":"master","sha":"95a9680287d26a5bfdf3dfd48e7255b3774d5209","user":{"login":"StingraySoftware","id":17048750,"avatar_url":"https://avatars.githubusercontent.com/u/17048750?v=3","gravatar_id":"","url":"https://api.github.com/users/StingraySoftware","html_url":"https://github.com/StingraySoftware","followers_url":"https://api.github.com/users/StingraySoftware/followers","following_url":"https://api.github.com/users/StingraySoftware/following{/other_user}","gists_url":"https://api.github.com/users/StingraySoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/StingraySoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StingraySoftware/subscriptions","organizations_url":"https://api.github.com/users/StingraySoftware/orgs","repos_url":"https://api.github.com/users/StingraySoftware/repos","events_url":"https://api.github.com/users/StingraySoftware/events{/privacy}","received_events_url":"https://api.github.com/users/StingraySoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":43449839,"name":"stingray","full_name":"StingraySoftware/stingray","owner":{"login":"StingraySoftware","id":17048750,"avatar_url":"https://avatars.githubusercontent.com/u/17048750?v=3","gravatar_id":"","url":"https://api.github.com/users/StingraySoftware","html_url":"https://github.com/StingraySoftware","followers_url":"https://api.github.com/users/StingraySoftware/followers","following_url":"https://api.github.com/users/StingraySoftware/following{/other_user}","gists_url":"https://api.github.com/users/StingraySoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/StingraySoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StingraySoftware/subscriptions","organizations_url":"https://api.github.com/users/StingraySoftware/orgs","repos_url":"https://api.github.com/users/StingraySoftware/repos","events_url":"https://api.github.com/users/StingraySoftware/events{/privacy}","received_events_url":"https://api.github.com/users/StingraySoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/StingraySoftware/stingray","description":"Time Series Methods For Astronomical X-ray Data That Aren''t Fishy At All!","fork":false,"url":"https://api.github.com/repos/StingraySoftware/stingray","forks_url":"https://api.github.com/repos/StingraySoftware/stingray/forks","keys_url":"https://api.github.com/repos/StingraySoftware/stingray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StingraySoftware/stingray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StingraySoftware/stingray/teams","hooks_url":"https://api.github.com/repos/StingraySoftware/stingray/hooks","issue_events_url":"https://api.github.com/repos/StingraySoftware/stingray/issues/events{/number}","events_url":"https://api.github.com/repos/StingraySoftware/stingray/events","assignees_url":"https://api.github.com/repos/StingraySoftware/stingray/assignees{/user}","branches_url":"https://api.github.com/repos/StingraySoftware/stingray/branches{/branch}","tags_url":"https://api.github.com/repos/StingraySoftware/stingray/tags","blobs_url":"https://api.github.com/repos/StingraySoftware/stingray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StingraySoftware/stingray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StingraySoftware/stingray/git/refs{/sha}","trees_url":"https://api.github.com/repos/StingraySoftware/stingray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StingraySoftware/stingray/statuses/{sha}","languages_url":"https://api.github.com/repos/StingraySoftware/stingray/languages","stargazers_url":"https://api.github.com/repos/StingraySoftware/stingray/stargazers","contributors_url":"https://api.github.com/repos/StingraySoftware/stingray/contributors","subscribers_url":"https://api.github.com/repos/StingraySoftware/stingray/subscribers","subscription_url":"https://api.github.com/repos/StingraySoftware/stingray/subscription","commits_url":"https://api.github.com/repos/StingraySoftware/stingray/commits{/sha}","git_commits_url":"https://api.github.com/repos/StingraySoftware/stingray/git/commits{/sha}","comments_url":"https://api.github.com/repos/StingraySoftware/stingray/comments{/number}","issue_comment_url":"https://api.github.com/repos/StingraySoftware/stingray/issues/comments{/number}","contents_url":"https://api.github.com/repos/StingraySoftware/stingray/contents/{+path}","compare_url":"https://api.github.com/repos/StingraySoftware/stingray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StingraySoftware/stingray/merges","archive_url":"https://api.github.com/repos/StingraySoftware/stingray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StingraySoftware/stingray/downloads","issues_url":"https://api.github.com/repos/StingraySoftware/stingray/issues{/number}","pulls_url":"https://api.github.com/repos/StingraySoftware/stingray/pulls{/number}","milestones_url":"https://api.github.com/repos/StingraySoftware/stingray/milestones{/number}","notifications_url":"https://api.github.com/repos/StingraySoftware/stingray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StingraySoftware/stingray/labels{/name}","releases_url":"https://api.github.com/repos/StingraySoftware/stingray/releases{/id}","deployments_url":"https://api.github.com/repos/StingraySoftware/stingray/deployments","created_at":"2015-09-30T18:04:33Z","updated_at":"2016-06-07T13:11:09Z","pushed_at":"2016-07-05T12:15:48Z","git_url":"git://github.com/StingraySoftware/stingray.git","ssh_url":"git@github.com:StingraySoftware/stingray.git","clone_url":"https://github.com/StingraySoftware/stingray.git","svn_url":"https://github.com/StingraySoftware/stingray","homepage":null,"size":989,"stargazers_count":13,"watchers_count":13,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":32,"mirror_url":null,"open_issues_count":34,"forks":32,"open_issues":34,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/StingraySoftware/stingray/pulls/113"},"html":{"href":"https://github.com/StingraySoftware/stingray/pull/113"},"issue":{"href":"https://api.github.com/repos/StingraySoftware/stingray/issues/113"},"comments":{"href":"https://api.github.com/repos/StingraySoftware/stingray/issues/113/comments"},"review_comments":{"href":"https://api.github.com/repos/StingraySoftware/stingray/pulls/113/comments"},"review_comment":{"href":"https://api.github.com/repos/StingraySoftware/stingray/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/StingraySoftware/stingray/pulls/113/commits"},"statuses":{"href":"https://api.github.com/repos/StingraySoftware/stingray/statuses/5403c885515beead8efbcb0e7909738ba974c1ba"}}}}
{"actor":{"display_login":"usmanwardag"}}