def get_tle_file(request_time, tle_files):
    """This function will find the appropriate hst tle file
       for the input request_time.
    """

    import time_util

    tle_keys = tle_files.keys()
    tle_keys.sort()
    sm4_time = time_util.spss_time("2009.139:00:00:00")
    time_of_interest = time_util.spss_time(request_time)

    if time_of_interest < sm4_time:
        min_index = 0
        max_index = tle_keys.index("2010.055:00:00:00")
    else:
        min_index = tle_keys.index("2010.055:00:00:00")
        max_index = len(tle_keys)
    # end if

    tle_file = tle_files[tle_keys[min_index]][0]
    for i in tle_keys[min_index:max_index]:
        if time_of_interest >= tle_files[i][1]:
            tle_file = tle_files[i][0]
        # end if
    # end for i

    return tle_file
        max_index = len(tle_keys)
    # end if

    tle_file = tle_files[tle_keys[min_index]][0]
    for i in tle_keys[min_index:max_index]:
        if time_of_interest >= tle_files[i][1]:
            tle_file = tle_files[i][0]
        # end if
    # end for i

    return tle_file


# end def get_tle_file

saa_switch_time = time_util.spss_time("2010.151:00:00:00")

# Deal with the input parameters
# 1st parm should be the start time for the HST ground track
# 2nd parm should be the end time for the HST ground track
# Both are required and in YYYY.JJJ:HH:MM:SS format
# Optional switch to label the HST ground track with HH:MM
labelhst = 0
allowed_options = ["labelhst"]
options, parms = spst_getopt.spst_getopt(tuple(sys.argv[1:]), allowed_options)
if options.has_key("-labelhst"):
    labelhst = 1
# end if

arg1 = time_util.spss_time(parms[0])
arg2 = time_util.spss_time(parms[1])
Exemplo n.º 3
0
import time_util
import spst_getopt

# Deal with the input parameters
# 1st parm should be the start time for the HST ground track
# 2nd parm should be the end time for the HST ground track
# Both are required and in YYYY.JJJ:HH:MM:SS format
# Optional switch to label the HST ground track with HH:MM
labelhst = 0
allowed_options = ['labelhst']
options, parms = spst_getopt.spst_getopt(tuple(sys.argv[1:]), allowed_options)
if (options.has_key('-labelhst')):
    labelhst = 1
# end if

arg1 = time_util.spss_time(parms[0])
arg2 = time_util.spss_time(parms[1])
hst_start = ephem.Date(arg1.strftime("%Y/%m/%d %H:%M:%S"))
hst_stop = ephem.Date(arg2.strftime("%Y/%m/%d %H:%M:%S"))
num_points = int((hst_stop - hst_start) / ephem.minute) + 1

# Read in the HST Two-Line ephemeris
#SMN suggestions
#import urllib2
#hand = urllib2.open('http://celestrak.com/NORAD/elements/science.txt')
#data = hand.readlines()
#hand.close()
#HST = [[d[val], d[val+1], d[val+2]] for val, line in enumerate(d) if 'HST' in line]
#hst = ephem.readtle(string.strip(HST[0][0]), string.strip(HST[0][1]), string.strip(HST[0][2]))
temp = open("/Users/niemi/Desktop/Misc/hst_new.tle", "r").readlines()
hst = ephem.readtle(string.strip(temp[0]), \
import spst_getopt
import cPickle

# Deal with the input parameters
# 1st parm should be the start time for the HST ground track
# 2nd parm should be the end time for the HST ground track
# Both are required and in YYYY.JJJ:HH:MM:SS format
# Optional switch to label the HST ground track with HH:MM
labelhst = 0
allowed_options = ['labelhst']
options, parms = spst_getopt.spst_getopt(tuple(sys.argv[1:]), allowed_options)
if (options.has_key('-labelhst')):
  labelhst = 1
# end if

arg1 = time_util.spss_time(parms[0])
print "arg1 = ", arg1
print "strftime(arg1) = ", arg1.strftime("%Y/%m/%d %H:%M:%S")
targ1 = arg1 + 1
arg2 = time_util.spss_time(parms[1])
targ2 = arg2 + 1
hst_start = ephem.Date(targ1.strftime("%Y/%m/%d %H:%M:%S"))
print "hst_start = ", hst_start
hst_stop  = ephem.Date(targ2.strftime("%Y/%m/%d %H:%M:%S"))
num_points = int((hst_stop - hst_start)/ephem.minute)

# Read in the HST Two-Line ephemeris
temp = open("/Users/reinhart/hst.tle","r").readlines()
hst = ephem.readtle(string.strip(temp[0]), \
                    string.strip(temp[1]), \
                    string.strip(temp[2]))
    cmpv = "LMMCPV"
    tlefile = "/Users/niemi/Desktop/Misc/hst_new.tle"
    ephemerisOnline = True

    # telemetry data files
    # FUV
    FUVAcountsfile = telepath + FUVAevents
    FUVBcountsfile = telepath + FUVBevents
    FUVAhvfile = telepath + FUVAhv
    FUVBhvfile = telepath + FUVBhv
    # MAMA
    lmeventsfile = telepath + events  # EVENTS
    lmmcpvfile = telepath + cmpv  # HV

    # Time manipulations
    arg1 = time_util.spss_time(startdate)
    arg2 = time_util.spss_time(stopdate)
    hst_start = ephem.Date(arg1.strftime("%Y/%m/%d %H:%M:%S"))
    hst_stop = ephem.Date(arg2.strftime("%Y/%m/%d %H:%M:%S"))
    hst_startMJD = toJulian(hst_start)
    hst_stopMJD = toJulian(hst_stop)
    # read the telemetry data in
    # FUV
    FUVAeventsData = N.loadtxt(FUVAcountsfile, dtype={"names": ("MJD", "COUNTS"), "formats": ("f8", "f4")})
    FUVBeventsData = N.loadtxt(FUVBcountsfile, dtype={"names": ("MJD", "COUNTS"), "formats": ("f8", "f4")})
    FUVAhvData = N.loadtxt(FUVAhvfile, dtype={"names": ("MJD", "COUNTS"), "formats": ("f8", "f4")})
    FUVBhvData = N.loadtxt(FUVBhvfile, dtype={"names": ("MJD", "COUNTS"), "formats": ("f8", "f4")})
    # MAMA
    MAMAeventsData = N.loadtxt(lmeventsfile, dtype={"names": ("MJD", "COUNTS"), "formats": ("f8", "f4")})
    MAMAhvData = N.loadtxt(lmmcpvfile, dtype={"names": ("MJD", "COUNTS"), "formats": ("f8", "f4")})
Exemplo n.º 6
0
 cmpv = 'LMMCPV'
 tlefile = '/Users/niemi/Desktop/Misc/hst_new.tle'
 ephemerisOnline = True
 
 #telemetry data files
 #FUV
 FUVAcountsfile = telepath + FUVAevents
 FUVBcountsfile = telepath + FUVBevents
 FUVAhvfile = telepath + FUVAhv
 FUVBhvfile = telepath + FUVBhv
 #MAMA
 lmeventsfile = telepath + events #EVENTS
 lmmcpvfile = telepath + cmpv     #HV
 
 #Time manipulations
 arg1 = time_util.spss_time(startdate)
 arg2 = time_util.spss_time(stopdate)
 hst_start = ephem.Date(arg1.strftime("%Y/%m/%d %H:%M:%S"))
 hst_stop  = ephem.Date(arg2.strftime("%Y/%m/%d %H:%M:%S"))
 hst_startMJD = toJulian(hst_start)
 hst_stopMJD = toJulian(hst_stop)        
 #read the telemetry data in
 #FUV
 FUVAeventsData = N.loadtxt(FUVAcountsfile, dtype={'names': ('MJD', 'COUNTS'), 'formats' : ('f8','f4')})
 FUVBeventsData = N.loadtxt(FUVBcountsfile, dtype={'names': ('MJD', 'COUNTS'), 'formats' : ('f8','f4')})
 FUVAhvData = N.loadtxt(FUVAhvfile, dtype={'names': ('MJD', 'COUNTS'), 'formats' : ('f8', 'f4')})
 FUVBhvData = N.loadtxt(FUVBhvfile, dtype={'names': ('MJD', 'COUNTS'), 'formats' : ('f8', 'f4')})
 #MAMA
 MAMAeventsData = N.loadtxt(lmeventsfile, dtype={'names': ('MJD', 'COUNTS'), 'formats' : ('f8','f4')})
 MAMAhvData = N.loadtxt(lmmcpvfile, dtype={'names': ('MJD', 'COUNTS'), 'formats' : ('f8', 'f4')})