wolfhece 2.1.127__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/PyDraw.py CHANGED
@@ -875,7 +875,7 @@ class Sim_Explorer(wx.Frame):
875
875
  right_bar.Add(self._texttime, 1, wx.EXPAND | wx.ALL, 5)
876
876
  self._texttime.Bind(wx.EVT_TEXT, self.OnTextTime)
877
877
 
878
- self._step_time = wx.ListBox(self._panel, choices=['{:.3f} - {}'.format(i, datetime.strftime(self._starting_date + timedelta(seconds=i), '%Y-%m-%d %H:%M:%S')) for i in self._all_times_steps[0]], style=wx.LB_SINGLE)
878
+ self._step_time = wx.ListBox(self._panel, choices=['{:.3f} - {}'.format(i, datetime.strftime(self._starting_date + timedelta(seconds=float(i)), '%Y-%m-%d %H:%M:%S')) for i in self._all_times_steps[0]], style=wx.LB_SINGLE)
879
879
  self._step_time.Bind(wx.EVT_LISTBOX, self.OnSelectNumStep)
880
880
  right_bar.Add(self._step_time, 1, wx.EXPAND | wx.ALL, 5)
881
881
 
@@ -9709,7 +9709,7 @@ class WolfMapViewer(wx.Frame):
9709
9709
  if ret == wx.ID_YES:
9710
9710
  loadhead = True
9711
9711
 
9712
- types = None
9712
+ newobj = cloud_vertices(filename, header=loadhead, mapviewer=self)
9713
9713
 
9714
9714
  elif filename.endswith('.dxf'):
9715
9715
  types = ['POLYLINE','LWPOLYLINE','LINE', 'MTEXT', 'INSERT']
@@ -9725,7 +9725,56 @@ class WolfMapViewer(wx.Frame):
9725
9725
  types = [types[i] for i in dlg.GetSelections()]
9726
9726
  dlg.Destroy()
9727
9727
 
9728
- newobj = cloud_vertices(filename, header=loadhead, mapviewer=self, dxf_imported_elts=types)
9728
+ newobj = cloud_vertices(filename, header=loadhead, mapviewer=self, dxf_imported_elts=types)
9729
+
9730
+ elif filename.endswith('.shp'):
9731
+
9732
+ types = None
9733
+
9734
+ if Path(filename).stem == 'Vesdre_Bridges':
9735
+ # We need to import the bridges from the clogging study/database
9736
+ data = gpd.read_file(filename)
9737
+
9738
+ #filter 'Clogging' == Yes
9739
+ clogged = data[data['Clogging'] == 'Yes']
9740
+ unclogged = data[data['Clogging'] == 'No']
9741
+ notsure = data[data['Clogging'] == 'No information']
9742
+
9743
+ from tempfile import TemporaryDirectory
9744
+ with TemporaryDirectory() as tmpdirname:
9745
+ clogged.to_file(tmpdirname + '/clogged.shp')
9746
+ unclogged.to_file(tmpdirname + '/unclogged.shp')
9747
+ notsure.to_file(tmpdirname + '/notsure.shp')
9748
+
9749
+ newobj = cloud_vertices(tmpdirname + '/unclogged.shp', header=loadhead, mapviewer=self, idx='unclogged')
9750
+ self.myclouds.append(newobj)
9751
+ newobj.set_mapviewer(self)
9752
+ newobj.myprop.color = (0,255,0)
9753
+ newobj.myprop.size = 10
9754
+
9755
+ myitem = self.treelist.AppendItem(curtree, newobj.idx, data=newobj)
9756
+ self.treelist.CheckItem(myitem)
9757
+ self.treelist.CheckItem(self.treelist.GetItemParent(myitem))
9758
+ newobj.check_plot()
9759
+
9760
+ newobj = cloud_vertices(tmpdirname + '/notsure.shp', header=loadhead, mapviewer=self, idx='notsure')
9761
+ self.myclouds.append(newobj)
9762
+ newobj.set_mapviewer(self)
9763
+ newobj.myprop.color = (0,0,255)
9764
+ newobj.myprop.size = 10
9765
+
9766
+ myitem = self.treelist.AppendItem(curtree, newobj.idx, data=newobj)
9767
+ self.treelist.CheckItem(myitem)
9768
+ self.treelist.CheckItem(self.treelist.GetItemParent(myitem))
9769
+ newobj.check_plot()
9770
+
9771
+ newobj = cloud_vertices(tmpdirname + '/clogged.shp', header=loadhead, mapviewer=self, idx='clogged')
9772
+ newobj.myprop.color = (255,0,0)
9773
+ newobj.myprop.size = 15
9774
+ id = 'clogged'
9775
+
9776
+ else:
9777
+ newobj = cloud_vertices(filename, header=loadhead, mapviewer=self)
9729
9778
 
9730
9779
  self.myclouds.append(newobj)
9731
9780
  self.active_cloud = newobj
wolfhece/PyPalette.py CHANGED
@@ -109,6 +109,34 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
109
109
  else:
110
110
  return self(xloc, bytes=True)
111
111
 
112
+ def get_rgba_oneval(self, x: float):
113
+ """Récupération de la couleur en fonction de la valeur x"""
114
+
115
+ dval = self.values[-1]-self.values[0]
116
+ if dval == 0.:
117
+ dval = 1.
118
+ xloc = (x-self.values[0])/dval
119
+
120
+ if self.interval_cst:
121
+ rgba = np.ones((4), dtype=np.uint8)
122
+
123
+ if xloc < 0.:
124
+ rgba = self.colormin_uint8
125
+ elif xloc >= 1.:
126
+ rgba = self.colormax_uint8
127
+ else:
128
+ for i in range(self.nb-1):
129
+ val1 = (self.values[i]-self.values[0])/dval
130
+ val2 = (self.values[i+1]-self.values[0])/dval
131
+ if (xloc >= val1) & (xloc < val2):
132
+ c1 = self.colorsuint8[i]
133
+ rgba = c1
134
+ break
135
+
136
+ return rgba
137
+ else:
138
+ return self(xloc, bytes=True)
139
+
112
140
  def export_palette_matplotlib(self, name):
113
141
  cmaps = OrderedDict()
114
142
  cmaps['Perceptually Uniform Sequential'] = ['viridis', 'plasma', 'inferno', 'magma', 'cividis']
@@ -213,6 +241,14 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
213
241
 
214
242
  self.fill_segmentdata()
215
243
 
244
+ def get_ScalarMappable_mpl(self):
245
+ """ Récupération de l'objet ScalarMappable via Matplotlib """
246
+ if self.interval_cst:
247
+ discrete_cmap = ListedColormap(self.colorsflt[:, :3])
248
+ colorbar = ScalarMappable(BoundaryNorm(self.values, ncolors=self.nb-1), cmap=discrete_cmap)
249
+ else:
250
+ return ScalarMappable(Normalize(self.values[0], self.values[-1]), cmap=self)
251
+
216
252
  def export_image(self, fn='', h_or_v: typing.Literal['h', 'v', ''] = '', figax=None):
217
253
  """
218
254
  Export image from colormap
wolfhece/PyParams.py CHANGED
@@ -753,7 +753,7 @@ class Wolf_Param(wx.Frame):
753
753
  def SavetoFile(self, event:wx.MouseEvent):
754
754
  """ sauvegarde dans le fichier texte """
755
755
 
756
- self.save()
756
+ self.Save()
757
757
 
758
758
  def Save(self, filename:str = ''):
759
759
  """ Save the parameters in a file """
@@ -1308,7 +1308,7 @@ class Wolf_Param(wx.Frame):
1308
1308
  posSep2 = positions[-1] #nameStr[posSep1+1:].find("$")
1309
1309
 
1310
1310
  # select the string between the two '$'
1311
- iterCode = nameStr[posSep1:posSep1+posSep2+1]
1311
+ iterCode = nameStr[posSep1:posSep2+1]
1312
1312
 
1313
1313
  positions_left = [i for i, char in enumerate(iterCode) if char == "("]
1314
1314
  positions_right = [i for i, char in enumerate(iterCode) if char == ")"]
@@ -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]