Skip to content

Commit 344b7e9

Browse files
committed
Use the doppler_optical equivalency to convert wavelength to veloctiy
1 parent ce70d91 commit 344b7e9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tutorials/UVES/UVES.ipynb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,14 @@
760760
"cell_type": "code",
761761
"collapsed": false,
762762
"input": [
763+
"# This function uses the Doppler equivalency between wavelength and velocity\n",
764+
"import astropy.units as u\n",
763765
"def wave2doppler(w, w0):\n",
764-
" doppler = ((w-w0)/w0 * c)\n",
765-
" return doppler\n",
766+
" w0_equiv = u.doppler_optical(w0)\n",
767+
" w_equiv = w.to(u.km/u.s, equivalencies=w0_equiv)\n",
768+
" return w_equiv\n",
766769
"\n",
767-
"print wave2doppler(waveclosetoHa, 656.489 * u.nm).decompose().to(u.km/u.s)"
770+
"print wave2doppler(waveclosetoHa, 656.489 * u.nm).decompose()"
768771
],
769772
"language": "python",
770773
"metadata": {},

0 commit comments

Comments
 (0)