| 528 | # Output any gaps in the given band ranges, and return a list of the gaps as |
| 529 | # a list of (percent, freq-min, freq-max) tuples. |
| 530 | def output_gaps(self, br_data): |
| 531 | def ogaps(br_cur, br_rest, i, gaps): |
| 532 | if not br_rest: |
| 533 | gaps = list(reversed(gaps)) |
| 534 | return [ |
| 535 | (gaps[i + 2], gaps[i + 1], gaps[i]) for i in range(0, len(gaps), 3) |
| 536 | ] |
| 537 | else: |
| 538 | br_rest_min_f = br_rest[0][0][0] |
| 539 | br_cur_max_f = br_cur[1][0] |
| 540 | if br_cur_max_f >= br_rest_min_f: |
| 541 | return ogaps(br_rest[0], br_rest[1:], i + 1, gaps) |
| 542 | gap_size = (200 * (br_rest_min_f - br_cur_max_f)) / ( |
| 543 | br_rest_min_f + br_cur_max_f |
| 544 | ) |
| 545 | if verbosity.mpb > 0: |
| 546 | fmt = "Gap from band {} ({}) to band {} ({}), {}%" |
| 547 | print(fmt.format(i, br_cur_max_f, i + 1, br_rest_min_f, gap_size)) |
| 548 | return ogaps( |
| 549 | br_rest[0], |
| 550 | br_rest[1:], |
| 551 | i + 1, |
| 552 | [gap_size, br_cur_max_f, br_rest_min_f] + gaps, |
| 553 | ) |
| 554 | |
| 555 | if not br_data: |
| 556 | return [] |
| 557 | else: |
| 558 | return ogaps(br_data[0], br_data[1:], 1, []) |
| 559 | |
| 560 | # Return the frequency gap from the band #lower-band to the band |
| 561 | # #(lower-band+1), as a percentage of mid-gap frequency. The "gap" |