Let's take care of the fundamental first...
%matplotlib notebook
import matplotlib.pyplot as plt
import numpy as np
Astropy virtual observatory (astropy.vo
) has a module called conesearch that lets you get all the targets in a cone centred in a given set of coordinates.
Let's import it and check the available catalogues:
from astropy.vo.client import conesearch
conesearch.list_catalogs()
['2MASS All-Sky Point Source Catalog 1', 'Guide Star Catalog v2 1', 'SDSS DR7 - Sloan Digital Sky Survey Data Release 7 1', 'SDSS DR7 - Sloan Digital Sky Survey Data Release 7 2', 'SDSS DR7 - Sloan Digital Sky Survey Data Release 7 3', 'SDSS DR7 - Sloan Digital Sky Survey Data Release 7 4', 'SDSS DR8 - Sloan Digital Sky Survey Data Release 8 1', 'SDSS DR8 - Sloan Digital Sky Survey Data Release 8 2', 'The HST Guide Star Catalog, Version 1.1 (Lasker+ 1992) 1', 'The HST Guide Star Catalog, Version 1.2 (Lasker+ 1996) 1', 'The HST Guide Star Catalog, Version GSC-ACT (Lasker+ 1996-99) 1', 'The PMM USNO-A1.0 Catalogue (Monet 1997) 1', 'The USNO-A2.0 Catalogue (Monet+ 1998) 1', 'Two Micron All Sky Survey (2MASS) 1', 'Two Micron All Sky Survey (2MASS) 2', 'USNO-A2 Catalogue 1']
Now we need the coordinates of an object. Why don't we start with M67.
Don't worry if yopu don't remeber the coordinates of all the Messier object by heart (it's not like you are an astronomer after all); there's an helpful module that does just that: gives you the coordinates of objects in the sky!
from astropy.coordinates import SkyCoord
from astropy import units as u
c = SkyCoord.from_name('M67')
c.ra, c.dec
(<Longitude 132.825 deg>, <Latitude 11.8 deg>)
You don't like right angles in degrees? I know, they should be expressed in hours:
c.ra.to('hourangle')
Or for the math enthusiasts:
c.ra.to('rad').value # .value because radians are NOT a unit
2.318233578961468
Now, let's look on 2MASS and see what we can find at these coordinates.
result = conesearch.conesearch( c, 12* u.arcmin, catalog_db='2MASS All-Sky Point Source Catalog 1')
Trying http://irsa.ipac.caltech.edu/cgi-bin/Oasis/CatSearch/nph-catsearch?CAT=fp_psc& Downloading http://irsa.ipac.caltech.edu/cgi-bin/Oasis/CatSearch/nph-catsearch?CAT=fp_psc&VERB=1&RA=132.825&DEC=11.8&SR=0.2 [Done]
WARNING: W22: http://irsa.ipac.caltech.edu/cgi-bin/Oasis/CatSearch/nph-catsearch?CAT=fp_psc&VERB=1&RA=132.825&DEC=11.8&SR=0.2:5:0: W22: The DEFINITIONS element is deprecated in VOTable 1.1. Ignoring [astropy.io.votable.tree] WARNING: W27: http://irsa.ipac.caltech.edu/cgi-bin/Oasis/CatSearch/nph-catsearch?CAT=fp_psc&VERB=1&RA=132.825&DEC=11.8&SR=0.2:6:0: W27: COOSYS deprecated in VOTable 1.2 [astropy.io.votable.tree] WARNING: W06: http://irsa.ipac.caltech.edu/cgi-bin/Oasis/CatSearch/nph-catsearch?CAT=fp_psc&VERB=1&RA=132.825&DEC=11.8&SR=0.2:12:0: W06: Invalid UCD 'POS_EQ_RA_MAIN': Unknown word 'POS_EQ_RA_MAIN' [astropy.io.votable.tree] WARNING: W06: http://irsa.ipac.caltech.edu/cgi-bin/Oasis/CatSearch/nph-catsearch?CAT=fp_psc&VERB=1&RA=132.825&DEC=11.8&SR=0.2:13:0: W06: Invalid UCD 'POS_EQ_DEC_MAIN': Unknown word 'POS_EQ_DEC_MAIN' [astropy.io.votable.tree] WARNING: W06: http://irsa.ipac.caltech.edu/cgi-bin/Oasis/CatSearch/nph-catsearch?CAT=fp_psc&VERB=1&RA=132.825&DEC=11.8&SR=0.2:40:0: W06: Invalid UCD 'ID_MAIN': Unknown word 'ID_MAIN' [astropy.io.votable.tree]
result = result.to_table()
result[:8]
ra | dec | err_maj | err_min | err_ang | designation | j_m | j_cmsig | j_msigcom | j_snr | h_m | h_cmsig | h_msigcom | h_snr | k_m | k_cmsig | k_msigcom | k_snr | ph_qual | rd_flg | bl_flg | cc_flg | ndet | prox | pxpa | pxcntr | gal_contam | mp_flg | cntr | hemis | xdate | scan | glon | glat | x_scan | jdate | j_psfchi | h_psfchi | k_psfchi | j_m_stdap | j_msig_stdap | h_m_stdap | h_msig_stdap | k_m_stdap | k_msig_stdap | dist_edge_ns | dist_edge_ew | dist_edge_flg | dup_src | use_src | a | dist_opt | phi_opt | b_m_opt | vr_m_opt | nopt_mchs | ext_key | scan_key | coadd_key | coadd |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
float64 | float64 | float64 | float64 | int32 | object | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | object | object | object | object | object | float64 | int32 | int32 | int32 | int32 | object | object | object | int32 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | object | int32 | int32 | object | float64 | int32 | float64 | float64 | int32 | int32 | int32 | int32 | int32 |
132.795 | 11.953 | 0.20000000000000001 | 0.19 | 114 | 08511082+1157102 | 16.202000000000002 | 0.081900000000000001 | 0.082799999999999999 | 13.23 | 15.862 | 0.14119999999999999 | 0.14149999999999999 | 8.0199999999999996 | 15.396000000000001 | 0.1434 | 0.14369999999999999 | 8.0 | ABB | 222 | 111 | 000 | 261506 | 13.0 | 33 | 131206702 | 0 | 0 | 131206699 | n | 1997-11-15 | 130 | 215.518103 | 31.933623000000001 | -114.22 | 2450767.9874999998 | 1.24 | 1.1399999999999999 | 0.85999999999999999 | 16.181000000000001 | 0.26200000000000001 | 15.56 | 0.27700000000000002 | 15.462 | 0.35699999999999998 | 276.19999999999999 | 132.80000000000001 | se | 1 | 1 | U | 0.47999999999999998 | 237 | 18.899999999999999 | 17.800000000000001 | 1 | -- | 7578 | 174272 | 9 |
132.787 | 11.965 | 0.089999999999999997 | 0.059999999999999998 | 0 | 08510885+1157537 | 13.127000000000001 | 0.019400000000000001 | 0.0229 | 224.71000000000001 | 12.848000000000001 | 0.022800000000000001 | 0.024400000000000002 | 128.74000000000001 | 12.781000000000001 | 0.020799999999999999 | 0.022499999999999999 | 88.920000000000002 | AAA | 222 | 111 | 000 | 666666 | 48.5 | 132 | 131206702 | 0 | 0 | 131206718 | n | 1997-11-15 | 130 | 215.50123099999999 | 31.931343999999999 | -85.25 | 2450767.9874999998 | 0.90000000000000002 | 0.81999999999999995 | 0.79000000000000004 | 13.130000000000001 | 0.012999999999999999 | 12.818 | 0.032000000000000001 | 12.817 | 0.033000000000000002 | 319.5 | 161.80000000000001 | se | 1 | 1 | U | 0.58999999999999997 | 249 | 14.800000000000001 | 13.800000000000001 | 1 | -- | 7578 | 174272 | 9 |
132.788 | 11.950 | 0.089999999999999997 | 0.059999999999999998 | 0 | 08510914+1157003 | 13.349 | 0.019400000000000001 | 0.0229 | 183.16 | 13.058 | 0.022800000000000001 | 0.024400000000000002 | 106.09999999999999 | 12.933999999999999 | 0.0263 | 0.027699999999999999 | 77.239999999999995 | AAA | 222 | 111 | 000 | 664466 | 14.199999999999999 | 284 | 131206695 | 0 | 0 | 131206692 | n | 1997-11-15 | 130 | 215.51768200000001 | 31.926238999999999 | -89.530000000000001 | 2450767.9874999998 | 0.84999999999999998 | 0.85999999999999999 | 1.24 | 13.358000000000001 | 0.014 | 13.058 | 0.017999999999999999 | 12.920999999999999 | 0.023 | 266.10000000000002 | 157.5 | se | 1 | 1 | U | 0.46999999999999997 | 240 | 15.1 | 13.9 | 1 | -- | 7578 | 174272 | 9 |
132.784 | 11.951 | 0.28999999999999998 | 0.26000000000000001 | 177 | 08510820+1157037 | 16.905999999999999 | 0.15390000000000001 | 0.15440000000000001 | 6.9199999999999999 | 16.045000000000002 | 0.17150000000000001 | 0.17169999999999999 | 6.7800000000000002 | 15.919 | 0.22900000000000001 | 0.22919999999999999 | 4.9400000000000004 | CCD | 222 | 111 | 000 | 060605 | 14.199999999999999 | 104 | 131206692 | 0 | 0 | 131206695 | n | 1997-11-15 | 130 | 215.51479599999999 | 31.923155000000001 | -75.760000000000005 | 2450767.9874999998 | 0.95999999999999996 | 1.1200000000000001 | 0.84999999999999998 | 17.145 | 0.24399999999999999 | 15.805999999999999 | 0.33600000000000002 | 16.039999999999999 | 0.59599999999999997 | 269.39999999999998 | 171.19999999999999 | se | 1 | 1 | 0 | -- | -- | -- | -- | 0 | -- | 7578 | 174272 | 9 |
132.762 | 11.983 | 0.089999999999999997 | 0.059999999999999998 | 0 | 08510286+1158580 | 14.454000000000001 | 0.0246 | 0.027400000000000001 | 66.200000000000003 | 13.938000000000001 | 0.0281 | 0.029399999999999999 | 47.170000000000002 | 13.835000000000001 | 0.0395 | 0.040399999999999998 | 33.68 | AAA | 222 | 111 | 000 | 665566 | 30.600000000000001 | 136 | 131206744 | 0 | 0 | 131206757 | n | 1997-11-15 | 130 | 215.47011000000001 | 31.916592999999999 | 2.6899999999999999 | 2450767.9874999998 | 1.1000000000000001 | 1.0700000000000001 | 1.4399999999999999 | 14.417999999999999 | 0.034000000000000002 | 14.029999999999999 | 0.035000000000000003 | 13.756 | 0.080000000000000002 | 383.19999999999999 | 249.69999999999999 | se | 0 | 1 | U | 0.62 | 239 | 16.800000000000001 | 15.300000000000001 | 1 | -- | 7578 | 174272 | 9 |
132.768 | 11.977 | 0.14000000000000001 | 0.11 | 3 | 08510430+1158360 | 16.009 | 0.079799999999999996 | 0.080699999999999994 | 15.81 | 15.833 | 0.13819999999999999 | 0.13850000000000001 | 8.2400000000000002 | 15.446 | 0.1525 | 0.1527 | 7.6399999999999997 | ABB | 222 | 111 | 000 | 260505 | 30.600000000000001 | 316 | 131206757 | 0 | 0 | 131206744 | n | 1997-11-15 | 130 | 215.47954799999999 | 31.919411 | -18.559999999999999 | 2450767.9874999998 | 1.22 | 1.0700000000000001 | 1.0 | 15.855 | 0.14199999999999999 | 16.577999999999999 | 0.46600000000000003 | 15.218 | 0.316 | 361.39999999999998 | 228.5 | se | 1 | 1 | 0 | -- | -- | -- | -- | 0 | -- | 7578 | 174272 | 9 |
132.738 | 11.947 | 0.089999999999999997 | 0.059999999999999998 | 0 | 08505706+1156507 | 13.645 | 0.0207 | 0.024 | 139.44999999999999 | 13.292999999999999 | 0.0241 | 0.025600000000000001 | 85.450000000000003 | 13.209 | 0.0263 | 0.027699999999999999 | 59.950000000000003 | AAA | 222 | 111 | 000 | 666655 | 30.5 | 269 | 131206686 | 0 | 0 | 131206688 | n | 1997-11-15 | 130 | 215.49634 | 31.880382000000001 | 87.709999999999994 | 2450767.9874999998 | 0.81999999999999995 | 0.93999999999999995 | 1.1899999999999999 | 13.648999999999999 | 0.019 | 13.279999999999999 | 0.025000000000000001 | 13.224 | 0.017000000000000001 | 255.5 | 165.0 | sw | 1 | 1 | U | 0.56000000000000005 | 234 | 15.5 | 14.6 | 1 | -- | 7578 | 174272 | 9 |
132.759 | 11.949 | 0.14000000000000001 | 0.12 | 5 | 08510216+1156554 | 16.140000000000001 | 0.077799999999999994 | 0.078700000000000006 | 14.01 | 15.361000000000001 | 0.0964 | 0.096799999999999997 | 12.720000000000001 | 15.276999999999999 | 0.13020000000000001 | 0.1305 | 8.9299999999999997 | AAB | 222 | 111 | 000 | 161606 | 36.399999999999999 | 244 | 131206681 | 0 | 0 | 131206689 | n | 1997-11-15 | 130 | 215.505145 | 31.899813000000002 | 12.91 | 2450767.9874999998 | 1.6399999999999999 | 0.97999999999999998 | 1.1399999999999999 | 16.213000000000001 | 0.29099999999999998 | 15.314 | 0.14699999999999999 | 15.218 | 0.313 | 260.69999999999999 | 239.80000000000001 | sw | 1 | 1 | 0 | -- | -- | -- | -- | 0 | -- | 7578 | 174272 | 9 |
Data tables in astropy are implemented through the Table class
from astropy.table import Table
You can read (and save) tables easily in many common formats (ascii, fits, hdf5, csv, etc.)
help( Table.read )
Help on method read in module astropy.table.table: read(*args, **kwargs) method of builtins.type instance Read and parse a data table and return as a Table. This function provides the Table interface to the astropy unified I/O layer. This allows easily reading a file in many supported data formats using syntax such as:: >>> from astropy.table import Table >>> dat = Table.read('table.dat', format='ascii') >>> events = Table.read('events.fits', format='fits') The arguments and keywords (other than ``format``) provided to this function are passed through to the underlying data reader (e.g. `~astropy.io.ascii.read`). The available built-in formats are: =========================== ==== ===== ============= ========== Format Read Write Auto-identify Deprecated =========================== ==== ===== ============= ========== ascii Yes Yes No ascii.aastex Yes Yes No ascii.basic Yes Yes No ascii.cds Yes No No ascii.commented_header Yes Yes No ascii.csv Yes Yes No ascii.daophot Yes No No ascii.ecsv Yes Yes No ascii.fast_basic Yes Yes No ascii.fast_commented_header Yes Yes No ascii.fast_csv Yes Yes No ascii.fast_no_header Yes Yes No ascii.fast_rdb Yes Yes No ascii.fast_tab Yes Yes No ascii.fixed_width Yes Yes No ascii.fixed_width_no_header Yes Yes No ascii.fixed_width_two_line Yes Yes No ascii.html Yes Yes Yes ascii.ipac Yes Yes No ascii.latex Yes Yes Yes ascii.no_header Yes Yes No ascii.rdb Yes Yes Yes ascii.sextractor Yes No No ascii.tab Yes Yes No fits Yes Yes Yes hdf5 Yes Yes Yes votable Yes No No aastex Yes Yes No Yes cds Yes No No Yes csv Yes Yes Yes Yes daophot Yes No No Yes html Yes Yes No Yes ipac Yes Yes No Yes latex Yes Yes No Yes rdb Yes Yes No Yes =========================== ==== ===== ============= ========== Deprecated format names like ``aastex`` will be removed in a future version. Use the full name (e.g. ``ascii.aastex``) instead.
Let's try to load the data we just downloaded
result = Table.read( 'https://people.lam.fr/bonamigo.mario/hackinghour/M67.dat', format='ascii.commented_header' )
result[:8]
Downloading https://people.lam.fr/bonamigo.mario/hackinghour/M67.dat [Done]
ra | dec | err_maj | err_min | err_ang | designation | j_m | j_cmsig | j_msigcom | j_snr | h_m | h_cmsig | h_msigcom | h_snr | k_m | k_cmsig | k_msigcom | k_snr | ph_qual | rd_flg | bl_flg | cc_flg | ndet | prox | pxpa | pxcntr | gal_contam | mp_flg | cntr | hemis | xdate | scan | glon | glat | x_scan | jdate | j_psfchi | h_psfchi | k_psfchi | j_m_stdap | j_msig_stdap | h_m_stdap | h_msig_stdap | k_m_stdap | k_msig_stdap | dist_edge_ns | dist_edge_ew | dist_edge_flg | dup_src | use_src | a | dist_opt | phi_opt | b_m_opt | vr_m_opt | nopt_mchs | ext_key | scan_key | coadd_key | coadd |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
float64 | float64 | float64 | float64 | int64 | str19 | float64 | str6 | str6 | str9 | float64 | str6 | str6 | str9 | float64 | str6 | str6 | str8 | str6 | str6 | str6 | str6 | str9 | float64 | int64 | int64 | int64 | int64 | str13 | str4 | str13 | int64 | float64 | float64 | float64 | float64 | str5 | str5 | str5 | str6 | str5 | str6 | str5 | str6 | str5 | float64 | float64 | str5 | int64 | int64 | str4 | str4 | str3 | str5 | str5 | int64 | str7 | int64 | int64 | int64 |
132.795 | 11.953 | 0.2 | 0.19 | 114 | b'08511082+1157102' | 16.202 | 0.0819 | 0.0828 | 13.23 | 15.862 | 0.1412 | 0.1415 | 8.02 | 15.396 | 0.1434 | 0.1437 | 8.0 | b'ABB' | b'222' | b'111' | b'000' | b'261506' | 13.0 | 33 | 131206702 | 0 | 0 | b'131206699' | b'n' | b'1997-11-15' | 130 | 215.518103 | 31.933623 | -114.22 | 2450767.9875 | 1.24 | 1.14 | 0.86 | 16.181 | 0.262 | 15.56 | 0.277 | 15.462 | 0.357 | 276.2 | 132.8 | b'se' | 1 | 1 | b'U' | 0.48 | 237 | 18.9 | 17.8 | 1 | -- | 7578 | 174272 | 9 |
132.787 | 11.965 | 0.09 | 0.06 | 0 | b'08510885+1157537' | 13.127 | 0.0194 | 0.0229 | 224.71 | 12.848 | 0.0228 | 0.0244 | 128.74 | 12.781 | 0.0208 | 0.0225 | 88.92 | b'AAA' | b'222' | b'111' | b'000' | b'666666' | 48.5 | 132 | 131206702 | 0 | 0 | b'131206718' | b'n' | b'1997-11-15' | 130 | 215.501231 | 31.931344 | -85.25 | 2450767.9875 | 0.9 | 0.82 | 0.79 | 13.13 | 0.013 | 12.818 | 0.032 | 12.817 | 0.033 | 319.5 | 161.8 | b'se' | 1 | 1 | b'U' | 0.59 | 249 | 14.8 | 13.8 | 1 | -- | 7578 | 174272 | 9 |
132.788 | 11.95 | 0.09 | 0.06 | 0 | b'08510914+1157003' | 13.349 | 0.0194 | 0.0229 | 183.16 | 13.058 | 0.0228 | 0.0244 | 106.1 | 12.934 | 0.0263 | 0.0277 | 77.24 | b'AAA' | b'222' | b'111' | b'000' | b'664466' | 14.2 | 284 | 131206695 | 0 | 0 | b'131206692' | b'n' | b'1997-11-15' | 130 | 215.517682 | 31.926239 | -89.53 | 2450767.9875 | 0.85 | 0.86 | 1.24 | 13.358 | 0.014 | 13.058 | 0.018 | 12.921 | 0.023 | 266.1 | 157.5 | b'se' | 1 | 1 | b'U' | 0.47 | 240 | 15.1 | 13.9 | 1 | -- | 7578 | 174272 | 9 |
132.784 | 11.951 | 0.29 | 0.26 | 177 | b'08510820+1157037' | 16.906 | 0.1539 | 0.1544 | 6.92 | 16.045 | 0.1715 | 0.1717 | 6.78 | 15.919 | 0.229 | 0.2292 | 4.94 | b'CCD' | b'222' | b'111' | b'000' | b'060605' | 14.2 | 104 | 131206692 | 0 | 0 | b'131206695' | b'n' | b'1997-11-15' | 130 | 215.514796 | 31.923155 | -75.76 | 2450767.9875 | 0.96 | 1.12 | 0.85 | 17.145 | 0.244 | 15.806 | 0.336 | 16.04 | 0.596 | 269.4 | 171.2 | b'se' | 1 | 1 | b'0' | -- | -- | -- | -- | 0 | -- | 7578 | 174272 | 9 |
132.762 | 11.983 | 0.09 | 0.06 | 0 | b'08510286+1158580' | 14.454 | 0.0246 | 0.0274 | 66.2 | 13.938 | 0.0281 | 0.0294 | 47.17 | 13.835 | 0.0395 | 0.0404 | 33.68 | b'AAA' | b'222' | b'111' | b'000' | b'665566' | 30.6 | 136 | 131206744 | 0 | 0 | b'131206757' | b'n' | b'1997-11-15' | 130 | 215.47011 | 31.916593 | 2.69 | 2450767.9875 | 1.1 | 1.07 | 1.44 | 14.418 | 0.034 | 14.03 | 0.035 | 13.756 | 0.08 | 383.2 | 249.7 | b'se' | 0 | 1 | b'U' | 0.62 | 239 | 16.8 | 15.3 | 1 | -- | 7578 | 174272 | 9 |
132.768 | 11.977 | 0.14 | 0.11 | 3 | b'08510430+1158360' | 16.009 | 0.0798 | 0.0807 | 15.81 | 15.833 | 0.1382 | 0.1385 | 8.24 | 15.446 | 0.1525 | 0.1527 | 7.64 | b'ABB' | b'222' | b'111' | b'000' | b'260505' | 30.6 | 316 | 131206757 | 0 | 0 | b'131206744' | b'n' | b'1997-11-15' | 130 | 215.479548 | 31.919411 | -18.56 | 2450767.9875 | 1.22 | 1.07 | 1.0 | 15.855 | 0.142 | 16.578 | 0.466 | 15.218 | 0.316 | 361.4 | 228.5 | b'se' | 1 | 1 | b'0' | -- | -- | -- | -- | 0 | -- | 7578 | 174272 | 9 |
132.738 | 11.947 | 0.09 | 0.06 | 0 | b'08505706+1156507' | 13.645 | 0.0207 | 0.024 | 139.45 | 13.293 | 0.0241 | 0.0256 | 85.45 | 13.209 | 0.0263 | 0.0277 | 59.95 | b'AAA' | b'222' | b'111' | b'000' | b'666655' | 30.5 | 269 | 131206686 | 0 | 0 | b'131206688' | b'n' | b'1997-11-15' | 130 | 215.49634 | 31.880382 | 87.71 | 2450767.9875 | 0.82 | 0.94 | 1.19 | 13.649 | 0.019 | 13.28 | 0.025 | 13.224 | 0.017 | 255.5 | 165.0 | b'sw' | 1 | 1 | b'U' | 0.56 | 234 | 15.5 | 14.6 | 1 | -- | 7578 | 174272 | 9 |
132.759 | 11.949 | 0.14 | 0.12 | 5 | b'08510216+1156554' | 16.14 | 0.0778 | 0.0787 | 14.01 | 15.361 | 0.0964 | 0.0968 | 12.72 | 15.277 | 0.1302 | 0.1305 | 8.93 | b'AAB' | b'222' | b'111' | b'000' | b'161606' | 36.4 | 244 | 131206681 | 0 | 0 | b'131206689' | b'n' | b'1997-11-15' | 130 | 215.505145 | 31.899813 | 12.91 | 2450767.9875 | 1.64 | 0.98 | 1.14 | 16.213 | 0.291 | 15.314 | 0.147 | 15.218 | 0.313 | 260.7 | 239.8 | b'sw' | 1 | 1 | b'0' | -- | -- | -- | -- | 0 | -- | 7578 | 174272 | 9 |
You can even save in $\LaTeX$ (yes, you can have latex command here)
result[ [ 'designation', 'ra', 'dec' ] ][:8].write( 'M67.tex' )
! cat M67.tex
\begin{table} \begin{tabular}{ccc} designation & ra & dec \\ b'08511082+1157102' & 132.795 & 11.953 \\ b'08510885+1157537' & 132.787 & 11.965 \\ b'08510914+1157003' & 132.788 & 11.95 \\ b'08510820+1157037' & 132.784 & 11.951 \\ b'08510286+1158580' & 132.762 & 11.983 \\ b'08510430+1158360' & 132.768 & 11.977 \\ b'08505706+1156507' & 132.738 & 11.947 \\ b'08510216+1156554' & 132.759 & 11.949 \\ \end{tabular} \end{table}
Let's get back to our open cluster.
Who's up for a H-R diagram?
color = result['j_m'] - result['k_m']
plt.close('all')
plt.plot( color, result['k_m'], '.' )
plt.axis( ( -0.2, 1.5, 17, 6 ) )
plt.xlabel( '$j - k_s$' )
plt.ylabel( '$k_s$' )
<matplotlib.text.Text at 0x7f75d3478908>
A little bit fancier:
color = result['j_m'] - result['k_m']
plt.close('all')
plt.scatter( color, result['k_m'], c=color, vmin=0., vmax=1.5,
marker='*', s=40, linewidths=0.2, cmap='hot_r' )
plt.axis( ( -0.2, 1.5, 17, 6 ) )
plt.xlabel( '$j - k_s$' )
plt.ylabel( '$k_s$' )
<matplotlib.text.Text at 0x7f75d1e0cda0>
Why don't we move outside this galaxy?
c = SkyCoord.from_name('Coma')
c.ra, c.dec
(<Longitude 194.95292 deg>, <Latitude 27.98056 deg>)
%%time
result = conesearch.conesearch( c, 20 * u.arcmin, catalog_db='SDSS DR8 - Sloan Digital Sky Survey Data Release 8 2')
Trying http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll& Downloading http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333 [Done]
WARNING: W50: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:51:0: W50: Invalid unit string 'days' [astropy.io.votable.tree] WARNING: W50: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:237:0: W50: Invalid unit string 'Angstroms' [astropy.io.votable.tree] WARNING: W50: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:240:0: W50: Invalid unit string 'Angstroms' [astropy.io.votable.tree] WARNING: W50: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:345:0: W50: Invalid unit string 'nanomaggies' [astropy.io.votable.tree] WARNING: W50: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:348:0: W50: Invalid unit string 'nanomaggies' [astropy.io.votable.tree] WARNING: W50: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:351:0: W50: Invalid unit string 'nanomaggies' [astropy.io.votable.tree] WARNING: W50: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:354:0: W50: Invalid unit string 'nanomaggies' [astropy.io.votable.tree] WARNING: W50: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:357:0: W50: Invalid unit string 'nanomaggies' [astropy.io.votable.tree] WARNING: W50: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:360:0: W50: Invalid unit string 'nanomaggies' [astropy.io.votable.tree] WARNING: W50: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:363:0: W50: Invalid unit string 'nanomaggies' (suppressing further warnings of this type...) [astropy.io.votable.tree] WARNING: W06: http://wfaudata.roe.ac.uk/sdssdr8-dsa/DirectCone?DSACAT=SDSS_DR8&DSATAB=SpecObjAll&VERB=1&RA=194.95292&DEC=27.98056&SR=0.3333333333333333:462:0: W06: Invalid UCD 'IMAGE?': UCD has invalid character '?' in 'IMAGE?' [astropy.io.votable.tree]
CPU times: user 39.2 s, sys: 585 ms, total: 39.8 s Wall time: 1min 12s
You know the drill...
result = Table.read( "https://people.lam.fr/bonamigo.mario/hackinghour/coma.fits" )
Downloading https://people.lam.fr/bonamigo.mario/hackinghour/coma.fits [Done]
plt.close('all')
z = result['z']
zlim = ( 0.01, 0.04 )
zmask = (z > zlim[0]) & (z < zlim[1])
zmed = np.median( z[ zmask ] )
plt.hist( z, bins=20, range=zlim, histtype='step' )
plt.axvline( zmed, color='k', ls='dashed' )
plt.xlabel( 'z' )
plt.title( "Redshift: {0:.4f} (NED gives: 0.023100)".format( zmed ) )
<matplotlib.text.Text at 0x7f75d1af5dd8>
We can use the cosmoloy module to convert this to comoving distance:
from astropy.cosmology import Planck15 as cosmo
cosmo.comoving_distance( zmed )
Or if you like your are not sure which cosmology to choose...
from astropy.cosmology import LambdaCDM, FlatLambdaCDM
plt.figure()
cflat = LambdaCDM( H0 = 70., Om0=1., Ode0=0. )
copen = LambdaCDM( H0 = 70., Om0=0.2, Ode0=0. )
clambda = FlatLambdaCDM( H0 = 70., Om0=0.28 )
zz = np.logspace( -2.3, 0.1, 100 )
plt.plot( zz, cflat.distmod(zz) - copen.distmod(zz) , '--', label='Flat CDM')
plt.plot( zz, clambda.distmod(zz) - copen.distmod(zz) , '-', label='Flat $\Lambda$CDM' )
plt.axhline( 0., ls='dotted' )
plt.axis( (0.005, 1.1, -0.5, 0.5 ) )
plt.semilogx()
plt.legend( loc=2 )
plt.xlabel( '$z$' )
plt.ylabel( '$\Delta (m - M) [mag]$')
<matplotlib.text.Text at 0x7f75d1a426d8>
Let's do something fun with these redshifts.
import astropy.constants as cn
vdisp = np.std( z[zmask] - zmed ) * cn.c / ( 1 + zmed )
np.sqrt( np.mean( vdisp.to('km/s')**2 ) )
(3 * 2*10**6 * u.lyr * np.median( vdisp**2 ) / 5 / cn.G).to('solMass').cgs