GitHub PullRequestReviewCommentEvent at 2014-02-12 02:33:01
Repository: GalSim
Actor: jmeyers314
Payload: {"comment":{"url":"https://api.github.com/repos/GalSim-developers/GalSim/pulls/comments/9653882","id":9653882,"diff_hunk":"@@ -0,0 +1,164 @@\n+# Copyright 2012, 2013 The GalSim developers:\n+# https://github.com/GalSim-developers\n+#\n+# This file is part of GalSim: The modular galaxy image simulation toolkit.\n+#\n+# GalSim is free software: you can redistribute it and/or modify\n+# it under the terms of the GNU General Public License as published by\n+# the Free Software Foundation, either version 3 of the License, or\n+# (at your option) any later version.\n+#\n+# GalSim is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with GalSim.  If not, see <http://www.gnu.org/licenses/>\n+#\n+\"\"\"@file sed.py\n+Simple spectral energy distribution class.  Used by galsim.chromatic.py\n+\"\"\"\n+\n+import numpy\n+\n+import galsim\n+\n+class SED(object):\n+    \"\"\"Very simple SED container object.  The created object is callable, returning the flux in\n+    photons/nm as a function of wavelength in nm.\"\"\"\n+    def __init__(self, wave=None, flambda=None, fnu=None, fphotons=None):\n+        \"\"\" Initialize SED with a wavelength array and a flux density array.  The flux density\n+        array can be represented in one of three ways.\n+\n+        @param wave     Array of wavelengths at which the SED is sampled.\n+        @param flambda  Array of flux density samples.  Units proprotional to erg/nm\n+        @param fnu      Array of flux density samples.  Units proprotional to erg/Hz\n+        @param fphotons Array of photon density samples.  Units proportional to photons/nm\n+        \"\"\"\n+        self.wave = numpy.array(wave, dtype=numpy.float)\n+        self.redshift = 0.0\n+        # could be more careful here with factors of hbar, c, etc...\n+        if flambda is not None:\n+            self.fphotons = numpy.array(flambda * wave, dtype=numpy.float)\n+        elif fnu is not None:\n+            self.fphotons = numpy.array(fnu / wave, dtype=numpy.float)\n+        elif fphotons is not None:\n+            self.fphotons = numpy.array(fphotons, dtype=numpy.float)\n+\n+        self.needs_new_interp = True\n+\n+    def __call__(self, wave, force_new_interp=False):\n+        \"\"\" Uses a galsim.LookupTable to interpolate the photon density at the requested wavelength.\n+        The LookupTable is cached for future use.\n+\n+        @param force_new_interp     Force rebuild of LookupTable.\n+\n+        @returns photon density, Units proportional to photons/nm\n+        \"\"\"\n+        interp = self._get_interp(force_new_interp=force_new_interp)\n+        return interp(wave)\n+\n+    def _get_interp(self, force_new_interp=False):\n+        # Return SED LookupTable, rebuild if requested.\n+        if force_new_interp or self.needs_new_interp:\n+            self.interp = galsim.LookupTable(self.wave * (1.0 + self.redshift), self.fphotons)\n+            self.needs_new_interp=False\n+        return self.interp\n+\n+    def __mul__(self, factor):\n+        # SED's can be multiplied by scalars.\n+        ret = self.copy()","path":"galsim/sed.py","position":null,"original_position":71,"commit_id":"cc94875bfaf84007f36b0f61cf4f9da1608d35e5","original_commit_id":"07aff88019bb4e3867123c28cc456e67b946c7b5","user":{"login":"jmeyers314","id":3650485,"avatar_url":"https://gravatar.com/avatar/8305d50633cdbbe09bae6a73102167e3?d=https%3A%2F%2Fidenticons.github.com%2F442bd863ef8f95bd21d0c9d3ce5eba58.png&r=x","gravatar_id":"8305d50633cdbbe09bae6a73102167e3","url":"https://api.github.com/users/jmeyers314","html_url":"https://github.com/jmeyers314","followers_url":"https://api.github.com/users/jmeyers314/followers","following_url":"https://api.github.com/users/jmeyers314/following{/other_user}","gists_url":"https://api.github.com/users/jmeyers314/gists{/gist_id}","starred_url":"https://api.github.com/users/jmeyers314/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmeyers314/subscriptions","organizations_url":"https://api.github.com/users/jmeyers314/orgs","repos_url":"https://api.github.com/users/jmeyers314/repos","events_url":"https://api.github.com/users/jmeyers314/events{/privacy}","received_events_url":"https://api.github.com/users/jmeyers314/received_events","type":"User","site_admin":false},"body":"This should now work, provided one has a `dust_func` at least.","created_at":"2014-02-12T02:33:01Z","updated_at":"2014-02-12T02:33:01Z","html_url":"https://github.com/GalSim-developers/GalSim/pull/504#discussion_r9653882","pull_request_url":"https://api.github.com/repos/GalSim-developers/GalSim/pulls/504","_links":{"self":{"href":"https://api.github.com/repos/GalSim-developers/GalSim/pulls/comments/9653882"},"html":{"href":"https://github.com/GalSim-developers/GalSim/pull/504#discussion_r9653882"},"pull_request":{"href":"https://api.github.com/repos/GalSim-developers/GalSim/pulls/504"}}}}