Code to download Pulsar catalog in VizieR and output in a format readable by the USES (Uniview Shader Effect System). Custom shaders are created to pulse the pulsars in realtime
#Set up astropy and astroquery
from astropy.table import Table,Column
from astropy.coordinates import SkyCoord, Distance, CartesianRepresentation
from astropy import units as u
from astroquery.vizier import Vizier
#Set up Matplotlib
%config InlineBackend.rc = {}
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
We will use a catalog of 706 pulsars from (Taylor+ 1995). This is VizieR catalog ID VII/189
v=Vizier(columns=['L']) #Need to ask for L explicitly as it is not part of the standard returned elements
v.ROW_LIMIT = -1
Cats = v.get_catalogs('VII/189')
pulsarCat=Cats[0]
pulsarCat.keep_columns(["RAJ2000","DEJ2000","dist","P","Age","L"])
#Create Column with dist in pc (not kpc) for WWT
distCol=Column(1000*pulsarCat['dist'].filled(0),name='distance',meta={'ucd': 'pos.distance'}, unit='pc')
pulsarCat.add_column(distCol)
del pulsarCat['dist']
pulsarCat.rename_column('RAJ2000', 'RA')
pulsarCat.rename_column('DEJ2000', 'dec')
pulsarCoords=SkyCoord(pulsarCat['RA'],pulsarCat['dec'],unit=(u.degree, u.degree),\
distance=Distance(pulsarCat['distance'],u.pc),frame='icrs')
pulsarGalCoords = pulsarCoords.galactic
pulsarGalCoords.representation='cartesian'
#Now we'll add the projection into the Galactic coordinate, minus signs convert from left-handed towards anti-center to right handed towards center
pulsarCat.add_column(Column(-1.0*pulsarCoords.galactic.represent_as(CartesianRepresentation).x,name='x_gal_coord',meta={'ucd': 'pos.cartesian.x'}),0)
pulsarCat.add_column(Column(-1.0*pulsarCoords.galactic.represent_as(CartesianRepresentation).y,name='y_gal_coord',meta={'ucd': 'pos.cartesian.y'}),1)
pulsarCat.add_column(Column(pulsarCoords.galactic.represent_as(CartesianRepresentation).z,name='z_gal_coord',meta={'ucd': 'pos.cartesian.z'}),2)
C:\Anaconda\lib\site-packages\astroquery\vizier\core.py:556: UserWarning: VOTABLE parsing raised exception: warnings.warn("VOTABLE parsing raised exception: {0}".format(ex))
pulsarCat
x_gal_coord | y_gal_coord | z_gal_coord | L | RA | dec | P | Age | distance |
---|---|---|---|---|---|---|---|---|
pc | pc | pc | [mJy.kpc2] | deg | deg | s | [yr] | pc |
159.702406285 | -486.532971175 | -477.26387815 | -1.009 | 1.52000 | 18.58306 | 0.6937476704700000 | 6.719 | 700.00 |
794.305967523 | -1593.31716053 | -464.777856515 | 1.676 | 3.57393 | 47.77585 | 1.2406989780800000 | 7.543 | 1840.00 |
-1870.39260492 | 2581.60854767 | -3175.99257085 | 1.491 | 5.95976 | -72.07540 | 0.0057567800116100 | -- | 4500.00 |
-1868.42525015 | 2582.95608052 | -3176.05493824 | 1.284 | 6.05782 | -72.07884 | 0.0053575732859000 | -- | 4500.00 |
-1868.98589738 | 2582.26220404 | -3176.28928547 | 0.000 | 6.02464 | -72.07304 | 0.0035363290000000 | -- | 4500.00 |
-1868.98589738 | 2582.26220404 | -3176.28928547 | 0.000 | 6.02464 | -72.07304 | 0.0026235790000000 | -- | 4500.00 |
-1868.98589738 | 2582.26220404 | -3176.28928547 | 0.000 | 6.02464 | -72.07304 | 0.0040403790000000 | -- | 4500.00 |
-1868.98589738 | 2582.26220404 | -3176.28928547 | 0.000 | 6.02464 | -72.07304 | 0.0032105000000000 | -- | 4500.00 |
-1868.98589738 | 2582.26220404 | -3176.28928547 | 0.000 | 6.02464 | -72.07304 | 0.0034849930000000 | -- | 4500.00 |
-1868.98589738 | 2582.26220404 | -3176.28928547 | 0.000 | 6.02464 | -72.07304 | 0.0021006334000000 | -- | 4500.00 |
-1868.98589738 | 2582.26220404 | -3176.28928547 | 0.000 | 6.02464 | -72.07304 | 0.0043461700000000 | -- | 4500.00 |
... | ... | ... | ... | ... | ... | ... | ... | ... |
114.973253897 | -1125.70324177 | -824.362397462 | 1.468 | 349.49082 | 21.83064 | 1.4446526746999999 | 7.338 | 1400.00 |
1211.09859835 | -2983.39220111 | -31.7987330787 | 2.572 | 350.47994 | 60.40852 | 2.2564878673700002 | 6.706 | 3220.00 |
70.3896015162 | -616.381061248 | -472.778691708 | 0.231 | 350.59315 | 20.95082 | 0.0048084282098382 | 9.893 | 780.00 |
-517.471591703 | 427.687998208 | -896.496585587 | 0.700 | 351.11195 | -60.90108 | 2.3474851960000001 | 7.155 | 1120.00 |
4226.30402348 | -9757.46118059 | 374.039583838 | 2.957 | 351.30579 | 63.28274 | 1.4363084791000000 | 6.896 | 10640.00 |
1879.18073922 | -4438.58982913 | 0.279532256375 | 2.597 | 351.74460 | 61.22681 | 0.2336519310508000 | 7.021 | 4820.00 |
-108.083846043 | -126.082109584 | -461.000199422 | 1.004 | 352.61170 | -20.09127 | 1.6436209539400000 | 6.750 | 490.00 |
1015.80265467 | -2251.43146642 | 10.0657228859 | 1.785 | 354.27408 | 61.85052 | 0.4952787846500000 | 4.612 | 2470.00 |
-91.0604128026 | -847.621752357 | -1753.78030727 | 1.621 | 356.77083 | -6.20000 | 1.1814499999999999 | -- | 1950.00 |
1454.56914514 | -2950.9666276 | -11.1608607905 | 2.265 | 358.51962 | 61.92966 | 0.9447824489830000 | 5.964 | 3290.00 |
import seaborn
import numpy as np
fig = plt.figure (figsize=(13,3))
ax = fig.add_subplot(121,projection="mollweide")
ax.grid(True)
ax.set_title("Pulsar Sky Distribution")
ax.scatter(pulsarCoords.galactic.l.wrap_at(180.*u.degree).radian,pulsarCoords.galactic.b.radian,c='orange')
a2 = fig.add_subplot(122)
a2.hist(pulsarCat['P'],bins=np.logspace(-4.0, 2.0, 100))
a2.set_title("Pulsar period distribution")
a2.set_xlabel("seconds")
a2.set_ylabel("N")
a2.set_xscale("log")
We will write the data table as an headerless, ASCII, space delimited nine element table which can be read by the UniView Shader Effects System.
pulsarCat.filled(-9999).write("pulsars.raw",format='ascii.no_header')
The bulk of the work is done in the geometry shader, because that has access to the Pulsar Period (which is encoded as the first coordinate of the third vertex of the triangle, or the seventh column of the .raw file) and Luminosity (which is encoded as the first coordinate of the second vertex of the triangle, or the forth column of the .raw file).
The geometry shader divides the sample into pulsars with periods less than a tenth of a second which are given a cyan forward facing square and pulsars with periods greater than a tenth of a second which are given a yellow forward facing square whose size sinusoidially varies according to the pulsar's period.
The vertex shader is just a pass through.
The fragment shader draws different markers on the square depending on a passed variable.