Mercurial > ~darius > hgwebdir.cgi > pyinst
annotate sitesurvey.py @ 42:184ea77c10e7
Use scipys interpolation routines rather than hand rolling.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Wed, 28 Sep 2011 14:38:23 +0930 |
parents | 660a2997e720 |
children | 7ba7207df078 |
rev | line source |
---|---|
31
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
2 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
3 # Copyright (c) 2011 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
4 # Daniel O'Connor <darius@dons.net.au>. All rights reserved. |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
5 # |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
6 # Redistribution and use in source and binary forms, with or without |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
7 # modification, are permitted provided that the following conditions |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
8 # are met: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
9 # 1. Redistributions of source code must retain the above copyright |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
10 # notice, this list of conditions and the following disclaimer. |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
11 # 2. Redistributions in binary form must reproduce the above copyright |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
12 # notice, this list of conditions and the following disclaimer in the |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
13 # documentation and/or other materials provided with the distribution. |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
14 # |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
15 # THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
18 # ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
25 # SUCH DAMAGE. |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
26 # |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
27 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
28 import calendar |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
29 import ConfigParser |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
30 import datetime |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
31 import exceptions |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
32 import numpy |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
33 import os |
42
184ea77c10e7
Use scipys interpolation routines rather than hand rolling.
Daniel O'Connor <darius@dons.net.au>
parents:
32
diff
changeset
|
34 import scipy.interpolate |
31
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
35 import scpi |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
36 import specan |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
37 import sys |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
38 import time |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
39 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
40 defaults = {} |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
41 confname = "sitesurvey.ini" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
42 confpaths = [ ".", os.path.dirname(os.path.realpath(sys.argv[0]))] |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
43 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
44 class Experiment(object): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
45 def __init__(self, conf, name): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
46 if not conf.has_section(name): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
47 raise exceptions.KeyError("No section for experiment " + name) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
48 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
49 self.name = name |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
50 self.recurrence = None |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
51 self.opts = {} |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
52 for k, v in conf.items(name): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
53 if k == "recurrence": |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
54 # In seconds |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
55 self.recurrence = int(v) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
56 continue |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
57 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
58 try: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
59 self.opts[k] = int(v) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
60 except exceptions.ValueError, e: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
61 try: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
62 self.opts[k] = float(v) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
63 except exceptions.ValueError, e: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
64 self.opts[k] = v |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
65 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
66 if self.recurrence == None: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
67 raise exceptions.KeyError("Mandatory parameter 'recurrence' is missing") |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
68 self.recurrence = datetime.timedelta(seconds = self.recurrence) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
69 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
70 self.last_run = None |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
71 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
72 def __repr__(self): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
73 return "<" + self.name + ">" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
74 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
75 class CalFile(object): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
76 def __init__(self, fname): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
77 f = file(fname) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
78 if f.readline().strip() != "Frequencies": |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
79 raise exceptions.SyntaxError("Format of cal file incorrect (frequencies header missing)") |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
80 freqs = numpy.fromstring(f.readline().strip(), sep = ',') |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
81 if f.readline().strip() != "Gain": |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
82 raise exceptions.SyntaxError("Format of cal file incorrect (gains header missing)") |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
83 gains = numpy.fromstring(f.readline().strip(), sep = ',') |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
84 if len(gains) != len(freqs): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
85 raise exceptions.SyntaxError("Format of cal file incorrect (length of gain and freqs aren't equal)") |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
86 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
87 self.calfreqs = freqs |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
88 self.calgains = gains |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
89 |
42
184ea77c10e7
Use scipys interpolation routines rather than hand rolling.
Daniel O'Connor <darius@dons.net.au>
parents:
32
diff
changeset
|
90 # Create interpolation function |
184ea77c10e7
Use scipys interpolation routines rather than hand rolling.
Daniel O'Connor <darius@dons.net.au>
parents:
32
diff
changeset
|
91 self.interp = scipy.interpolate.interp1d(self.calfreqs, self.calgains, bound_error = True) |
31
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
92 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
93 def getexpt(sequence): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
94 '''Given a sequence return the experiment which should be run next and how long until it should start''' |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
95 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
96 now = datetime.datetime.utcnow() |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
97 #print "now is " + str(now) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
98 soonestdly = None |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
99 soonestexp = None |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
100 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
101 for e in sequence: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
102 #print "Looking at " + str(e) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
103 # If an experiment has ever run do it now |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
104 if e.last_run == None: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
105 return e, datetime.timedelta(0) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
106 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
107 # Time until this experiment should be run |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
108 nextrun = e.last_run + e.recurrence |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
109 dly = nextrun - now |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
110 #print "Last run was at %s, nextrun at %s, rec = %s, dly = %s / %f" % (str(e.last_run), str(nextrun), str(e.recurrence), str(dly), dly.total_seconds()) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
111 # Haven't looked at an experiment yet or this one is sooner |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
112 if soonestdly == None or dly < soonestdly: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
113 #print "sooner" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
114 soonestdly = dly |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
115 soonestexp = e |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
116 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
117 if soonestdly < datetime.timedelta(0): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
118 #print "Capping " + e.name + " to run now" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
119 soonestdly = datetime.timedelta(0) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
120 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
121 #print "Returning " + str(soonestexp) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
122 return soonestexp, soonestdly |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
123 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
124 def getsweep(inst, conf): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
125 print " Sending configuration" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
126 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
127 for k in conf: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
128 #time.sleep(0.3) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
129 inst.setconf(k, conf[k]) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
130 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
131 # Otherwise the R&S doens't respond.. |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
132 #time.sleep(0.3) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
133 rconf = inst.dumpconf() |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
134 fstart = rconf['fstart'] |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
135 fstop = rconf['fstop'] |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
136 print " Configuration is " + str(rconf) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
137 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
138 print " Fetching trace" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
139 yaxis = inst.gettrace() |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
140 xaxis = numpy.arange(fstart, fstop, (fstop - fstart) / yaxis.shape[0]) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
141 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
142 return xaxis, yaxis, rconf |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
143 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
144 def savesweep(fname, exp, x, y): |
32
660a2997e720
Don't put timestamp_hex & _dec in the data file.
Daniel O'Connor <darius@dons.net.au>
parents:
31
diff
changeset
|
145 print " Saving to " + fname |
31
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
146 f = open(fname, 'wb') |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
147 for k in exp: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
148 f.write("%s %s\n" % (k.upper(), str(exp[k]))) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
149 f.write("XDATA ") |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
150 numpy.savetxt(f, [x], delimiter = ', ', fmt = '%.3f') # Produces a trailing \n |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
151 f.write("YDATA ") |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
152 numpy.savetxt(f, [y], delimiter = ', ', fmt = '%.3f') |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
153 del f |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
154 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
155 def total_seconds(td): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
156 return (td.microseconds + (td.seconds + td.days * 24.0 * 3600.0) * 10.0**6) / 10.0**6 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
157 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
158 if __name__ == '__main__': |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
159 # Read in config file(s) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
160 conf = ConfigParser.SafeConfigParser(defaults) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
161 r = conf.read(map(lambda a: os.path.join(a, confname), confpaths)) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
162 if len(r) == 0: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
163 print "Unable to find any configuration file(s)" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
164 sys.exit(1) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
165 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
166 if not conf.has_section('general'): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
167 print "Configuration file doesn't have a 'general' section" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
168 sys.exit(1) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
169 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
170 if not conf.has_option('general', 'url'): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
171 print "Configuration file doesn't have a 'url' option in the 'general' section" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
172 sys.exit(1) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
173 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
174 if not conf.has_option('general', 'type'): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
175 print "Configuration file doesn't have a 'type' option in the 'general' section" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
176 sys.exit(1) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
177 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
178 if not conf.has_option('general', 'sequence'): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
179 print "Configuration file doesn't have a 'sequence' option in the 'general' section" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
180 sys.exit(1) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
181 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
182 if not conf.has_option('general', 'fname'): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
183 print "Configuration file doesn't have a 'fname' option in the 'general' section" |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
184 sys.exit(1) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
185 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
186 if conf.has_option('general', 'ampcal'): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
187 ampcal = CalFile(conf.get('general', 'ampcal')) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
188 else: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
189 ampcal = None |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
190 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
191 if conf.has_option('general', 'antcal'): |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
192 antcal = CalFile(conf.get('general', 'antcal')) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
193 else: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
194 antcal = None |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
195 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
196 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
197 sequence = [] |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
198 seqnames = conf.get('general', 'sequence').split() |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
199 for e in seqnames: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
200 sequence.append(Experiment(conf, e)) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
201 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
202 url = conf.get('general', 'url') |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
203 insttype = conf.get('general', 'type') |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
204 fnamefmt = conf.get('general', 'fname') |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
205 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
206 # Connect to the instrument |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
207 print "Connecting to " + url |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
208 con = scpi.instURL(url) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
209 con.write("*IDN?") |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
210 idn = con.read() |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
211 print "Instrument is a " + idn |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
212 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
213 # Get class for this instrument & instantiate it |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
214 inst = specan.getInst(insttype)(con) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
215 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
216 while True: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
217 # Find the next experiment to run |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
218 exp, dly = getexpt(sequence) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
219 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
220 # Sleep if necessary |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
221 dly = total_seconds(dly) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
222 if dly > 1: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
223 print "Sleeping for %.1f seconds" % (dly) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
224 time.sleep(dly) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
225 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
226 # Run it |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
227 print "--> Running experiment " + str(exp) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
228 freqs, power, opts = getsweep(inst, exp.opts) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
229 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
230 # Adjust power based on amplifier and antenna calibration |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
231 if ampcal != None: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
232 adj = ampcal.interp(freqs) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
233 power = power - adj |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
234 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
235 if antcal != None: |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
236 adj = antcal.interp(freqs) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
237 power = power - adj |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
238 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
239 # Update last run time |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
240 exp.last_run = datetime.datetime.utcnow() |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
241 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
242 # Add some informative params |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
243 tsepoch = calendar.timegm(exp.last_run.utctimetuple()) |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
244 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
245 extras = { 'timestamp' : exp.last_run, |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
246 'tag' : exp.name, |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
247 } |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
248 opts = dict(opts.items() + extras.items()) |
32
660a2997e720
Don't put timestamp_hex & _dec in the data file.
Daniel O'Connor <darius@dons.net.au>
parents:
31
diff
changeset
|
249 |
660a2997e720
Don't put timestamp_hex & _dec in the data file.
Daniel O'Connor <darius@dons.net.au>
parents:
31
diff
changeset
|
250 fmtextras = { 'timestamp_hex' : '%08x' % (tsepoch), |
660a2997e720
Don't put timestamp_hex & _dec in the data file.
Daniel O'Connor <darius@dons.net.au>
parents:
31
diff
changeset
|
251 'timestamp_dec' : '%d' % (tsepoch), |
660a2997e720
Don't put timestamp_hex & _dec in the data file.
Daniel O'Connor <darius@dons.net.au>
parents:
31
diff
changeset
|
252 'fstart_mhz' : '%.1f' % (float(opts['fstart']) / 1e6), |
660a2997e720
Don't put timestamp_hex & _dec in the data file.
Daniel O'Connor <darius@dons.net.au>
parents:
31
diff
changeset
|
253 'fstop_mhz' : '%.1f' % (float(opts['fstop']) / 1e6), |
660a2997e720
Don't put timestamp_hex & _dec in the data file.
Daniel O'Connor <darius@dons.net.au>
parents:
31
diff
changeset
|
254 } |
660a2997e720
Don't put timestamp_hex & _dec in the data file.
Daniel O'Connor <darius@dons.net.au>
parents:
31
diff
changeset
|
255 fmtopts = dict(opts.items() + fmtextras.items()) |
660a2997e720
Don't put timestamp_hex & _dec in the data file.
Daniel O'Connor <darius@dons.net.au>
parents:
31
diff
changeset
|
256 fname = fnamefmt % fmtopts |
31
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
257 |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
258 # Save data |
c6c86dcb54ba
Add code to automate a sitesurvey (to some degree).
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
259 savesweep(fname, opts, freqs, power) |