Created
April 5, 2014 20:04
-
-
Save eteq/9997406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:10aedd225dd64951356a066fe282727689a8da49dd87ace0c710ed11b9f07de7" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import astropy.units as u\n", | |
"import astropy.constants as cn\n", | |
"from astropy import coordinates as c" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"(1*u.Jy).to(u.erg/u.s/u.cm**2/u.Hz)" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"latex": [ | |
"$1\\times 10^{-23} \\; \\mathrm{\\frac{erg}{Hz\\,s\\,cm^{2}}}$" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 2, | |
"text": [ | |
"<Quantity 1e-23 erg / (cm2 Hz s)>" | |
] | |
} | |
], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"(1*u.Jy).to(u.erg/u.s/u.cm**2/u.AA, \n", | |
" equivalencies=u.spectral_density(4000*u.AA))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"latex": [ | |
"$1.8737\\times 10^{-12} \\; \\mathrm{\\frac{erg}{\\AA\\,s\\,cm^{2}}}$" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 3, | |
"text": [ | |
"<Quantity 1.8737028625e-12 erg / (Angstrom cm2 s)>" | |
] | |
} | |
], | |
"prompt_number": 3 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"(1*u.Jy).to(u.erg/u.s/u.cm**2/u.AA, \n", | |
" equivalencies=u.spectral_density(7.49e14*u.Hz))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"latex": [ | |
"$1.8713\\times 10^{-12} \\; \\mathrm{\\frac{erg}{\\AA\\,s\\,cm^{2}}}$" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 4, | |
"text": [ | |
"<Quantity 1.8712979097025858e-12 erg / (Angstrom cm2 s)>" | |
] | |
} | |
], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"(1*u.Jy).to(u.erg/u.s/u.cm**2/u.AA, \n", | |
" equivalencies=u.spectral_density(3.1e-3 * u.keV))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"latex": [ | |
"$1.87418\\times 10^{-12} \\; \\mathrm{\\frac{erg}{\\AA\\,s\\,cm^{2}}}$" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 5, | |
"text": [ | |
"<Quantity 1.8741806598432307e-12 erg / (Angstrom cm2 s)>" | |
] | |
} | |
], | |
"prompt_number": 5 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"(1*u.Jy).to(u.erg/u.s/u.cm**2/u.keV, \n", | |
" equivalencies=u.spectral_density(3.1e-3 * u.keV))" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stderr", | |
"text": [ | |
"ERROR:astropy:UnitsError: 'Jy' (spectral flux density) and 'erg / (cm2 keV s)' are not convertible\n" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"ERROR: UnitsError: 'Jy' (spectral flux density) and 'erg / (cm2 keV s)' are not convertible [astropy.units.core]\n" | |
] | |
}, | |
{ | |
"ename": "UnitsError", | |
"evalue": "'Jy' (spectral flux density) and 'erg / (cm2 keV s)' are not convertible", | |
"output_type": "pyerr", | |
"traceback": [ | |
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mUnitsError\u001b[0m Traceback (most recent call last)", | |
"\u001b[1;32m<ipython-input-6-c7660efb5c9d>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m (1*u.Jy).to(u.erg/u.s/u.cm**2/u.keV, \n\u001b[1;32m----> 2\u001b[1;33m equivalencies=u.spectral_density(3.1e-3 * u.keV))\n\u001b[0m", | |
"\u001b[1;32m/home/erik/src/astropy/build/lib.linux-x86_64-2.7/astropy/units/quantity.pyc\u001b[0m in \u001b[0;36mto\u001b[1;34m(self, unit, equivalencies)\u001b[0m\n\u001b[0;32m 499\u001b[0m \u001b[0munit\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mUnit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0munit\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 500\u001b[0m new_val = np.asarray(\n\u001b[1;32m--> 501\u001b[1;33m self.unit.to(unit, self.value, equivalencies=equivalencies))\n\u001b[0m\u001b[0;32m 502\u001b[0m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__quantity_view__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnew_val\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0munit\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 503\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_unit\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0munit\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m/home/erik/src/astropy/build/lib.linux-x86_64-2.7/astropy/units/core.pyc\u001b[0m in \u001b[0;36mto\u001b[1;34m(self, other, value, equivalencies)\u001b[0m\n\u001b[0;32m 915\u001b[0m \u001b[0mIf\u001b[0m \u001b[0munits\u001b[0m \u001b[0mare\u001b[0m \u001b[0minconsistent\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 916\u001b[0m \"\"\"\n\u001b[1;32m--> 917\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_converter\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mequivalencies\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mequivalencies\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 918\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 919\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0min_units\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mother\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1.0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mequivalencies\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m/home/erik/src/astropy/build/lib.linux-x86_64-2.7/astropy/units/core.pyc\u001b[0m in \u001b[0;36mget_converter\u001b[1;34m(self, other, equivalencies)\u001b[0m\n\u001b[0;32m 851\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mUnitsError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 852\u001b[0m return self._apply_equivalences(\n\u001b[1;32m--> 853\u001b[1;33m self, other, self._normalize_equivalencies(equivalencies))\n\u001b[0m\u001b[0;32m 854\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mval\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mscale\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0m_condition_arg\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mval\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 855\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m/home/erik/src/astropy/build/lib.linux-x86_64-2.7/astropy/units/core.pyc\u001b[0m in \u001b[0;36m_apply_equivalences\u001b[1;34m(self, unit, other, equivalencies)\u001b[0m\n\u001b[0;32m 814\u001b[0m raise UnitsError(\n\u001b[0;32m 815\u001b[0m \"{0} and {1} are not convertible\".format(\n\u001b[1;32m--> 816\u001b[1;33m unit_str, other_str))\n\u001b[0m\u001b[0;32m 817\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 818\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mget_converter\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mother\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mequivalencies\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;31mUnitsError\u001b[0m: 'Jy' (spectral flux density) and 'erg / (cm2 keV s)' are not convertible" | |
] | |
} | |
], | |
"prompt_number": 6 | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment