<div dir="ltr">thanks Eric<div><br></div><div>For the midpoint I went for</div><div><br></div><div><div>def midpoint(coord1, coord2):</div><div>    ra1 = coord1.ra</div><div>    dec1 = coord1.dec</div><div>    ra2 = coord2.ra</div><div>    dec2 = coord2.dec</div><div><br></div><div>    delta_ra = ra2 - ra1</div><div>    bx = np.cos(dec2) * np.cos(delta_ra)</div><div>    by = np.cos(dec2) * np.sin(delta_ra)</div><div>    dec_term1 = np.sin(dec1) + np.sin(dec2)</div><div>    dec_term2 = np.sqrt(np.power((np.cos(dec1) + bx), 2) + np.power(by, 2))</div><div>    decMid = np.arctan2(dec_term1, dec_term2)</div><div>    raMid = ra1 + np.arctan2(by, np.cos(dec1) + bx)</div><div><br></div><div>    return SkyCoord(raMid, decMid, frame='fk5')</div></div><div><br></div><div>not my code but it calculates the midpoint on sky.</div><div><br></div><div>Thanks again,</div><div><br></div><div>Frank</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 31, 2016 at 5:00 AM,  <span dir="ltr"><<a href="mailto:astropy-request@scipy.org" target="_blank">astropy-request@scipy.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send AstroPy mailing list submissions to<br>
        <a href="mailto:astropy@scipy.org">astropy@scipy.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://mail.scipy.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/astropy</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:astropy-request@scipy.org">astropy-request@scipy.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:astropy-owner@scipy.org">astropy-owner@scipy.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of AstroPy digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. calculate a new coordinate on sky given RA and Dec offsets<br>
      and midpoint coordinate between two targets on sky (Pistacho Datil)<br>
   2. Re: calculate a new coordinate on sky given RA and Dec<br>
      offsets and midpoint coordinate between two targets on sky<br>
      (Eric Jensen)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Wed, 30 Mar 2016 17:22:23 -0700<br>
From: Pistacho Datil <<a href="mailto:datilp@gmail.com">datilp@gmail.com</a>><br>
To: <a href="mailto:astropy@scipy.org">astropy@scipy.org</a><br>
Subject: [AstroPy] calculate a new coordinate on sky given RA and Dec<br>
        offsets and midpoint coordinate between two targets on sky<br>
Message-ID:<br>
        <<a href="mailto:CABH4OQKtS1s7js1s5823_EO4xJgOj8j19c1scTgTVeNK-jJFvA@mail.gmail.com">CABH4OQKtS1s7js1s5823_EO4xJgOj8j19c1scTgTVeNK-jJFvA@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi,<br>
<br>
First of all apologies if these two questions are too simplistic.<br>
<br>
1) I wonder if there is a way in astropy, given a target and an offset in<br>
RA and Dec to calculate a new target on sky.<br>
<br>
2) Given two targets t1 and t2, is there a way using astropy of calculating<br>
the midpoint coordinate also on sky?<br>
<br>
Many thanks in advance,<br>
<br>
Frank<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="https://mail.scipy.org/pipermail/astropy/attachments/20160330/0e20a58b/attachment-0001.html" rel="noreferrer" target="_blank">https://mail.scipy.org/pipermail/astropy/attachments/20160330/0e20a58b/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 30 Mar 2016 21:26:21 -0400<br>
From: Eric Jensen <<a href="mailto:ejensen1@swarthmore.edu">ejensen1@swarthmore.edu</a>><br>
To: Astronomical Python mailing list <<a href="mailto:astropy@scipy.org">astropy@scipy.org</a>><br>
Subject: Re: [AstroPy] calculate a new coordinate on sky given RA and<br>
        Dec     offsets and midpoint coordinate between two targets on sky<br>
Message-ID: <<a href="mailto:BE913B6C-F771-40D0-B316-AD15A6658362@swarthmore.edu">BE913B6C-F771-40D0-B316-AD15A6658362@swarthmore.edu</a>><br>
Content-Type: text/plain; charset="windows-1252"<br>
<br>
Hi Frank,<br>
<br>
For #1, here?s a way you can do it:<br>
<br>
from astropy.coordinates import Angle, SkyCoord<br>
from astropy import units as u<br>
<br>
# Define our initial coordinate position:<br>
old_pos = SkyCoord('00h42m30s', '+61d12m00s', frame='icrs')<br>
<br>
# Define the offsets:<br>
ra_offset = Angle(15, unit=u.arcsec)<br>
dec_offset = Angle(-4.5, unit=u.arcsec)<br>
<br>
# Add the offsets to create a new coordinate position:<br>
new_pos = SkyCoord(old_pos.ra + ra_offset, old_pos.dec + dec_offset, frame='icrs')<br>
<br>
print(old_pos.to_string('hmsdms'))<br>
print(new_pos.to_string('hmsdms'))<br>
<br>
<br>
00h42m30s +61d12m00s<br>
00h42m31s +61d11m55.5s<br>
<br>
One thing to watch out for if you do it this way: notice that the RA offset is 15 arcseconds *of RA*, not 15 arcseconds *on the sky*.   At a dec of 61 degrees, 15 arcseconds of angle on the sky would be more like 30 arcseconds of RA (or in HMS, about 2 seconds of time rather than 1).<br>
<br>
If you want to specify the RA offset in real angle on the sky and convert it to the appropriate RA offset to add to the initial coords, you could change the above to do something like<br>
<br>
import numpy as np<br>
ra_offset = Angle(15, unit=u.arcsec) / np.cos(<a href="http://old_pos.dec.to" rel="noreferrer" target="_blank">old_pos.dec.to</a>('radian'))<br>
<br>
and then proceeding as before, you would get output:<br>
<br>
00h42m30s +61d12m00s<br>
00h42m32.0757s +61d11m55.5s<br>
<br>
For your question number 2, you should be able to just do the arithmetic with subtracting the two RA values to find the RA separation, then halve it and add it to t1?s RA, then similarly with Dec, following the example above, to get the midpoint coordinates.<br>
<br>
Both of the above answers probably break down at some level if you have large angular separations, but for small separations they should be reasonably good.   I also don?t know how these coordinate object handle edge cases, like crossing over RA = 0 or Dec = 90, but you could test it out.<br>
<br>
Eric<br>
<br>
<br>
<br>
On Mar 30, 2016, at 8:22 PM, Pistacho Datil <<a href="mailto:datilp@gmail.com">datilp@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> First of all apologies if these two questions are too simplistic.<br>
><br>
> 1) I wonder if there is a way in astropy, given a target and an offset in RA and Dec to calculate a new target on sky.<br>
><br>
> 2) Given two targets t1 and t2, is there a way using astropy of calculating the midpoint coordinate also on sky?<br>
><br>
> Many thanks in advance,<br>
><br>
> Frank<br>
><br>
> _______________________________________________<br>
> AstroPy mailing list<br>
> <a href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a><br>
> <a href="https://mail.scipy.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/astropy</a><br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="https://mail.scipy.org/pipermail/astropy/attachments/20160330/b8b29f53/attachment-0001.html" rel="noreferrer" target="_blank">https://mail.scipy.org/pipermail/astropy/attachments/20160330/b8b29f53/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
AstroPy mailing list<br>
<a href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/astropy" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/astropy</a><br>
<br>
<br>
------------------------------<br>
<br>
End of AstroPy Digest, Vol 114, Issue 12<br>
****************************************<br>
</blockquote></div><br></div>