Home > matutils > interf > radec2azel.m

radec2azel

PURPOSE ^

function [az,el]=radec2azel(ra,dec,lst,lat)

SYNOPSIS ^

function [az,el]=radec2azel(ra,dec,lst,lat)

DESCRIPTION ^

 function [az,el]=radec2azel(ra,dec,lst,lat)

 Inputs:
   ra:  apparent Right Ascention in decimal hours
   dec: apparent Declination in decimal degrees
   lst: apparent Local Siderial time in decimal hours
   lat: telescope latitude in decimal degrees.

 Outputs
   az: Azimuth (degrees)
   el: Elevation (degrees)

 MKS stolen from C code, possibly Erik's?
-----------------------------------------------------
 Edited 12/04/2013 by Paddy: 
 lat input added, array operations tidied up a bit.
----------------------------------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [az,el]=radec2azel(ra,dec,lst,lat)
0002 % function [az,el]=radec2azel(ra,dec,lst,lat)
0003 %
0004 % Inputs:
0005 %   ra:  apparent Right Ascention in decimal hours
0006 %   dec: apparent Declination in decimal degrees
0007 %   lst: apparent Local Siderial time in decimal hours
0008 %   lat: telescope latitude in decimal degrees.
0009 %
0010 % Outputs
0011 %   az: Azimuth (degrees)
0012 %   el: Elevation (degrees)
0013 %
0014 % MKS stolen from C code, possibly Erik's?
0015 %-----------------------------------------------------
0016 % Edited 12/04/2013 by Paddy:
0017 % lat input added, array operations tidied up a bit.
0018 %----------------------------------------------------
0019 %
0020 
0021 % hour angle
0022 ha=lst-ra;
0023 r2d=180./pi;
0024 
0025 if (~exist('lat','var')) % Use location of C-BASS North:
0026     lat=37.2339;
0027 end
0028 
0029 % ha to deg
0030 ha = 360.*ha/24.;
0031 % to rad
0032 ha  = ha/r2d;
0033 dec = dec/r2d;
0034 lat = lat/r2d;
0035 
0036 cos_el_cos_az = sin(dec) * cos(lat) - (cos(dec) * sin(lat)) .* cos(ha);
0037 cos_el_sin_az = -cos(dec) .* sin(ha);
0038 sin_el = sin(dec) * sin(lat) + (cos(dec) * cos(lat)) .* cos(ha);
0039 
0040 el = asin(sin_el);
0041 az = atan2(cos_el_sin_az, cos_el_cos_az);
0042 
0043 % Alternative algorithm: slightly more precise near zero el, but
0044 % capable of giving out-of-range elevations due to round-off errors:
0045 %
0046 %cos_el = sqrt(cos_el_cos_az.^2 + cos_el_sin_az.^2);
0047 %el = atan2(sin_el, cos_el);
0048 
0049 el=el*r2d;
0050 az=az*r2d;
0051 
0052 return
0053

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005