Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mslib/msui/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

# ToDo refactor to a function
MSS_AUTOPLOT = os.getenv('MSS_AUTOPLOT', os.path.join(MSUI_CONFIG_PATH, "mssautoplot.json"))
DEFAULT_FTML_PATH = os.getenv('MSS_FTML_PATH', os.path.join(MSUI_CONFIG_PATH, "example_flight.ftml"))

@ReimarBauer ReimarBauer May 6, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please use the users config var mss_dir, and don't create a new constant

or investigate how it stores the first used dir.
e.g. when you store in a ftml dir, it uses that dir for e.g. an import

it should not behave different to the common user interface.

look for self.last_save_directory


# We try to create an empty MSUI_SETTINGS file if not existing
# but there can be a permission problem
Expand Down
20 changes: 11 additions & 9 deletions mslib/utils/mssautoplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
from mslib.utils.auth import get_auth_from_url_and_name
from mslib.utils.loggerdef import configure_mpl_logger
from mslib.utils.verify_user_token import verify_user_token
from mslib.msui.constants import DEFAULT_FTML_PATH


TEXT_CONFIG = {
Expand Down Expand Up @@ -234,15 +235,14 @@ def __init__(self, cpath, msc_url=None, msc_auth_password=None, username=None, p
if filename != "" and filename == flight:
self.read_operation(flight, msc_url, msc_auth_password, username, password)
elif filename != "":
# Todo add the dir to the file in the mssautoplot.json
dirpath = "./"
file_path = os.path.join(dirpath, filename)
file_path = DEFAULT_FTML_PATH

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use the users config of mss_dir

exists = os.path.exists(file_path)
if not exists:
print("Filename {} doesn't exist".format(filename))
self.pdlg.close()
if self.pdlg:
self.pdlg.close()
raise SystemExit("Filename {} doesn't exist".format(filename))
self.read_ftml(filename)
self.read_ftml(DEFAULT_FTML_PATH)

def setup(self):
pass
Expand All @@ -260,7 +260,7 @@ def update_path(self, filename=None):
"""
# plot path and label
if filename != "":
self.read_ftml(filename)
self.read_ftml(DEFAULT_FTML_PATH)
self.fig.canvas.draw()
self.plotter.update_from_waypoints(self.wp_model_data)
self.plotter.redraw_path(waypoints_model_data=self.wp_model_data)
Expand All @@ -275,6 +275,8 @@ def update_path_ops(self, filename=None):
self.plotter.redraw_path(waypoints_model_data=self.wp_model_data)

def read_ftml(self, filename):
if filename is None:
filename = DEFAULT_FTML_PATH
self.wps, self.wp_model_data = load_from_ftml(filename)
self.wp_lats, self.wp_lons, self.wp_locs = [[x[i] for x in self.wps] for i in [0, 1, 3]]
self.wp_press = [mslib.utils.thermolib.flightlevel2pressure(wp[2] * units.hft).to("Pa").m for wp in self.wps]
Expand Down Expand Up @@ -411,7 +413,7 @@ def update_path(self, filename=None):
"""
# plot path and label
if filename != "":
self.read_ftml(filename)
self.read_ftml(DEFAULT_FTML_PATH)
self.fig.canvas.draw()
self.plotter.update_from_waypoints(self.wp_model_data)
indices = list(zip(self.intermediate_indexes, self.wp_press))
Expand Down Expand Up @@ -509,7 +511,7 @@ def setup(self):
def update_path(self, filename=None):
self.setup()
if filename != "":
self.read_ftml(filename)
self.read_ftml(DEFAULT_FTML_PATH)

highlight = [[wp[0], wp[1]] for wp in self.wps]
self.myfig.draw_vertical_lines(highlight, self.lats, self.lons)
Expand Down Expand Up @@ -582,7 +584,7 @@ def draw(self, flight, section, vertical, filename, init_time, time, url, layer,
@click.command()
@click.option('--cpath', default=constants.MSS_AUTOPLOT, help='Path of the configuration file.')
@click.option('--view', default="top", help='View of the plot (top/side/linear).')
@click.option('--ftrack', default="", help='Flight track.')
@click.option('--ftrack', type=click.Path(exists=True), help='Path to the .ftml file')
@click.option('--itime', default="", help='Initial time.')
@click.option('--vtime', default="", help='Valid time.')
@click.option('--intv', default=0, help='Time interval.')
Expand Down