Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
f4a550dc
Commit
f4a550dc
authored
1 year ago
by
Wernle, Alexandra Nicole
Browse files
Options
Downloads
Patches
Plain Diff
Cleaning up Instrument class with descriptions and deleting unnecessary attributes.
parent
a8bc9c91
No related branches found
No related tags found
1 merge request
!290
New Instrument class and Observatory class edits
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/metadata/Instrument/Instrument.py
+88
-41
88 additions, 41 deletions
geomagio/metadata/Instrument/Instrument.py
with
88 additions
and
41 deletions
geomagio/metadata/Instrument/Instrument.py
+
88
−
41
View file @
f4a550dc
from
pydantic
import
BaseModel
,
Field
,
validator
from
obspy
import
UTCDateTime
from
pydantic
import
BaseModel
,
Field
class
Instrument
(
BaseModel
):
"""
Class for Instrument metadata.
Attributes
----------
serial: serial number of instrument.
model: model number of instrument.
description: description of instrument.
"""
serial
:
str
=
None
start_time
:
UTCDateTime
=
None
end_time
:
UTCDateTime
=
None
model
:
str
=
None
broken
:
bool
description
:
str
=
None
@validator
(
"
end_time
"
,
pre
=
False
,
always
=
False
)
def
validate_end_time
(
cls
,
end_time
,
values
):
start_time
=
values
.
get
(
"
start_time
"
)
if
start_time
and
end_time
and
end_time
<
start_time
:
raise
ValueError
(
"
End time cannot be earlier than start time
"
)
return
end_time
# TODO: add Offsets to Observatory.py or keep here?
class
Offsets
(
Instrument
):
observatory
:
str
u_offset_offset
:
int
=
Field
(...,
description
=
"
U offset in nT
"
)
v_offset
:
int
=
Field
(...,
description
=
"
V offset in nT
"
)
w_offset
:
int
=
Field
(...,
description
=
"
W offset in nT
"
)
"""
This class is used to store nT offsets. Typically used for FGE offsets.
Attributes
----------
u_offset: U channel offset in nT.
v_offset: V channel offset in nT.
w_offset: W channel offset in nT.
"""
u_offset
:
float
=
Field
(...,
description
=
"
U offset in nT
"
)
v_offset
:
float
=
Field
(...,
description
=
"
V offset in nT
"
)
w_offset
:
float
=
Field
(...,
description
=
"
W offset in nT
"
)
class
Electronics
(
Instrument
):
"""
This class contains sensor electronics information.
Attributes
----------
type: type of electronics.
resistance: resistance in kOhm.
temperature_scale: temperature scale in V/K.
u_bin: U channel bin number in nT/bin.
v_bin: V channel bin number in nT/bin.
w_bin: W channel bin number in nT/bin.
"""
type
:
str
resistance
:
float
=
None
# kOhm
temperature_scale
:
float
=
None
# V/K
u_bin
:
int
=
None
#
nT/bin
v_bin
:
int
=
None
#
nT/bin
w_bin
:
int
=
None
#
nT/bin
resistance
:
float
=
None
temperature_scale
:
float
=
None
u_bin
:
int
=
Field
(...,
description
=
"
U
nT/bin
"
)
v_bin
:
int
=
Field
(...,
description
=
"
V
nT/bin
"
)
w_bin
:
int
=
Field
(...,
description
=
"
W
nT/bin
"
)
class
Sensor
(
Instrument
):
"""
This class contains sensor type and calibration information.
Attributes
----------
type: type of sensor.
u_constant: U channel constant in nT/mA.
v_constant: V channel constant in nT/mA.
w_constant: W channel constant in nT/mA.
"""
type
:
str
u_constant
:
in
t
=
Field
(...,
description
=
"
U constant in nT/mA
"
)
v_constant
:
in
t
=
Field
(...,
description
=
"
V constant in nT/mA
"
)
w_constant
:
in
t
=
Field
(...,
description
=
"
W constant in nT/mA
"
)
u_constant
:
floa
t
=
Field
(...,
description
=
"
U constant in nT/mA
"
)
v_constant
:
floa
t
=
Field
(...,
description
=
"
V constant in nT/mA
"
)
w_constant
:
floa
t
=
Field
(...,
description
=
"
W constant in nT/mA
"
)
class
DataLogger
(
Instrument
):
"""
This class contains datalogger information.
Attributes
----------
type: type of datalogger.
"""
type
:
str
class
Digitizer
(
Instrument
):
"""
This class contains digitizer type and factors. Typically these are from CompactRIO modules.
Attributes
----------
type: type of digitizer.
u_scale: U channel scale in counts/V.
u_offset: U channel offset in counts.
v_scale: V channel scale in counts/V.
v_offset: V channel offset in counts.
w_scale: W channel scale in counts/V.
w_offset: W channel offset in counts.
"""
type
:
str
u_scale
:
int
=
Field
(...,
description
=
"
U scale in counts/V
"
)
u_offset
:
int
=
Field
(...,
description
=
"
U offset in counts
"
)
v_scale
:
int
=
Field
(...,
description
=
"
V scale in counts/V
"
)
v_offset
:
int
=
Field
(...,
description
=
"
V offset in counts
"
)
w_scale
:
int
=
Field
(...,
description
=
"
W scale in counts/V
"
)
w_offset
:
int
=
Field
(...,
description
=
"
W offset in counts
"
)
class
Active_Instruments
(
BaseModel
):
"""
This class is meant to contain active instruments for a particular observatory.
It is often referred to as a
"
bucket
"
.
Attributes
----------
offsets: offsets metadata.
electronics: electronics metadata.
sensor: sensor metadata.
data_logger: dataLogger metadata.
digitizer: digitizer metadata.
"""
offsets
:
Offsets
electronics
:
Electronics
sensor
:
Sensor
...
...
@@ -65,11 +128,7 @@ class Active_Instruments(BaseModel):
if
__name__
==
"
__main__
"
:
instrument_data
=
{
"
offsets
"
:
{
"
observatory
"
:
"
BOU
"
,
"
start_time
"
:
UTCDateTime
(
"
2023-10-27T16:20:00.000Z
"
),
"
end_time
"
:
None
,
"
model
"
:
None
,
"
broken
"
:
False
,
"
description
"
:
"
Observatory offsets
"
,
"
u_offset
"
:
12620
,
# nT
"
v_offset
"
:
0
,
# nT
...
...
@@ -77,10 +136,7 @@ if __name__ == "__main__":
},
"
electronics
"
:
{
"
serial
"
:
"
E0568
"
,
"
start_time
"
:
UTCDateTime
(
"
2023-10-27T16:20:00.000Z
"
),
"
end_time
"
:
None
,
"
model
"
:
"
K2
"
,
"
broken
"
:
True
,
"
description
"
:
"
FGE electronics box
"
,
"
type
"
:
"
FGE Electronics
"
,
"
resistance
"
:
18.6
,
# kOhm
...
...
@@ -91,10 +147,7 @@ if __name__ == "__main__":
},
"
sensor
"
:
{
"
serial
"
:
"
S0443
"
,
"
start_time
"
:
UTCDateTime
(
"
2023-10-27T16:20:00.000Z
"
),
"
end_time
"
:
None
,
"
model
"
:
None
,
"
broken
"
:
False
,
"
description
"
:
"
sensor constants combine with electronics resistance to give scale values
"
,
"
type
"
:
"
FGE
"
,
"
u_constant
"
:
37062
,
# nT/mA
...
...
@@ -103,19 +156,13 @@ if __name__ == "__main__":
},
"
data_logger
"
:
{
"
serial
"
:
"
S0443
"
,
"
start_time
"
:
UTCDateTime
(
"
2023-10-27T16:20:00.000Z
"
),
"
end_time
"
:
None
,
"
model
"
:
None
,
"
broken
"
:
False
,
"
description
"
:
None
,
"
type
"
:
"
ObsRIO Chassis
"
,
},
"
digitizer
"
:
{
"
serial
"
:
"
1EA7C53
"
,
"
start_time
"
:
UTCDateTime
(
"
2023-10-27T16:20:00.000Z
"
),
"
end_time
"
:
None
,
"
model
"
:
None
,
"
broken
"
:
False
,
"
description
"
:
None
,
"
type
"
:
"
ObsRIO Module
"
,
"
u_scale
"
:
37062
,
# counts/V
...
...
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