mcdLST.py

Compute the Apparent Local Sideral Time given an input UT date/time in isot format.

                             yyyy mm dd hh mm ss.ss        
%  mcdLST.py 2008-05-03T04:27:12.36  

Usage: mcdLST.py 2008-05-03T04:27:12.36

Time:
2008-05-03T04:27:12.360
Julian Date          = 2454589.685560
Modified Julian Date = 54589.185560
12h16m54.548s
12:16:56.09     (Expected LST)

If the input isot time string is "2008-05-03T04:27:12.36" the code recognizes this special case and prints out the expected value based on an old LRS FITS header value.

Probably very soon I'll make a less chatty version, but this the the first piece of code I have developed that uses the Astropy Times package. I want to record it here while it works!

 


#!/usr/bin/python
print "Usage: mcdLST.py 2008-05-03T04:27:12.36\n"

# Example from LRS header 
# DATE-OBS = 2008-05-03
#       UT = 04:27:12.36
#       ST = 12:16:56.09

# Setup to read the name of the input file 
from sys import argv
script_name, UTisot = argv

from astropy.time import Time

###############################################
# For McDonald 
# long = -104.0216667 degrees (- means WEST) 
# lat  =  +30.6716667 degrees (+ means NORTH) 
###############################################

t = Time(UTisot, scale='utc', format='isot', location=('-104.0216667', '+30.6716667d')) 

print "Time:"
print t 

new_jd = t.jd
print "Julian Date          = %0.6f" % (new_jd) 
new_mjd = t.mjd
print "Modified Julian Date = %0.6f" % (new_mjd) 

xlst = t.sidereal_time('apparent')
print "%s" % (xlst) 

if UTisot == "2008-05-03T04:27:12.36": 
  SThead = "12:16:56.09"
  print "%s     (Expected LST)" % (SThead) 

 

A test with REAL data!

To test the mcdLST.py routine I collected values form the FITS headers of LRS images using gethead. I wrote a little python script that split the entries for 3 files: list.DATE-OBS,list.UT,list.ST with the idea that I can use the DATE-OBS and UT values to compute ST values. I can compare these to the FITS header ST values. First I show the script I used for this (because it constructes the isot-format line for mcdLST.py and runs mcdLST.py. Then I show the results, which look good to within a couple seconds!

 

%  ls 
Cal_LST.sh*  list.DATE-OBS  list.ST  list.UT  

% cat Cal_LST.sh 



#!/bin/bash

# Test the use of mcdLST.py 

# Check that an argument is present
if [ -z "$1" ]
  then
    printf "Usage: Cal_LST.sh list.DATE-OBS list.UT list.ST \n"
    printf "arg1 = DATE file\n"
    exit 1
fi
if [ -z "$2" ]
  then
    printf "arg2 = UT file \n"
    exit 2
fi
if [ -z "$3" ]
  then
    printf "arg3 = file of expected ST values \n"
    exit 3
fi

i="0"
# Read each line in the input file (= $1)
# using file descriptor 4
exec 3<$1
exec 4<$2
exec 5<$3
while read -u3 DATE
do

 i=$[$i+1]
 read -u4 UT
 read -u5 ST_expected
 
#printf "DATE,UT = $DATE $UT\n"
# printf "DATE,UT = $DATE"T"$UT\n"
 mcdLST.py $DATE"T"$UT > lss

read STcal < lss

printf "cal,expected:  $STcal $ST_expected\n"
done 

 

Now I show the results which compare the computed values of ST (from mcdLST.py) to the expected values listed in the list.ST file. I find pretty good agreement for all 38 images.
 

%  Cal_LST.sh list.DATE-OBS list.UT list.ST 
cal,expected:  11h52m58.9416s 11:53:00.5
cal,expected:  12h31m22.2407s 12:31:23.79
cal,expected:  12h44m25.1585s 12:44:26.72
cal,expected:  12h51m54.5555s 12:51:56.11
cal,expected:  13h38m44.0468s 13:38:45.6
cal,expected:  14h45m57.8811s 14:45:59.44
cal,expected:  17h11m19.7058s 17:11:21.26
cal,expected:  17h58m48.0431s 17:58:49.6
cal,expected:  11h23m03.1223s 11:23:04.67
cal,expected:  11h36m24.1294s 11:36:25.68
cal,expected:  12h10m58.5537s 12:11:00.1
cal,expected:  12h54m05.4472s 12:54:07.0
cal,expected:  13h24m43.486s 13:24:45.03
cal,expected:  14h11m37.9308s 14:11:39.48
cal,expected:  16h13m39.5626s 16:13:41.11
cal,expected:  17h01m40.1881s 17:01:41.74
cal,expected:  17h50m17.9652s 17:50:19.51
cal,expected:  11h26m16.8541s 11:26:18.39
cal,expected:  11h39m41.6414s 11:39:43.18
cal,expected:  12h34m11.5794s 12:34:13.12
cal,expected:  12h16m54.548s 12:16:56.09
cal,expected:  11h38m17.9802s 11:38:19.51
cal,expected:  12h24m30.1196s 12:24:31.65
cal,expected:  13h37m43.135s 13:37:44.67
cal,expected:  13h05m19.2772s 13:05:20.8
cal,expected:  14h03m22.3379s 14:03:23.86
cal,expected:  14h21m49.7818s 14:21:51.31
cal,expected:  17h18m12.0673s 17:18:13.6
cal,expected:  16h55m59.8195s 16:56:01.35
cal,expected:  11h46m15.4131s 11:46:16.93
cal,expected:  12h33m18.3111s 12:33:19.82
cal,expected:  21h45m11.3917s 21:45:12.57
cal,expected:  22h48m28.5598s 22:48:29.74
cal,expected:  17h37m07.5519s 17:37:08.73
cal,expected:  19h22m58.713s 19:22:59.89
cal,expected:  21h33m11.4348s 21:33:12.62
cal,expected:  22h52m37.6483s 22:52:38.83
cal,expected:  23h46m26.8954s 23:46:28.08
It should be noted that I am finding that the mcdLST.py routine does run rather slowly. It took about 30-40 seconds to do all 38 images with this script!




Back to SCO CODES page