Change overlap calculation in station page
parent
9b9dd472d5
commit
1d744b9b38
|
@ -84,7 +84,7 @@ def resolve_overlaps(scheduled_obs, start, end):
|
|||
|
||||
|
||||
def create_station_window(window_start, window_end, azr, azs, elevation, tle,
|
||||
overlapped, overlap_percentage=0):
|
||||
valid_duration, overlapped, overlap_ratio=0):
|
||||
return {'start': window_start.strftime("%Y-%m-%d %H:%M:%S.%f"),
|
||||
'end': window_end.strftime("%Y-%m-%d %H:%M:%S.%f"),
|
||||
'az_start': azr,
|
||||
|
@ -93,7 +93,9 @@ def create_station_window(window_start, window_end, azr, azs, elevation, tle,
|
|||
'tle0': tle.tle0,
|
||||
'tle1': tle.tle1,
|
||||
'tle2': tle.tle2,
|
||||
'overlapped': overlapped}
|
||||
'valid_duration': valid_duration,
|
||||
'overlapped': overlapped,
|
||||
'overlap_ratio': overlap_ratio}
|
||||
|
||||
|
||||
def create_station_windows(scheduled_obs, overlapped, pass_params, observer, satellite, tle):
|
||||
|
@ -113,7 +115,6 @@ def create_station_windows(scheduled_obs, overlapped, pass_params, observer, sat
|
|||
if len(windows) == 0:
|
||||
# No nonrlapping windows found
|
||||
return []
|
||||
|
||||
if windows_changed:
|
||||
# Windows changed due to overlap, recalculate observation parameters
|
||||
if overlapped == 0:
|
||||
|
@ -137,13 +138,18 @@ def create_station_windows(scheduled_obs, overlapped, pass_params, observer, sat
|
|||
elevation,
|
||||
tle,
|
||||
True,
|
||||
window_duration / initial_duration
|
||||
True,
|
||||
min(1, 1 - (window_duration / initial_duration))
|
||||
))
|
||||
elif overlapped == 2:
|
||||
initial_duration = (pass_params['set_time'] - pass_params['rise_time']).total_seconds()
|
||||
total_window_duration = 0
|
||||
window_duration = 0
|
||||
duration_validity = True
|
||||
for window_start, window_end in windows:
|
||||
window_duration += (window_end - window_start).total_seconds()
|
||||
window_duration = (window_end - window_start).total_seconds()
|
||||
duration_validity = duration_validity and over_min_duration(window_duration)
|
||||
total_window_duration += window_duration
|
||||
|
||||
# Add a window for the overlapped pass
|
||||
station_windows.append(create_station_window(
|
||||
|
@ -153,21 +159,25 @@ def create_station_windows(scheduled_obs, overlapped, pass_params, observer, sat
|
|||
pass_params['set_az'],
|
||||
pass_params['tca_alt'],
|
||||
tle,
|
||||
duration_validity,
|
||||
True,
|
||||
window_duration / initial_duration
|
||||
min(1, 1 - (window_duration / initial_duration))
|
||||
))
|
||||
else:
|
||||
# Add a window for a full pass
|
||||
station_windows.append(create_station_window(
|
||||
pass_params['rise_time'],
|
||||
pass_params['set_time'],
|
||||
pass_params['rise_az'],
|
||||
pass_params['set_az'],
|
||||
pass_params['tca_alt'],
|
||||
tle,
|
||||
False,
|
||||
0
|
||||
))
|
||||
window_duration = (windows[0][1] - windows[0][0]).total_seconds()
|
||||
if over_min_duration(window_duration):
|
||||
# Add a window for a full pass
|
||||
station_windows.append(create_station_window(
|
||||
pass_params['rise_time'],
|
||||
pass_params['set_time'],
|
||||
pass_params['rise_az'],
|
||||
pass_params['set_az'],
|
||||
pass_params['tca_alt'],
|
||||
tle,
|
||||
True,
|
||||
False,
|
||||
0
|
||||
))
|
||||
return station_windows
|
||||
|
||||
|
||||
|
|
|
@ -395,7 +395,7 @@ def prediction_windows(request):
|
|||
end_date = request.POST['end_time']
|
||||
station_ids = request.POST.getlist('stations[]', [])
|
||||
min_horizon = request.POST.get('min_horizon', None)
|
||||
overlapped = request.POST.get('overlapped', 0)
|
||||
overlapped = int(request.POST.get('overlapped', 0))
|
||||
try:
|
||||
sat = Satellite.objects.filter(transmitters__alive=True) \
|
||||
.filter(status='alive').distinct().get(norad_cat_id=sat_id)
|
||||
|
@ -692,7 +692,9 @@ def pass_predictions(request, id):
|
|||
|
||||
if station_windows:
|
||||
for window in station_windows:
|
||||
valid = window['start'] > observation_date_min_start
|
||||
valid = window['start'] > observation_date_min_start and window['valid_duration']
|
||||
window_start = datetime.strptime(window['start'], '%Y-%m-%d %H:%M:%S.%f')
|
||||
window_end = datetime.strptime(window['end'], '%Y-%m-%d %H:%M:%S.%f')
|
||||
sat_pass = {'name': str(satellite.name),
|
||||
'id': str(satellite.id),
|
||||
'success_rate': str(satellite.success_rate),
|
||||
|
@ -705,12 +707,14 @@ def pass_predictions(request, id):
|
|||
'norad_cat_id': str(satellite.norad_cat_id),
|
||||
'tle1': window['tle1'],
|
||||
'tle2': window['tle2'],
|
||||
'tr': window['start'].replace(' ', 'T'), # Rise time
|
||||
'azr': window['az_start'], # Rise Azimuth
|
||||
'altt': window['elev_max'], # Max altitude
|
||||
'ts': window['end'].replace(' ', 'T'), # Set time
|
||||
'azs': window['az_end'], # Set azimuth
|
||||
'valid': valid}
|
||||
'tr': window_start, # Rise time
|
||||
'azr': window['az_start'], # Rise Azimuth
|
||||
'altt': window['elev_max'], # Max altitude
|
||||
'ts': window_end, # Set time
|
||||
'azs': window['az_end'], # Set azimuth
|
||||
'valid': valid,
|
||||
'overlapped': window['overlapped'],
|
||||
'overlap_ratio': window['overlap_ratio']}
|
||||
nextpasses.append(sat_pass)
|
||||
|
||||
data = {
|
||||
|
|
|
@ -557,6 +557,7 @@ $(document).ready( function(){
|
|||
}, function(){
|
||||
if (obs_filter_dates && obs_filter_station && obs_filter_satellite){
|
||||
$('#obs-selection-tools').hide();
|
||||
$('#truncate-overlapped').click();
|
||||
calculate_observation();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -150,38 +150,6 @@ $(document).ready(function() {
|
|||
$('#antenna-filter').submit();
|
||||
});
|
||||
|
||||
// Function for overlap check
|
||||
function check_overlap(jobs, passstart, passend) {
|
||||
var overlap = 0;
|
||||
for (var i in jobs) {
|
||||
var job_start = moment(jobs[i].start);
|
||||
var job_end = moment(jobs[i].end);
|
||||
// If scheduled ends before predicion, skip!
|
||||
if (job_end.isBefore(passstart)) {continue;}
|
||||
|
||||
// If scheduled starts after prediction, skip!
|
||||
if (job_start.isAfter(passend)) {continue;}
|
||||
|
||||
// If scheduled start is in prediction, calculate overlap
|
||||
if (job_start.isBetween(passstart, passend, null, '[]')) {
|
||||
overlap = Math.round((job_start.diff(passstart) / passend.diff(passstart)) * 100);
|
||||
overlap = 100 - overlap;
|
||||
}
|
||||
|
||||
// If scheduled end is in prediction, calculate overlap
|
||||
if (job_end.isBetween(passstart, passend, null, '[]')) {
|
||||
overlap = Math.round((passend.diff(job_end) / passend.diff(passstart)) * 100);
|
||||
overlap = 100 - overlap;
|
||||
}
|
||||
|
||||
// If prediction is within job, total overlap
|
||||
if (job_start.isBefore(passstart) && job_end.isAfter(passend)) {
|
||||
overlap = 100;
|
||||
}
|
||||
}
|
||||
return overlap;
|
||||
}
|
||||
|
||||
// Pass predictions loading
|
||||
$('#loading-image').show();
|
||||
$.ajax({
|
||||
|
@ -193,19 +161,6 @@ $(document).ready(function() {
|
|||
var station = $('#station-info').attr('data-id');
|
||||
var can_schedule = $('#station-info').data('schedule');
|
||||
|
||||
var jobs = [];
|
||||
|
||||
$.ajax({
|
||||
url: '/api/jobs/?ground_station=' + $('#station-info').attr('data-id'),
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function(data){
|
||||
jobs = data;
|
||||
},
|
||||
complete: function(){
|
||||
}
|
||||
});
|
||||
|
||||
for (var i = 0; i <= len; i++) {
|
||||
var schedulable = data.nextpasses[i].valid && can_schedule;
|
||||
var tr = moment(data.nextpasses[i].tr).format('YYYY/MM/DD HH:mm');
|
||||
|
@ -218,8 +173,9 @@ $(document).ready(function() {
|
|||
var ts_svg = moment.utc(data.nextpasses[i].ts).format();
|
||||
|
||||
var overlap_style = null;
|
||||
var overlap = check_overlap(jobs, moment.utc(data.nextpasses[i].tr), moment.utc(data.nextpasses[i].ts));
|
||||
if (overlap >= 50) {
|
||||
var overlap = 0;
|
||||
if (data.nextpasses[i].overlapped) {
|
||||
overlap = Math.round(data.nextpasses[i].overlap_ratio * 100);
|
||||
overlap_style = 'overlap';
|
||||
}
|
||||
$('#pass_predictions').append(`
|
||||
|
|
Loading…
Reference in New Issue