[Tutor] Request for advice on Python code

Elaina Ann Hyde elainahyde at gmail.com
Tue Feb 14 00:50:46 CET 2012


Hi, I'm working on a routine for reading in the Schlegel dustmaps.  I have
an ascii table with values, Ra-Dec and I'm trying to convert 2 columns to
l,b and get the dust values out, this is a 2 part problem as I need to
first convert to l,b, keep those values for other uses (calculating VLSR),
and get extinctions for each l,b value, I have:

import astropysics
from astropysics.coords import ICRSCoordinates,GalacticCoordinates
import asciitable

x='Core_rod_name.list'
dat=asciitable.read(x,Reader=asciitable.CommentedHeader,
fill_values=['','-999.99'])
Radeg=dat['ra-drad']*180./math.pi
Decdeg=dat['dec-drad']*180./math.pi

plot(Radeg,Decdeg,'o')
xlabel('Radeg')
ylabel('Decdeg')

gcoords=ICRSCoordinates(dat['ra-drad'],dat['dec-drad'],radians=True).convert(GalacticCoordinates)
l=gcoords.l.degrees
b=gcoords.b.degrees

VLSR=dat['Vhel_f'] + 9*np.cos(l)*np.cos(b) + 12*np.sin(l)*np.cos(b) +
7*np.sin(b)
VGSR=VLSR + 220*np.sin(l)*np.cos(b)

dustmap='SFD_dust_4096_ngp.fits'
EB_V=astropysics.obstools.get_SFD_dust(l,b,dustmap,interpolate=True)
-------
this gives the error 'Only length-1 arrays can be converted to Python
scalars' ... however, I cannot do:

for row in dat:

gcoords=ICRSCoordinates(dat['ra-drad'],dat['dec-drad'],radians=True).convert(GalacticCoordinates)

without the same error.  Any ideas would be apreciated, thanks!

~Elaina
-- 
PhD Candidate
Department of Physics and Astronomy
Faculty of Science
Macquarie University
North Ryde, NSW 2109, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120214/cd1827a0/attachment.html>


More information about the Tutor mailing list