On Tue, Feb 14, 2012 at 1:38 PM, Andre' Walker-Loud <walksl...@gmail.com>wrote:
> Hi Elaina, > > just reading your question (and responses). There is an issue with what > you wrote in the email, which may help. > > > for row in dat: > > > > gcoords=ICRSCoordinates(dat['ra-drad'],dat['dec-drad'],radians=True).convert(GalacticCoordinates) > > This line is identical to the one that broke before, and now you are just > looping over it, so it is not surprising to fail in the same way. If a > loop will work, you would need the following instead > > """ > for row in dat: > gcoords = > ICRSCoordinates(row['ra-drad'],row['dec-drad'],radians=True).convert(GalacticCoordinates) > """ > > notice the "dat" --> "row" inside the loop. Now if that works, you can > get it to work along the following lines > > Example: suppose the output (gcoords) is a scalar float, and you would > like to store these data in an array. Then you can do > > """ > import numpy as np #just copying the style from a previous reply > > gcoords = np.zeros([len(dat)]) #this creates a numpy array of the length > of dat, and fills it with all zeros > for i,row in enumerate(dat): > gcoords[i] = > ICRSCoordinates(row['ra-drad'],row['dec-drad'],radians=True).convert(GalacticCoordinates) > """ > > If the loop doesn't work, then you need to investigate the astrophysics > library you are using, as previously mentioned, and hopefully there is > someone who is familiar with it you can ask questions to. > > Actually, even if the loop does work, you want to be more familiar with > the astrophysics library. You certainly would not want to produce results > with it (and base some conclusions on them/publish them) without being 100% > sure you know what it is doing. > > > Good luck, > > Andre Thanks to everyone who replied, Andre's idea was very good and led to the following solution: l=[] b=[] for i in xrange(len(Radeg)): gcoords=ICRSCoordinates(Radeg[i],Decdeg[i]).convert(GalacticCoordinates) l.append(gcoords.l.degrees) b.append(gcoords.b.degrees) .... you know, just in case anyone ever wants to convert to galactic coordinates in the future. Thanks again ~Elaina
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor