kopia lustrzana https://github.com/rs1729/RS
dft_detect: option -d2, detect twice
rodzic
81eeb0f84c
commit
08af407e24
|
@ -0,0 +1,101 @@
|
||||||
|
|
||||||
|
## detect radiosonde type
|
||||||
|
|
||||||
|
#### Files
|
||||||
|
|
||||||
|
* `dft_detect.c`
|
||||||
|
|
||||||
|
#### Compile
|
||||||
|
`gcc dft_detect.c -lm -o dft_detect`
|
||||||
|
|
||||||
|
#### Usage
|
||||||
|
`./dft_detect [options] <file>` <br />
|
||||||
|
options:<br />
|
||||||
|
`--IQ <fq>` : IQ data input, where `<fq>` is the relative frequency in `-0.5..0.5` <br />
|
||||||
|
`-v` : sample count <br />
|
||||||
|
`-c` : continuous output<br />
|
||||||
|
`-t <sec>` : time limit <br />
|
||||||
|
|
||||||
|
(input `<file>` can be `stdin`)
|
||||||
|
<br />
|
||||||
|
|
||||||
|
FM data:<br />
|
||||||
|
`./dft_detect <fm_audio.wav>` <br />
|
||||||
|
|
||||||
|
IQ data:<br />
|
||||||
|
`./dft_detect --IQ <fq> <iq_data.wav>` <br />
|
||||||
|
For IQ data (i.e. 2 channels) it is possible to read raw data (without wav header): <br />
|
||||||
|
`./dft_detect --IQ <fq> - <sr> <bs> <iq_data.raw>` <br />
|
||||||
|
where <br />
|
||||||
|
`<sr>` : sample rate <br />
|
||||||
|
`<bs>=8,16,32` : bits per (real) sample (u8, s16 or f32)
|
||||||
|
|
||||||
|
`dft_detect` stops, if a (potential) radiosonde signal is detected, or if a time limit is set with option `-t`. <br />
|
||||||
|
With option `-c` detection is continued, but a time limit can be set with `-t`.
|
||||||
|
|
||||||
|
Output is of the form `<TYPE>: <score>` where the correlation score is a normalized value in `-1..+1`.
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
|
||||||
|
Ex.1
|
||||||
|
```
|
||||||
|
$ ./dft_detect fm_audio.wav
|
||||||
|
sample_rate: 48000
|
||||||
|
bits : 8
|
||||||
|
channels : 1
|
||||||
|
RS41: 0.9885
|
||||||
|
```
|
||||||
|
Ex.2
|
||||||
|
```
|
||||||
|
$ ./dft_detect -c fm_audio.wav 2>/dev/null
|
||||||
|
RS41: 0.9885
|
||||||
|
RS41: 0.9851
|
||||||
|
RS41: 0.9784
|
||||||
|
RS41: 0.9869
|
||||||
|
RS41: 0.9845
|
||||||
|
RS41: 0.9828
|
||||||
|
RS41: 0.9814
|
||||||
|
RS41: 0.9821
|
||||||
|
RS41: 0.9823
|
||||||
|
RS41: 0.9882
|
||||||
|
[...]
|
||||||
|
```
|
||||||
|
|
||||||
|
Ex.3
|
||||||
|
```
|
||||||
|
$ ./dft_detect -c -t 4 fm_audio.wav 2>/dev/null
|
||||||
|
RS41: 0.9885
|
||||||
|
RS41: 0.9851
|
||||||
|
RS41: 0.9784
|
||||||
|
RS41: 0.9869
|
||||||
|
RS41: 0.9845
|
||||||
|
```
|
||||||
|
|
||||||
|
Ex.4
|
||||||
|
```
|
||||||
|
$ ./dft_detect -v -c -t 2 fm_audio.wav 2>/dev/null
|
||||||
|
sample: 39801
|
||||||
|
RS41: 0.9885
|
||||||
|
sample: 87824
|
||||||
|
RS41: 0.9851
|
||||||
|
sample: 135831
|
||||||
|
RS41: 0.9784
|
||||||
|
```
|
||||||
|
|
||||||
|
Ex.5<br />
|
||||||
|
Some radiosonde types have similar signals, false detection is possible.
|
||||||
|
```
|
||||||
|
$ ./dft_detect -c -t 4 fm_meisei.wav 2>/dev/null
|
||||||
|
MEISEI: 0.9802
|
||||||
|
MRZ: -0.9720
|
||||||
|
MEISEI: 0.9829
|
||||||
|
```
|
||||||
|
Here a Meisei radiosonde seems to be more likely.
|
||||||
|
|
||||||
|
Ex.6<br />
|
||||||
|
Confirmed detection (two hits):
|
||||||
|
```
|
||||||
|
$ ./dft_detect -d2 -t 4 fm_meisei.wav 2>/dev/null
|
||||||
|
MEISEI: 0.9829
|
||||||
|
```
|
||||||
|
|
|
@ -32,6 +32,7 @@ static int option_verbose = 0, // ausfuehrliche Anzeige
|
||||||
option_dc = 0,
|
option_dc = 0,
|
||||||
option_silent = 0,
|
option_silent = 0,
|
||||||
option_cont = 0,
|
option_cont = 0,
|
||||||
|
option_d2 = 0,
|
||||||
option_pcmraw = 0,
|
option_pcmraw = 0,
|
||||||
option_singleLpIQ = 0,
|
option_singleLpIQ = 0,
|
||||||
wavloaded = 0;
|
wavloaded = 0;
|
||||||
|
@ -178,6 +179,23 @@ static int idx_MTS01 = -1,
|
||||||
idx_IMET1AB = -1;
|
idx_IMET1AB = -1;
|
||||||
|
|
||||||
|
|
||||||
|
static int rs_detect2[Nrs];
|
||||||
|
|
||||||
|
static int rs_d2() {
|
||||||
|
int tn = 0;
|
||||||
|
for (tn = 0; tn < Nrs; tn++) {
|
||||||
|
if ( rs_detect2[tn] > 1 ) break;
|
||||||
|
}
|
||||||
|
return tn;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int reset_d2() {
|
||||||
|
int n = 0;
|
||||||
|
for (n = 0; n < Nrs; n++) rs_detect2[n] = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// m10-false-positive:
|
// m10-false-positive:
|
||||||
// m10-preamble similar to rs41-preamble, parts of rs92/imet1ab, imet1ab; diffs:
|
// m10-preamble similar to rs41-preamble, parts of rs92/imet1ab, imet1ab; diffs:
|
||||||
|
@ -1302,6 +1320,8 @@ int main(int argc, char **argv) {
|
||||||
int j_max;
|
int j_max;
|
||||||
float mv_max;
|
float mv_max;
|
||||||
|
|
||||||
|
int d2_tn = Nrs;
|
||||||
|
|
||||||
|
|
||||||
#ifdef CYGWIN
|
#ifdef CYGWIN
|
||||||
_setmode(fileno(stdin), _O_BINARY); // _setmode(_fileno(stdin), _O_BINARY);
|
_setmode(fileno(stdin), _O_BINARY); // _setmode(_fileno(stdin), _O_BINARY);
|
||||||
|
@ -1364,6 +1384,9 @@ int main(int argc, char **argv) {
|
||||||
if (*argv) tl = atof(*argv);
|
if (*argv) tl = atof(*argv);
|
||||||
else return -50;
|
else return -50;
|
||||||
}
|
}
|
||||||
|
else if ( (strcmp(*argv, "-d2") == 0) ) {
|
||||||
|
option_d2 = 1;
|
||||||
|
}
|
||||||
else if ( (strcmp(*argv, "--ch2") == 0) ) { wav_channel = 1; } // right channel (default: 0=left)
|
else if ( (strcmp(*argv, "--ch2") == 0) ) { wav_channel = 1; } // right channel (default: 0=left)
|
||||||
else if ( (strcmp(*argv, "--ths") == 0) ) {
|
else if ( (strcmp(*argv, "--ths") == 0) ) {
|
||||||
++argv;
|
++argv;
|
||||||
|
@ -1397,6 +1420,9 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
if (!wavloaded) fp = stdin;
|
if (!wavloaded) fp = stdin;
|
||||||
|
|
||||||
|
if (option_d2) {
|
||||||
|
option_cont = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (option_pcmraw == 0) {
|
if (option_pcmraw == 0) {
|
||||||
j = read_wav_header(fp, wav_channel);
|
j = read_wav_header(fp, wav_channel);
|
||||||
|
@ -1547,16 +1573,23 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if (header_found) {
|
if (header_found) {
|
||||||
if (!option_silent && (mv[j] > rs_hdr[j].thres || mv[j] < -rs_hdr[j].thres)) {
|
if (!option_silent && (mv[j] > rs_hdr[j].thres || mv[j] < -rs_hdr[j].thres)) {
|
||||||
if (option_verbose) fprintf(stdout, "sample: %d\n", mv_pos[j]);
|
if (option_d2) {
|
||||||
fprintf(stdout, "%s: %.4f", rs_hdr[j].type, mv[j]);
|
rs_detect2[j] += 1;
|
||||||
if (option_dc && option_iq) {
|
d2_tn = rs_d2();
|
||||||
fprintf(stdout, " , %+.1fHz", rs_hdr[j].df*sr_base);
|
if ( d2_tn == Nrs ) header_found = 0;
|
||||||
if (option_verbose) {
|
}
|
||||||
fprintf(stdout, " [ fq-ofs: %+.6f", rs_hdr[j].df);
|
if ( !option_d2 || j == d2_tn ) {
|
||||||
fprintf(stdout, " = %+.1fHz ]", rs_hdr[j].df*sr_base);
|
if (option_verbose) fprintf(stdout, "sample: %d\n", mv_pos[j]);
|
||||||
}
|
fprintf(stdout, "%s: %.4f", rs_hdr[j].type, mv[j]);
|
||||||
|
if (option_dc && option_iq) {
|
||||||
|
fprintf(stdout, " , %+.1fHz", rs_hdr[j].df*sr_base);
|
||||||
|
if (option_verbose) {
|
||||||
|
fprintf(stdout, " [ fq-ofs: %+.6f", rs_hdr[j].df);
|
||||||
|
fprintf(stdout, " = %+.1fHz ]", rs_hdr[j].df*sr_base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stdout, "\n");
|
||||||
}
|
}
|
||||||
fprintf(stdout, "\n");
|
|
||||||
}
|
}
|
||||||
// if ((j < 3) && mv[j] < 0) header_found = -1;
|
// if ((j < 3) && mv[j] < 0) header_found = -1;
|
||||||
|
|
||||||
|
@ -1570,7 +1603,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header_found && !option_cont) break;
|
if (header_found && !option_cont || d2_tn < Nrs) break;
|
||||||
header_found = 0;
|
header_found = 0;
|
||||||
for (j = 0; j < Nrs; j++) mv[j] = 0.0;
|
for (j = 0; j < Nrs; j++) mv[j] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue