Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name = name[4:]
self.body = self.select_body(name)
self.year = int(year)
longstr, latstr = re.search(r'Location: (.\d\d\d \d\d), (.\d\d \d\d)',
self.content).groups()
longstr = longstr.replace(' ', ':').replace('W', '-').strip('E')
latstr = latstr.replace(' ', ':').replace('S', '-').strip('N')
self.observer = o = ephem.Observer()
o.lat = latstr
o.long = longstr
o.elevation = 0
setup_horizon(o)
self.error = ephem.minute # error we tolerate in predicted time
def mouseReleaseEvent(self, evt):
if self.editing is not None:
rect = self.rx[self.editing].rect()
pos = evt.pos()
self.rx[self.editing].setRect(rect.x(), rect.y(), rect.width(), pos.y()-rect.y()+ self.verticalScrollBar().value())
rect = self.rx[self.editing].rect()
print 'release', self.rx[self.editing].rect()
if rect.height() / self.scale_y > 0.1:
print 'Start time', str(ephem.date(ephem.now() + ((rect.y() - self.orig_y) / self.scale_y) * ephem.minute))
print 'Duration', rect.height() / self.scale_y
print 'Centre Frequency', (rect.x() + rect.width()/2 - self.orig_x) / self.scale_x + (self.fx0 * 1e6)
self.rx[self.editing].setParams(ephem.date(ephem.now() + ((rect.y() - self.orig_y) / self.scale_y) * ephem.minute),
rect.height() / self.scale_y,
(rect.x() + rect.width()/2 - self.orig_x) / self.scale_x + (self.fx0 * 1e6))
for f in self.scene().items(rect):
print f
if isinstance(f, PlannerSat):
print f.name, f.mode, f.freq, f.params
self.rx[self.editing].addChannel(f.name, f.mode, f.freq, f.tle, f.params)
else:
self.rx[self.editing].hide()
self.rx[self.editing] = None
self.rx = self.rx[:-1]
'sats': sats,
'tles': tles,
'fs': sample_rate,
'fc': center_freq,
'lat':lat,
'lon':lon,
'alt':alt,
}
savemat('./data/' + filename, save_dict, do_compression=True)
print("File saved: {}".format('./data/' + filename))
file_count -= 1
else:
sat_detected = False
for minute in range(0, 60*12):
obs.date = ephem.now() + minute * ephem.minute
for sat_name in active_orbcomm_satellites:
sat = active_orbcomm_satellites[sat_name]['sat_obj']
sat.compute(obs)
if degrees(sat.alt) > min_elevation:
sat_detected = True
if minute > 1:
print("Minutes until next satellite visible: {:.0f}".format(minute))
sleep(60)
break
if sat_detected:
break
if sat_detected == False:
print("No upcoming satellite passes detected within 12 hours.")
:param datestr: string containing date
:param convert: whether or not to convert to time string/ angle degrees
:return: a dictionary of values
"""
if datestr is not None:
date = parser.parse(datestr)
date = date.replace(tzinfo=tz.tzlocal())
dateutc = ephem.Date(str(date.astimezone(tz.tzutc())))
else:
dateutc = ephem.Date(str(datetime.utcnow()))
observer = ephem.Observer() # create a copy of observer
observer.lon = self.observer.lon
observer.lat = self.observer.lat
observer.elev = self.observer.elev
observer.epoch = self.observer.epoch
observer.date = ephem.Date(dateutc + ephem.minute)
satellite = ephem.readtle(self.tle[0], self.tle[1], self.tle[2]) # make a copy of satellite
satellite.compute(observer)
next_pass = observer.next_pass(satellite)
if convert:
next_pass = {'risetime': tolocal(next_pass[0]), 'riseaz': todegs(next_pass[1]), 'maxtime': tolocal(next_pass[2])
, 'maxalt': todegs(next_pass[3]), 'settime': tolocal(next_pass[4]), 'setaz': todegs(next_pass[5])}
else:
next_pass = {'risetime': next_pass[0], 'riseaz': next_pass[1], 'maxtime': next_pass[2]
, 'maxalt': next_pass[3], 'settime': next_pass[4], 'setaz': next_pass[5]}
return next_pass
def setInfo(self, lon, lat, sat, pstart = None):
obs = ephem.Observer()
obs.long = lon
obs.lat = lat
dtime = datetime.datetime.now() - ephem.now().datetime()
if pstart != None:
obs.date = str(pstart)
obs.date -= ephem.minute # Make sure we start before the AOS
obs.date -= (dtime.days + (dtime.seconds + dtime.microseconds/1.0e6) * ephem.second) # convert to GMT from local
self.sat = sat
self.plot = PolarPlot()
self.setWindowTitle(sat.name)
self.setLayout(QtGui.QGridLayout())
self.layout().addWidget(self.plot)
tr, azr, tt, altt, ts, azs = obs.next_pass(self.sat)
data = []
tr_time = tr.datetime()
ltime = (datetime.datetime(tr_time.year, tr_time.month, tr_time.day, tr_time.hour, tr_time.minute, 0) +
datetime.timedelta(seconds=60))
while tr < ts:
obs.date = tr
location.date = now
# List of passes
passes = []
# Make predictions
for p in range(num_passes):
tr, azr, tt, altt, ts, azs = location.next_pass(iss)
duration = int((ts - tr) *60*60*24)
year, month, day, hour, minute, second = tr.tuple()
dt = datetime.datetime(year, month, day, hour, minute, int(second))
passes.append({"risetime": unixtime(dt), "duration": duration})
# Increase the time by more than a pass and less than an orbit
location.date = tr + 25*ephem.minute
# Return object
obj = {"request": { "datetime": unixtime(now)
,"latitude": latitude
,"longitude": longitude
,"altitude": altitude
,"passes": num_passes}
,"response": passes
,"message": "success"}
# print data
print "Content-Type: application/json;charset=utf-8"
print
print simplejson.dumps(obj)
}
sdr.read_samples_async(rtlsdr_callback, num_samples_per_recording, context_dict)
print("Ending async RTLSDR processing")
queue.close()
queue.join_thread()
p.join()
if should_finish:
break
else:
# If no satellite is overhead, find the next one that will be
sat_detected = False
for minute in range(0, 60*12):
obs.date = ephem.now() + minute * ephem.minute
for sat_name in active_orbcomm_satellites:
sat = active_orbcomm_satellites[sat_name]['sat_obj']
sat.compute(obs)
if degrees(sat.alt) > min_elevation:
sat_detected = True
if minute > 1:
print("Time until next satellite ({}) visible: {:.0f} minutes".format(sat_name, minute))
sleep(60)
else:
sleep(1)
break
if sat_detected:
break
if sat_detected == False:
print """Date/Time (UTC) Alt/Azim Lat/Long Range Doppler"""
print """=================================================================="""
while tr < ts:
obs.date = tr
sat.compute(obs)
print "%s | %4.1f %5.1f | %4.1f %+6.1f | %5.1f | %+6.1f" % \
(tr,
math.degrees(sat.alt),
math.degrees(sat.az),
math.degrees(sat.sublat),
math.degrees(sat.sublong),
sat.range/1000.,
sat.range_velocity * 435e6 / 3.0e8)
tr = ephem.Date(tr + 20.0 * ephem.second)
print
obs.date = tr + ephem.minute
"obj_id": obj_id,
"rise_time": sat_rise,
"transit_time": sat_transit,
"set_time": sat_set,
"azimuth": np.rad2deg(az),
"elevation": np.rad2deg(el),
"altitude": alt,
"doppler_frequency": obj_doppler,
"doppler_bandwidth": obj_bandwidth,
}
if opt.schedule:
d = sat_rise.tuple()
rise_time = "%04d%02d%02d_%02d%02d" % (d[0], d[1], d[2], d[3], d[4])
offset_rise = ephem.date(sat_rise - ephem.minute)
d = offset_rise.tuple()
offset_rise_time = "%04d-%02d-%02dT%02d:%02d:%02dZ" % (
d[0],
d[1],
d[2],
d[3],
d[4],
int(d[5]),
)
offset_set = ephem.date(sat_set + ephem.minute)
d = offset_set.tuple()
offset_set_time = "%04d-%02d-%02dT%02d:%02d:%02dZ" % (
d[0],
d[1],
d[2],
# Of course it varies because of the eccentricity
# (and other complications) of the moon's orbit,
# that being the whole point of looking for analemmas,
# so what we want is the average time.
#
# But the actual number should be
# (360 / 27.321661 - 360 / 365.25) * 24*60/360 = 48.76 hmm
# (previous reasoning, wrong) 48.76 =
# 24 * 60 / 29.530588853, days in a synodic month.
# But in this simulation, 48.76 doesn't return the moon
# to the same place after the end of a month.
# 50.47 gives the tightest grouping.
# += doesn't work on ephem.Dates, it converts to float.
transit = ephem.Date(transit + 1.0 + 50.47 * ephem.minute)
# transit = ephem.Date(transit + 1.0 + 48.76 * ephem.minute)
else:
# Calculate earliest sunrise and suchlike.
self.calc_special_dates()
# Draw three analemmas, showing the sun positions at 7:40 am,
# noon, and 4:40 pm ... in each case adjusted for mean solar time,
# i.e. the observer's position within their timezone.
for time in [ '7:30', '12:00', '16:30' ]:
for m in range(1, 13):
self.draw_sun_position('%d/%d/1 %s' % (self.year, m, time))
self.draw_sun_position('%d/%d/10 %s' % (self.year, m, time))
self.draw_sun_position('%d/%d/20 %s' % (self.year, m, time))
# Mark special dates for mean solar noon.