Last active
August 17, 2017 06:24
-
-
Save Sunmish/4fb5c6f939a80f9251a59445c2cc4ca3 to your computer and use it in GitHub Desktop.
Print a string of coordinates in sexagesimal format for use in MNRAS LaTeX articles.
This file contains hidden or 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
| def mnras_coords(ra, dec): | |
| '''Convert coordinates to MNRAS LaTeX friendly strings. | |
| ra, dec must be in the format hh:mm:ss.s, dd:mm:ss, and will only return | |
| the precision shown there. | |
| ''' | |
| ra_hms, dec_dms = ra, dec | |
| if '+' in dec_dms: | |
| dec_dms = r'$+$'+dec_dms[1]+dec_dms[2]+r'\degr'+dec_dms[4]+dec_dms[5]+\ | |
| r'\arcmin'+dec_dms[7]+dec_dms[8]+r'\arcsec' | |
| elif '-' in dec_dms: | |
| dec_dms = r'$-$'+dec_dms[1]+dec_dms[2]+r'\degr'+dec_dms[4]+dec_dms[5]+\ | |
| r'\arcmin'+dec_dms[7]+dec_dms[8]+r'\arcsec' | |
| else: | |
| dec_dms = r'$+$'+dec_dms[0]+dec_dms[1]+r'\degr'+dec_dms[3]+dec_dms[4]+\ | |
| r'\arcmin'+dec_dms[6]+dec_dms[7]+r'\arcsec' | |
| try: | |
| ra_hms = ra_hms[0]+ra_hms[1]+r'$^{\mathrm{h}}$'+ra_hms[3]+ra_hms[4]+\ | |
| r'$^{\mathrm{m}}$'+ra_hms[6]+ra_hms[7]+r'\fs'+ra_hms[9] | |
| except IndexError: | |
| ra_hms = ra_hms[0]+ra_hms[1]+r'$^{\mathrm{h}}$'+ra_hms[3]+ra_hms[4]+\ | |
| r'$^{\mathrm{m}}$'+ra_hms[6]+ra_hms[7]+r'\fs'+'0' | |
| print(ra_hms+' & '+dec_dms) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment