Results 1 to 7 of 7

Thread: Gain Optimization Script

  1. #1
    Captain abcd567's Avatar
    Join Date
    Sep 2013
    Location
    Toronto CYYZ
    Posts
    2,377

    Gain Optimization Script

    ACKNOWLEDGEMENTS:
    Original author of optimization script: BartJr
    Enhancement by: lignumaqua

    Source: http://discussions.flightaware.com/a...t37172-25.html


    PROCEDURE:
    (1) Install Python:
    sudo apt-get install python

    (2) Create a new file optimize-gain-mut.py
    sudo nano optimize-gain-mut.py

    (3) Copy paste code below in the new blank file, save file (Ctrl+o) and close file (Ctrl+x)

    (4) Make file executable
    sudo chmod +x optimize-gain-mut.py

    (5) Start test
    sudo ./optimize-gain-mut.py


    It is a very lengthy test. Be patient.
    Results will be displayed after test is completed.


    Code below to be copy-pasted in blank file "optimize-gain-mut.py".
    It requires dump1090-mutability ver 1.15~dev installed on Pi
    Code:
    #!/usr/bin/python2
    import time, socket, subprocess, fileinput, os
    
    measure_duration = 62 #seconds
    ntests = 5
    gains = "20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6".split()
    #gains = "36.4 38.6 40.2 42.1 44.5 48.0 49.6".split()
    #gains = "22.9 25.4 28.0 29.7 32.8 33.8 36.4".split()
    gains.reverse()
    results = {}
    
    for i in range(ntests):
      print "test", i+1, "of", ntests 
      for g in gains:
       if g not in results:
          results[g] = [0,0,{}] #msgs, positions, aircraft
    
       for line in fileinput.input('/etc/default/dump1090-mutability', inplace=1):
          if line.startswith('GAIN'):
             print 'GAIN='+g
          else:
             print line,
       os.system("sudo /etc/init.d/dump1090-mutability restart")
       time.sleep(2)
       s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
       s.connect(('localhost',30003))
       t = time.time()
       d = ''
       while 1:
          d += s.recv(32)
          if time.time() - t > measure_duration:
             break
       s.close()
       messages = 0
       positions = 0
       planes = {}
       for l in d.split('\n'):
          a = l.split(',')
          messages += 1
          if len(a) > 4:
             if a[1] == '3':
                positions += 1
             planes[a[4]] = 1
       print "gain=",g, "messages=", messages, "positions=", positions, "planes=", len(planes.keys())
       results[g][0] += messages
       results[g][1] += positions
       for hex in planes.keys():
          results[g][2][hex] = 1
    
    print "\n===Totals==="
    print "Gain, Messages, Positions, Aircraft"
    for g in gains:
       (messages,positions,planes) = results[g]
       print g, messages, positions, len(planes.keys())

    When the test is run, it will start giving output, one line at a time then pause, then next line then pause and so on.
    It is a very lengthy test. Be patient.
    Results will be displayed after test is completed.

    test 1 of 5
    [ ok ] Restarting dump1090-mutability (via systemctl): dump1090-mutability.service.
    gain= 49.6 messages= 2147 positions= 392 planes= 14
    [ ok ] Restarting dump1090-mutability (via systemctl): dump1090-mutability.service.
    gain= 48.0 messages= 2071 positions= 346 planes= 13
    ....................
    ....................
    ....................
    [ ok ] Restarting dump1090-mutability (via systemctl): dump1090-mutability.service.
    gain= 22.9 messages= 1116 positions= 182 planes= 9
    [ ok ] Restarting dump1090-mutability (via systemctl): dump1090-mutability.service.
    gain= 20.7 messages= 705 positions= 91 planes= 8


    test 2 of 5
    [ ok ] Restarting dump1090-mutability (via systemctl): dump1090-mutability.service.
    gain= 49.6 messages= 1136 positions= 178 planes= 9
    [ ok ] Restarting dump1090-mutability (via systemctl): dump1090-mutability.service.
    gain= 48.0 messages= 1267 positions= 239 planes= 12
    ......................
    .......................
    ......................



    ===Totals===
    Gain, Messages, Positions, Aircraft
    49.6 23647 585 183
    48.0 24298 594 175
    44.5 24238 558 182
    43.9 26731 613 189
    43.4 26240 572 184
    42.1 24494 663 183
    40.2 25305 537 179
    38.6 24298 602 177
    37.2 25508 631 180
    36.4 26784 615 170
    33.8 27507 718 174
    32.8 31027 767 181
    29.7 28477 552 185
    28.0 29911 656 188
    25.4 31822 1187 188
    22.9 31240 1035 186
    20.7 33081 955 192
    Last edited by abcd567; 2017-07-28 at 15:03.

  2. #2
    Passenger RockRidge's Avatar
    Join Date
    Jul 2017
    Location
    Cloverdale CA USA
    Posts
    20
    Thanks so much for sharing this very helpful script.
    It took about 90 minutes for it to run and I ran it six times yesterday to find the best gain settings.
    The numbers varied on each run but I could see a pattern after the third run. Again, I am in a rural area with mountains so my aircraft tracked numbers can vary greatly at any point during the day.
    Even in a high traffic area, I would think it would be helpful to run it more than once.
    Thanks for the help.

  3. #3
    Passenger
    Join Date
    May 2018
    Location
    T-ESGG48
    Posts
    16
    Thank you for this script here is my test results:

    ===Totals===
    Gain, Messages, Positions, Aircraft
    49.6 70882 6428 99
    48.0 69677 6259 107
    44.5 71281 6640 110
    43.9 74554 6817 113
    43.4 73720 6514 106
    42.1 74566 6610 108
    40.2 71729 6421 108
    38.6 69304 6124 109
    37.2 70772 6341 102
    36.4 73151 6425 104
    33.8 73187 6573 102
    32.8 68985 6189 96
    29.7 60018 5594 100
    28.0 58577 5373 90
    25.4 50954 4674 77
    22.9 45718 4183 75
    20.7 33690 3077 72
    It seems like 43.9 is best gain setting for me.

  4. #4
    Purser
    Join Date
    Nov 2016
    Posts
    128
    Thanks abcd567 for passing this on from the other source. As you didn't specify a directory for Step 2, I used /etc. Seems to be running as indicated.

    ylis

  5. #5
    Captain abcd567's Avatar
    Join Date
    Sep 2013
    Location
    Toronto CYYZ
    Posts
    2,377
    ylis

    It is ok if you placed it in folder /etc
    The location of gain script file is not important. It can be placed in any folder and will work equally good.

    I normally place it in /home/pi/ folder (cd ~/).

  6. #6
    Passenger
    Join Date
    Dec 2018
    Posts
    1
    Hello, Is there any way to run this under Windows?

  7. #7
    Captain abcd567's Avatar
    Join Date
    Sep 2013
    Location
    Toronto CYYZ
    Posts
    2,377
    w9bqo

    Never tried with fr24feed's Windows feeder, which has its integral dump1090 (Malcolm Robb).

    May be possible with modifications in the .py script plus installation of python on Windows.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •