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
63bb0b45
Commit
63bb0b45
authored
4 months ago
by
Wernle, Alexandra Nicole
Browse files
Options
Downloads
Patches
Plain Diff
Removed some unnecessary code, raise Abort() if no spikes detected.
parent
aed7b732
No related branches found
No related tags found
1 merge request
!344
New MetadataAlgorithm, SpikesAlgorithm, and flag-spikes application
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/processing/flag_spikes.py
+7
-10
7 additions, 10 deletions
geomagio/processing/flag_spikes.py
with
7 additions
and
10 deletions
geomagio/processing/flag_spikes.py
+
7
−
10
View file @
63bb0b45
...
@@ -11,7 +11,7 @@ from ..algorithm.SpikesAlgorithm import SpikesAlgorithm
...
@@ -11,7 +11,7 @@ from ..algorithm.SpikesAlgorithm import SpikesAlgorithm
def
flag_spikes
(
def
flag_spikes
(
observatory
:
str
=
typer
.
Option
(...,
help
=
"
Observatory code
"
),
observatory
:
str
=
typer
.
Option
(...,
help
=
"
Observatory code
"
),
channels
:
str
=
typer
.
Option
(
channels
:
str
=
typer
.
Option
(
default
=
[
"
F
"
]
,
help
=
"
Channels to despike, default is F. Example input: HEZF
"
default
=
"
F
"
,
help
=
"
Channels to despike, default is F. Example input: HEZF
"
),
),
starttime
:
datetime
=
typer
.
Option
(
starttime
:
datetime
=
typer
.
Option
(
default
=
None
,
default
=
None
,
...
@@ -64,13 +64,16 @@ def flag_spikes(
...
@@ -64,13 +64,16 @@ def flag_spikes(
spikes
=
spike_algorithm
.
run
()
spikes
=
spike_algorithm
.
run
()
if
len
(
spikes
)
==
0
:
print
(
"
No spikes found
"
)
raise
typer
.
Abort
()
# confirm whether or not to create spike metadata
# confirm whether or not to create spike metadata
if
not
force
:
if
not
force
:
typer
.
confirm
(
f
"
Are you sure you want to create flag metadata?
"
,
abort
=
True
)
typer
.
confirm
(
f
"
Are you sure you want to create flag metadata?
"
,
abort
=
True
)
print
(
"
Creating flag metadata
"
)
print
(
"
Creating flag metadata
"
)
# write flag metadata to metadata service
# write flag metadata to metadata service
metadata_factory
=
MetadataFactory
(
token
=
metadata_token
,
url
=
metadata_url
)
with
typer
.
progressbar
(
with
typer
.
progressbar
(
iterable
=
spikes
,
label
=
"
Uploading to metadata service
"
iterable
=
spikes
,
label
=
"
Uploading to metadata service
"
)
as
progressbar
:
)
as
progressbar
:
...
@@ -99,20 +102,14 @@ def upload_spike_metadata(algorithm: SpikesAlgorithm, spike: Metadata) -> Metada
...
@@ -99,20 +102,14 @@ def upload_spike_metadata(algorithm: SpikesAlgorithm, spike: Metadata) -> Metada
Metadata
Metadata
created metadata object.
created metadata object.
"""
"""
# check if metadata already exists for period before uploading
# check if metadata already exists for period before uploading
prior_metadata_ID
=
SpikesAlgorithm
.
check_existing_metadata
(
prior_metadata
=
SpikesAlgorithm
.
check_existing_metadata
(
algorithm
,
spike
)
algorithm
,
metadata_obj
=
spike
if
prior_metadata
:
)
if
prior_metadata_ID
:
# TODO: Confirm whether or not to add force or simply update automatically
# TODO: Confirm whether or not to add force or simply update automatically
typer
.
confirm
(
typer
.
confirm
(
f
"
Spikes already exist for this period, would you like to update this metadata?
"
,
f
"
Spikes already exist for this period, would you like to update this metadata?
"
,
abort
=
True
,
abort
=
True
,
)
)
# set spike.id to prior_metadata.id to update that metadata object in the database
spike
.
id
=
prior_metadata_ID
return
SpikesAlgorithm
.
update_metadata
(
algorithm
,
spike
)
return
SpikesAlgorithm
.
update_metadata
(
algorithm
,
spike
)
else
:
else
:
return
SpikesAlgorithm
.
create_new_metadata
(
algorithm
,
spike
)
return
SpikesAlgorithm
.
create_new_metadata
(
algorithm
,
spike
)
...
...
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