Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
LOFAR2.0
tango
Commits
c61066b9
Commit
c61066b9
authored
3 years ago
by
Stefano Di Frischia
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-406
: test masked values query with python
parent
75ffb1c2
No related branches found
No related tags found
1 merge request
!190
Resolve L2SS-406 "Grafana archiver"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
devices/toolkit/archiver.py
+32
-3
32 additions, 3 deletions
devices/toolkit/archiver.py
devices/toolkit/archiver_config/lofar2.json
+2
-2
2 additions, 2 deletions
devices/toolkit/archiver_config/lofar2.json
with
34 additions
and
5 deletions
devices/toolkit/archiver.py
+
32
−
3
View file @
c61066b9
...
@@ -419,11 +419,11 @@ class Retriever():
...
@@ -419,11 +419,11 @@ class Retriever():
return
result
return
result
def
get_attribute_value_by_interval
(
self
,
attribute_fqname
:
str
,
start_time
:
datetime
,
stop_time
:
datetime
):
def
get_attribute_value_by_interval
(
self
,
attribute_fqname
:
str
,
start_time
:
datetime
,
stop_time
:
datetime
):
'''
"""
Takes as input the attribute name and a certain starting and ending point-time.
Takes as input the attribute name and a certain starting and ending point-time.
The datetime format is pretty flexible (e.g.
"
YYYY-MM-dd hh:mm:ss
"
).
The datetime format is pretty flexible (e.g.
"
YYYY-MM-dd hh:mm:ss
"
).
Returns a list of timestamps and a list of values
Returns a list of timestamps and a list of values
'''
"""
attr_id
=
self
.
get_attribute_id
(
attribute_fqname
)
attr_id
=
self
.
get_attribute_id
(
attribute_fqname
)
attr_datatype
=
self
.
get_attribute_datatype
(
attribute_fqname
)
attr_datatype
=
self
.
get_attribute_datatype
(
attribute_fqname
)
attr_table_name
=
'
att_
'
+
str
(
attr_datatype
)
attr_table_name
=
'
att_
'
+
str
(
attr_datatype
)
...
@@ -437,4 +437,33 @@ class Retriever():
...
@@ -437,4 +437,33 @@ class Retriever():
except
AttributeError
as
e
:
except
AttributeError
as
e
:
raise
Exception
(
f
"
Empty result! Attribute
{
attribute_fqname
}
not found
"
)
from
e
raise
Exception
(
f
"
Empty result! Attribute
{
attribute_fqname
}
not found
"
)
from
e
return
result
return
result
def
get_masked_fpga_temp
(
self
,
start_time
:
datetime
,
stop_time
:
datetime
,
temp_attr_name
:
str
=
'
LTS/SDP/1/fpga_temp_r
'
,
mask_attr_name
:
str
=
'
LTS/SDP/1/tr_fpga_mask_r
'
):
"""
Returns a list of SDP/fpga_temp_r values, but only if SDP/tr_fpga_mask_r values are TRUE
"""
mask_values
=
self
.
get_attribute_value_by_interval
(
mask_attr_name
,
start_time
,
stop_time
)
temp_values
=
self
.
get_attribute_value_by_interval
(
temp_attr_name
,
start_time
,
stop_time
)
# Since timestamps can be not syncrhonized, remove first or last element from arrays
if
len
(
mask_values
)
==
len
(
temp_values
):
first_mask_datatime
=
mask_values
[
0
].
data_time
first_temp_datatime
=
temp_values
[
0
].
data_time
if
(
first_mask_datatime
>
first_temp_datatime
):
mask_values
=
mask_values
[:
-
int
(
mask_values
[
0
].
dim_x_r
)]
temp_values
=
temp_values
[
int
(
temp_values
[
0
].
dim_x_r
):]
elif
(
first_mask_datatime
<
first_temp_datatime
):
mask_values
=
mask_values
[
int
(
mask_values
[
0
].
dim_x_r
)]
temp_values
=
temp_values
[:
-
int
(
temp_values
[
0
].
dim_x_r
):]
else
:
raise
Exception
# Convert DB Array records into Python lists
mask_data
=
build_array_from_record
(
mask_values
,
mask_values
[
0
].
dim_x_r
)
temp_data
=
build_array_from_record
(
temp_values
,
temp_values
[
0
].
dim_x_r
)
# Extract only the value from the array
mask_array_values
=
get_values_from_record
(
mask_data
)
temp_array_values
=
get_values_from_record
(
temp_data
)
# Multiply the matrix
#masked_values = np.multiply(temp_array_values,mask_array_values)
masked_values
=
np
.
ma
.
masked_array
(
temp_array_values
,
mask
=
np
.
invert
(
mask_array_values
.
astype
(
bool
)))
return
masked_values
,
mask_values
,
temp_values
This diff is collapsed.
Click to expand it.
devices/toolkit/archiver_config/lofar2.json
+
2
−
2
View file @
c61066b9
...
@@ -6,12 +6,12 @@
...
@@ -6,12 +6,12 @@
"devices"
:{
"devices"
:{
"LTS/RECV/1"
:
{
"LTS/RECV/1"
:
{
"environment"
:
"development"
,
"environment"
:
"development"
,
"include"
:
[
"rcu_temperature_r"
],
"include"
:
[],
"exclude"
:
[
"CLK_Enable_PWR_R"
,
"CLK_I2C_STATUS_R"
,
"CLK_PLL_error_R"
,
"CLK_PLL_locked_R"
,
"CLK_translator_busy_R"
]
"exclude"
:
[
"CLK_Enable_PWR_R"
,
"CLK_I2C_STATUS_R"
,
"CLK_PLL_error_R"
,
"CLK_PLL_locked_R"
,
"CLK_translator_busy_R"
]
},
},
"LTS/SDP/1"
:
{
"LTS/SDP/1"
:
{
"environment"
:
"development"
,
"environment"
:
"development"
,
"include"
:
[],
"include"
:
[
"FPGA_temp_R"
,
"TR_fpga_mask_R"
],
"exclude"
:
[]
"exclude"
:
[]
},
},
"LTS/SST/1"
:
{
"LTS/SST/1"
:
{
...
...
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