[AstroPy] Visibility plot with the list of coords

Ilya Yakunin arckest at gmail.com
Tue Jul 28 08:45:15 EDT 2015


Thanks for the clarification, Evert! Adding a new axis do the trick.



2015-07-27 23:16 GMT+03:00 Evert Rol <evert.rol at gmail.com>:
>> I'd like to plot observability curves for list of the objects of my
>> interest. Following this example
>> https://astropy.readthedocs.org/en/v1.0.3/coordinates/observing-example.html
>> I created coords list using SkyCoord:
>>
>>>>> coords = SkyCoord(data[:,2], data[:,3], unit=(u.deg,u.deg))
>>
>> which contains more than 300 objects.
>>
>> And then, when I'm trying to transform equatorial coords to horizontal I get:
>>
>>>>> from astropy.coordinates import get_sun
>>>>> delta_midnight = np.linspace(-12, 12, 1000)*u.hour
>>>>> times = midnight + delta_midnight
>>>>> altazframe = AltAz(obstime=times, location=bta_location)
>>>>> sunaltazs = get_sun(times).transform_to(altazframe)
>>>>> coordaltazs = coords.transform_to(altazframe)
>>
>> Traceback (most recent call last):
>>  File "testing", line 38, in <module>
>>    corraaltazs = coords.transform_to(altazframe)
>>  File "/usr/lib/python2.7/dist-packages/astropy/coordinates/sky_coordinate.py",
>> line 348, in transform_to
>>    new_coord = trans(self.frame, generic_frame)
>>  File "/usr/lib/python2.7/dist-packages/astropy/coordinates/transformations.py",
>> line 920, in __call__
>>    curr_coord = t(curr_coord, curr_toframe)
>>  File "/usr/lib/python2.7/dist-packages/astropy/coordinates/transformations.py",
>> line 708, in __call__
>>    res = self.func(fromcoord, toframe)
>>  File "/usr/lib/python2.7/dist-packages/astropy/coordinates/builtin_frames/icrs_cirs_transforms.py",
>> line 41, in icrs_to_cirs
>>    cirs_ra, cirs_dec = erfa.atciq(i_ra, i_dec, 0, 0, px, 0, astrom)
>>  File "/usr/lib/python2.7/dist-packages/astropy/_erfa/core.py", line
>> 22306, in atciq
>>    broadcast = numpy.broadcast(numpy.int32(0.0), numpy.int32(0.0),
>> rc_in, dc_in, pr_in, pd_in, px_in, rv_in, astrom_in)
>> ValueError: shape mismatch: objects cannot be broadcast to a single shape
>
> I guess this has more to do with the fact that both the times (and thus, in a way, the altazframe object) and the coords are both arrays; in the example in the docs, only times is an array.
> So you’ll need to work towards getting a 2D array as output for coordaltazs in this case. Perhaps this should be done under the hood, but possibly, this is not done/built-in out of the principle of least surprise (generally, using numpy, when 1D arrays are input, a 1D array is output, not a 2D array).
> What seems to work for me is adding an extra dimension to the coords array:
>
>     >>> coordaltazs = coords[:,np.newaxis].transform_to(altazframe)
>
> which will give you 2D arrays for coordaltazs.alt and coordaltazs.az to be plotted
> (depending on the plot you want to make, you may need to loop around pyplot.scatter).
>
>
>
>> But when I use a single string from coords list (say, coords[20] )
>> everything goes well.
>> Looks like transform_to() waits for a single SkyCoord object but I
>> have a list. Is there any way to convert and plot several objects on
>> one plot?
>>
>> Thanks for the any help!
>>
>> --
>> Cheers,
>> Ilya
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at scipy.org
>> http://mail.scipy.org/mailman/listinfo/astropy
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy



-- 
Удачи,
            Илья



More information about the AstroPy mailing list