Skip to content

Commit

Permalink
Add default titles to time series plots
Browse files Browse the repository at this point in the history
  • Loading branch information
azvoleff committed Jul 6, 2022
1 parent 90761b3 commit e72dd26
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 0 additions & 2 deletions LDMP/jobs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ def get_job_local_script(script_name: str) -> ExecutionScript:

def _get_script_by_id_from_remote(script_id: str) -> ExecutionScript:
remote_scripts = get_remote_scripts()
log(f"remote_scripts: {remote_scripts}")

if remote_scripts is None:
return
try:
Expand Down
5 changes: 4 additions & 1 deletion LDMP/jobs/mvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,11 @@ def show_time_series_plot(self):
return

data = [x for x in table if x["name"] == "mean"][0]
task_name = self.job.task_name
base_title = self.tr("Time Series")
if self.job.task_name:
task_name = self.job.task_name
else:
task_name = ""
dlg_plot = DlgPlotTimeries(self.main_dock.iface.mainWindow())
dlg_plot.setWindowTitle(f"{base_title} - {task_name}")
labels = {
Expand Down
25 changes: 21 additions & 4 deletions LDMP/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ def __init__(
)
self.vl_aoi.addWidget(self.area_widget)

self.task_name.setText(self.get_plot_title())

def traj_indic_changed(self):
self.dataset_climate_update()
self.task_name.setText(self.get_plot_title())

def dataset_climate_update(self):
self.traj_climate.clear()
Expand Down Expand Up @@ -140,6 +143,7 @@ def traj_climate_changed(self):
self.traj_climate.currentText()
]["End year"]
self.update_time_bounds()
self.task_name.setText(self.get_plot_title())

def dataset_ndvi_changed(self):
this_ndvi_dataset = self.datasets["NDVI"][self.dataset_ndvi.currentText()]
Expand All @@ -164,6 +168,7 @@ def dataset_ndvi_changed(self):
)

self.update_time_bounds()
self.task_name.setText(self.get_plot_title())

def update_time_bounds(self):
# TODO: need to also account for GAEZ and/or CCI data dates for
Expand Down Expand Up @@ -246,6 +251,19 @@ def _on_sync_action_toggled(self, status):
else:
self.hide()

def get_plot_title(self):
if self.traj_climate.currentText() != "":
return (
f"{self.traj_indic.currentText()} "
f" - {self.dataset_ndvi.currentText()}, "
f"{self.traj_climate.currentText()}"
)
else:
return (
f"{self.traj_indic.currentText()} "
f"- {self.dataset_ndvi.currentText()}"
)

def btn_calculate(self):
# Note that the super class has several tests in it - if they fail it
# returns False, which would mean this function should stop execution
Expand All @@ -259,15 +277,15 @@ def btn_calculate(self):

# Limit area that can be processed
aoi_area = self.aoi.get_area() / (1000 * 1000)
log(u"AOI area is: {:n}".format(aoi_area))
if aoi_area > 1e7:
if aoi_area > 1e6:
log("AOI area is: {:n} - blocking processing".format(aoi_area))
QtWidgets.QMessageBox.critical(
None,
self.tr("Error"),
self.tr(
"The bounding box of the requested area (approximately "
"{:.6n} sq km) is too large. The timeseries tool can "
"process a maximum area of 10 million sq km at a time. "
"process a maximum area of 1 million sq km at a time. "
"Choose a smaller area to process.".format(aoi_area)
),
)
Expand All @@ -277,7 +295,6 @@ def btn_calculate(self):
climate_gee_dataset = self.climate_datasets[
self.traj_climate.currentText()
]["GEE Dataset"]
log("climate_gee_dataset {}".format(climate_gee_dataset))
else:
climate_gee_dataset = None

Expand Down

0 comments on commit e72dd26

Please sign in to comment.