Skip to content

Commit a767891

Browse files
committed
raw option and docs added
1 parent ff64202 commit a767891

2 files changed

Lines changed: 28 additions & 13 deletions

File tree

docs/mssautoplot.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ The CLI tool has the following parameters:
2525
+--------------+-------+----------------------------------------------------------------------+
2626
| ``--etime`` | TEXT | Ending time for downloading multiple plots with a fixed interval. |
2727
+--------------+-------+----------------------------------------------------------------------+
28+
| ``--raw`` | BOOL | Saves the raw image with its projection in topview. |
29+
+--------------+-------+----------------------------------------------------------------------+
30+
2831

2932
A short description of how to start the program is given by the ``--help`` option.
3033

@@ -52,6 +55,13 @@ For downloading plots of multiple flight tracks, specify the flight track and it
5255
The above command will download plots of the with/without flight track from start time "2019-09-01T00:00:00" to end time "2019-09-02T00:00:00". The user would need to compulsorily specify the init_time and time in mss_autoplot.json inorder to use this functionality.
5356

5457

58+
4. ``mssautoplot --cpath mssautoplot.json --raw=True``
59+
60+
This command stores the data of topview as PNG for overlays without axis, titles etc.
61+
This could be used in systems like PLANET. You may want to set large values in the layout
62+
of topview in the mssautoplot.json.
63+
64+
5565
Settings file
5666
--------------
5767

mslib/utils/mssautoplot.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def get_op_id(msc_url, token, op_name):
197197

198198

199199
class Plotting:
200-
def __init__(self, cpath, msc_url=None, msc_auth_password=None, username=None, password=None, pdlg=None):
200+
def __init__(self, cpath, msc_url=None, msc_auth_password=None, username=None, password=None, pdlg=None, raw=False):
201201
"""
202202
Initialize the Plotting object with the provided parameters.
203203
@@ -300,8 +300,8 @@ def read_operation(self, op_name, msc_url, msc_auth_password, username, password
300300

301301

302302
class TopViewPlotting(Plotting):
303-
def __init__(self, cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg):
304-
super(TopViewPlotting, self).__init__(cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg)
303+
def __init__(self, cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg, raw=False):
304+
super(TopViewPlotting, self).__init__(cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg, raw)
305305
self.pdlg = pdlg
306306
self.myfig = qt.TopViewPlotter()
307307
self.myfig.fig.canvas.draw()
@@ -313,6 +313,7 @@ def __init__(self, cpath, msc_url, msc_auth_password, msc_username, msc_password
313313
self.password = msc_password
314314
self.msc_auth = msc_auth_password
315315
self.url = msc_url
316+
self.raw = raw
316317

317318
def setup(self):
318319
pass
@@ -356,17 +357,20 @@ def draw(self, flight, section, vertical, filename, init_time, time, url, layer,
356357
img = wms.getmap(**kwargs)
357358
image_io = io.BytesIO(img.read())
358359
img = PIL.Image.open(image_io)
359-
self.myfig.draw_image(img)
360360
t = str(time)
361361
date_time = re.sub(r'\W+', '', t)
362362
plot_filename = slugify(f"{flight}_{layer}_{section}_{date_time}_{no_of_plots}_{elevation}") + ".png"
363-
self.myfig.fig.savefig(plot_filename)
363+
if self.raw:
364+
img.save(plot_filename)
365+
else:
366+
self.myfig.draw_image(img)
367+
self.myfig.fig.savefig(plot_filename)
364368
print(f"The image is saved at: {os.getcwd()}/{plot_filename}")
365369

366370

367371
class SideViewPlotting(Plotting):
368-
def __init__(self, cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg):
369-
super(SideViewPlotting, self).__init__(cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg)
372+
def __init__(self, cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg, raw=False):
373+
super(SideViewPlotting, self).__init__(cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg, raw)
370374
self.pdlg = pdlg
371375
self.myfig = qt.SideViewPlotter()
372376
self.ax = self.myfig.ax
@@ -481,8 +485,8 @@ def draw(self, flight, section, vertical, filename, init_time, time, url, layer,
481485

482486
class LinearViewPlotting(Plotting):
483487
# ToDo Implement access of MSColab
484-
def __init__(self, cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg):
485-
super(LinearViewPlotting, self).__init__(cpath, msc_url, msc_auth_password, msc_username, msc_password)
488+
def __init__(self, cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg, raw=False):
489+
super(LinearViewPlotting, self).__init__(cpath, msc_url, msc_auth_password, msc_username, msc_password, raw)
486490
self.pdlg = pdlg
487491
self.myfig = qt.LinearViewPlotter()
488492
self.ax = self.myfig.ax
@@ -584,8 +588,9 @@ def draw(self, flight, section, vertical, filename, init_time, time, url, layer,
584588
@click.option('--intv', default=0, help='Time interval.')
585589
@click.option('--stime', default="", help='Starting time for downloading multiple plots with a fixed interval.')
586590
@click.option('--etime', default="", help='Ending time for downloading multiple plots with a fixed interval.')
591+
@click.option('--raw', default=False, help='Saves the raw image with its projection in topview')
587592
@click.pass_context
588-
def main(ctx, cpath, view, ftrack, itime, vtime, intv, stime, etime):
593+
def main(ctx, cpath, view, ftrack, itime, vtime, intv, stime, etime, raw):
589594
pdlg = None
590595

591596
def close_process_dialog(pdlg):
@@ -623,13 +628,13 @@ def close_process_dialog(pdlg):
623628

624629
# Choose view (top or side)
625630
if view == "top":
626-
top_view = TopViewPlotting(cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg)
631+
top_view = TopViewPlotting(cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg, raw)
627632
sec = "automated_plotting_hsecs"
628633
elif view == "side":
629-
side_view = SideViewPlotting(cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg)
634+
side_view = SideViewPlotting(cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg, raw)
630635
sec = "automated_plotting_vsecs"
631636
elif view == "linear":
632-
linear_view = LinearViewPlotting(cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg)
637+
linear_view = LinearViewPlotting(cpath, msc_url, msc_auth_password, msc_username, msc_password, pdlg, raw)
633638
sec = "automated_plotting_lsecs"
634639
else:
635640
print("Invalid view")

0 commit comments

Comments
 (0)