1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
| import wx
import os
import numpy as np
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
import netCDF4
from netCDF4 import Dataset
class MainFrame(wx.Frame):
def __init__(self,parent):
super().__init__(parent, title="QUICK", size=(2000, 1000))
left = LeftPanel(self)
middle = MiddlePanel(self)
right = RightPanel(self)
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(left, 3, wx.EXPAND)
sizer.Add(middle, 5, wx.EXPAND)
sizer.Add(right, 5, wx.EXPAND)
self.SetSizer(sizer)
sizer1 = wx.BoxSizer(wx.VERTICAL)
sizer1.Add(left,2,wx.EXPAND)
sizer1.Add(right,2,wx.EXPAND)
sizer1.Add(middle,2,wx.EXPAND)
self.Show()
class LeftPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
self.SetBackgroundColour('122')
class MiddlePanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
self.SetBackgroundColour('179')
class RightPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
self.SetBackgroundColour('179 ')
class LeftPanelTop(wx.Panel):
def __init__(self, parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
self.SetBackgroundColour('snow2')
List_choices = ["1Km","3Km"]
List2 = ["3X3","5X5","7X7"]
self.dateLbl = wx.StaticBox(self, -1, 'Outils ', size=(410, 320))
self.dategraphSizer = wx.StaticBoxSizer(self.dateLbl, wx.VERTICAL)
combobox1 = wx.ComboBox(self,choices = List_choices, size =(80,20),pos =(180,50))
combobox2 = wx.ComboBox(self,choices = List2, size =(80,20),pos =(180,90))
wx.StaticText(self, label='Résolution:', pos=(70, 50))
wx.StaticText(self, label='Taille de cible:', pos=(70, 90))
QuickLook = wx.Button(self ,-1, "Open file" , size =(80, 25),pos =(180,130))
wx.StaticText(self, label='QuickLook:', pos=(70, 130))
QuickLook.Bind(wx.EVT_BUTTON, self.onOpen)
self.load_options = "netCDF4 files (nc)|*.nc| Text files (txt) |*.txt| All files |*.*"
def onOpen(self, event):
with wx.FileDialog(self, "On open", wildcard=self.load_options,
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE) as fileDialog:
if fileDialog.ShowModal() != wx.ID_CANCEL:
chosen_file = fileDialog.GetPath()
if fileDialog.ShowModal() != wx.ID_CANCEL:
chosen_file = fileDialog.GetPath()
if chosen_file.endswith('.txt'):
QuickLook(parent=self, text=chosen_file)
elif chosen_file.endswith('.nc'):
QuickLook_plot(parent=self, text=chosen_file)
class LeftPanelBottom(wx.Panel):
def __init__(self, parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
self.SetBackgroundColour('whitesmoke')
class LeftPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
top = LeftPanelTop(self)
bottom = LeftPanelBottom(self)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(top, 1, wx.EXPAND)
sizer.Add(bottom, 2, wx.EXPAND)
self.SetSizer(sizer)
class RightPanelTop(wx.Panel):
def __init__(self, parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
self.SetBackgroundColour('black')
canal=wx.Button(self,-1,"Variable",size=(140,30),pos=(100,0))
dynamique=wx.Button(self,-1,"Dynamique",size=(140,30),pos=(240,0))
file = wx.Button(self,-1,"File", size = (110,30),pos=(0,0))
dynamique.SetBackgroundColour('white')
canal.SetBackgroundColour('white')
file.SetBackgroundColour('white')
dynamique.Bind(wx.EVT_BUTTON, self.OnClick)
file.Bind(wx.EVT_BUTTON, self.onOpen)
def onOpen(self, event):
wildcard = "netCDF4 files (*.nc)|*.nc| HDF5 files (*.h5) |*.h5"
dialog = wx.FileDialog(self, "Open netCDF4 Files| HDF5 files", wildcard=wildcard,
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if dialog.ShowModal() == wx.ID_CANCEL:
return
path = dialog.GetPath()
if os.path.exists(path):
with open(path) as fobj:
for line in fobj:
self.my_text.WriteText(line)
def OnClick(self,event):
dlg = wx.TextEntryDialog(self, 'Enter Dynamique of image','Dynamique de image')
if dlg.ShowModal() == wx.ID_OK:
self.text.SetValue("Dynamique:"+dlg.GetValue())
dlg.Destroy()
class RightPanelBottom(wx.Panel):
def __init__(self, parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
self.SetBackgroundColour('red')
class RightPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
top = RightPanelTop(self)
bottom = RightPanelBottom(self)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(top, 2, wx.EXPAND)
sizer.Add(bottom, 2, wx.EXPAND)
self.SetSizer(sizer)
class MiddlePanelTop(wx.Panel):
def __init__(self, parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
self.SetBackgroundColour('black')
canal=wx.Button(self,-1,label ="Variable",size=(140,30),pos=(100,0))
dynamique=wx.Button(self,-1,"Dynamique",size=(140,30),pos=(240,0))
file = wx.Button(self,-1,"File", size = (110,30),pos=(0,0))
dynamique.SetBackgroundColour('white')
canal.SetBackgroundColour('white')
file.SetBackgroundColour('white')
dynamique.Bind(wx.EVT_BUTTON, self.OnClick)
file.Bind(wx.EVT_BUTTON, self.onOpen)
def onOpen(self, event):
wildcard = "netCDF4 files (*.nc)|*.nc"
dialog = wx.FileDialog(self, "Open netCDF4 Files", wildcard=wildcard,
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if dialog.ShowModal() == wx.ID_CANCEL:
return
path = dialog.GetPath()
if os.path.exists(path):
with open(path) as fobj:
for line in fobj:
self.my_text.WriteText(line)
def OnClick(self,event):
dlg = wx.TextEntryDialog(self, 'Enter Dynamique of image','Dynamique de image')
if dlg.ShowModal() == wx.ID_OK:
self.text.SetValue("Dynamique:"+dlg.GetValue())
dlg.Destroy()
class MiddlePanelBottom(wx.Panel):
def __init__(self, parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
self.SetBackgroundColour('black')
canal=wx.Button(self,-1,"Variable",size=(140,30),pos=(100,0))
dynamique=wx.Button(self,-1,"Dynamique",size=(140,30),pos=(240,0))
file = wx.Button(self,-1,"File", size = (110,30),pos=(0,0))
dynamique.SetBackgroundColour('white')
canal.SetBackgroundColour('white')
file.SetBackgroundColour('white')
dynamique.Bind(wx.EVT_BUTTON, self.OnClick)
file.Bind(wx.EVT_BUTTON, self.onOpen)
self.load_options = "netCDF4 files (nc)|*.nc| Text files (txt) |*.txt| All files |*.*"
def onOpen(self, event):
wildcard = "netCDF4 files (*.nc)|*.nc"
dialog = wx.FileDialog(self, "Open netCDF4 Files", wildcard=wildcard,
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if dialog.ShowModal() == wx.ID_CANCEL:
return
path = dialog.GetPath()
if os.path.exists(path):
with open(path) as fobj:
for line in fobj:
self.my_text.WriteText(line)
def OnClick(self,event):
dlg = wx.TextEntryDialog(self, 'Enter Dynamique of image','Dynamique de image')
if dlg.ShowModal() == wx.ID_OK:
self.text.SetValue("Dynamique:"+dlg.GetValue())
dlg.Destroy()
class MiddlePanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
top = MiddlePanelTop(self)
bottom = MiddlePanelBottom(self)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(top, 3, wx.EXPAND)
sizer.Add(bottom, 3, wx.EXPAND)
self.SetSizer(sizer)
class PanelTop(wx.Panel):
def __init__(self,parent):
super().__init__(parent)
self.SetBackgroundColour('black')
class PanelBottom(wx.Panel):
def __init__(self,parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
self.SetBackgroundColour('grey77')
self.dateLbl = wx.StaticBox(self, -1, 'Info', size=(700, 280))
self.dategraphSizer = wx.StaticBoxSizer(self.dateLbl, wx.VERTICAL)
class RightPanelBottom(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
top = PanelTop(self)
bottom = PanelBottom(self)
sizer1 = wx.BoxSizer(wx.VERTICAL)
sizer1.Add(top,2, wx.EXPAND)
sizer1.Add(bottom,4,wx.EXPAND)
self.SetSizer(sizer1)
class leftPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
self.SetBackgroundColour('black')
class midllePanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
self.SetBackgroundColour('black')
class rightPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent,style = wx.SUNKEN_BORDER)
self.SetBackgroundColour('black')
class PanelTop(wx.Panel):
def __init__(self,parent):
super().__init__(parent)
left = leftPanel(self)
right = rightPanel(self)
midlle = midllePanel(self)
sizer1 = wx.BoxSizer(wx.HORIZONTAL)
sizer1.Add(left,2, wx.EXPAND)
sizer1.Add(midlle,2,wx.EXPAND)
sizer1.Add(right,2,wx.EXPAND)
self.SetSizer(sizer1)
class QuickLook_plot(wx.Frame):
def __init__(self, parent,text=None):
wx.Frame.__init__(self, parent, wx.ID_ANY, "Quick Plot", size=(610,510))
panel = wx.Panel(self, wx.ID_ANY, size=(600,500))
self.figure = Figure()
self.axes = self.figure.add_subplot(111)
self.canvas = FigureCanvas(panel, -1, self.figure)
Quit_button = wx.Button(panel, wx.ID_ANY, "&Quit")
Quit_button.Bind(wx.EVT_BUTTON, self.OnQuit)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.sizer.Add(Quit_button, 0,wx.ALIGN_RIGHT)
panel.SetSizerAndFit(self.sizer)
#plot figure
fic='S_NWC_CI-VISIR_20180220T090000Z.nc'
path='/net/stockag/safn/2018/02/20/'
nc = netCDF4.Dataset(path+fic,'r')
ci_recup=nc.variables['ci_prob30'][:]
#Affichage de la variable
plt.pcolormesh(ci_recup)
plt.colorbar()
plt.show()
def OnQuit(self,event):
self.Close()
self.Destroy()
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, 'A test dialog')
frame.Show()
return True
app = wx.App()
frame = MainFrame(None).Show()
app.MainLoop() |
Partager