Mosh -4 years ago 119

Python Question

I'm trying to fix this code which used

`astlib`

`astropy`

`from astLib import astCoords as coords`

#Convert B1950 coordinates (as given)

clra=zeros(3)

cldec=zeros(3)

for i in range(len(clra)):

clra[i], cldec[i] = coords.convertCoords(

'B1950', 'J2000', clra1950[i],

cldec1950[i], 1950

)

#Convert input coords to Galactic coords

lgal,bgal = radians(coords.convertCoords(

'J2000', 'GALACTIC', ra,

dec,2000

))

I need help with 2 things.

- What are the proper imports for if I want to change from
`astropy`

to`B1950`

, and the proper imports to go from`J2000`

to galactic coordinates?`J2000`

- in the areas that start with , What are the functions and arguments from astropy that go in its place. In other words, what do I replace it with?
`coords.convertCoords()`

Also, I had done some research into this issue. I found this link here: http://docs.astropy.org/en/v0.2.1/coordinates/

It describes the notation for

`astropy's`

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

This is one way to do it:

```
In [1]: import numpy as np
In [2]: from astropy import units as u
In [3]: from astropy.coordinates import SkyCoord, FK4, FK5, Galactic
In [4]: clra = np.zeros(3)
In [5]: cldec = np.zeros(3)
In [6]: c1 = SkyCoord(clra * u.deg, cldec * u.deg, frame=FK4)
In [7]: c2 = c1.transform_to(FK5(equinox='J2000'))
In [8]: c3 = c2.transform_to(Galactic)
In [9]: print(c3.l.degree)
[ 97.74220094 97.74220094 97.74220094]
In [10]: print(c3.b.degree)
[-60.18102359 -60.18102359 -60.18102359]
```

Note that you can convert `c1`

to Galactic directly too.

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**

Latest added