3 # Copyright 2003,2004,2005 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
29 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37 # Simple class for allowing local definition of a calibration function
38 # for raw samples coming from the RA detector chain. Each observatory
39 # is different, and rather than hacking up the main code in usrp_ra_receiver
40 # we define the appropriate function here.
42 # For example, one could calibrate the output in Janskys, rather than
47 def calib_default_total_power(data):
48 r = 10.0*math.log10(data)
51 def calib_numogate_ridge_observatory_total_power(data):
56 # PyEphem wants lat/long as strings, rather than floats--took me quite
57 # a long time to figure that out. If they don't arrive as strings,
58 # the calculations for sidereal time are complete garbage
60 me.long = globals()["calib_long"]
61 me.lat = globals()["calib_lat"]
64 sidtime = me.sidereal_time()
66 foo = time.localtime()
67 if not "calib_prefix" in globals():
70 pfx = globals()["calib_prefix"]
71 filenamestr = "%s/%04d%02d%02d%02d" % (pfx, foo.tm_year,
72 foo.tm_mon, foo.tm_mday, foo.tm_hour)
74 numogate_file = open (filenamestr+".tpdat","a")
78 #r = calib_default_total_power(data)
79 inter = globals()["calib_decln"]
80 integ = globals()["calib_integ_setting"]
81 fc = globals()["calib_freq_setting"]
83 bw = globals()["calib_bw_setting"]
85 ga = globals()["calib_gain_setting"]
89 if not "calib_then_tpdat" in globals():
90 globals()["calib_then_tpdat"] = now
92 if (now - globals()["calib_then_tpdat"]) >= 20:
93 globals()["calib_then_tpdat"] = now
95 numogate_file.write(str(ephem.hours(sidtime))+" "+flt+" Dn="+str(inter)+",")
96 numogate_file.write("Ti="+str(integ)+",Fc="+str(fc)+",Bw="+str(bw))
97 numogate_file.write(",Ga="+str(ga)+"\n")
99 numogate_file.write(str(ephem.hours(sidtime))+" "+flt+"\n")
101 numogate_file.close()
104 def calib_numogate_ridge_observatory_fft(data,l):
106 me = ephem.Observer()
109 # PyEphem wants lat/long as strings, rather than floats--took me quite
110 # a long time to figure that out. If they don't arrive as strings,
111 # the calculations for sidereal time are complete garbage
113 me.long = globals()["calib_long"]
114 me.lat = globals()["calib_lat"]
116 me.date = ephem.now()
117 sidtime = me.sidereal_time()
119 foo = time.localtime()
121 if not "calib_prefix" in globals():
124 pfx = globals()["calib_prefix"]
125 filenamestr = "%s/%04d%02d%02d%02d" % (pfx, foo.tm_year,
126 foo.tm_mon, foo.tm_mday, foo.tm_hour)
130 if not "calib_then" in globals():
131 globals()["calib_then"] = now
135 if (now - globals()["calib_then"]) >= delta:
137 globals()["calib_then"] = now
138 numogate_file = open (filenamestr+".sdat","a")
141 inter = globals()["calib_decln"]
142 fc = globals()["calib_freq_setting"]
144 bw = globals()["calib_bw_setting"]
146 av = globals()["calib_avg_alpha"]
147 numogate_file.write("data:"+str(ephem.hours(sidtime))+" Dn="+str(inter)+",Fc="+str(fc)+",Bw="+str(bw)+",Av="+str(av))
148 numogate_file.write(" "+str(r)+"\n")
149 numogate_file.close()
154 def calib_default_fft(db,l):
158 # We capture various parameters from the receive chain here, because
159 # they can affect the calibration equations.
162 def calib_set_gain(gain):
163 globals()["calib_gain_setting"] = gain
164 globals()["calib_then_tpdat"] = time.time() - 50
166 def calib_set_integ(integ):
167 globals()["calib_integ_setting"] = integ
168 globals()["calib_then_tpdat"] = time.time() - 50
170 def calib_set_bw(bw):
171 globals()["calib_bw_setting"] = bw
172 globals()["calib_then_tpdat"] = time.time() - 50
174 def calib_set_freq(freq):
175 globals()["calib_freq_setting"] = freq
176 globals()["calib_then_tpdat"] = time.time() - 50
178 def calib_set_avg_alpha(alpha):
179 globals()["calib_avg_alpha"] = alpha
181 def calib_set_interesting(inter):
182 globals()["calib_is_interesting"] = inter
184 def calib_set_decln(dec):
185 globals()["calib_decln"] = dec
186 globals()["calib_then_tpdat"] = time.time() - 50
188 def calib_set_prefix(pfx):
189 globals()["calib_prefix"] = pfx
191 def calib_set_long(long):
192 globals()["calib_long"] = long
194 def calib_set_lat(lat):
195 globals()["calib_lat"] = lat