22import PyQt5
33from PyQt5 import QtCore , QtWidgets
44from PyQt5 .QtWidgets import QWidget , QLabel , QAction , QTabWidget , QPushButton , QFileDialog , QRadioButton , QMessageBox , \
5- QComboBox , QLineEdit , QSizePolicy
5+ QComboBox , QLineEdit , QSizePolicy , QCheckBox
66from PyQt5 .QtCore import QDateTime
77from PyQt5 .QtGui import QIcon , QDoubleValidator
88from datetime import datetime , timedelta
1818from matplotlib .backends .backend_qt5agg import FigureCanvas , NavigationToolbar2QT as NavigationToolbar
1919from matplotlib .figure import Figure
2020
21+ from solarannotator .template import create_thmap_template
22+
2123if hasattr (QtCore .Qt , 'AA_EnableHighDpiScaling' ):
2224 PyQt5 .QtWidgets .QApplication .setAttribute (QtCore .Qt .AA_EnableHighDpiScaling , True )
2325
@@ -69,7 +71,7 @@ def __init__(self, config):
6971 self .pix = np .vstack ((xv .flatten (), yv .flatten ())).T
7072
7173 lineprops = dict (color = "red" , linewidth = 2 )
72- self .lasso = LassoSelector (self .axs [0 ], self .onlasso , lineprops = lineprops )
74+ self .lasso = LassoSelector (self .axs [0 ], self .onlasso , props = lineprops )
7375 self .fig .tight_layout ()
7476
7577 def onlasso (self , verts ):
@@ -209,7 +211,7 @@ def clearBoundaries(self):
209211 self .region_patches = []
210212 self .fig .canvas .draw_idle ()
211213
212- def loadThematicMap (self , thmap ):
214+ def loadThematicMap (self , thmap , template = True ):
213215 try :
214216 download_message = QMessageBox .information (self ,
215217 'Downloading' ,
@@ -220,9 +222,11 @@ def loadThematicMap(self, thmap):
220222 self .data_does_not_exist_popup ()
221223 else :
222224 self .thmap = thmap
225+ if template :
226+ self .thmap = create_thmap_template (self .composites )
223227 self .thmap .copy_195_metadata (self .composites )
224228 self .history = [thmap .data .copy ()]
225- self .thmap_data = thmap .data
229+ self .thmap_data = self . thmap .data
226230 self .thmap_axesimage .set_data (self .thmap_data )
227231 self .preview_axesimage .set_data (self .composites ['94' ].data )
228232 self .fig .canvas .draw_idle ()
@@ -479,9 +483,12 @@ def initUI(self):
479483 layout = QtWidgets .QHBoxLayout ()
480484 instructions = QLabel ("Please select a time for the new file." , self )
481485 self .dateEdit = QtWidgets .QDateTimeEdit (QDateTime .currentDateTime ())
486+ self .template_option = QCheckBox ("Use template" )
487+ self .template_option .setChecked (True )
482488 submit_button = QPushButton ("Submit" )
483489 layout .addWidget (instructions )
484490 layout .addWidget (self .dateEdit )
491+ layout .addWidget (self .template_option )
485492 layout .addWidget (submit_button )
486493 self .setLayout (layout )
487494 submit_button .clicked .connect (self .onSubmit )
@@ -493,7 +500,7 @@ def onSubmit(self):
493500 {'DATE-OBS' : str (self .parent .date ),
494501 'DATE' : str (datetime .today ())},
495502 self .parent .config .solar_class_name )
496- self .parent .annotator .loadThematicMap (new_thmap )
503+ self .parent .annotator .loadThematicMap (new_thmap , self . template_option . isChecked () )
497504 self .parent .controls .onTabChange () # Us
498505 self .close ()
499506 self .parent .setWindowTitle ("SolarAnnotator: {}" .format (new_thmap .date_obs ))
0 commit comments