{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Coordinates, Date and Time " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Pre-requisites: working with units and angles" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import astropy.units as u\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Let's enter manually the coordinates of Paranal UT3 in the correct units \n", "\n", "From the ESO web site:\n", " https://www.eso.org/sci/facilities/paranal/astroclimate/site.html" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "Geographical Information\n", "Altitude above sea level\t2635.43 m\n", "Telescope number\tLatitude\tLongitude\n", "UT1\t-24deg 37 min 33.117 sec\t-70 deg 24 min 11.642 sec\n", "UT2\t-24deg 37 min 31.465 sec\t-70 deg 24 min 10.855 sec\n", "UT3\t-24deg 37 min 30.300 sec\t-70 deg 24 min 9.896 sec\n", "UT4\t-24deg 37 min 31.000 sec\t-70 deg 24 min 8.000 sec" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "latitude = -(24+37/60.+30.300/3600)*u.degree\n", "longitude = -(70+24/60.+9.896/3600)*u.degree\n", "altitude = 2635.43*u.meter" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(latitude)\n", "print(longitude)\n", "print(altitude)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# To display the longitude in hour:\n", "longitude.to(u.hourangle)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# To display the altitude in km:\n", "altitude.to(u.km)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Let's retrieve thoses values from the header\n" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "dfits SPHERE.fits | fitsort DATE DATE-OBS TEL.GEOLON TEL.GEOLAT TEL.GEOELEV\n", "FILE \tDATE \tDATE-OBS \tTEL.GEOLON\tTEL.GEOLAT\tTEL.GEOELEV\t\n", "SPHERE.fits\t2015-10-04T01:20:46.0168\t2015-10-04T01:17:47.6337\t-70.4045 \t-24.6268 \t2648.0 \t" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from astropy.io import fits\n", "import os\n", "path = '/Users/jmilli/Documents/these/Python/coordinates'\n", "testFile = 'SPHERE.fits'\n", "header = fits.getheader(os.path.join(path,testFile))\n", "altitude_h = header['HIERARCH ESO TEL GEOELEV']*u.meter\n", "latitude_h = header['HIERARCH ESO TEL GEOLAT']*u.degree\n", "longitude_h = header['HIERARCH ESO TEL GEOLON']*u.degree" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(latitude_h)\n", "print(longitude_h)\n", "print(altitude_h)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Mmmh there is a slight difference in the latitude between the SPHERE header and the ESO website information" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from astropy import coordinates as coords\n", "latitude_o = coords.Angle(latitude_h)\n", "print(latitude_o)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "latitude_o-latitude" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 2. Coordinates" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "dfits SPHERE.fits | fitsort TEL.TARG.ALPHA TEL.TARG.DELTA OBS.TARG.NAME TEL.TARG.PMA TEL.TARG.PMD\n", "\n", "FILE \tTEL.TARG.ALPHA\tTEL.TARG.DELTA\tOBS.TARG.NAME\tTEL.TARG.PMA\tTEL.TARG.PMD\t\n", "SPHERE.fits\t214521.900 \t-124700.060 \tHD206893 \t0.093670 \t0.000330 \t\n", "\n", "dfits SPHERE.fits | grep pointing\n", "RA = 326.341584 / [deg] 21:45:21.9 RA (J2000) pointing\n", "DEC = -12.78359 / [deg] -12:47:00.9 DEC (J2000) pointing" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "From Simbdad\n", "\n", "HD 206893 -- Star\n", "ICRS coord. (ep=J2000) :\t21 45 21.90482 -12 47 00.0690 (Optical) [ 5.79 3.25 90 ] A 2007A&A...474..653V\n", "Proper motions mas/yr :\t93.67 0.33 [0.66 0.37 0] A 2007A&A...474..653V\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Let's enter it manually" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "icrs_coords_star = coords.SkyCoord(21+45/60.+21.90/3600. ,\n", " -12-47/60.- 0.069/3600.,\n", " unit=(u.hourangle, u.deg), frame='icrs')\n", "pma = 0.09367 # arcsec/y\n", "pmd = 0.00033 # arcsec/yr" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "icrs_coords_star" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Let's retrieve it from the header" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ra = header['HIERARCH ESO TEL TARG ALPHA']\n", "dec=header['HIERARCH ESO TEL TARG DELTA']\n", "print(ra,dec)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ra_str = '{0:s}:{1:s}:{2:s}'.format(str(ra)[0:2],str(ra)[2:4],str(ra)[4:])\n", "print(ra_str)\n", "dec_str = '{0:s}:{1:s}:{2:s}'.format(str(dec)[0:3],str(dec)[3:5],str(dec)[5:])\n", "print(dec_str)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "icrs_coords_star_2 = coords.SkyCoord(ra_str,dec_str, frame='icrs', unit=(u.hourangle,u.deg))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "icrs_coords_star_2" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Let's check if this is correct\n", "icrs_coords_star_2.ra" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Let's retrieve it from Simbdad" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "star = header['HIERARCH ESO OBS TARG NAME']\n", "icrs_coords_star_3 = coords.SkyCoord.from_name(star)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "icrs_coords_star_3" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Let's retrieve the pointed location" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "pointed_ra = header['RA']*u.degree\n", "pointed_dec=header['DEC']*u.degree\n", "pointed_coords = coords.SkyCoord(pointed_ra , pointed_dec, frame='fk5')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "pointed_coords" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Let's change the reference frame" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print('ICRS J2000.000', icrs_coords_star.to_string('hmsdms'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 3. Time" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from astropy.time import Time" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "dfits SPHERE.fits | fitsort DATE DATE-OBS\n", "FILE \tDATE \tDATE-OBS \t\n", "SPHERE.fits\t2015-10-04T01:20:46.0168\t2015-10-04T01:17:47.6337" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "start_time = Time('2015-10-04T01:17:47.6337', location=(longitude, latitude, altitude))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "start_time" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "start_time = Time(header['DATE-OBS'], location=(longitude, latitude, altitude))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A Time object has many useful properties" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "start_time.decimalyear" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "start_time.jyear_str" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 4. Changing reference frame" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# -- ICRS -> FK5\n", "fk5_timeOfObservation = coords.FK5(equinox=start_time.jyear_str)\n", "fk5_coords_star = icrs_coords_star.transform_to(fk5_timeOfObservation)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# without proper motion\n", "current_coords_star_no_pm = coords.SkyCoord(fk5_coords_star.ra,fk5_coords_star.dec,frame=fk5_timeOfObservation)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(current_coords_star_no_pm)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(current_coords_star_no_pm.to_string('hmsdms'))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(current_coords_star_no_pm.ra-icrs_coords_star.ra)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(current_coords_star_no_pm.dec-icrs_coords_star.dec)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# with proper motion\n", "current_coords_star = coords.SkyCoord(\n", " fk5_coords_star.ra + (start_time.jyear-2000)*pma*u.arcsec/np.cos(fk5_coords_star.dec),\n", " fk5_coords_star.dec + (start_time.jyear-2000)*pmd*u.arcsec,\n", " frame=fk5_timeOfObservation)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print('FK5 '+start_time.jyear_str, current_coords_star.to_string('hmsdms'))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "(current_coords_star.ra-icrs_coords_star_2.ra).to(u.arcmin)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "(current_coords_star.dec-icrs_coords_star_2.dec).to(u.arcmin)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 5. Sideral time and parallactic angles" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "#start_time.sidereal_time?\n", "# -- compute parallactic angle\n", "hour_angle = start_time.sidereal_time('mean') - current_coords_star.ra\n", "y = np.sin(hour_angle)\n", "x = np.tan(latitude) * np.cos(current_coords_star.dec ) - np.sin(current_coords_star.dec) * np.cos(hour_angle)\n", "print('Parallactic angle: {0:6.2f}'.format(np.rad2deg(np.arctan2( y, x ))))\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "header['HIERARCH ESO TEL PARANG START']" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.12" } }, "nbformat": 4, "nbformat_minor": 1 }