Commit eabd2c89 authored by George Vardakis's avatar George Vardakis

Remove split option and increase height size in APT sink block

parent 4f45abaf
Pipeline #17003772 passed with stage
in 10 minutes and 19 seconds
<?xml version='1.0' encoding='utf-8'?>
<?grc format='1' created='3.7.11'?>
<?grc format='1' created='3.7.12'?>
<flow_graph>
<timestamp>Mon Apr 10 23:26:02 2017</timestamp>
<block>
......@@ -72,6 +72,10 @@
<key>run</key>
<value>True</value>
</param>
<param>
<key>sizing_mode</key>
<value>fixed</value>
</param>
<param>
<key>thread_safe_setters</key>
<value></value>
......@@ -80,6 +84,10 @@
<key>title</key>
<value>NOAA APT Decoder</value>
</param>
<param>
<key>placement</key>
<value>(0,0)</value>
</param>
</block>
<block>
<key>variable</key>
......@@ -370,6 +378,10 @@ TX sampling rate</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>string</value>
......@@ -492,6 +504,10 @@ TX sampling rate</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>eng_float</value>
......@@ -578,6 +594,10 @@ TX sampling rate</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>string</value>
......@@ -621,6 +641,10 @@ TX sampling rate</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>string</value>
......@@ -664,6 +688,10 @@ TX sampling rate</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>intx</value>
......@@ -707,6 +735,10 @@ TX sampling rate</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>intx</value>
......@@ -809,6 +841,10 @@ TX sampling rate</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>string</value>
......@@ -889,7 +925,7 @@ TX sampling rate</value>
</param>
<param>
<key>_coordinate</key>
<value>(472, 716)</value>
<value>(312, 716)</value>
</param>
<param>
<key>_rotation</key>
......@@ -907,6 +943,10 @@ TX sampling rate</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>intx</value>
......@@ -1060,6 +1100,10 @@ TX sampling rate</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>eng_float</value>
......@@ -1103,6 +1147,10 @@ TX sampling rate</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>string</value>
......@@ -1147,6 +1195,10 @@ we shift the LO a little further</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>eng_float</value>
......@@ -2597,6 +2649,10 @@ we shift the LO a little further</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>intx</value>
......@@ -2876,6 +2932,10 @@ we shift the LO a little further</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>eng_float</value>
......@@ -2919,6 +2979,10 @@ we shift the LO a little further</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>intx</value>
......@@ -2962,6 +3026,10 @@ we shift the LO a little further</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>eng_float</value>
......@@ -3005,6 +3073,10 @@ we shift the LO a little further</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>string</value>
......@@ -3034,7 +3106,7 @@ we shift the LO a little further</value>
</param>
<param>
<key>_coordinate</key>
<value>(471, 119)</value>
<value>(464, 176)</value>
</param>
<param>
<key>_rotation</key>
......@@ -3148,16 +3220,12 @@ we shift the LO a little further</value>
</param>
<param>
<key>height</key>
<value>1500</value>
<value>1800</value>
</param>
<param>
<key>width</key>
<value>2080</value>
</param>
<param>
<key>split</key>
<value>bool(split_images)</value>
</param>
<param>
<key>sync</key>
<value>bool(sync)</value>
......@@ -3320,49 +3388,6 @@ we shift the LO a little further</value>
<value>samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth))</value>
</param>
</block>
<block>
<key>parameter</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(304, 716)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>split_images</value>
</param>
<param>
<key>label</key>
<value></value>
</param>
<param>
<key>short_id</key>
<value></value>
</param>
<param>
<key>type</key>
<value>intx</value>
</param>
<param>
<key>value</key>
<value>0</value>
</param>
</block>
<block>
<key>parameter</key>
<param>
......@@ -3397,6 +3422,10 @@ we shift the LO a little further</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>intx</value>
......@@ -3440,6 +3469,10 @@ we shift the LO a little further</value>
<key>short_id</key>
<value></value>
</param>
<param>
<key>hide</key>
<value>none</value>
</param>
<param>
<key>type</key>
<value>string</value>
......
......@@ -5,7 +5,7 @@
# Title: NOAA APT Decoder
# Author: Manolis Surligas, George Vardakis
# Description: A NOAA APT Decoder with automatic image synchronization
# Generated: Fri Jan 19 21:55:37 2018
# Generated: Fri Feb 2 16:19:42 2018
##################################################
from gnuradio import analog
......@@ -23,7 +23,7 @@ import time
class satnogs_noaa_apt_decoder(gr.top_block):
def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/noaa', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=20, enable_iq_dump=0, file_path='/tmp/test.ogg', flip_images=0, if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=90.4e6, rx_sdr_device='usrpb200', split_images=0, sync=1, waterfall_file_path='/tmp/waterfall.dat'):
def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/noaa', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=20, enable_iq_dump=0, file_path='/tmp/test.ogg', flip_images=0, if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=90.4e6, rx_sdr_device='usrpb200', sync=1, waterfall_file_path='/tmp/waterfall.dat'):
gr.top_block.__init__(self, "NOAA APT Decoder")
##################################################
......@@ -45,7 +45,6 @@ class satnogs_noaa_apt_decoder(gr.top_block):
self.rigctl_port = rigctl_port
self.rx_freq = rx_freq
self.rx_sdr_device = rx_sdr_device
self.split_images = split_images
self.sync = sync
self.waterfall_file_path = waterfall_file_path
......@@ -69,7 +68,7 @@ class satnogs_noaa_apt_decoder(gr.top_block):
self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)), 0.0, 8, 1024, waterfall_file_path, 0)
self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, 1000/doppler_correction_per_sec, 1500)
self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(file_path, 48000, 0.8)
self.satnogs_noaa_apt_sink_0 = satnogs.noaa_apt_sink(decoded_data_file_path, 2080, 1500, bool(split_images), bool(sync), bool(flip_images))
self.satnogs_noaa_apt_sink_0 = satnogs.noaa_apt_sink(decoded_data_file_path, 2080, 1800, bool(sync), bool(flip_images))
self.satnogs_iq_sink_0 = satnogs.iq_sink(32767, iq_file_path, False, enable_iq_dump)
self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx /first_stage_decimation)
self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
......@@ -123,6 +122,8 @@ class satnogs_noaa_apt_decoder(gr.top_block):
audio_decimation=audio_decimation,
)
##################################################
# Connections
##################################################
......@@ -254,12 +255,6 @@ class satnogs_noaa_apt_decoder(gr.top_block):
self.osmosdr_source_0.set_bb_gain(satnogs.handle_rx_bb_gain(self.rx_sdr_device, self.bb_gain), 0)
self.osmosdr_source_0.set_antenna(satnogs.handle_rx_antenna(self.rx_sdr_device, self.antenna), 0)
def get_split_images(self):
return self.split_images
def set_split_images(self, split_images):
self.split_images = split_images
def get_sync(self):
return self.sync
......@@ -368,9 +363,6 @@ def argument_parser():
parser.add_option(
"", "--rx-sdr-device", dest="rx_sdr_device", type="string", default='usrpb200',
help="Set rx_sdr_device [default=%default]")
parser.add_option(
"", "--split-images", dest="split_images", type="intx", default=0,
help="Set split_images [default=%default]")
parser.add_option(
"", "--sync", dest="sync", type="intx", default=1,
help="Set sync [default=%default]")
......@@ -384,7 +376,7 @@ def main(top_block_cls=satnogs_noaa_apt_decoder, options=None):
if options is None:
options, _ = argument_parser().parse_args()
tb = top_block_cls(antenna=options.antenna, bb_gain=options.bb_gain, decoded_data_file_path=options.decoded_data_file_path, dev_args=options.dev_args, doppler_correction_per_sec=options.doppler_correction_per_sec, enable_iq_dump=options.enable_iq_dump, file_path=options.file_path, flip_images=options.flip_images, if_gain=options.if_gain, iq_file_path=options.iq_file_path, lo_offset=options.lo_offset, ppm=options.ppm, rf_gain=options.rf_gain, rigctl_port=options.rigctl_port, rx_freq=options.rx_freq, rx_sdr_device=options.rx_sdr_device, split_images=options.split_images, sync=options.sync, waterfall_file_path=options.waterfall_file_path)
tb = top_block_cls(antenna=options.antenna, bb_gain=options.bb_gain, decoded_data_file_path=options.decoded_data_file_path, dev_args=options.dev_args, doppler_correction_per_sec=options.doppler_correction_per_sec, enable_iq_dump=options.enable_iq_dump, file_path=options.file_path, flip_images=options.flip_images, if_gain=options.if_gain, iq_file_path=options.iq_file_path, lo_offset=options.lo_offset, ppm=options.ppm, rf_gain=options.rf_gain, rigctl_port=options.rigctl_port, rx_freq=options.rx_freq, rx_sdr_device=options.rx_sdr_device, sync=options.sync, waterfall_file_path=options.waterfall_file_path)
tb.start()
tb.wait()
......
......@@ -4,7 +4,7 @@
<key>satnogs_noaa_apt_sink</key>
<category>[SatNOGS]</category>
<import>import satnogs</import>
<make>satnogs.noaa_apt_sink($*filename_png, $width, $height, $split, $sync, $flip)</make>
<make>satnogs.noaa_apt_sink($*filename_png, $width, $height, $sync, $flip)</make>
<param>
<name>Output PNG Filename</name>
<key>filename_png</key>
......@@ -22,21 +22,7 @@
<key>height</key>
<value>1500</value>
<type>int</type>
</param>
<param>
<name>Split Images</name>
<key>split</key>
<value>False</value>
<type>bool</type>
<option>
<name>Yes</name>
<key>True</key>
</option>
<option>
<name>No</name>
<key>False</key>
</option>
</param>
</param>
<param>
<name>Synchronize</name>
<key>sync</key>
......
<?xml version="1.0"?>
<block>
<name>noaa_apt_sync</name>
<key>satnogs_noaa_apt_sync</key>
<category>[SatNOGS]</category>
<import>import satnogs</import>
<make>satnogs.noaa_apt_sync($*filename,$*filename_png, $width, $height, $split)</make>
<param>
<name>Output Data Filename</name>
<key>filename</key>
<value></value>
<type>file_save</type>
</param>
<param>
<name>Output PNG Filename</name>
<key>filename_png</key>
<value></value>
<type>file_save</type>
</param>
<param>
<name>PNG width</name>
<key>width</key>
<type>int</type>
</param>
<param>
<name>PNG height</name>
<key>height</key>
<type>int</type>
</param>
<param>
<name>Split Images</name>
<key>split</key>
<value>False</value>
<type>bool</type>
<hide>part</hide>
<option>
<name>Yes</name>
<key>True</key>
</option>
<option>
<name>No</name>
<key>False</key>
</option>
</param>
<sink>
<name>in</name>
<type>float</type>
</sink>
</block>
......@@ -68,7 +68,7 @@ namespace gr
*
*/
static sptr
make (const char *filename_png, size_t width, size_t height, bool split,
make (const char *filename_png, size_t width, size_t height,
bool sync, bool flip);
};
......
......@@ -60,10 +60,10 @@ namespace gr
noaa_apt_sink::sptr
noaa_apt_sink::make (const char *filename_png, size_t width, size_t height,
bool split, bool sync, bool flip)
bool sync, bool flip)
{
return gnuradio::get_initial_sptr (
new noaa_apt_sink_impl (filename_png, width, height, split, sync,
new noaa_apt_sink_impl (filename_png, width, height, sync,
flip));
}
......@@ -73,20 +73,19 @@ namespace gr
*/
noaa_apt_sink_impl::noaa_apt_sink_impl (const char *filename_png,
size_t width, size_t height,
bool split, bool sync, bool flip) :
bool sync, bool flip) :
gr::sync_block ("noaa_apt_sink",
gr::io_signature::make (1, 1, sizeof(float)),
gr::io_signature::make (0, 0, 0)),
f_average_alpha (0.25),
d_row_write_threshold (250),
d_filename_png (filename_png),
d_width (width),
d_height (height),
d_split (split),
d_synchronize_opt (sync),
d_flip (flip),
d_history_length (40),
d_has_sync (false),
d_image_received(false),
d_current_x (0),
d_current_y (0),
d_num_images (0),
......@@ -95,35 +94,9 @@ namespace gr
f_average(0.0)
{
set_history(d_history_length);
init_images();
d_full_image = png::image<png::gray_pixel>(d_width, d_height);
}
void
noaa_apt_sink_impl::init_images () {
// Split the filename option into path + filename and extension
// Construct numbered filename for the full image
d_full_filename = d_filename_png + std::to_string(d_num_images);
// Create a new empty png
d_full_image = png::image<png::gray_pixel>(d_width, d_height);
if(d_split) {
// In case split images are requested construct filenames for those as well
d_left_filename = d_filename_png + std::to_string(d_num_images)
+ "_left";
d_right_filename = d_filename_png + std::to_string(d_num_images)
+ "_right";
// Create new empty pngs for the split images
d_left_image = png::image<png::gray_pixel>(d_width/2, d_height);
d_right_image = png::image<png::gray_pixel>(d_width/2, d_height);
}
}
void
noaa_apt_sink_impl::write_image (png::image<png::gray_pixel> image,
std::string filename)
......@@ -153,48 +126,10 @@ namespace gr
}
}
void
noaa_apt_sink_impl::write_images () {
// Write out the full image
write_image(d_full_image, d_full_filename);
if(d_split) {
// Write out the split images if the split option is enabled
write_image(d_left_image, d_left_filename);
write_image(d_right_image, d_right_filename);
}
}
noaa_apt_sink_impl::~noaa_apt_sink_impl () {
// Nothing happens here
}
bool
noaa_apt_sink_impl::stop () {
// As a teardown action, the remaining pngs
//should be cropped to the correct size and written to disk
// Grab the buffers from the fullsize pngs
png::image<png::gray_pixel>::pixbuf buf_full_image = d_full_image.get_pixbuf();
png::image<png::gray_pixel>::pixbuf buf_left_image = d_left_image.get_pixbuf();
png::image<png::gray_pixel>::pixbuf buf_right_image = d_right_image.get_pixbuf();
// Create new smaller pngs using the old buffers
d_full_image = png::image<png::gray_pixel>(d_width, d_current_y + 1);
d_full_image.set_pixbuf(buf_full_image);
d_left_image = png::image<png::gray_pixel>(d_width/2, d_current_y + 1);
d_left_image .set_pixbuf(buf_left_image);
d_right_image = png::image<png::gray_pixel>(d_width/2, d_current_y + 1);
d_right_image.set_pixbuf(buf_right_image);
// Write the smaller images to disk
write_images();
return true;
if(!d_image_received){
write_image(d_full_image, d_filename_png);
}
}
......@@ -203,21 +138,8 @@ namespace gr
sample = (sample - f_min_level) / (f_max_level - f_min_level) * 255;
// Set the pixel in the full image
d_full_image.set_pixel(x, y, sample);
// Id the split otions is set
if(d_split) {
// Set the pixel in the right image,
// depending on its coordinate
if(x < d_width / 2) {
d_left_image.set_pixel(x, y, sample);
}
else {
d_right_image.set_pixel(x - d_width / 2, y, sample);
}
}
}
void
noaa_apt_sink_impl::skip_to (size_t new_x, size_t pos, const float *samples) {
// Check if the skip is forward or backward
......@@ -255,8 +177,6 @@ namespace gr
if((sample > 0 && syncb_seq[i]) || (sample < 0 && !syncb_seq[i])) {
count_b += 1;
}
}
// Prefer sync pattern a as it is detected more reliable
......@@ -278,6 +198,10 @@ namespace gr
gr_vector_void_star &output_items)
{
const float *in = (const float *) input_items[0];
/* If we have already produced one image, ignore the remaining observation*/
if(d_image_received){
return noutput_items;
}
// Structure of in[]:
// - d_history_length many historical samples
......@@ -336,17 +260,13 @@ namespace gr
// Reset x position to line start
d_current_x = 0;
// If there are enough lines decoded write the image to disk
if(d_current_y % d_row_write_threshold == 0) {
write_images();
}
// Split the image if there are enough lines decoded
if(d_current_y >= d_height) {
d_current_y = 0;
d_num_images += 1;
write_images();
init_images();
// Write out the full image
write_image(d_full_image, d_filename_png);
d_image_received = true;
}
}
}
......
......@@ -40,23 +40,17 @@ namespace gr
// Factor exponential smoothing average,
// which is used for sync pattern detection
const float f_average_alpha;
// The images are written to disk every d_row_write_threshold lines
// so in case something goes horribly wrong, partial images will be available
const size_t d_row_write_threshold;
static const bool synca_seq[];
static const bool syncb_seq[];
std::string d_filename_png;
size_t d_width;
size_t d_height;
bool d_split;
bool d_synchronize_opt;
bool d_flip;
size_t d_history_length;
bool d_has_sync;
bool d_image_received;
png::image<png::gray_pixel> d_full_image;
png::image<png::gray_pixel> d_left_image;
......@@ -75,7 +69,7 @@ namespace gr
public:
noaa_apt_sink_impl (const char *filename_png, size_t width, size_t height,
bool split, bool sync, bool flip);
bool sync, bool flip);
~noaa_apt_sink_impl ();
// Where all the action really happens
......@@ -83,14 +77,8 @@ namespace gr
work (int noutput_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
// For teardown actions, like writing the remaining images to disk
bool
stop ();
private:
// Generates new empty images and the filenames for them
void
init_images ();
/*
* Checks if the history portion of the input contains a sync marker.
......@@ -110,10 +98,6 @@ namespace gr
void
skip_to (size_t new_x, size_t pos, const float *samples);
// Writes all images to disk
void
write_images ();
// Writes a single image to disk, also takes care of flipping
void
write_image (png::image<png::gray_pixel> image, std::string filename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment