-
Notifications
You must be signed in to change notification settings - Fork 2
Loading Files
The raw Schottky signals in the Radio Frequency (RF) range, after being mixed with a reference sinusoid down to the Intermediate Frequency (IF), are sampled and digitized by the spectrum analyzer into the so-called IQ (In-phase & Quadrature) data. Those data are then continuously streamed to the disk to form individual data files of various sizes according to the preset acquisition parameters.
Currently two file formats, namely the wv
and the tiq
, are supported by the script preprocessing.py
, in which a dedicated class Preprocessing
handles the IO interface with those kinds of files.
Apart from reading IQ pairs from the data block, the class is also capable of extracting the acquisition-relevant meta-data from the header section, and parsing them in a suitable manner.
The digital Schottky signal can thus be re-constructed from the combined information of IQ pairs and meta-data.
Preprocessing(file_str, verbose=True)
Instantiate the class.
-
arguments:
-
file_str
: str
Name of the data file. The file format can only be recognized from the file extension, which is case insensitive.*.tiq
implies atiq
file;*.wvh
or*.wvd
implies awv
file. -
verbose
: bool, default True
If True, print the data acquisition parameters onto the screen.
-
To divert the IO load when the file is extremely large so as to improve the executive efficiency, the class sets an upper limit on the IQ pairs to be read at once, as is specified with a global attribute n_buffer
.
Its default value is 0.1 million.
extract_wv()
Extract the meta-data from a
wv
file and parse them.
-
arguments:
None
-
returns:
-
None
The parsed meta-data are stored as class attributes. Some frequently referred ones can beref_level
[dBm],center_frequency
[Hz],span
[Hz], andsampling_rate
[Hz].
-
extract_tiq()
Extract the meta-data from a
tiq
file and parse them.
-
arguments:
None
-
returns:
-
None
The parsed meta-data are stored as class attributes. Some frequently referred ones can beref_level
[dBm],center_frequency
[Hz],span
[Hz], andsampling_rate
[Hz].
-
display()
Print all the data acquisition parameters onto the screen. The displayed message is file-format-aware.
-
arguments:
None
-
returns:
None
load(size, offset, decimating_factor=1, draw=False)
Load a number of IQ pairs from the file starting at the beginning with an offset. The actual loaded data size may be smaller than the given one, due to the insufficient samples in the file. In such a case, the remaining samples from the offset will all be loaded. The IQ pairs may also be loaded in a stride mode, where only one pair is adopted among every a few other contiguous pairs.
-
arguments:
-
size
: int
Number of IQ pairs to be loaded. -
offset
: int
Offset from the beginning of the file where the data start to load. -
decimating_factor
: int, default 1
The stride distance between two neighboring IQ pairs to be loaded. 1 means contiguous loading. Ifdecimating_factor
is larger than 1, thesize
still counts the total number of loaded IQ pairs. -
draw
: bool, default False
If True, also plot the loaded IQ pairs.
-
-
returns:
-
times
: numpy array
A real array of time stamps in units of second. -
data
: numpy array
A complex array of data sequences in units of volt.
-
draw(t, signal)
Plot the signal in the in-phase and quadrature parts as a function of time.
-
arguments:
-
t
: numpy array
A real array specifying the time. -
signal
: numpy array
A complex array specifying the signal.
-
-
returns:
None
diagnosis(n_point=None, draw=True)
Inspect the acquired data in a file by plotting them in the in-phase and quadrature parts.
-
arguments:
-
n_point
: int, default None
If None,n_point
will be set ton_buffer
. If negative, plot all the data contained in the file, after divided into a few segments in compliance with then_buffer
constraint. Otherwise, plot the decimated data, if necessary, with size no more thann_point
from the beginning of the file through the end. -
draw
: bool, default True
If True, also plot the data in the file.
-
-
returns:
-
times
: numpy array, optional
Ifn_point
is None or positive, return a real array of time stamps in units of second. -
data
: numpy array, optional
Ifn_point
is None or positive, return a complex array of data sequences in units of volt.
-