Module ammosreader.PPDWContainer
Expand source code
import numpy as np
from datetime import datetime
class PPDWContainer():
"""
I store multiple signals imported from one or more .ppdw files
.. automethod:: __init__
"""
def __init__(self, name, signals=None):
if signals is None:
self.signals = []
else:
self.signals = signals
def __str__(self):
return "\n".join(["Number of pulses:" + str(len(self.signals)),
"Start time:" + str(self.start_time()),
"End time:" + str(self.end_time())])
def add(self, a_pdw):
self.signals.append(a_pdw)
def julian_date_string(self):
ts = (self.start_time() - np.datetime64('1970-01-01T00:00:00')) / np.timedelta64(1, 's')
time_tuple = datetime.utcfromtimestamp(ts).timetuple()
return str(time_tuple.tm_year)[2:] + str(time_tuple.tm_yday).zfill(3)
def center_frequencies(self):
return list({each.center_frequency for each in self.signals})
def channels(self):
return list({each.channel for each in self.signals})
def modulations(self):
return list({each.modulation for each in self.signals})
def bandwidths(self):
return list({each.frequency_shift_or_bandwidth for each in self.signals})
def start_time(self):
return min([each.time_of_arrival for each in self.signals])
def end_time(self):
return max([each.time_of_arrival for each in self.signals])
def to_json(self):
return {'JULIANDATE': self.julian_date_string(),
'STARTTIME': str(self.start_time()),
'ENDTIME': str(self.end_time()),
# 'CENTERFREQUENCIES': self.center_frequencies(),
'CHANNELS': self.channels()
# 'MODULATIONS': self.modulations(),
# 'BANDWIDTHS': self.bandwidths()
}
if __name__ == '__main__':
pass
Classes
class PPDWContainer (name, signals=None)
-
I store multiple signals imported from one or more .ppdw files
Automethod: init
Expand source code
class PPDWContainer(): """ I store multiple signals imported from one or more .ppdw files .. automethod:: __init__ """ def __init__(self, name, signals=None): if signals is None: self.signals = [] else: self.signals = signals def __str__(self): return "\n".join(["Number of pulses:" + str(len(self.signals)), "Start time:" + str(self.start_time()), "End time:" + str(self.end_time())]) def add(self, a_pdw): self.signals.append(a_pdw) def julian_date_string(self): ts = (self.start_time() - np.datetime64('1970-01-01T00:00:00')) / np.timedelta64(1, 's') time_tuple = datetime.utcfromtimestamp(ts).timetuple() return str(time_tuple.tm_year)[2:] + str(time_tuple.tm_yday).zfill(3) def center_frequencies(self): return list({each.center_frequency for each in self.signals}) def channels(self): return list({each.channel for each in self.signals}) def modulations(self): return list({each.modulation for each in self.signals}) def bandwidths(self): return list({each.frequency_shift_or_bandwidth for each in self.signals}) def start_time(self): return min([each.time_of_arrival for each in self.signals]) def end_time(self): return max([each.time_of_arrival for each in self.signals]) def to_json(self): return {'JULIANDATE': self.julian_date_string(), 'STARTTIME': str(self.start_time()), 'ENDTIME': str(self.end_time()), # 'CENTERFREQUENCIES': self.center_frequencies(), 'CHANNELS': self.channels() # 'MODULATIONS': self.modulations(), # 'BANDWIDTHS': self.bandwidths() }
Methods
def add(self, a_pdw)
-
Expand source code
def add(self, a_pdw): self.signals.append(a_pdw)
def bandwidths(self)
-
Expand source code
def bandwidths(self): return list({each.frequency_shift_or_bandwidth for each in self.signals})
def center_frequencies(self)
-
Expand source code
def center_frequencies(self): return list({each.center_frequency for each in self.signals})
def channels(self)
-
Expand source code
def channels(self): return list({each.channel for each in self.signals})
def end_time(self)
-
Expand source code
def end_time(self): return max([each.time_of_arrival for each in self.signals])
def julian_date_string(self)
-
Expand source code
def julian_date_string(self): ts = (self.start_time() - np.datetime64('1970-01-01T00:00:00')) / np.timedelta64(1, 's') time_tuple = datetime.utcfromtimestamp(ts).timetuple() return str(time_tuple.tm_year)[2:] + str(time_tuple.tm_yday).zfill(3)
def modulations(self)
-
Expand source code
def modulations(self): return list({each.modulation for each in self.signals})
def start_time(self)
-
Expand source code
def start_time(self): return min([each.time_of_arrival for each in self.signals])
def to_json(self)
-
Expand source code
def to_json(self): return {'JULIANDATE': self.julian_date_string(), 'STARTTIME': str(self.start_time()), 'ENDTIME': str(self.end_time()), # 'CENTERFREQUENCIES': self.center_frequencies(), 'CHANNELS': self.channels() # 'MODULATIONS': self.modulations(), # 'BANDWIDTHS': self.bandwidths() }