Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aeri_quality_control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
aeri
aeri_quality_control
Commits
75d2ebfa
Commit
75d2ebfa
authored
8 years ago
by
Coda Phillips
Browse files
Options
Downloads
Patches
Plain Diff
Try plotting things
parent
242730a6
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
interpret_qc.py
+67
-0
67 additions, 0 deletions
interpret_qc.py
with
67 additions
and
0 deletions
interpret_qc.py
0 → 100644
+
67
−
0
View file @
75d2ebfa
import
netCDF4
import
pandas
as
pd
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
aeri_tools.io.dmv.housekeeping
import
get_all_housekeeping
from
main
import
files_to_update
from
glob
import
glob
import
os
def
save_plot
(
filename
):
print
(
'
saving {}
'
.
format
(
filename
))
plt
.
savefig
(
filename
,
transparent
=
True
)
def
plot_variable_qc
(
frame
,
loc
,
filename
):
qc_loc
=
'
qc_
'
+
loc
if
sum
(
frame
[
qc_loc
])
>
0
:
plt
.
figure
()
plot_outliers
(
frame
,
frame
[
qc_loc
]
==
0
,
loc
)
save_plot
(
filename
)
def
plot_outliers
(
frame
,
qc_mask
,
loc
):
if
(
~
qc_mask
).
any
():
frame
.
ix
[
qc_mask
&
(
frame
[
'
qc_percent
'
]
==
0
),
loc
].
plot
(
style
=
'
b.
'
)
frame
.
ix
[
qc_mask
&
(
frame
[
'
qc_percent
'
]
>
0
),
loc
].
plot
(
style
=
'
k.
'
,
alpha
=
.
2
)
frame
.
ix
[
~
qc_mask
,
loc
].
plot
(
style
=
'
r.
'
)
plt
.
xlabel
(
'
Time
'
)
plt
.
title
(
loc
)
def
make_plots_here
(
dirname
,
frame
):
for
qc_variable
in
([
'
ABBapexTemp
'
,
'
ABBtopTemp
'
,
'
ABBbottomTemp
'
,
'
HBBapexTemp
'
,
'
HBBtopTemp
'
,
'
HBBbottomTemp
'
,
'
calibrationAmbientTemp
'
]):
plot_variable_qc
(
frame
,
qc_variable
,
os
.
path
.
join
(
dirname
,
qc_variable
+
'
.png
'
))
def
get_qc_frame
(
qc_path
):
nc
=
netCDF4
.
Dataset
(
qc_path
)
frame
=
pd
.
DataFrame
({
k
:
v
[:]
for
k
,
v
in
nc
.
variables
.
items
()})
frame
.
index
=
pd
.
to_datetime
((
frame
[
'
base_time
'
]
+
frame
[
'
time_offset
'
]),
utc
=
True
)
nc
.
close
()
return
frame
def
generate_plots
(
qc_file
,
cxs_file
,
sum_file
):
cxs
=
get_all_housekeeping
(
cxs_file
)
frame
=
cxs
.
combine_first
(
get_all_housekeeping
(
sum_file
))
frame
=
frame
.
combine_first
(
get_qc_frame
(
qc_file
))
make_plots_here
(
os
.
path
.
dirname
(
qc_file
),
frame
)
def
generate_all_plots
(
ftp_dir
):
for
qc_file
,
cxs_file
,
sum_file
in
files_to_update
(
glob
(
os
.
path
.
join
(
ftp_dir
,
'
AE*
'
,
'
*B1.CXS
'
)),
update_only
=
False
):
if
os
.
path
.
isfile
(
qc_file
):
generate_plots
(
qc_file
,
cxs_file
,
sum_file
)
if
__name__
==
'
__main__
'
:
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
ftp
'
)
args
=
parser
.
parse_args
()
generate_all_plots
(
args
.
ftp
)
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