{"action":"created","comment":{"url":"https://api.github.com/repos/lsst/sims_catUtils/pulls/comments/42194372","id":42194372,"diff_hunk":"@@ -620,3 +621,133 @@ def get_lsst_magnitudes(self):\n \n         return self._magnitudeGetter(self.lsstBandpassDict, self.get_lsst_magnitudes._colnames, indices=indices)\n \n+\n+class PhotometrySSM(PhotometryBase):\n+    \"\"\"\n+    A mixin to calculate photometry for solar system objects.\n+    \"\"\"\n+    # Because solar system objects will not have dust extinctions, we should be able to read in every\n+    # SED exactly once, calculate the colors and magnitudes, and then get actual magnitudes by adding\n+    # an offset based on magNorm.\n+\n+    def _magnitudeGetter(self, bandpassDict, bandpassTag='lsst'):\n+        \"\"\"\n+        Method that actually does the work calculating magnitudes for solar system objects.\n+\n+        Because solar system objects have no dust extinction, this method works by loading\n+        each unique Sed once, normalizing it, calculating its magnitudes in the desired\n+        bandpasses, and then storing the normalizing magnitudes and the bandpass magnitudes\n+        in a dict.  Magnitudes for subsequent objects with identical Seds will be calculated\n+        by adding an offset to the magnitudes.  The offset is determined by comparing normalizing\n+        magnitues.\n+\n+        @param [in] bandpassDict is an intantiation of BandpassDict representing the bandpasses\n+        to be integrated over\n+\n+        @param [in] bandpassTag (optional) is a string indicating the name of the bandpass system\n+        (i.e. 'lsst', 'sdss', etc.).  This is in case the user wants to calculate the magnitudes\n+        in multiple systems simultaneously.  In that case, the dict will store magnitudes for each\n+        Sed in each magnitude system separately.\n+\n+        @param [out] a numpy array of magnitudes corresponding to bandpassDict.\n+        \"\"\"\n+\n+        if not hasattr(self, '_ssmMagDict'):\n+            self._ssmMagDict = {}\n+            self._ssmMagNormDict = {}\n+            self._file_dir = getPackageDir('sims_sed_library')\n+            self._spec_map = defaultSpecMap\n+            self._normalizing_bandpass = Bandpass()\n+            self._normalizing_bandpass.imsimBandpass()\n+\n+        sedNameList = self.column_by_name('sedFilename')\n+        magNormList = self.column_by_name('magNorm')\n+\n+        if len(sedNameList)==0:\n+            # need to return something when InstanceCatalog goes through\n+            # it's \"dry run\" to determine what columns are required from\n+            # the database\n+            return numpy.zeros((len(bandpassDict.keys()),0))\n+\n+        magListOut = []\n+\n+        for sedName, magNorm in zip(sedNameList, magNormList):\n+            magTag = bandpassTag+'_'+sedName\n+            if sedName not in self._ssmMagNormDict or magTag not in self._ssmMagDict:\n+                dummySed = Sed()\n+                dummySed.readSED_flambda(os.path.join(self._file_dir, self._spec_map[sedName]))\n+                fnorm = dummySed.calcFluxNorm(magNorm, self._normalizing_bandpass)\n+                dummySed.multiplyFluxNorm(fnorm)\n+                magList = bandpassDict.magListForSed(dummySed)\n+                self._ssmMagDict[magTag] = magList\n+                self._ssmMagNormDict[sedName] = magNorm\n+            else:\n+                dmag = magNorm - self._ssmMagNormDict[sedName]\n+                magList = self._ssmMagDict[magTag] + dmag\n+            magListOut.append(magList)\n+\n+        return numpy.array(magListOut).transpose()\n+\n+\n+    @compound('lsst_u','lsst_g','lsst_r','lsst_i','lsst_z','lsst_y')\n+    def get_lsst_magnitudes(self):\n+        \"\"\"\n+        getter for LSST magnitudes of solar system objects\n+        \"\"\"\n+\n+        if not hasattr(self, 'lsstBandpassDict'):\n+            self.lsstBandpassDict = BandpassDict.loadTotalBandpassesFromFiles()\n+\n+        return self._magnitudeGetter(self.lsstBandpassDict)\n+\n+\n+    @compound('dmagTrailing', 'dmagDetection')\n+    def get_ssm_dmag(self):\n+        \"\"\"\n+        This getter will calculate:\n+\n+        dmagTrailing: the offset in m5 used to represent the loss in signal to noise\n+        resulting from the fact that the object's motion smears out its PSF\n+\n+        dmagDetection: the offset in m5 used to represent the shift in detection\n+        threshold resulting from the fact that the object's motion smears out\n+        its PSF\n+        \"\"\"\n+\n+        if self.obs_metadata.seeing is None:\n+            raise RuntimeError(\"Cannot calculate dmagTraling/dmagDetection. \"\n+                               \"Your catalog's ObservationMetaData does not \"\n+                               \"specify seeing.\")\n+\n+        if not isinstance(self.obs_metadata.bandpass, str):\n+            raise RuntimeError(\"dmagTrailing/dmagDetection calculation is confused. \"\n+                               \"Your catalog's ObservationMetaData contains multiple \"\n+                               \"bandpasses.  It is unclear what seeing value you mean. \"\n+                               \"Re-create your catalog with only one bandpass.\")\n+\n+        if not hasattr(self, 'photParams') or self.photParams is None:\n+            raise RuntimeError(\"You cannot calculate dmagTrailing/dmagDetection. \"\n+                               \"Your catalog does not have an associated PhotometricParameters \"\n+                               \"member variable.  It is impossible to know what the exposure time is.\")\n+\n+        dradt = self.column_by_name('velRa') # in radians per day (actual sky velocity;\n+                                             # i.e., no need to divide by cos(dec))\n+\n+        ddecdt = self.column_by_name('velDec') # in radians per day\n+\n+        if len(dradt)==0:\n+            return numpy.zeros((2,0))\n+\n+        a_trail = 0.76\n+        b_trail = 1.16\n+        a_det = 0.42\n+        b_det = 0.00\n+        seeing = self.obs_metadata.seeing[self.obs_metadata.bandpass] # this will be in arcsec\n+        texp = self.photParams.nexp*self.photParams.exptime\n+        velocity = numpy.sqrt(numpy.power(numpy.degrees(dradt),2) + numpy.power(numpy.degrees(ddecdt),2))","path":"python/lsst/sims/catUtils/mixins/PhotometryMixin.py","position":144,"original_position":144,"commit_id":"470bc522e3e4f3cd5bedd2a935fa6dea3769889b","original_commit_id":"470bc522e3e4f3cd5bedd2a935fa6dea3769889b","user":{"login":"rhiannonlynne","id":1855711,"avatar_url":"https://avatars.githubusercontent.com/u/1855711?v=3","gravatar_id":"","url":"https://api.github.com/users/rhiannonlynne","html_url":"https://github.com/rhiannonlynne","followers_url":"https://api.github.com/users/rhiannonlynne/followers","following_url":"https://api.github.com/users/rhiannonlynne/following{/other_user}","gists_url":"https://api.github.com/users/rhiannonlynne/gists{/gist_id}","starred_url":"https://api.github.com/users/rhiannonlynne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhiannonlynne/subscriptions","organizations_url":"https://api.github.com/users/rhiannonlynne/orgs","repos_url":"https://api.github.com/users/rhiannonlynne/repos","events_url":"https://api.github.com/users/rhiannonlynne/events{/privacy}","received_events_url":"https://api.github.com/users/rhiannonlynne/received_events","type":"User","site_admin":false},"body":"off topic: I want to get the velocity (rather than just separate velRa/velDec) into the output catalogs, so that it's accessible for MAF. I need to add another mixin method? (and can I put it into this PR?)","created_at":"2015-10-15T23:28:43Z","updated_at":"2015-10-15T23:28:43Z","html_url":"https://github.com/lsst/sims_catUtils/pull/29#discussion_r42194372","pull_request_url":"https://api.github.com/repos/lsst/sims_catUtils/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/lsst/sims_catUtils/pulls/comments/42194372"},"html":{"href":"https://github.com/lsst/sims_catUtils/pull/29#discussion_r42194372"},"pull_request":{"href":"https://api.github.com/repos/lsst/sims_catUtils/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/lsst/sims_catUtils/pulls/29","id":47839303,"html_url":"https://github.com/lsst/sims_catUtils/pull/29","diff_url":"https://github.com/lsst/sims_catUtils/pull/29.diff","patch_url":"https://github.com/lsst/sims_catUtils/pull/29.patch","issue_url":"https://api.github.com/repos/lsst/sims_catUtils/issues/29","number":29,"state":"open","locked":false,"title":"Feature/sim 1504/ssm mixins","user":{"login":"danielsf","id":1682854,"avatar_url":"https://avatars.githubusercontent.com/u/1682854?v=3","gravatar_id":"","url":"https://api.github.com/users/danielsf","html_url":"https://github.com/danielsf","followers_url":"https://api.github.com/users/danielsf/followers","following_url":"https://api.github.com/users/danielsf/following{/other_user}","gists_url":"https://api.github.com/users/danielsf/gists{/gist_id}","starred_url":"https://api.github.com/users/danielsf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielsf/subscriptions","organizations_url":"https://api.github.com/users/danielsf/orgs","repos_url":"https://api.github.com/users/danielsf/repos","events_url":"https://api.github.com/users/danielsf/events{/privacy}","received_events_url":"https://api.github.com/users/danielsf/received_events","type":"User","site_admin":false},"body":"This should implement all of the solar system object mixins we talked about yesterday (October 14, 2015).\r\n\r\nTo add the focal plane, just make sure that your catalog class inherits from AstrometrySSM (which gives it access to raObserved and decObserved for solar system objects) and CameraCoords (which gives it access to chipName and pixel coordinates in the usual way).","created_at":"2015-10-15T20:45:56Z","updated_at":"2015-10-15T23:28:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"542bdc7d6cf5083dc2b55a4af0c0b12dd0f4b5f5","assignee":{"login":"rhiannonlynne","id":1855711,"avatar_url":"https://avatars.githubusercontent.com/u/1855711?v=3","gravatar_id":"","url":"https://api.github.com/users/rhiannonlynne","html_url":"https://github.com/rhiannonlynne","followers_url":"https://api.github.com/users/rhiannonlynne/followers","following_url":"https://api.github.com/users/rhiannonlynne/following{/other_user}","gists_url":"https://api.github.com/users/rhiannonlynne/gists{/gist_id}","starred_url":"https://api.github.com/users/rhiannonlynne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhiannonlynne/subscriptions","organizations_url":"https://api.github.com/users/rhiannonlynne/orgs","repos_url":"https://api.github.com/users/rhiannonlynne/repos","events_url":"https://api.github.com/users/rhiannonlynne/events{/privacy}","received_events_url":"https://api.github.com/users/rhiannonlynne/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/lsst/sims_catUtils/pulls/29/commits","review_comments_url":"https://api.github.com/repos/lsst/sims_catUtils/pulls/29/comments","review_comment_url":"https://api.github.com/repos/lsst/sims_catUtils/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lsst/sims_catUtils/issues/29/comments","statuses_url":"https://api.github.com/repos/lsst/sims_catUtils/statuses/470bc522e3e4f3cd5bedd2a935fa6dea3769889b","head":{"label":"lsst:feature/SIM-1504/ssmMixins","ref":"feature/SIM-1504/ssmMixins","sha":"470bc522e3e4f3cd5bedd2a935fa6dea3769889b","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":34668130,"name":"sims_catUtils","full_name":"lsst/sims_catUtils","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/sims_catUtils","description":"LSST Simulations package for catalog utilities","fork":false,"url":"https://api.github.com/repos/lsst/sims_catUtils","forks_url":"https://api.github.com/repos/lsst/sims_catUtils/forks","keys_url":"https://api.github.com/repos/lsst/sims_catUtils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/sims_catUtils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/sims_catUtils/teams","hooks_url":"https://api.github.com/repos/lsst/sims_catUtils/hooks","issue_events_url":"https://api.github.com/repos/lsst/sims_catUtils/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/sims_catUtils/events","assignees_url":"https://api.github.com/repos/lsst/sims_catUtils/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/sims_catUtils/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/sims_catUtils/tags","blobs_url":"https://api.github.com/repos/lsst/sims_catUtils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/sims_catUtils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/sims_catUtils/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/sims_catUtils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/sims_catUtils/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/sims_catUtils/languages","stargazers_url":"https://api.github.com/repos/lsst/sims_catUtils/stargazers","contributors_url":"https://api.github.com/repos/lsst/sims_catUtils/contributors","subscribers_url":"https://api.github.com/repos/lsst/sims_catUtils/subscribers","subscription_url":"https://api.github.com/repos/lsst/sims_catUtils/subscription","commits_url":"https://api.github.com/repos/lsst/sims_catUtils/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/sims_catUtils/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/sims_catUtils/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/sims_catUtils/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/sims_catUtils/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/sims_catUtils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/sims_catUtils/merges","archive_url":"https://api.github.com/repos/lsst/sims_catUtils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/sims_catUtils/downloads","issues_url":"https://api.github.com/repos/lsst/sims_catUtils/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/sims_catUtils/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/sims_catUtils/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/sims_catUtils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/sims_catUtils/labels{/name}","releases_url":"https://api.github.com/repos/lsst/sims_catUtils/releases{/id}","created_at":"2015-04-27T13:25:00Z","updated_at":"2015-04-30T16:47:12Z","pushed_at":"2015-10-15T20:45:56Z","git_url":"git://github.com/lsst/sims_catUtils.git","ssh_url":"git@github.com:lsst/sims_catUtils.git","clone_url":"https://github.com/lsst/sims_catUtils.git","svn_url":"https://github.com/lsst/sims_catUtils","homepage":null,"size":2472,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":5,"forks":2,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"lsst:master","ref":"master","sha":"a004f57b7ab76932cc207c36b2920dda7415dc81","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":34668130,"name":"sims_catUtils","full_name":"lsst/sims_catUtils","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/sims_catUtils","description":"LSST Simulations package for catalog utilities","fork":false,"url":"https://api.github.com/repos/lsst/sims_catUtils","forks_url":"https://api.github.com/repos/lsst/sims_catUtils/forks","keys_url":"https://api.github.com/repos/lsst/sims_catUtils/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/sims_catUtils/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/sims_catUtils/teams","hooks_url":"https://api.github.com/repos/lsst/sims_catUtils/hooks","issue_events_url":"https://api.github.com/repos/lsst/sims_catUtils/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/sims_catUtils/events","assignees_url":"https://api.github.com/repos/lsst/sims_catUtils/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/sims_catUtils/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/sims_catUtils/tags","blobs_url":"https://api.github.com/repos/lsst/sims_catUtils/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/sims_catUtils/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/sims_catUtils/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/sims_catUtils/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/sims_catUtils/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/sims_catUtils/languages","stargazers_url":"https://api.github.com/repos/lsst/sims_catUtils/stargazers","contributors_url":"https://api.github.com/repos/lsst/sims_catUtils/contributors","subscribers_url":"https://api.github.com/repos/lsst/sims_catUtils/subscribers","subscription_url":"https://api.github.com/repos/lsst/sims_catUtils/subscription","commits_url":"https://api.github.com/repos/lsst/sims_catUtils/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/sims_catUtils/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/sims_catUtils/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/sims_catUtils/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/sims_catUtils/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/sims_catUtils/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/sims_catUtils/merges","archive_url":"https://api.github.com/repos/lsst/sims_catUtils/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/sims_catUtils/downloads","issues_url":"https://api.github.com/repos/lsst/sims_catUtils/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/sims_catUtils/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/sims_catUtils/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/sims_catUtils/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/sims_catUtils/labels{/name}","releases_url":"https://api.github.com/repos/lsst/sims_catUtils/releases{/id}","created_at":"2015-04-27T13:25:00Z","updated_at":"2015-04-30T16:47:12Z","pushed_at":"2015-10-15T20:45:56Z","git_url":"git://github.com/lsst/sims_catUtils.git","ssh_url":"git@github.com:lsst/sims_catUtils.git","clone_url":"https://github.com/lsst/sims_catUtils.git","svn_url":"https://github.com/lsst/sims_catUtils","homepage":null,"size":2472,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":5,"forks":2,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lsst/sims_catUtils/pulls/29"},"html":{"href":"https://github.com/lsst/sims_catUtils/pull/29"},"issue":{"href":"https://api.github.com/repos/lsst/sims_catUtils/issues/29"},"comments":{"href":"https://api.github.com/repos/lsst/sims_catUtils/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/lsst/sims_catUtils/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/lsst/sims_catUtils/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lsst/sims_catUtils/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/lsst/sims_catUtils/statuses/470bc522e3e4f3cd5bedd2a935fa6dea3769889b"}}}}