Skip to content

Commit

Permalink
change wf saving format
Browse files Browse the repository at this point in the history
  • Loading branch information
baskiton committed Aug 4, 2024
1 parent 0f832ba commit c7a26c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion sats_receiver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,14 @@ def plot(self, out_fn, vmin=None, vmax=None):
fig = plt.colorbar(aspect=50, pad=0.1)
fig.set_label('Power, dB')

plt.savefig(out_fn, bbox_inches='tight', dpi=200)
plt.savefig(out_fn, bbox_inches='tight', dpi=200, format='png', transparent=0)
i = Image.open(out_fn).convert('RGB')
kw = {}
if out_fn.suffix == '.png':
kw.update(optimize=1)
elif out_fn.suffix == '.jpg':
kw.update(optimize=1, subsampling=2, quality=95)
i.save(out_fn, **kw)
plt.close()

def spec_compress(self):
Expand Down
10 changes: 5 additions & 5 deletions tools/client_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ def action(self):

elif dtype == Decode.RAW:
try:
self._draw_wr(fp, params)
self._draw_wf(fp, params)
except:
self.log.exception('waterfall')

elif dtype == Decode.PROTO_RAW:
try:
self._draw_wr(fp, params)
self._draw_wf(fp, params)
except:
self.log.error('waterfall')

Expand All @@ -194,7 +194,7 @@ def action(self):

self.log.info('%s done: %s', params['sat_name'], res.name)

def _draw_wr(self, fp, params):
def _draw_wf(self, fp, params):
self.log.info('Draw Waterfall')

wf = 0
Expand All @@ -206,7 +206,7 @@ def _draw_wr(self, fp, params):
elif ftype != RawFileType.AUDIO:
self.log.warning('Unknown filetype: %s', ftype)
if wf:
wf.plot(fp.with_stem(f'{fp.stem}_{ftype.name}_wf').with_suffix('.png'), -110, -50)
wf.plot(fp.with_stem(f'{fp.stem}_{ftype.name}_wf').with_suffix('.jpg'))#, -110, -50)


class MyTCPHandler(socketserver.StreamRequestHandler):
Expand Down Expand Up @@ -412,7 +412,7 @@ def setup_logging(q, log_lvl):
pil_logger.setLevel(logging.DEBUG + 2)

gr_logger = gr.gr.logging()
gr_logger.set_default_level(gr.gr.log_levels.info)
gr_logger.set_default_level(gr.gr.log_levels.err)


if __name__ == '__main__':
Expand Down

0 comments on commit c7a26c1

Please sign in to comment.