Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
analisiperditescw
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs
gui
analisiperditescw
Commits
c46e00ad
Commit
c46e00ad
authored
4 years ago
by
Claudio Scafuri
Browse files
Options
Downloads
Patches
Plain Diff
first import from repo elettra/panels/analisiperditescw release_02
parent
9e4ded63
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+20
-0
20 additions, 0 deletions
Makefile
README.md
+32
-2
32 additions, 2 deletions
README.md
src/analisiperditescw.py
+281
-0
281 additions, 0 deletions
src/analisiperditescw.py
with
333 additions
and
2 deletions
Makefile
0 → 100644
+
20
−
0
View file @
c46e00ad
PROJECT_NAME
=
analisiperditescw
NAME
=
$(
PROJECT_NAME
)
-gui
MAIN
=
$(
PROJECT_NAME
)
.py
DIRNAME
=
$(
NAME:-gui
=
)
PY_FILES
+=
$(
wildcard src/
*
.py
)
default
:
bin ${PY_FILES}
@
cp
${
PY_FILES
}
bin/
${
DIRNAME
}
@
echo
"#!/bin/bash
\n
exec /runtime/bin/
${
DIRNAME
}
/
${
MAIN
}
"
>
bin/
${
NAME
}
@
chmod
+x bin/
${
NAME
}
bin/
${
DIRNAME
}
/
${
MAIN
}
bin
:
@
test
-d
$@
||
mkdir
-p
$@
/
${
DIRNAME
}
clean
:
@
rm
-fr
bin/ src/
*
~
.PHONY
:
clean
This diff is collapsed.
Click to expand it.
README.md
+
32
−
2
View file @
c46e00ad
# analisiperditescw
# Project naem
analisiperditescw
## Description
python gui for analysing Elettra SCW beamdump monitor files
## Dependencies
python Tk, matplotlib
## Installation & deployment
first version must be installed by hand
## History
2020-03-30 imported from CVS repo elettra/panels/analisiperditescw release_02
## Credits
developed by Luca Vidotto
Elettra-Sincrotrone Trieste S.C.p.A. di interesse nazionale
Strada Statale 14 - km 163,5 in AREA Science Park
34149 Basovizza, Trieste ITALY
## License
GPL 3
python gui for analysing SCW radiation monitor beam dump files
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/analisiperditescw.py
0 → 100755
+
281
−
0
View file @
c46e00ad
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# $Name: $
import
sys
import
datetime
import
matplotlib
matplotlib
.
use
(
'
TkAgg
'
)
import
Tkinter
as
Tk
import
tkFileDialog
as
fd
from
matplotlib.backends.backend_tkagg
import
FigureCanvasTkAgg
,
NavigationToolbar2TkAgg
from
matplotlib.figure
import
Figure
import
warnings
warnings
.
filterwarnings
(
"
ignore
"
,
category
=
UserWarning
,
module
=
"
matplotlib
"
)
warnings
.
filterwarnings
(
"
ignore
"
,
category
=
FutureWarning
,
module
=
"
scipy
"
)
import
os
import
csv
import
threading
import
time
chn
=
[
True
,
False
,
False
,
True
,
True
]
tab
=
-
1
titolo
=
""
titoloS
=
""
fileTab
=
''
btnAbi
=
1
def
disegna
():
global
btnAbi
btnAbi
=
0
labAtt
.
config
(
text
=
'
Creazione grafico...
'
,
bg
=
'
red
'
,
fg
=
'
white
'
)
t
=
threading
.
Thread
(
target
=
disegnaGrafico
)
t
.
start
()
def
disegnaGrafico
():
global
titolo
global
tab
global
chn
global
btnAbi
x
=
[
None
]
*
len
(
tab
[
0
])
i
=
0
for
dati
in
tab
[
0
]:
x
[
i
]
=
i
*
0.000864
i
=
i
+
1
if
tab
!=
-
1
:
f
.
subplots_adjust
(
top
=
0.89
,
bottom
=
0.07
,
right
=
0.97
,
left
=
0.05
)
a
.
clear
()
b
.
clear
()
if
chn
[
0
]:
a
.
plot
(
tab
[
0
],
'
b
'
,
label
=
'
corrente
'
)
if
chn
[
1
]:
a
.
plot
(
tab
[
1
],
'
g
'
,
label
=
'
data1
'
)
if
chn
[
2
]:
a
.
plot
(
tab
[
2
],
'
r
'
,
label
=
'
data2
'
)
if
chn
[
3
]:
a
.
plot
(
tab
[
3
],
'
c
'
,
label
=
'
dose1
'
)
if
chn
[
4
]:
a
.
plot
(
tab
[
4
],
'
m
'
,
label
=
'
dose2
'
)
titoloF
.
set_text
(
titolo
)
b
.
plot
(
x
,
[
0
]
*
len
(
tab
[
0
]),
alpha
=
0
)
a
.
legend
()
b
.
set_xlabel
(
"
[millisecondi]
"
)
a
.
set_xlabel
(
"
[giri]
"
)
b
.
xaxis
.
tick_top
()
b
.
xaxis
.
set_label_position
(
'
top
'
)
canvas
.
draw
()
labAtt
.
config
(
text
=
''
,
bg
=
root
[
'
bg
'
])
btnAbi
=
1
def
getTitolo
(
nFile
):
global
titolo
global
titoloS
dataOra
=
nFile
[
-
32
:
-
13
]
titolo
=
"
Perdite SCW
"
+
dataOra
[
8
:
11
]
+
dataOra
[
5
:
8
]
+
dataOra
[:
4
]
+
"
"
+
dataOra
[
11
:
13
]
+
"
:
"
+
dataOra
[
14
:
16
]
+
"
:
"
+
dataOra
[
17
:
19
]
titoloS
=
"
Perdite_SCW_
"
+
dataOra
[
8
:
11
]
+
dataOra
[
5
:
8
]
+
dataOra
[:
4
]
+
"
_
"
+
dataOra
[
11
:
13
]
+
"
-
"
+
dataOra
[
14
:
16
]
+
"
-
"
+
dataOra
[
17
:
19
]
def
getTabella
(
perF
):
tabella
=
[[],
[],
[],
[],
[]]
with
open
(
perF
,
'
r
'
)
as
csvfile
:
f
=
csv
.
reader
(
csvfile
)
i
=
0
for
row
in
f
:
if
i
>
2
:
j
=
0
for
n
in
row
:
tabella
[
j
].
append
(
int
(
n
))
j
=
j
+
1
i
=
i
+
1
j
=
0
for
i
in
tabella
[
1
]:
j
=
j
+
1
j
=
0
for
i
in
tabella
[
2
]:
j
=
j
+
1
j
=
0
for
i
in
tabella
[
3
]:
j
=
j
+
1
j
=
0
for
i
in
tabella
[
4
]:
j
=
j
+
1
return
tabella
class
CustomToolbar
(
NavigationToolbar2TkAgg
):
def
_init_toolbar
(
self
):
xmin
,
xmax
=
self
.
canvas
.
figure
.
bbox
.
intervalx
height
,
width
=
50
,
xmax
-
xmin
Tk
.
Frame
.
__init__
(
self
,
master
=
self
.
window
,
width
=
width
,
height
=
height
,
borderwidth
=
2
)
self
.
update
()
# Make axes menu
self
.
bHome
=
self
.
_Button
(
text
=
"
Ripristina
"
,
file
=
"
home
"
,
command
=
self
.
home
)
self
.
bBack
=
self
.
_Button
(
text
=
"
Indietro
"
,
file
=
"
back
"
,
command
=
self
.
back
)
self
.
bForward
=
self
.
_Button
(
text
=
"
Avanti
"
,
file
=
"
forward
"
,
command
=
self
.
forward
)
self
.
bPan
=
self
.
_Button
(
text
=
"
Sposta
"
,
file
=
"
move
"
,
command
=
self
.
pan
)
self
.
bZoom
=
self
.
_Button
(
text
=
"
Zoom
"
,
file
=
"
zoom_to_rect
"
,
command
=
self
.
zoom
)
self
.
bsave
=
self
.
_Button
(
text
=
"
Salva nel log
"
,
file
=
"
filesave
"
,
command
=
self
.
save_figure
)
self
.
message
=
Tk
.
StringVar
(
master
=
self
)
self
.
_message_label
=
Tk
.
Label
(
master
=
self
,
textvariable
=
self
.
message
)
self
.
_message_label
.
pack
(
side
=
Tk
.
RIGHT
)
self
.
pack
(
side
=
Tk
.
BOTTOM
,
fill
=
Tk
.
X
)
def
save_figure
(
self
,
*
args
):
global
titoloS
self
.
canvas
.
print_figure
(
"
/tmp/
"
+
titoloS
)
os
.
system
(
"
scp %s Web@elog:/cygdrive/h/NewElogBook/logbook/my_documents/my_pictures
"
%
(
"
/tmp/
"
+
titoloS
+
"
.png
"
))
os
.
system
(
"
wget -q -O - --proxy=off http://elog/InsertImageElettra.php?param1=%s
"
%
(
titoloS
+
"
.png
"
))
os
.
system
(
"
rm %s
"
%
(
"
/tmp/
"
+
titoloS
+
"
.png
"
))
def
on_key_event
(
event
):
pass
def
_quit
():
root
.
quit
()
# stops mainloop
root
.
destroy
()
# this is necessary on Windows
def
_ridisegna
():
if
(
btnAbi
==
1
):
disegna
()
def
tabOpenFile
():
global
fileTab
global
tab
tab
=
getTabella
(
fileTab
)
getTitolo
(
fileTab
)
labAtt
.
config
(
text
=
'
Creazione grafico...
'
,
bg
=
'
red
'
,
fg
=
'
white
'
)
disegnaGrafico
()
def
_openFile
():
global
fileTab
global
btnAbi
if
(
btnAbi
==
1
):
FileBeamdump
=
fd
.
askopenfilename
(
initialdir
=
'
/home/elettra/scwrad/monitor
'
)
if
FileBeamdump
!=
''
:
btnAbi
=
0
labAtt
.
config
(
text
=
'
Caricamento dati...
'
,
bg
=
'
red
'
,
fg
=
'
white
'
)
fileTab
=
FileBeamdump
t
=
threading
.
Thread
(
target
=
tabOpenFile
)
t
.
start
()
def
_updateChn
():
global
chn
chn
[
0
]
=
var0
.
get
()
chn
[
1
]
=
var1
.
get
()
chn
[
2
]
=
var2
.
get
()
chn
[
3
]
=
var3
.
get
()
chn
[
4
]
=
var4
.
get
()
root
=
Tk
.
Tk
()
root
.
wm_title
(
"
Analisi dati perdite SCW
"
)
f
=
Figure
(
figsize
=
(
15
,
8
),
dpi
=
100
,
facecolor
=
root
[
"
bg
"
])
titoloF
=
f
.
suptitle
(
''
)
a
=
f
.
add_subplot
(
111
)
b
=
a
.
twiny
()
a
.
plot
()
canvas
=
FigureCanvasTkAgg
(
f
,
master
=
root
)
canvas
.
_tkcanvas
.
config
(
highlightthickness
=
0
)
canvas
.
show
()
toolbar
=
CustomToolbar
(
canvas
,
root
)
toolbar
.
pack_forget
()
toolbar
.
pack
(
side
=
Tk
.
BOTTOM
,
anchor
=
Tk
.
W
)
canvas
.
get_tk_widget
().
pack
(
side
=
Tk
.
LEFT
,
fill
=
Tk
.
BOTH
,
expand
=
1
)
canvas
.
mpl_connect
(
'
key_press_event
'
,
on_key_event
)
btnOpen
=
Tk
.
Button
(
master
=
root
,
text
=
'
Apri file
'
,
command
=
_openFile
)
btnOpen
.
pack
(
side
=
Tk
.
TOP
,
anchor
=
Tk
.
W
)
btnDis
=
Tk
.
Button
(
master
=
root
,
text
=
'
Disegna
'
,
command
=
_ridisegna
)
btnDis
.
pack
(
side
=
Tk
.
TOP
,
anchor
=
Tk
.
W
)
var0
=
Tk
.
IntVar
()
chn0
=
Tk
.
Checkbutton
(
master
=
root
,
text
=
'
corrente
'
,
command
=
_updateChn
,
variable
=
var0
)
chn0
.
select
()
chn0
.
pack
(
side
=
Tk
.
TOP
,
anchor
=
Tk
.
S
)
var1
=
Tk
.
IntVar
()
chn1
=
Tk
.
Checkbutton
(
master
=
root
,
text
=
'
data1
'
,
command
=
_updateChn
,
variable
=
var1
)
chn1
.
pack
(
side
=
Tk
.
TOP
,
anchor
=
Tk
.
W
)
var2
=
Tk
.
IntVar
()
chn2
=
Tk
.
Checkbutton
(
master
=
root
,
text
=
'
data2
'
,
command
=
_updateChn
,
variable
=
var2
)
chn2
.
pack
(
side
=
Tk
.
TOP
,
anchor
=
Tk
.
W
)
var3
=
Tk
.
IntVar
()
chn3
=
Tk
.
Checkbutton
(
master
=
root
,
text
=
'
dose1
'
,
command
=
_updateChn
,
variable
=
var3
)
chn3
.
select
()
chn3
.
pack
(
side
=
Tk
.
TOP
,
anchor
=
Tk
.
W
)
var4
=
Tk
.
IntVar
()
chn4
=
Tk
.
Checkbutton
(
master
=
root
,
text
=
'
dose2
'
,
command
=
_updateChn
,
variable
=
var4
)
chn4
.
select
()
chn4
.
pack
(
side
=
Tk
.
TOP
,
anchor
=
Tk
.
W
)
labAtt
=
Tk
.
Label
(
master
=
root
,
text
=
''
,
)
labAtt
.
pack
(
side
=
Tk
.
TOP
,
anchor
=
Tk
.
W
)
def
inizio
():
global
tab
global
btnAbi
tab
=
getTabella
(
sys
.
argv
[
1
])
getTitolo
(
sys
.
argv
[
1
])
labAtt
.
config
(
text
=
'
Creazione grafico...
'
,
bg
=
'
red
'
,
fg
=
'
white
'
)
disegnaGrafico
()
if
len
(
sys
.
argv
)
>
2
and
sys
.
argv
[
2
]
==
"
save
"
:
toolbar
.
save_figure
()
btnAbi
=
1
labAtt
.
config
(
text
=
''
,
bg
=
root
[
'
bg
'
])
if
len
(
sys
.
argv
)
>
1
and
os
.
path
.
isfile
(
sys
.
argv
[
1
]):
btnAbi
=
0
labAtt
.
config
(
text
=
'
Caricamento dati...
'
,
bg
=
'
red
'
,
fg
=
'
white
'
)
t
=
threading
.
Thread
(
target
=
inizio
)
t
.
start
()
root
.
protocol
(
"
WM_DELETE_WINDOW
"
,
_quit
)
root
.
mainloop
()
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment