Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cur_sidereal(longitude,val):
global doephem
if doephem == False:
return (("12:00:00","9999999999"))
longstr = "%02d" % int(longitude)
longstr = longstr + ":"
longitude = abs(longitude)
frac = longitude - int(longitude)
frac *= 60
mins = int(frac)
longstr += "%02d" % mins
longstr += ":00"
x = ephem.Observer()
x.date = ephem.now()
x.long = longstr
jdate = ephem.julian_date(x)
tokens=str(x.sidereal_time()).split(":")
hours=int(tokens[0])
minutes=int(tokens[1])
seconds=int(float(tokens[2]))
sidt = "%02d:%02d:%02d" % (hours, minutes, seconds)
return ((sidt,jdate))
def set_jultime(self, t=None):
"""Set the current time to a Julian date."""
if t is None: t = ephem.julian_date()
self.set_ephemtime(juldate2ephem(t))
def set_ephemtime(self, t=None):
def epochString(self):
if self.epoch == Epoch.J2000:
return "J2000.0"
elif self.epoch == Epoch.B1950:
return "B1950.0"
else:
return "J%.2f" % (2000.0 + (ephem.julian_date() - 2451545.0) / 365.25)
def calculate_julian_century(datetime):
"""
"""
# Convert the scene timestamp to a julian date
d = ephem.date(datetime)
jdate = ephem.julian_date(d)
# Get the J2000 epoch
epoch = ephem.date((2000, 01, 01, 12.00))
j2_epoch = ephem.julian_date(epoch)
# Note:
# This differes from online sources such as
# http://www.pietro.org/astro_util_staticdemo/FDetailDateConversions.htm
# http://en.wikipedia.org/wiki/Equinox_(celestial_coordinates)
# which use:
# 2000 + (jdate - epoch) / 365.25
century = (jdate - j2_epoch) / 36525
return century
def JD(self, t=None):
if not t:
t = self.ut()
return ephem.julian_date(t)
def set_jultime(self, t=None):
"""Set current time as a Julian date."""
if t is None: t = ephem.julian_date()
self.set_ephemtime(juldate2ephem(t))
def set_ephemtime(self, t=None):
reference_time = start_time * 86400.0 - TIME_OFFSET
st = reference_time - timestep
et = end_time * 86400.0 + timestep + TIME_OFFSET
#print ("getting string",reference_time)
str_start_time = obtain_observation_year_month_day_hms(reference_time)
timerange= [st, et]
except:
print ('no time range given')
print ('exiting')
return -1,-1,-1
elif HAS_EPHEM:
if time_in_sec:
dublin_start = start_time / 86400.0 -15019.5
dublin_end = end_time / 86400.0 -15019.5
start_time = ephem.julian_date(ephem.Date(dublin_start)) - 2400000.5
end_time = ephem.julian_date(ephem.Date(dublin_end)) - 2400000.5
else:
start_time = ephem.julian_date(ephem.Date(start_time)) - 2400000.5
end_time = ephem.julian_date(ephem.Date(end_time)) - 2400000.5
print ('ephem start and end time ', start_time, end_time)
reference_time = start_time * 86400.0 - TIME_OFFSET
st = reference_time - timestep
et = end_time * 86400.0 + timestep + TIME_OFFSET
str_start_time = obtain_observation_year_month_day_hms(reference_time)
timerange= [st, et]
else:
print ('unable to get time range so exiting!')
return -1,-1,-1
return timerange,str_start_time,reference_time