Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring and testing of Interactor classes #1570

Conversation

swsrkty
Copy link
Collaborator

@swsrkty swsrkty commented Sep 28, 2022

Refactoring Interactor module to separate Interactor classes from Plotting classes.

@swsrkty swsrkty changed the title Incomplete refactoring of HPathInteractor Refactoring and testing of Interactor classes Oct 17, 2022
mslib/msui/mpl_pathinteractor.py Outdated Show resolved Hide resolved
self.ax.draw_artist(t)


class PathL_GCPlotter(PathPlotter):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above.

mslib/msui/mpl_pathinteractor.py Outdated Show resolved Hide resolved
mslib/msui/mpl_qtwidget.py Show resolved Hide resolved
waypoints_list.append((lat, lon, flightlevel, location, comments))
return waypoints_list
waypoints_list1.append((lat, lon, flightlevel, location, comments))
waypoints_list2.append(ft.Waypoint(lat, lon, flightlevel, location, comments))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As most of the mslib stuff uses the list of ft.Waypoint's, I would try to remove the need of the waypoints_list1.

@@ -87,84 +93,55 @@ def __init__(self):
self.params["basemap"].update(self.config["predefined_map_sections"][section]["map"])
print(self.params)
self.bbox_units = self.params["bbox"]
self.wps = load_from_ftml(filename)
self.wpslist = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessary

self.fig.clear()
self.ax = self.fig.add_subplot(111, zorder=99)
self.path = [(wp[0], wp[1], datetime.datetime.now()) for wp in self.wps]
self.vertices = [list(a) for a in (zip(self.wp_lons, self.wp_lats))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed. The "vertices" of the msui classes are often in different units then lon/lat. The restructuring of using update_from_waypoints should have made this superfluous anyway.


# plot path
def TopViewPath(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function names do not follow the PEP8 convention. Also adding TopView here seems redundant.

I think it is sensible to have small functions plotting the individual plot components. However calling three functions without any argument in main() seems like a strange design. Why not only one? In principle you could put everything in the constructor - or make a simple function doing all that.

What makes sense is reusing the MyFigure class for all plots of one type. But maybe the draw() function should not contain the loop. Instead the loop should IMO go into the main() function and call a draw function with flightpath etc. as arguments.
I also suspect that this does not work properly for multiple flights as, e.g., the label functions must be called after changing the flight.
But maybe I am mistaken, I haven't tested it in practice.

autoplot.py Outdated
@@ -0,0 +1,58 @@
import click
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see template.py, please add the common header. Add your name as initial author

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the module should go to mslib.utils

autoplot.py Outdated
for flight, section, vertical, filename, init_time, time in \
config["automated_plotting_flights"]:
for url, layer, style, elevation in config["automated_plotting_hsecs"]:
if(intv == 0):
Copy link
Member

@ReimarBauer ReimarBauer Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the brackets are unusual, not needed.

brackets are used for multiline statements and they have a blank between if and (

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if is a condition, not a function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://peps.python.org/pep-0008/ search for if-statement

autoplot.py Outdated
i = 1
time = starttime
while(time <= endtime):
print(time)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be replace print by logging.info, logging.debug

@@ -69,6 +69,27 @@
except IOError:
logging.error(f'"{MSUI_SETTINGS}" can''t be created')

MSS_AUTOPLOT = os.getenv('MSS_AUTOPLOT', os.path.join(MSUI_CONFIG_PATH, "mss_autoplot.json"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a ToDo, # ToDo refactor to a function

else:
inittime = itime
time = datetime.strptime(vtime, "%Y-%m-%dT" "%H:%M:%S")
if(ftrack != ""):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this "(" is only used for multiline statements and then with a blank after the "if"

see if-statement in
https://peps.python.org/pep-0008/

@joernu76
Copy link
Member

This was part of another pull request already.

@joernu76 joernu76 closed this Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants