Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
kis_tools
Manage
Activity
Members
Labels
Plan
Issues
35
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sdc
kis_tools
Commits
1e498b0d
Commit
1e498b0d
authored
6 years ago
by
Carl Schaffer
Browse files
Options
Downloads
Patches
Plain Diff
cleaning
parent
635f2427
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
meta_tools/tagger.py
+0
-84
0 additions, 84 deletions
meta_tools/tagger.py
with
0 additions
and
84 deletions
meta_tools/tagger.py
deleted
100644 → 0
+
0
−
84
View file @
635f2427
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 11 11:56:49 2018
@author: schaffer
"""
import
pandas
as
pd
from
tkinter
import
*
from
PIL
import
ImageTk
,
Image
,
ImageOps
from
os.path
import
exists
import
datetime
from
os.path
import
basename
,
exists
from
sdc_importer.util.util
import
gris_run_number
class
GrisTagger
():
def
__init__
(
self
,
possible_tags
=
[
'
Quiet Sun
'
,
'
Lightbridge
'
,
'
Spicule
'
,
'
Emerging Flux Region
'
,
'
Pore
'
,
'
Flare
'
,
'
Sunspot(s)
'
,
'
Facula/Plage
'
,
'
USAF
'
,
'
Umbra
'
,
'
Network
'
,
'
Penumbra
'
,
'
Filament/Prominence
'
]):
# Store Inputs:
self
.
possible_tags
=
possible_tags
# Setup data containers
self
.
tagged
=
[]
def
store_tags
(
self
):
tags
=
{
'
path
'
:
self
.
current_file
}
for
tag_name
,
tag_var
in
self
.
box_vars
.
items
():
res
=
tag_var
.
get
()
tags
[
tag_name
]
=
res
self
.
tagged
.
append
(
tags
)
self
.
root
.
destroy
()
def
get_tags
(
self
,
filename
,
existing_tags
=
[]):
if
not
exists
(
filename
):
print
(
f
'
Warning! File
{
filename
}
does not exist. could not tag!
'
)
return
self
.
current_file
=
filename
self
.
root
=
Tk
()
self
.
box_vars
=
{}
for
t
in
self
.
possible_tags
:
self
.
box_vars
[
t
]
=
IntVar
()
# Label
l
=
Label
(
self
.
root
,
text
=
'
Please select correct tags
'
,
anchor
=
'
w
'
)
l
.
grid
(
column
=
0
,
row
=
0
)
# checkboxes:
checkboxes
=
[]
for
i
,
t
in
enumerate
(
self
.
possible_tags
):
checkboxes
.
append
(
Checkbutton
(
self
.
root
,
variable
=
self
.
box_vars
[
t
],
text
=
t
))
checkboxes
[
i
].
grid
(
column
=
0
,
row
=
i
+
1
,
sticky
=
'
w
'
)
if
t
in
existing_tags
:
checkboxes
[
i
].
select
()
# Add finish button
button
=
Button
(
self
.
root
,
text
=
"
Done
"
,
command
=
self
.
store_tags
)
button
.
grid
(
column
=
0
,
row
=
len
(
self
.
possible_tags
)
+
1
,
sticky
=
'
w
'
)
# Add frame for Image
image
=
Image
.
open
(
self
.
current_file
)
# image = ImageOps.fit(image, (500, 500), Image.ANTIALIAS) #The (250, 250) is (height, width)
image
.
thumbnail
((
800
,
800
),
Image
.
ANTIALIAS
)
img
=
ImageTk
.
PhotoImage
(
image
)
panel
=
Label
(
self
.
root
,
image
=
img
).
grid
(
column
=
1
,
row
=
0
,
rowspan
=
len
(
self
.
possible_tags
)
+
2
)
#Begin
self
.
root
.
mainloop
()
def
to_df
(
self
):
df
=
pd
.
DataFrame
()
for
t
in
self
.
tagged
:
df
=
df
.
append
(
t
,
ignore_index
=
True
)
df
[
'
date
'
]
=
df
.
path
.
apply
(
lambda
x
:
datetime
.
datetime
.
strptime
(
basename
(
x
).
split
(
'
.
'
)[
0
],
'
%d%b%y
'
))
df
[
'
run
'
]
=
df
.
path
.
apply
(
gris_run_number
)
df
=
df
.
set_index
([
'
date
'
,
'
run
'
])
return
df
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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