wolfhece 2.1.128__py3-none-any.whl → 2.1.129__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wolfhece/PyParams.py CHANGED
@@ -1973,10 +1973,14 @@ class Wolf_Param(wx.Frame):
1973
1973
  elif not self.is_in_active(group, name) and self.is_in_default(group, name):
1974
1974
  # le paramètre est dans les paramètres par défaut mais pas dans les paramètres actifs --> on l'ajoute
1975
1975
  default_value = self.myparams_default[group][name]
1976
+ if key_Param.ADDED_JSON in default_value.keys():
1977
+ json = default_value[key_Param.ADDED_JSON]
1978
+ else:
1979
+ json = None
1976
1980
  self.add_param(group, name, value,
1977
1981
  default_value[key_Param.TYPE],
1978
1982
  comment=default_value[key_Param.COMMENT],
1979
- jsonstr=default_value[key_Param.ADDED_JSON],
1983
+ jsonstr=json,
1980
1984
  whichdict='Active')
1981
1985
  elif self.is_in_active(group, name):
1982
1986
  param = self.myparams[group][name]
@@ -7883,22 +7883,67 @@ class Zones(wx.Frame, Element_To_Draw):
7883
7883
 
7884
7884
  sz = []
7885
7885
 
7886
+ # Getting s values and Z values from the xls grid
7887
+ # s in column 4 and z in column 2
7888
+ # The first row is the header
7886
7889
  i = 0
7887
7890
  while self.xls.GetCellValue(i,4) != '':
7888
- sz.append((float(self.xls.GetCellValue(i,4)), float(self.xls.GetCellValue(i,2))))
7889
- i += 1
7891
+ s = self.xls.GetCellValue(i,4)
7892
+ z = self.xls.GetCellValue(i,2)
7893
+ try:
7894
+ s = float(s)
7895
+ except:
7896
+ logging.error(_('Error during update from sz support - check your s data and types (only float)'))
7897
+ return
7898
+
7899
+ try:
7900
+ if z == '':
7901
+ logging.warning(_('No z value -- setting to 0.0'))
7902
+ z = 0.0
7903
+ else:
7904
+ z = float(z)
7905
+ except:
7906
+ logging.error(_('Error during update from sz support - check your z data and types (only float)'))
7907
+ return
7908
+
7909
+ sz.append((s, z))
7910
+ i += 1
7911
+
7912
+ if len(sz) == 0:
7913
+ logging.warning(_('No data to update -- Please set s in column "s curvi" (5th) and z in column Z (3th)'))
7914
+ return
7890
7915
 
7891
7916
  logging.info(f'Number of points: {len(sz)}')
7892
7917
 
7893
7918
  vec_sz = np.array(sz)
7894
7919
 
7895
- self.update_from_sz_support(vec=self.active_vector, sz=vec_sz)
7920
+ memory_xyz = []
7921
+ i = 0
7922
+ while self.xls.GetCellValue(i,0) != '':
7923
+ memory_xyz.append((float(self.xls.GetCellValue(i,0)), float(self.xls.GetCellValue(i,1)), float(self.xls.GetCellValue(i,2))))
7924
+ i += 1
7896
7925
 
7897
- # update of the xls grid
7898
- for k in range(self.active_vector.nbvertices ):
7899
- self.xls.SetCellValue(k,0,str(self.active_vector.myvertices[k].x))
7900
- self.xls.SetCellValue(k,1,str(self.active_vector.myvertices[k].y))
7926
+ try:
7927
+ self.update_from_sz_support(vec=self.active_vector, sz=vec_sz)
7928
+
7929
+ # update of the xls grid
7930
+ for k in range(self.active_vector.nbvertices ):
7931
+ self.xls.SetCellValue(k,0,str(self.active_vector.myvertices[k].x))
7932
+ self.xls.SetCellValue(k,1,str(self.active_vector.myvertices[k].y))
7933
+ except:
7934
+ logging.error(_('Error during update from sz support - check your data'))
7935
+ logging.info(_('Resetting the active vector to its original state'))
7936
+
7937
+ self.active_vector.myvertices = []
7938
+ for cur in memory_xyz:
7939
+ self.active_vector.add_vertex(wolfvertex(cur[0], cur[1], cur[2]))
7940
+ self.active_vector._reset_listogl()
7941
+ self.active_vector.update_lengths()
7942
+ self.active_vector.find_minmax(True)
7901
7943
 
7944
+ for k in range(self.active_vector.nbvertices ):
7945
+ self.xls.SetCellValue(k,0,str(self.active_vector.myvertices[k].x))
7946
+ self.xls.SetCellValue(k,1,str(self.active_vector.myvertices[k].y))
7902
7947
 
7903
7948
  def update_from_sz_direction(self, xy1:np.ndarray, xy2:np.ndarray, sz:np.ndarray):
7904
7949
  """ Update the active vector from the sz values in the xls grid """
wolfhece/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 1
8
- self.patch = 128
8
+ self.patch = 129
9
9
 
10
10
  def __str__(self):
11
11
 
@@ -67,7 +67,8 @@ class Catchment:
67
67
  iP_Cloud:cloud_vertices # cloud of points containing the given coordinates (given in param files) of all subbasin outlets
68
68
 
69
69
  catchmentDict:dict[Union[str, int], Union[SubBasin, RetentionBasin]] # dictionnary containing all the elements of the catchment
70
- subBasinDict:dict[int, SubBasin] # dictionnary containing all the subbasins
70
+ subBasinDict:dict[int, SubBasin] # dictionnary containing all the subbasins with the convention dict{ID Interior Point : SubBasin object}
71
+ retentionBasinDict:dict[str, RetentionBasin] # dictionnary containing all the anthropogenic modules
71
72
 
72
73
  def __init__(self, _name, _workingDir, _plotAllSub, _plotNothing, _initWithResults=True, _catchmentFileName="", _rbFileName="", _tz=0, version=cst.VERSION_WOLFHYDRO):
73
74
  "This is the constructor of the class Catchment in which all the caractertics and the network of sub-basins will be created"
@@ -1390,6 +1391,75 @@ class Catchment:
1390
1391
  writer.close()
1391
1392
 
1392
1393
 
1394
+
1395
+ def save_hydro_for_2D(self, fileName:str="Hydros_2_simul2D.txt", directory:str="", format:str='%1.5e'):
1396
+ """
1397
+ Procedure that saves the data in an text file that can be read and used in a 2D model.
1398
+
1399
+ Args:
1400
+ fileName (str, optional): The name of the file to save the data to. Defaults to "Hydros_2_simul2D.txt".
1401
+ directory (str, optional): The directory to save the file in. Defaults to an empty string.
1402
+
1403
+ Returns:
1404
+ None
1405
+ """
1406
+ # Writes subbasins' hydrographs
1407
+ if(directory==""):
1408
+ directory = join(self.workingDir,"PostProcess")
1409
+
1410
+ cur_file = join(directory,fileName)
1411
+ time = np.reshape(self.time - self.time[0],(len(self.time),1))
1412
+ # Extract the data for the hydrological and anthropogenic modules
1413
+ data_subs = [cur_sub.outFlow for cur_sub in sorted(self.subBasinDict.values(), key=lambda sub: sub.iDSorted)]
1414
+ data_anth = [cur_anth.get_outFlow(whichOutFlow=name) for cur_anth in self.retentionBasinDict.values() for name in cur_anth.get_outFlow_names()]
1415
+ # Extract the column names according to their sorted subbasin indices
1416
+ col_time = ["Time [s]"]
1417
+ col_subs = [cur_sub.name for cur_sub in sorted(self.subBasinDict.values(), key=lambda sub: sub.iDSorted)]
1418
+ col_anth = [" : ".join([cur_anth.name, name])
1419
+ for cur_anth in self.retentionBasinDict.values()
1420
+ for name in cur_anth.get_outFlow_names()]
1421
+
1422
+
1423
+ all_data = np.concatenate((time, np.array(data_subs).T, np.array(data_anth).T), axis=1)
1424
+ all_columns = "\t".join(col_time+col_subs+col_anth)
1425
+
1426
+ # Save the data in a text file
1427
+ np.savetxt(cur_file, all_data, delimiter='\t', newline="\n", header=all_columns, fmt=format)
1428
+
1429
+
1430
+ def save_own_hydro_for_2D(self, fileName:str="HydrosSub_2_simul2D.txt", directory:str="", format:str='%1.5e'):
1431
+ """
1432
+ Saves subbasins' hydrographs from their own drained surface only (not taking into account the
1433
+ surface drained by the inlets or upstream elements) to a text file that can be read and used in a 2D model.
1434
+
1435
+ Args:
1436
+ fileName (str, optional): Name of the output file. Defaults to "HydrosSub_2_simul2D.txt".
1437
+ directory (str, optional): Directory where the file will be saved. Defaults to an empty string.
1438
+ format (str, optional): Format string for the data values. Defaults to '%1.5e'.
1439
+
1440
+ Returns:
1441
+ None
1442
+ """
1443
+ # Writes subbasins' hydrographs
1444
+ if(directory==""):
1445
+ directory = join(self.workingDir,"PostProcess")
1446
+
1447
+ cur_file = join(directory,fileName)
1448
+ time = np.reshape(self.time - self.time[0],(len(self.time),1))
1449
+ # Extract the data for the hydrological and anthropogenic modules
1450
+ data_subs = [cur_sub.get_myHydro(unit="m3/s") for cur_sub in sorted(self.subBasinDict.values(), key=lambda sub: sub.iDSorted)]
1451
+ # Extract the column names according to their sorted subbasin indices
1452
+ col_time = ["Time [s]"]
1453
+ col_subs = [cur_sub.name for cur_sub in sorted(self.subBasinDict.values(), key=lambda sub: sub.iDSorted)]
1454
+
1455
+
1456
+ all_data = np.concatenate((time, np.array(data_subs).T), axis=1)
1457
+ all_columns = "\t".join(col_time+col_subs)
1458
+
1459
+ # Save the data in a text file
1460
+ np.savetxt(cur_file, all_data, delimiter='\t', newline="\n", header=all_columns, fmt=format)
1461
+
1462
+
1393
1463
  def save_characteristics(self):
1394
1464
  "Procedure that saves the data in an Excel file."
1395
1465
  # Writes subbasins' main characteristics
@@ -1857,8 +1927,8 @@ class Catchment:
1857
1927
  # paramsInput.ApplytoMemory(None)
1858
1928
  paramsInput.SavetoFile(None)
1859
1929
 
1860
-
1861
- def _correct_Umax_from_old_model(self, adapt_with_rain:bool=True):
1930
+
1931
+ def _correct_Umax_from_old_model(self, adapt_with_rain:bool=True, k_opt:float=0.0, U_max_opt=0.0):
1862
1932
  fileName = "simul_soil.param"
1863
1933
  which="Umax"
1864
1934
 
@@ -1870,8 +1940,10 @@ class Catchment:
1870
1940
 
1871
1941
  paramsInput = Wolf_Param(to_read=False,toShow=False)
1872
1942
  paramsInput.ReadFile(fileToModif)
1873
-
1874
- if adapt_with_rain:
1943
+
1944
+ if U_max_opt>0.0:
1945
+ maxRain = U_max_opt
1946
+ elif adapt_with_rain:
1875
1947
  myInterval = paramsInput.get_param("Distributed production model parameters", "Time span soil", default_value=0.0)
1876
1948
  if myInterval==0.0:
1877
1949
  nbIntervals = len(myBasin.myRain)-1
@@ -1885,10 +1957,13 @@ class Catchment:
1885
1957
  if maxRain==0.0:
1886
1958
  logging.warning("The Umax is not adapted with the rain and its value is 0.0. It might be better to put 'adapt_with_rain' to True.")
1887
1959
 
1888
- k = paramsInput.get_param("Horton parameters", "k", default_value=0.0)
1889
- if k==0.0:
1890
- continue
1891
-
1960
+ if k_opt==0.0:
1961
+ k = paramsInput.get_param("Horton parameters", "k", default_value=0.0)
1962
+ if k==0.0:
1963
+ continue
1964
+ else:
1965
+ k = k_opt
1966
+
1892
1967
  U_max = maxRain/k
1893
1968
 
1894
1969
  paramsInput.change_param("Distributed production model parameters", which, U_max)
@@ -1899,7 +1974,7 @@ class Catchment:
1899
1974
 
1900
1975
 
1901
1976
 
1902
- def plot_all_diff_cumulRain_with_lagtime(self, interval, lagTime, selection_by_iD=[], graph_title="", show=True, writeDir="", lawNetRain=0, netRainParams={}):
1977
+ def plot_all_diff_cumulRain_with_lagtime(self, interval=0, lagTime=0, selection_by_iD=[], graph_title="", show=True, writeDir="", lawNetRain=0, netRainParams={}):
1903
1978
  """
1904
1979
 
1905
1980
  """
@@ -2835,6 +2910,32 @@ class Catchment:
2835
2910
  self._set_temporal_parameters(value)
2836
2911
 
2837
2912
 
2913
+ def _set_IC_qif(self, keys:list[str], values:np.ndarray):
2914
+ assert len(keys) == len(values), "The number of keys should be equal to the number of values !"
2915
+ # assert len(keys) == len(self.subBasinDict), "The number of keys should be equal to the number of sub-basins !"
2916
+ # assert len(values) == len(self.subBasinDict), "The number of values should be equal to the number of sub-basins !"
2917
+ fileName = "simul_if.param"
2918
+ group = "Initial conditions"
2919
+ key = "Outflow"
2920
+
2921
+ for iBasin in range(1,len(self.subBasinDict)+1):
2922
+ if self.subBasinDict[iBasin].name in keys:
2923
+ index = np.where(np.array(keys) == self.subBasinDict[iBasin].name)[0][0]
2924
+ else:
2925
+ logging.warning(f"The sub-basin {self.subBasinDict[iBasin].name} is not in the keys list !")
2926
+ continue
2927
+ myBasin = self.subBasinDict[iBasin]
2928
+ dirID = myBasin.iDSorted
2929
+
2930
+ fileToModif = os.path.join(self.workingDir, "Subbasin_" + str(dirID), fileName)
2931
+
2932
+ paramsInput = Wolf_Param(to_read=False,toShow=False)
2933
+ paramsInput.ReadFile(fileToModif)
2934
+ paramsInput.change_param(group, key, values[index])
2935
+ paramsInput.SavetoFile(None)
2936
+ paramsInput.Reload(None)
2937
+
2938
+
2838
2939
  def make_nd_array(self, c_pointer, shape, dtype=np.float64, order='C', own_data=True,readonly=False):
2839
2940
  arr_size = np.prod(shape[:]) * np.dtype(dtype).itemsize
2840
2941
 
@@ -419,10 +419,10 @@ class Comparison:
419
419
  tzPlot = plotDict["General Parameters"]["Time Zone Plot"]
420
420
  tzDelta = datetime.timedelta(hours=tzPlot)
421
421
 
422
- if(envelop and not("Ref Name" in plotDict["General Parameters"])):
423
- refName = "Catchment 1"
424
- else:
425
- refName = plotDict["General Parameters"]["Ref Name"]
422
+ # if(envelop and not("Ref Name" in plotDict["General Parameters"])):
423
+ # refName = "Catchment 1"
424
+ # else:
425
+ # refName = plotDict["General Parameters"]["Ref Name"]
426
426
 
427
427
  if(not("Add Table" in plotDict["General Parameters"])):
428
428
  addTable = False
@@ -524,7 +524,7 @@ class Comparison:
524
524
  yLabels = []
525
525
  if(not("Catchment traits" in plotDict["General Parameters"])):
526
526
  myTraits = []
527
- rain = []
527
+ rain = None
528
528
  z = []
529
529
  nbAddRain=0
530
530
  y_labelAddRain = []
@@ -721,7 +721,7 @@ class Comparison:
721
721
  myTraits.append('-')
722
722
 
723
723
  if(sameRain and displayRain):
724
- if(rain==[]):
724
+ if(rain is None):
725
725
  rain = curCatch.subBasinDict[id].rain/curCatch.subBasinDict[id].surfaceDrainedHydro*3.6
726
726
  elif(displayRain):
727
727
  upperPlot = True
@@ -748,7 +748,7 @@ class Comparison:
748
748
  myTraits.append('-')
749
749
 
750
750
  if(sameRain and displayRain):
751
- if(rain==[]):
751
+ if(rain is None):
752
752
  rain = curCatch.subBasinDict[id].rain/curCatch.subBasinDict[id].surfaceDrainedHydro*3.6
753
753
  elif(displayRain):
754
754
  upperPlot = True
@@ -801,7 +801,7 @@ class Comparison:
801
801
  if("Measures" in plotDict[basinNames[id]]):
802
802
  Measures = plotDict[basinNames[id]]["Measures"]
803
803
  myMeasure = Measures.myHydro
804
- yLabels.append(_("Measures"))
804
+ yLabels.append(_("Measurement"))
805
805
  catchColorsAddData.append('k')
806
806
  myTraits.append('-')
807
807
  if(Measures.surfaceDrainedHydro>0.0):
@@ -904,6 +904,11 @@ class Comparison:
904
904
  else:
905
905
  dt = plotDict["General Parameters"]["Dt"]
906
906
 
907
+ if(not("Add Table" in plotDict["General Parameters"])):
908
+ addTable = False
909
+ else:
910
+ addTable = plotDict["General Parameters"]["Add Table"]
911
+
907
912
  # if(envelop and not("Ref Name" in plotDict["General Parameters"])):
908
913
  # refName = "Catchment 1"
909
914
 
@@ -1029,7 +1034,7 @@ class Comparison:
1029
1034
  if("Measures" in plotDict[RBNames[id]]):
1030
1035
  Measures = plotDict[RBNames[id]]["Measures"]
1031
1036
  myMeasure = Measures.myHydro
1032
- yLabels.append(_("Measures"))
1037
+ yLabels.append(_("Measurement"))
1033
1038
  catchColorsAddData.append('k')
1034
1039
  myTraits.append('--')
1035
1040
  else:
@@ -1052,15 +1057,17 @@ class Comparison:
1052
1057
 
1053
1058
 
1054
1059
  # Plot Rains
1055
- yTitles = "Hauteurs d'eau [m]"
1056
- writeFileDef = writeFile + "_H_" + graph_title.replace(".","")
1060
+ yTitles = _("Water level [m]")
1061
+ writeFileDef = os.path.join(writeFile, "H_" + graph_title.replace(".",""))
1057
1062
  if(Measures is not None):
1058
1063
  ph.plot_hydro(nbCatchment+nbAddData, y1,x_title=x_title, y_titles=yTitles, beginDate=beginDateRB+beginDateAddData,endDate=endDateRB+endDateAddData,dt=dt+dtAddData,graph_title=graph_title, \
1059
1064
  y_labels=yLabels,rangeData=xRange,y_data_range=yRange,myColors=catchColors+catchColorsAddData,typeOfTraits=myTraits,writeFile=writeFileDef,\
1060
- measures=myMeasure,beginDateMeasure=Measures.dateBegin+tzDelta, endDateMeasure=Measures.dateEnd+tzDelta,dtMeasure=Measures.deltaT,deltaMajorTicks=86400/2.0,deltaMinorTicks=3600)
1065
+ measures=myMeasure,beginDateMeasure=Measures.dateBegin+tzDelta, endDateMeasure=Measures.dateEnd+tzDelta,dtMeasure=Measures.deltaT,deltaMajorTicks=86400/2.0,deltaMinorTicks=3600,
1066
+ addTable=addTable)
1061
1067
  else:
1062
1068
  ph.plot_hydro(nbCatchment+nbAddData, y1,x_title=x_title, y_titles=yTitles, beginDate=beginDateRB+beginDateAddData,endDate=endDateRB+endDateAddData,dt=dt+dtAddData,graph_title=graph_title, \
1063
- y_labels=yLabels,rangeData=xRange,y_data_range=yRange,myColors=catchColors+catchColorsAddData,typeOfTraits=myTraits,writeFile=writeFileDef,deltaMajorTicks=86400/2.0,deltaMinorTicks=3600)
1069
+ y_labels=yLabels,rangeData=xRange,y_data_range=yRange,myColors=catchColors+catchColorsAddData,typeOfTraits=myTraits,writeFile=writeFileDef,deltaMajorTicks=86400/2.0,deltaMinorTicks=3600,
1070
+ addTable=addTable)
1064
1071
 
1065
1072
  if(show):
1066
1073
  plt.show()
@@ -1175,7 +1182,7 @@ class Comparison:
1175
1182
  yLabels = []
1176
1183
  if(not("Catchment traits" in plotDict["General Parameters"])):
1177
1184
  myTraits = []
1178
- rain = []
1185
+ rain = None
1179
1186
  z = []
1180
1187
  nbAddRain=0
1181
1188
  y_labelAddRain = []
@@ -1308,7 +1315,7 @@ class Comparison:
1308
1315
  if("Measures" in plotDict[RBNames[id]]):
1309
1316
  Measures = plotDict[RBNames[id]]["Measures"]
1310
1317
  myMeasure = Measures.myHydro
1311
- yLabels.append(_("Measures"))
1318
+ yLabels.append(_("Measurement"))
1312
1319
  catchColorsAddData.append('k')
1313
1320
  myTraits.append('-')
1314
1321
  if(Measures.surfaceDrainedHydro>0.0):
@@ -1387,7 +1394,7 @@ class Comparison:
1387
1394
 
1388
1395
 
1389
1396
 
1390
- def plot_all_diff_cumulRain_with_lagtime(self, interval, selection_by_iD=[], writeDir=""):
1397
+ def plot_all_diff_cumulRain_with_lagtime(self, interval=0, selection_by_iD=[], writeDir=""):
1391
1398
 
1392
1399
  for idCatch in self.myCatchments:
1393
1400
  curCatch:Catchment = self.myCatchments[idCatch]['Object']
@@ -1529,10 +1536,7 @@ class Comparison:
1529
1536
  self.plotDict[stationKey]["Add Data"]["Dt"] = []
1530
1537
 
1531
1538
  for element in myAddDataObj:
1532
- if addDataUnits == "mm/h":
1533
- self.plotDict[stationKey]["Add Data"]["Data"].append(element.myHydro[:])
1534
- else:
1535
- self.plotDict[stationKey]["Add Data"]["Data"].append(element.myHydro[:]*element.surfaceDrained/3.6)
1539
+ self.plotDict[stationKey]["Add Data"]["Data"].append(element.get_myHydro(unit=addDataUnits))
1536
1540
  self.plotDict[stationKey]["Add Data"]["Date Begin"].append(element.dateBegin)
1537
1541
  self.plotDict[stationKey]["Add Data"]["Date End"].append(element.dateEnd)
1538
1542
  self.plotDict[stationKey]["Add Data"]["Dt"].append(element.deltaT)
@@ -1579,7 +1583,7 @@ class Comparison:
1579
1583
 
1580
1584
 
1581
1585
 
1582
- def plot_Nash_and_peak(self, stationKey:list[str, int], measures:list[SubBasin], intervals:list=[]):
1586
+ def plot_Nash_and_peak(self, stationKey:list[str, int], measures:list[SubBasin], intervals:list=[], toShow:bool=True):
1583
1587
  assert len(stationKey) == len(measures)
1584
1588
 
1585
1589
  all_ns = {stationKey[i]: [ self.myCatchments[el]["Object"].get_sub_Nash(measures[i], stationKey[i], intervals)
@@ -1662,8 +1666,8 @@ class Comparison:
1662
1666
  type_of_data = ["Nash", r"$ \frac{Q^{s}_{max}-Q^{m}_{max}}{Q^{m}_{max}} $ "]
1663
1667
  type_of_data_names = ["Nash", "Exceedance"]
1664
1668
 
1665
- ph.bar_Nash_n_other(all_data, all_colors, nb_x=len(intervals), nb_data=len(type_of_model), nb_lines=nb_stations,
1666
- y_titles=type_of_data, x_titles=all_names, nameModel=type_of_model, line_names=sorted_keys, toShow=False)
1669
+ # ph.bar_Nash_n_other(all_data, all_colors, nb_x=len(intervals), nb_data=len(type_of_model), nb_lines=nb_stations,
1670
+ # y_titles=type_of_data, x_titles=all_names, nameModel=type_of_model, line_names=sorted_keys, toShow=False)
1667
1671
 
1668
1672
  # =========
1669
1673
  # =========
@@ -1700,5 +1704,5 @@ class Comparison:
1700
1704
  ph.table_Nash_n_other(cur_data, name_of_data,
1701
1705
  row_names=sorted_keys, column_names=all_names,
1702
1706
  writeFile=file_name, toShow=False)
1703
-
1704
- plt.show()
1707
+ if toShow:
1708
+ plt.show()