Commit 38f3d16ecacc4b5c3bafecef77332d2f333b1556

Authored by Jérémy Baudry
0 parents
Exists in master

first commit

Antarctic-sea-ice-008.jpg 0 → 100644

42.7 KB

gui.py 0 → 100755
  1 +++ a/gui.py
... ... @@ -0,0 +1,266 @@
  1 +#!/usr/bin/python
  2 +from gi.repository import Gtk
  3 +from netCDF4 import Dataset
  4 +import matplotlib.pyplot as plt
  5 +import numpy as np
  6 +from mpl_toolkits.mplot3d import Axes3D
  7 +from matplotlib import cm
  8 +from matplotlib.ticker import LinearLocator, FormatStrFormatter
  9 +from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
  10 +from matplotlib.backends.backend_gtk3 import NavigationToolbar2GTK3 as NavigationToolbar
  11 +
  12 +
  13 +
  14 +class Handler:
  15 + def __init__(self):
  16 + self.gladefile = "/home/jeremy/Bureau/GUI/wim.glade"
  17 + self.builder = Gtk.Builder()
  18 + self.builder.add_from_file(self.gladefile)
  19 + self.builder.connect_signals(self)
  20 + self.window = self.builder.get_object("window1")
  21 + self.window.show()
  22 + self.hscale1 = self.builder.get_object("hscale1")
  23 + self.hscale2 = self.builder.get_object("hscale2")
  24 + self.thick = self.builder.get_object("checkbutton1")
  25 + self.conc = self.builder.get_object("checkbutton2")
  26 + self.meanfloe = self.builder.get_object("checkbutton3")
  27 + self.FSTD = self.builder.get_object("checkbutton5")
  28 +
  29 +
  30 +
  31 +
  32 +
  33 + def disable(self,widget,event):
  34 + return True
  35 +
  36 + def on_destroy(self,closewindow):
  37 + closewindow.hide()
  38 +
  39 + def on_window1_destroy(self,window):
  40 + Gtk.main_quit()
  41 +
  42 +#===================choose_file_button===================================
  43 + def on_filechooserbutton1_file_set(self,choosefile):
  44 + global data
  45 + data = choosefile.get_filename()
  46 + self.readnc(data)
  47 + ad1 = Gtk.Adjustment(25,0,99,1,1, 0)
  48 + self.hscale1.set_adjustment(adjustment=ad1)
  49 + ad2 = Gtk.Adjustment(25,0,99,1,1, 0)
  50 + self.hscale2.set_adjustment(adjustment=ad2)
  51 + global xvalue
  52 + xvalue=x_axis[0]
  53 + global timevalue
  54 + timevalue=time[0]
  55 +
  56 + self.windowthick = Gtk.Window()
  57 + self.windowthick.set_default_size(400,400)
  58 + self.windowthick.connect("delete-event",self.disable)
  59 + self.fig1=plt.figure(1)
  60 + canvas1 = FigureCanvas(self.fig1)
  61 + canvas1.set_size_request(100,100)
  62 + self.axthick = self.fig1.add_subplot(111)
  63 + self.axthick.plot(x_axis,thickness)
  64 + self.vline1=self.axthick.axvline(x_axis[xvalue],color='k',ls='dashed')
  65 + self.hline1=self.axthick.axhline(thickness[xvalue],color='k',ls='dashed')
  66 + self.pointer=self.axthick.plot(x_axis[xvalue],thickness[xvalue],'ro',markersize=10.0)[0]
  67 + self.axthick.set_ylabel('Mean ice thickness')
  68 + self.windowthick.set_title('Mean ice thickness')
  69 + self.vbox = Gtk.VBox()
  70 + self.windowthick.add(self.vbox)
  71 + self.vbox.pack_start(canvas1,True,True, 0)
  72 + toolbar = NavigationToolbar(canvas1,self.windowthick)
  73 + self.vbox.pack_start(toolbar, False, False,0)
  74 +
  75 + self.windowconc = Gtk.Window()
  76 + self.windowconc.set_default_size(400,400)
  77 + self.windowconc.set_title('Ice concentration')
  78 + self.windowconc.connect("delete-event",self.disable)
  79 + self.fig3=plt.figure(3)
  80 + canvas3 = FigureCanvas(self.fig3)
  81 + canvas3.set_size_request(100,100)
  82 + self.axconc = self.fig3.add_subplot(111)
  83 + self.axconc.plot(x_axis,ice_concentration)
  84 + self.vline2=self.axconc.axvline(x_axis[xvalue],color='k',ls='dashed')
  85 + self.hline2=self.axconc.axhline(ice_concentration[xvalue],color='k',ls='dashed')
  86 + self.pointer2=self.axconc.plot(x_axis[xvalue],ice_concentration[xvalue],'ro',markersize=10.0)[0]
  87 + self.axconc.set_ylabel('Ice concentration')
  88 + self.vboxconc = Gtk.VBox()
  89 + self.windowconc.add(self.vboxconc)
  90 + self.vboxconc.pack_start(canvas3,True,True, 0)
  91 + toolbar3 = NavigationToolbar(canvas3,self.windowconc)
  92 + self.vboxconc.pack_start(toolbar3, False, False,0)
  93 +
  94 + self.windowmeanfloe = Gtk.Window()
  95 + self.windowmeanfloe.set_default_size(400,400)
  96 + self.windowmeanfloe.set_title('Mean Floe size')
  97 + self.windowmeanfloe.connect("delete-event",self.disable)
  98 + self.fig4=plt.figure(4)
  99 + canvas4 = FigureCanvas(self.fig4)
  100 + canvas4.set_size_request(100,100)
  101 + self.axmeanfloe = self.fig4.add_subplot(111)
  102 + self.axmeanfloe.plot(x_axis,D_ave)
  103 + self.vline3=self.axmeanfloe.axvline(x_axis[xvalue],color='k',ls='dashed')
  104 + self.hline3=self.axmeanfloe.axhline(D_ave[xvalue],color='k',ls='dashed')
  105 + self.pointer3=self.axmeanfloe.plot(x_axis[xvalue],D_ave[xvalue],'ro',markersize=10.0)[0]
  106 + self.axconc.set_ylabel('Mean floe size')
  107 + self.vboxmeanfloe = Gtk.VBox()
  108 + self.windowmeanfloe.add(self.vboxmeanfloe)
  109 + self.vboxmeanfloe.pack_start(canvas4,True,True, 0)
  110 + toolbar4 = NavigationToolbar(canvas4,self.windowmeanfloe)
  111 + self.vboxmeanfloe.pack_start(toolbar4, False, False,0)
  112 +
  113 + self.windowfstd = Gtk.Window()
  114 + self.windowfstd.set_default_size(400,400)
  115 + self.windowfstd.set_title('FSTD')
  116 + self.windowfstd.connect("delete-event",self.disable)
  117 + self.fig2=plt.figure(2)
  118 + canvas2 = FigureCanvas(self.fig2)
  119 + canvas2.set_size_request(100,100)
  120 + self.axfstd= self.fig2.add_subplot(111)
  121 + FSD2=FSD[:,:,xvalue,timevalue]
  122 + ITD2=ITD[:,xvalue]
  123 + global FSTD
  124 + FSTD=np.zeros((50,60))
  125 + for i in xrange(0,49):
  126 + FSTD[i,:]=FSD2[i,:]*ITD2[i]
  127 + self.fstdplot=self.axfstd.imshow(FSTD, interpolation='nearest', cmap=cm.coolwarm)
  128 + self.cbar = self.fig2.colorbar(self.fstdplot)
  129 + self.cbar.set_clim(0,0.1)
  130 + self.vboxfstd = Gtk.VBox()
  131 + self.windowfstd.add(self.vboxfstd)
  132 + self.vboxfstd.pack_start(canvas2,True,True, 0)
  133 + toolbar2 = NavigationToolbar(canvas2,self.windowfstd)
  134 + self.vboxfstd.pack_start(toolbar2, False, False,0)
  135 +
  136 +
  137 + if self.thick.get_active():
  138 + self.plot_thick(x_axis,thickness,xvalue)
  139 + if self.conc.get_active():
  140 + self.plot_conc(x_axis,ice_concentration,xvalue)
  141 + if self.meanfloe.get_active():
  142 + self.plot_meanfloe(x_axis,D_ave,xvalue)
  143 + if self.FSTD.get_active():
  144 + self.plot_FSTD(xvalue,timevalue,Fsize,hcat,FSD,ITD)
  145 +
  146 +
  147 +#======================scale_buttons======================================
  148 + def on_hscale1_value_changed(self,timescale):
  149 + timevalue=timescale.get_value()
  150 + if self.FSTD.get_active():
  151 + self.plot_FSTD(xvalue,timevalue,Fsize,hcat,FSD,ITD)
  152 +
  153 + def on_hscale2_value_changed(self,xscale):
  154 + xvalue=xscale.get_value()
  155 + if self.thick.get_active():
  156 + self.plot_thick(x_axis,thickness,xvalue)
  157 + if self.FSTD.get_active():
  158 + self.plot_FSTD(xvalue,timevalue,Fsize,hcat,FSD,ITD)
  159 + if self.conc.get_active():
  160 + self.plot_conc(x_axis,ice_concentration,xvalue)
  161 + if self.meanfloe.get_active():
  162 + self.plot_meanfloe(x_axis,D_ave,xvalue)
  163 +
  164 +#====================toggle_button=========================================
  165 + def on_checkbutton1_toggled(self,but1):
  166 + if but1.get_active():
  167 + self.plot_thick(x_axis,thickness,xvalue)
  168 + else:
  169 + self.on_destroy(self.windowthick)
  170 +
  171 + def on_checkbutton2_toggled(self,butconc):
  172 + if butconc.get_active():
  173 + self.plot_conc(x_axis,ice_concentration,xvalue)
  174 + else:
  175 + self.on_destroy(self.windowconc)
  176 +
  177 + def on_checkbutton3_toggled(self,butmeanfloe):
  178 + if butmeanfloe.get_active():
  179 + self.plot_meanfloe(x_axis,D_ave,xvalue)
  180 + else:
  181 + self.on_destroy(self.windowmeanfloe)
  182 +
  183 + def on_checkbutton5_toggled(self,butFSTD):
  184 + if butFSTD.get_active():
  185 + self.plot_FSTD(xvalue,timevalue,Fsize,hcat,FSD,ITD)
  186 + else:
  187 + self.on_destroy(self.windowfstd)
  188 +
  189 +#==========================================================================
  190 + def plot_thick(self,x_axis,thickness,xvalue):
  191 + self.pointer.set_ydata(thickness[xvalue])
  192 + self.vline1.set_xdata(x_axis[xvalue])
  193 + self.hline1.set_ydata(thickness[xvalue])
  194 + self.pointer.set_xdata(x_axis[xvalue])
  195 + self.windowthick.show_all()
  196 + self.windowthick.present()
  197 + self.window.present()
  198 +
  199 +#==========================================================================
  200 + def plot_conc(self,x_axis,ice_concentration,xvalue):
  201 + self.pointer2.set_ydata(ice_concentration[xvalue])
  202 + self.vline2.set_xdata(x_axis[xvalue])
  203 + self.hline2.set_ydata(ice_concentration[xvalue])
  204 + self.pointer2.set_xdata(x_axis[xvalue])
  205 + self.windowconc.show_all()
  206 + self.windowconc.present()
  207 + self.window.present()
  208 +
  209 +#==========================================================================
  210 + def plot_meanfloe(self,x_axis,D_ave,xvalue):
  211 + self.pointer3.set_ydata(D_ave[xvalue])
  212 + self.vline3.set_xdata(x_axis[xvalue])
  213 + self.hline3.set_ydata(D_ave[xvalue])
  214 + self.pointer3.set_xdata(x_axis[xvalue])
  215 + self.windowmeanfloe.show_all()
  216 + self.windowmeanfloe.present()
  217 + self.window.present()
  218 +
  219 +#=========================================================================
  220 + def plot_FSTD(self,xvalue,timevalue,Fsize,hcat,FSD,ITD):
  221 + FSD2=FSD[:,:,xvalue,timevalue]
  222 + ITD2=ITD[:,xvalue]
  223 + global FSTD
  224 + FSTD=np.zeros((50,60))
  225 + for i in xrange(0,49):
  226 + FSTD[i,:]=FSD2[i,:]*ITD2[i]
  227 + self.fstdplot.set_data(FSTD)
  228 + plt.draw()
  229 + self.windowfstd.show_all()
  230 + self.windowfstd.present()
  231 + self.window.present()
  232 +#==========================================================================
  233 +
  234 + def readnc(self,data):
  235 + global omega
  236 + global x_axis
  237 + global time
  238 + global hcat
  239 + global Fsize
  240 + global spectrum
  241 + global D_ave
  242 + global ice_concentration
  243 + global FSD
  244 + global Hs
  245 + global ITD
  246 + global thickness
  247 + fh = Dataset(data)
  248 + omega = fh.variables['omega'][:]
  249 + x_axis = fh.variables['x_axis'][:]
  250 + time = fh.variables['time'][:]
  251 + hcat= fh.variables['thickness categories'][:]
  252 + Fsize= fh.variables['floe size'][:]
  253 + spectrum = fh.variables['Spectrum'][:,:,:]
  254 + D_ave = fh.variables['Dave'][:]
  255 + ice_concentration = fh.variables['Ice concentration'][:]
  256 + thickness = fh.variables['Ice thickness'][:]
  257 + FSD = fh.variables['Floe size distribution'][:,:,:,:]
  258 + Hs = fh.variables['significant height'][:,:]
  259 + ITD = fh.variables['Ice Thickness Distribution'][:,:]
  260 + fh.close()
  261 +
  262 +
  263 +if __name__ == "__main__":
  264 + main = Handler()
  265 +Gtk.main()
  266 +
... ...
gui.py~ 0 → 100755
  1 +++ a/gui.py~
... ... @@ -0,0 +1,266 @@
  1 +#!/usr/bin/python
  2 +from gi.repository import Gtk
  3 +from netCDF4 import Dataset
  4 +import matplotlib.pyplot as plt
  5 +import numpy as np
  6 +from mpl_toolkits.mplot3d import Axes3D
  7 +from matplotlib import cm
  8 +from matplotlib.ticker import LinearLocator, FormatStrFormatter
  9 +from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas
  10 +from matplotlib.backends.backend_gtk3 import NavigationToolbar2GTK3 as NavigationToolbar
  11 +
  12 +
  13 +
  14 +class Handler:
  15 + def __init__(self):
  16 + self.gladefile = "/home/jeremy/Bureau/GUI/wim.glade"
  17 + self.builder = Gtk.Builder()
  18 + self.builder.add_from_file(self.gladefile)
  19 + self.builder.connect_signals(self)
  20 + self.window = self.builder.get_object("window1")
  21 + self.window.show()
  22 + self.hscale1 = self.builder.get_object("hscale1")
  23 + self.hscale2 = self.builder.get_object("hscale2")
  24 + self.thick = self.builder.get_object("checkbutton1")
  25 + self.conc = self.builder.get_object("checkbutton2")
  26 + self.meanfloe = self.builder.get_object("checkbutton3")
  27 + self.FSTD = self.builder.get_object("checkbutton5")
  28 +
  29 +
  30 +
  31 +
  32 +
  33 + def disable(self,widget,event):
  34 + return True
  35 +
  36 + def on_destroy(self,closewindow):
  37 + closewindow.hide()
  38 +
  39 + def on_window1_destroy(self,window):
  40 + Gtk.main_quit()
  41 +
  42 +#===================choose_file_button===================================
  43 + def on_filechooserbutton1_file_set(self,choosefile):
  44 + global data
  45 + data = choosefile.get_filename()
  46 + self.readnc(data)
  47 + ad1 = Gtk.Adjustment(25,0,99,1,1, 0)
  48 + self.hscale1.set_adjustment(adjustment=ad1)
  49 + ad2 = Gtk.Adjustment(25,0,99,1,1, 0)
  50 + self.hscale2.set_adjustment(adjustment=ad2)
  51 + global xvalue
  52 + xvalue=x_axis[0]
  53 + global timevalue
  54 + timevalue=time[0]
  55 +
  56 + self.windowthick = Gtk.Window()
  57 + self.windowthick.set_default_size(400,400)
  58 + self.windowthick.connect("delete-event",self.disable)
  59 + self.fig1=plt.figure(1)
  60 + canvas1 = FigureCanvas(self.fig1)
  61 + canvas1.set_size_request(100,100)
  62 + self.axthick = self.fig1.add_subplot(111)
  63 + self.axthick.plot(x_axis,thickness)
  64 + self.vline1=self.axthick.axvline(x_axis[xvalue],color='k',ls='dashed')
  65 + self.hline1=self.axthick.axhline(thickness[xvalue],color='k',ls='dashed')
  66 + self.pointer=self.axthick.plot(x_axis[xvalue],thickness[xvalue],'ro',markersize=10.0)[0]
  67 + self.axthick.set_ylabel('Mean ice thickness')
  68 + self.windowthick.set_title('Mean ice thickness')
  69 + self.vbox = Gtk.VBox()
  70 + self.windowthick.add(self.vbox)
  71 + self.vbox.pack_start(canvas1,True,True, 0)
  72 + toolbar = NavigationToolbar(canvas1,self.windowthick)
  73 + self.vbox.pack_start(toolbar, False, False,0)
  74 +
  75 + self.windowconc = Gtk.Window()
  76 + self.windowconc.set_default_size(400,400)
  77 + self.windowconc.set_title('Ice concentration')
  78 + self.windowconc.connect("delete-event",self.disable)
  79 + self.fig3=plt.figure(3)
  80 + canvas3 = FigureCanvas(self.fig3)
  81 + canvas3.set_size_request(100,100)
  82 + self.axconc = self.fig3.add_subplot(111)
  83 + self.axconc.plot(x_axis,ice_concentration)
  84 + self.vline2=self.axconc.axvline(x_axis[xvalue],color='k',ls='dashed')
  85 + self.hline2=self.axconc.axhline(ice_concentration[xvalue],color='k',ls='dashed')
  86 + self.pointer2=self.axconc.plot(x_axis[xvalue],ice_concentration[xvalue],'ro',markersize=10.0)[0]
  87 + self.axconc.set_ylabel('Ice concentration')
  88 + self.vboxconc = Gtk.VBox()
  89 + self.windowconc.add(self.vboxconc)
  90 + self.vboxconc.pack_start(canvas3,True,True, 0)
  91 + toolbar3 = NavigationToolbar(canvas3,self.windowconc)
  92 + self.vboxconc.pack_start(toolbar3, False, False,0)
  93 +
  94 + self.windowmeanfloe = Gtk.Window()
  95 + self.windowmeanfloe.set_default_size(400,400)
  96 + self.windowmeanfloe.set_title('Mean Floe size')
  97 + self.windowmeanfloe.connect("delete-event",self.disable)
  98 + self.fig4=plt.figure(4)
  99 + canvas4 = FigureCanvas(self.fig4)
  100 + canvas4.set_size_request(100,100)
  101 + self.axmeanfloe = self.fig4.add_subplot(111)
  102 + self.axmeanfloe.plot(x_axis,D_ave)
  103 + self.vline3=self.axmeanfloe.axvline(x_axis[xvalue],color='k',ls='dashed')
  104 + self.hline3=self.axmeanfloe.axhline(D_ave[xvalue],color='k',ls='dashed')
  105 + self.pointer3=self.axmeanfloe.plot(x_axis[xvalue],D_ave[xvalue],'ro',markersize=10.0)[0]
  106 + self.axconc.set_ylabel('Mean floe size')
  107 + self.vboxmeanfloe = Gtk.VBox()
  108 + self.windowmeanfloe.add(self.vboxmeanfloe)
  109 + self.vboxmeanfloe.pack_start(canvas4,True,True, 0)
  110 + toolbar4 = NavigationToolbar(canvas4,self.windowmeanfloe)
  111 + self.vboxmeanfloe.pack_start(toolbar4, False, False,0)
  112 +
  113 + self.windowfstd = Gtk.Window()
  114 + self.windowfstd.set_default_size(400,400)
  115 + self.windowfstd.set_title('FSTD')
  116 + self.windowfstd.connect("delete-event",self.disable)
  117 + self.fig2=plt.figure(2)
  118 + canvas2 = FigureCanvas(self.fig2)
  119 + canvas2.set_size_request(100,100)
  120 + self.axfstd= self.fig2.add_subplot(111)
  121 + FSD2=FSD[:,:,xvalue,timevalue]
  122 + ITD2=ITD[:,xvalue]
  123 + global FSTD
  124 + FSTD=np.zeros((50,60))
  125 + for i in xrange(0,49):
  126 + FSTD[i,:]=FSD2[i,:]*ITD2[i]
  127 + self.fstdplot=self.axfstd.imshow(FSTD, interpolation='nearest', cmap=cm.coolwarm)
  128 + self.cbar = self.fig2.colorbar(self.fstdplot)
  129 + self.cbar.set_clim(0,0.1)
  130 + self.vboxfstd = Gtk.VBox()
  131 + self.windowfstd.add(self.vboxfstd)
  132 + self.vboxfstd.pack_start(canvas2,True,True, 0)
  133 + toolbar2 = NavigationToolbar(canvas2,self.windowfstd)
  134 + self.vboxfstd.pack_start(toolbar2, False, False,0)
  135 +
  136 +
  137 + if self.thick.get_active():
  138 + self.plot_thick(x_axis,thickness,xvalue)
  139 + if self.conc.get_active():
  140 + self.plot_conc(x_axis,ice_concentration,xvalue)
  141 + if self.meanfloe.get_active():
  142 + self.plot_meanfloe(x_axis,D_ave,xvalue)
  143 + if self.FSTD.get_active():
  144 + self.plot_FSTD(xvalue,timevalue,Fsize,hcat,FSD,ITD)
  145 +
  146 +
  147 +#======================scale_buttons======================================
  148 + def on_hscale1_value_changed(self,timescale):
  149 + timevalue=timescale.get_value()
  150 + if self.FSTD.get_active():
  151 + self.plot_FSTD(xvalue,timevalue,Fsize,hcat,FSD,ITD)
  152 +
  153 + def on_hscale2_value_changed(self,xscale):
  154 + xvalue=xscale.get_value()
  155 + if self.thick.get_active():
  156 + self.plot_thick(x_axis,thickness,xvalue)
  157 + if self.FSTD.get_active():
  158 + self.plot_FSTD(xvalue,timevalue,Fsize,hcat,FSD,ITD)
  159 + if self.conc.get_active():
  160 + self.plot_conc(x_axis,ice_concentration,xvalue)
  161 + if self.meanfloe.get_active():
  162 + self.plot_meanfloe(x_axis,D_ave,xvalue)
  163 +
  164 +#====================toggle_button=========================================
  165 + def on_checkbutton1_toggled(self,but1):
  166 + if but1.get_active():
  167 + self.plot_thick(x_axis,thickness,xvalue)
  168 + else:
  169 + self.on_destroy(self.windowthick)
  170 +
  171 + def on_checkbutton2_toggled(self,butconc):
  172 + if butconc.get_active():
  173 + self.plot_conc(x_axis,ice_concentration,xvalue)
  174 + else:
  175 + self.on_destroy(self.windowconc)
  176 +
  177 + def on_checkbutton3_toggled(self,butmeanfloe):
  178 + if butmeanfloe.get_active():
  179 + self.plot_meanfloe(x_axis,D_ave,xvalue)
  180 + else:
  181 + self.on_destroy(self.windowmeanfloe)
  182 +
  183 + def on_checkbutton5_toggled(self,butFSTD):
  184 + if butFSTD.get_active():
  185 + self.plot_FSTD(xvalue,timevalue,Fsize,hcat,FSD,ITD)
  186 + else:
  187 + self.on_destroy(self.windowfstd)
  188 +
  189 +#==========================================================================
  190 + def plot_thick(self,x_axis,thickness,xvalue):
  191 + self.pointer.set_ydata(thickness[xvalue])
  192 + self.vline1.set_xdata(x_axis[xvalue])
  193 + self.hline1.set_ydata(thickness[xvalue])
  194 + self.pointer.set_xdata(x_axis[xvalue])
  195 + self.windowthick.show_all()
  196 + self.windowthick.present()
  197 + self.window.present()
  198 +
  199 +#==========================================================================
  200 + def plot_conc(self,x_axis,ice_concentration,xvalue):
  201 + self.pointer2.set_ydata(ice_concentration[xvalue])
  202 + self.vline2.set_xdata(x_axis[xvalue])
  203 + self.hline2.set_ydata(ice_concentration[xvalue])
  204 + self.pointer2.set_xdata(x_axis[xvalue])
  205 + self.windowconc.show_all()
  206 + self.windowconc.present()
  207 + self.window.present()
  208 +
  209 +#==========================================================================
  210 + def plot_meanfloe(self,x_axis,D_ave,xvalue):
  211 + self.pointer3.set_ydata(D_ave[xvalue])
  212 + self.vline3.set_xdata(x_axis[xvalue])
  213 + self.hline3.set_ydata(D_ave[xvalue])
  214 + self.pointer3.set_xdata(x_axis[xvalue])
  215 + self.windowmeanfloe.show_all()
  216 + self.windowmeanfloe.present()
  217 + self.window.present()
  218 +
  219 +#=========================================================================
  220 + def plot_FSTD(self,xvalue,timevalue,Fsize,hcat,FSD,ITD):
  221 + FSD2=FSD[:,:,xvalue,timevalue]
  222 + ITD2=ITD[:,xvalue]
  223 + global FSTD
  224 + FSTD=np.zeros((50,60))
  225 + for i in xrange(0,49):
  226 + FSTD[i,:]=FSD2[i,:]*ITD2[i]
  227 + self.fstdplot.set_data(FSTD)
  228 + plt.draw()
  229 + self.windowfstd.show_all()
  230 + self.windowfstd.present()
  231 + self.window.present()
  232 +#==========================================================================
  233 +
  234 + def readnc(self,data):
  235 + global omega
  236 + global x_axis
  237 + global time
  238 + global hcat
  239 + global Fsize
  240 + global spectrum
  241 + global D_ave
  242 + global ice_concentration
  243 + global FSD
  244 + global Hs
  245 + global ITD
  246 + global thickness
  247 + fh = Dataset(data)
  248 + omega = fh.variables['omega'][:]
  249 + x_axis = fh.variables['x_axis'][:]
  250 + time = fh.variables['time'][:]
  251 + hcat= fh.variables['thickness categories'][:]
  252 + Fsize= fh.variables['floe size'][:]
  253 + spectrum = fh.variables['Spectrum'][:,:,:]
  254 + D_ave = fh.variables['Dave'][:]
  255 + ice_concentration = fh.variables['Ice concentration'][:]
  256 + thickness = fh.variables['Ice thickness'][:]
  257 + FSD = fh.variables['Floe size distribution'][:,:,:,:]
  258 + Hs = fh.variables['significant height'][:,:]
  259 + ITD = fh.variables['Ice Thickness Distribution'][:,:]
  260 + fh.close()
  261 +
  262 +
  263 +if __name__ == "__main__":
  264 + main = Handler()
  265 +Gtk.main()
  266 +
... ...
sea-ice.jpg 0 → 100644

27.6 KB

test.py 0 → 100755
  1 +++ a/test.py
... ... @@ -0,0 +1,18 @@
  1 +#!/usr/bin/env python
  2 +
  3 +
  4 +
  5 +import numpy as np
  6 +import matplotlib.pyplot as plt
  7 +import matplotlib.animation as animation
  8 +
  9 +plt.ion()
  10 +img = np.random.rand(40,40)
  11 +fig=plt.figure(1)
  12 +image = plt.imshow(img,interpolation='nearest',animated=True,label="blah")
  13 +
  14 +for k in range(1,10000):
  15 + img = np.random.rand(40,40)
  16 + image.set_data(img)
  17 + plt.draw()
  18 +
... ...
test.py~ 0 → 100755
  1 +++ a/test.py~
... ... @@ -0,0 +1,18 @@
  1 +#!/usr/bin/env python
  2 +
  3 +
  4 +
  5 +import numpy as np
  6 +import matplotlib.pyplot as plt
  7 +import matplotlib.animation as animation
  8 +
  9 +plt.ion()
  10 +img = np.random.rand(40,40)
  11 +fig=plt.figure(1)
  12 +image = plt.imshow(img,interpolation='nearest',animated=True,label="blah")
  13 +
  14 +for k in range(1,10000):
  15 + img = np.random.rand(40,40)
  16 + image.set_data(img)
  17 + plt.draw()
  18 +
... ...
testgui2.nc 0 → 100644
No preview for this file type
wave-512.png 0 → 100644

16 KB

wim.glade 0 → 100644
  1 +++ a/wim.glade
... ... @@ -0,0 +1,487 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<interface>
  3 + <requires lib="gtk+" version="2.20"/>
  4 + <!-- interface-naming-policy project-wide -->
  5 + <object class="GtkAdjustment" id="adjustment1">
  6 + <property name="upper">100</property>
  7 + <property name="step_increment">1</property>
  8 + <property name="page_increment">10</property>
  9 + </object>
  10 + <object class="GtkAdjustment" id="adjustment2">
  11 + <property name="upper">100</property>
  12 + <property name="step_increment">1</property>
  13 + <property name="page_increment">10</property>
  14 + </object>
  15 + <object class="GtkWindow" id="window1">
  16 + <property name="can_focus">False</property>
  17 + <property name="title" translatable="yes">WIMviewer</property>
  18 + <property name="resizable">False</property>
  19 + <property name="window_position">center</property>
  20 + <property name="icon">Antarctic-sea-ice-008.jpg</property>
  21 + <signal name="destroy" handler="on_window1_destroy" swapped="no"/>
  22 + <child>
  23 + <object class="GtkVBox" id="vbox1">
  24 + <property name="visible">True</property>
  25 + <property name="can_focus">False</property>
  26 + <child>
  27 + <object class="GtkVBox" id="vbox3">
  28 + <property name="visible">True</property>
  29 + <property name="can_focus">False</property>
  30 + <child>
  31 + <object class="GtkMenuBar" id="menubar1">
  32 + <property name="visible">True</property>
  33 + <property name="can_focus">False</property>
  34 + <child>
  35 + <object class="GtkMenuItem" id="menuitem1">
  36 + <property name="visible">True</property>
  37 + <property name="can_focus">False</property>
  38 + <property name="use_action_appearance">False</property>
  39 + <property name="label" translatable="yes">_Fichier</property>
  40 + <property name="use_underline">True</property>
  41 + <child type="submenu">
  42 + <object class="GtkMenu" id="menu1">
  43 + <property name="visible">True</property>
  44 + <property name="can_focus">False</property>
  45 + <child>
  46 + <object class="GtkImageMenuItem" id="imagemenuitem1">
  47 + <property name="label">gtk-new</property>
  48 + <property name="visible">True</property>
  49 + <property name="can_focus">False</property>
  50 + <property name="use_action_appearance">False</property>
  51 + <property name="use_underline">True</property>
  52 + <property name="use_stock">True</property>
  53 + </object>
  54 + </child>
  55 + <child>
  56 + <object class="GtkImageMenuItem" id="imagemenuitem2">
  57 + <property name="label">gtk-open</property>
  58 + <property name="visible">True</property>
  59 + <property name="can_focus">False</property>
  60 + <property name="use_action_appearance">False</property>
  61 + <property name="use_underline">True</property>
  62 + <property name="use_stock">True</property>
  63 + </object>
  64 + </child>
  65 + <child>
  66 + <object class="GtkImageMenuItem" id="imagemenuitem3">
  67 + <property name="label">gtk-save</property>
  68 + <property name="visible">True</property>
  69 + <property name="can_focus">False</property>
  70 + <property name="use_action_appearance">False</property>
  71 + <property name="use_underline">True</property>
  72 + <property name="use_stock">True</property>
  73 + </object>
  74 + </child>
  75 + <child>
  76 + <object class="GtkImageMenuItem" id="imagemenuitem4">
  77 + <property name="label">gtk-save-as</property>
  78 + <property name="visible">True</property>
  79 + <property name="can_focus">False</property>
  80 + <property name="use_action_appearance">False</property>
  81 + <property name="use_underline">True</property>
  82 + <property name="use_stock">True</property>
  83 + </object>
  84 + </child>
  85 + <child>
  86 + <object class="GtkSeparatorMenuItem" id="separatormenuitem1">
  87 + <property name="visible">True</property>
  88 + <property name="can_focus">False</property>
  89 + <property name="use_action_appearance">False</property>
  90 + </object>
  91 + </child>
  92 + <child>
  93 + <object class="GtkImageMenuItem" id="imagemenuitem5">
  94 + <property name="label">gtk-quit</property>
  95 + <property name="visible">True</property>
  96 + <property name="can_focus">False</property>
  97 + <property name="use_action_appearance">False</property>
  98 + <property name="use_underline">True</property>
  99 + <property name="use_stock">True</property>
  100 + </object>
  101 + </child>
  102 + </object>
  103 + </child>
  104 + </object>
  105 + </child>
  106 + <child>
  107 + <object class="GtkMenuItem" id="menuitem2">
  108 + <property name="visible">True</property>
  109 + <property name="can_focus">False</property>
  110 + <property name="use_action_appearance">False</property>
  111 + <property name="label" translatable="yes">É_dition</property>
  112 + <property name="use_underline">True</property>
  113 + <child type="submenu">
  114 + <object class="GtkMenu" id="menu2">
  115 + <property name="visible">True</property>
  116 + <property name="can_focus">False</property>
  117 + <child>
  118 + <object class="GtkImageMenuItem" id="imagemenuitem6">
  119 + <property name="label">gtk-cut</property>
  120 + <property name="visible">True</property>
  121 + <property name="can_focus">False</property>
  122 + <property name="use_action_appearance">False</property>
  123 + <property name="use_underline">True</property>
  124 + <property name="use_stock">True</property>
  125 + </object>
  126 + </child>
  127 + <child>
  128 + <object class="GtkImageMenuItem" id="imagemenuitem7">
  129 + <property name="label">gtk-copy</property>
  130 + <property name="visible">True</property>
  131 + <property name="can_focus">False</property>
  132 + <property name="use_action_appearance">False</property>
  133 + <property name="use_underline">True</property>
  134 + <property name="use_stock">True</property>
  135 + </object>
  136 + </child>
  137 + <child>
  138 + <object class="GtkImageMenuItem" id="imagemenuitem8">
  139 + <property name="label">gtk-paste</property>
  140 + <property name="visible">True</property>
  141 + <property name="can_focus">False</property>
  142 + <property name="use_action_appearance">False</property>
  143 + <property name="use_underline">True</property>
  144 + <property name="use_stock">True</property>
  145 + </object>
  146 + </child>
  147 + <child>
  148 + <object class="GtkImageMenuItem" id="imagemenuitem9">
  149 + <property name="label">gtk-delete</property>
  150 + <property name="visible">True</property>
  151 + <property name="can_focus">False</property>
  152 + <property name="use_action_appearance">False</property>
  153 + <property name="use_underline">True</property>
  154 + <property name="use_stock">True</property>
  155 + </object>
  156 + </child>
  157 + </object>
  158 + </child>
  159 + </object>
  160 + </child>
  161 + <child>
  162 + <object class="GtkMenuItem" id="menuitem3">
  163 + <property name="visible">True</property>
  164 + <property name="can_focus">False</property>
  165 + <property name="use_action_appearance">False</property>
  166 + <property name="label" translatable="yes">_Affichage</property>
  167 + <property name="use_underline">True</property>
  168 + </object>
  169 + </child>
  170 + <child>
  171 + <object class="GtkMenuItem" id="menuitem4">
  172 + <property name="visible">True</property>
  173 + <property name="can_focus">False</property>
  174 + <property name="use_action_appearance">False</property>
  175 + <property name="label" translatable="yes">Aid_e</property>
  176 + <property name="use_underline">True</property>
  177 + <child type="submenu">
  178 + <object class="GtkMenu" id="menu3">
  179 + <property name="visible">True</property>
  180 + <property name="can_focus">False</property>
  181 + <child>
  182 + <object class="GtkImageMenuItem" id="imagemenuitem10">
  183 + <property name="label">gtk-about</property>
  184 + <property name="visible">True</property>
  185 + <property name="can_focus">False</property>
  186 + <property name="use_action_appearance">False</property>
  187 + <property name="use_underline">True</property>
  188 + <property name="use_stock">True</property>
  189 + </object>
  190 + </child>
  191 + </object>
  192 + </child>
  193 + </object>
  194 + </child>
  195 + </object>
  196 + <packing>
  197 + <property name="expand">False</property>
  198 + <property name="fill">True</property>
  199 + <property name="position">0</property>
  200 + </packing>
  201 + </child>
  202 + <child>
  203 + <object class="GtkVBox" id="vbox4">
  204 + <property name="visible">True</property>
  205 + <property name="can_focus">False</property>
  206 + <child>
  207 + <object class="GtkImage" id="image1">
  208 + <property name="visible">True</property>
  209 + <property name="can_focus">False</property>
  210 + <property name="pixbuf">sea-ice.jpg</property>
  211 + </object>
  212 + <packing>
  213 + <property name="expand">True</property>
  214 + <property name="fill">True</property>
  215 + <property name="position">0</property>
  216 + </packing>
  217 + </child>
  218 + <child>
  219 + <object class="GtkVBox" id="vbox5">
  220 + <property name="visible">True</property>
  221 + <property name="can_focus">False</property>
  222 + <child>
  223 + <object class="GtkLabel" id="label3">
  224 + <property name="visible">True</property>
  225 + <property name="can_focus">False</property>
  226 + <property name="xalign">0.019999999552965164</property>
  227 + <property name="ypad">5</property>
  228 + <property name="label" translatable="yes">Select netCDF output file:</property>
  229 + <attributes>
  230 + <attribute name="weight" value="bold"/>
  231 + </attributes>
  232 + </object>
  233 + <packing>
  234 + <property name="expand">True</property>
  235 + <property name="fill">True</property>
  236 + <property name="position">0</property>
  237 + </packing>
  238 + </child>
  239 + <child>
  240 + <object class="GtkFileChooserButton" id="filechooserbutton1">
  241 + <property name="height_request">49</property>
  242 + <property name="visible">True</property>
  243 + <property name="can_focus">False</property>
  244 + <property name="title" translatable="yes">Sélectionner un fichier netcdf</property>
  245 + <signal name="file-set" handler="on_filechooserbutton1_file_set" swapped="no"/>
  246 + </object>
  247 + <packing>
  248 + <property name="expand">True</property>
  249 + <property name="fill">True</property>
  250 + <property name="position">1</property>
  251 + </packing>
  252 + </child>
  253 + <child>
  254 + <object class="GtkLabel" id="label4">
  255 + <property name="visible">True</property>
  256 + <property name="can_focus">False</property>
  257 + <property name="xalign">0.019999999552965164</property>
  258 + <property name="ypad">5</property>
  259 + <property name="label" translatable="yes">Display settings:</property>
  260 + <property name="width_chars">2</property>
  261 + <attributes>
  262 + <attribute name="weight" value="bold"/>
  263 + </attributes>
  264 + </object>
  265 + <packing>
  266 + <property name="expand">True</property>
  267 + <property name="fill">True</property>
  268 + <property name="position">2</property>
  269 + </packing>
  270 + </child>
  271 + </object>