Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VLBI-cwl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ResearchAndDevelopment
VLBI-cwl
Commits
aee9fb8a
Commit
aee9fb8a
authored
1 month ago
by
Matthijs van der Wild
Browse files
Options
Downloads
Patches
Plain Diff
Allow prep_delay to execute TargetListToCoords.py
parent
3dafe748
No related branches found
No related tags found
1 merge request
!95
Allow prep_delay to execute TargetListToCoords.py
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/TargetListToCoords.py
+56
-13
56 additions, 13 deletions
scripts/TargetListToCoords.py
steps/prep_delay.cwl
+14
-23
14 additions, 23 deletions
steps/prep_delay.cwl
with
70 additions
and
36 deletions
scripts/TargetListToCoords.py
100644 → 100755
+
56
−
13
View file @
aee9fb8a
#!/usr/bin/env python3
import
argparse
import
json
from
astropy.table
import
Table
from
astropy.table
import
Table
def
plugin_main
(
**
kwargs
):
def
plugin_main
(
**
kwargs
):
"""
"""
Takes in a catalogue with a target and returns appropriate coordinates
Takes in a catalogue with a target and returns appropriate coordinates
...
@@ -19,32 +25,69 @@ def plugin_main(**kwargs):
...
@@ -19,32 +25,69 @@ def plugin_main(**kwargs):
"""
"""
# parse the input
# parse the input
target_file
=
kwargs
[
'
target_file
'
]
target_file
=
kwargs
[
"
target_file
"
]
mode
=
kwargs
[
'
mode
'
]
mode
=
kwargs
[
"
mode
"
]
# read in the catalogue to get source_id, RA, and DEC
# read in the catalogue to get source_id, RA, and DEC
t
=
Table
.
read
(
target_file
,
format
=
'
csv
'
)
t
=
Table
.
read
(
target_file
,
format
=
"
csv
"
)
RA_val
=
t
[
'
RA
'
].
data
RA_val
=
t
[
"
RA
"
].
data
DEC_val
=
t
[
'
DEC
'
].
data
DEC_val
=
t
[
"
DEC
"
].
data
Source_id
=
t
[
'
Source_id
'
].
data
Source_id
=
t
[
"
Source_id
"
].
data
if
mode
==
'
delay_calibration
'
:
if
mode
==
"
delay_calibration
"
:
RA_val
=
[
RA_val
[
0
]]
RA_val
=
[
RA_val
[
0
]]
DEC_val
=
[
DEC_val
[
0
]]
DEC_val
=
[
DEC_val
[
0
]]
Source_id
=
Source_id
[
0
]
Source_id
=
Source_id
[
0
]
if
isinstance
(
Source_id
,
str
):
if
isinstance
(
Source_id
,
str
):
Source_id
=
[
Source_id
]
Source_id
=
[
Source_id
]
else
:
else
:
Source_id
=
[
'
S
'
+
str
(
Source_id
)]
Source_id
=
[
"
S
"
+
str
(
Source_id
)]
# make a string of coordinates for the DP3 command
# make a string of coordinates for the DP3 command
ss
=
[
'
[
'
+
str
(
x
)
+
'
deg,
'
+
str
(
y
)
+
'
deg]
'
for
x
,
y
in
zip
(
RA_val
,
DEC_val
)
]
ss
=
[
"
[
"
+
str
(
x
)
+
"
deg,
"
+
str
(
y
)
+
"
deg]
"
for
x
,
y
in
zip
(
RA_val
,
DEC_val
)]
if
mode
==
"
delay_calibration
"
:
if
mode
==
"
delay_calibration
"
:
ss
=
ss
[
0
]
ss
=
ss
[
0
]
elif
mode
==
"
split_directions
"
:
elif
mode
==
"
split_directions
"
:
ss
=
"
[
"
+
(
ss
[
0
]
if
len
(
ss
)
==
1
else
"
,
"
.
join
(
ss
))
+
"
]
"
ss
=
"
[
"
+
(
ss
[
0
]
if
len
(
ss
)
==
1
else
"
,
"
.
join
(
ss
))
+
"
]
"
else
:
else
:
raise
ValueError
(
"
Argument mode must be one of
"
raise
ValueError
(
+
"
\"
delay_calibration
\"
,
\"
split_directions
\"
"
"
Argument mode must be one of
"
+
f
"
but was
\"
{
mode
}
\"
.
"
)
+
'
"
delay_calibration
"
,
"
split_directions
"'
+
f
'
but was
"
{
mode
}
"
.
'
)
return
{
"
name
"
:
"
,
"
.
join
(
Source_id
),
"
coords
"
:
ss
}
def
parse_arguments
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
--target_file
"
,
help
=
"
The path of the file containing the properties and coordinates of the delay calibrator
"
,
type
=
str
,
)
parser
.
add_argument
(
"
--mode
"
,
help
=
"
The name of the processing mode
"
,
choices
=
[
"
delay_calibration
"
,
"
split_directions
"
],
type
=
str
,
)
return
parser
.
parse_args
()
def
main
():
arguments
=
parse_arguments
()
output
=
plugin_main
(
target_file
=
arguments
.
target_file
,
mode
=
arguments
.
mode
,
)
with
open
(
"
./out.json
"
,
"
w
"
)
as
fp
:
json
.
dump
(
output
,
fp
)
return
{
'
name
'
:
"
,
"
.
join
(
Source_id
),
'
coords
'
:
ss
}
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
steps/prep_delay.cwl
+
14
−
23
View file @
aee9fb8a
...
@@ -5,9 +5,7 @@ label: Prepare delay
...
@@ -5,9 +5,7 @@ label: Prepare delay
doc: |
doc: |
Converts the delay calibrator information into strings.
Converts the delay calibrator information into strings.
baseCommand:
baseCommand: TargetListToCoords.py
- python3
- prep_delay.py
inputs:
inputs:
- id: delay_calibrator
- id: delay_calibrator
...
@@ -15,32 +13,25 @@ inputs:
...
@@ -15,32 +13,25 @@ inputs:
doc: |
doc: |
The file containing the properties and
The file containing the properties and
coordinates of the delay calibrator.
coordinates of the delay calibrator.
inputBinding:
prefix: --target_file
separate: true
- id: mode
- id: mode
type: string
type:
type: enum
symbols:
- "delay_calibration"
- "split_directions"
doc: |
doc: |
A boolean that, if set to true, ensures that
The name of the processing mode.
the step will only extract the source_id and
Must be either 'delay_calibration' or 'split_directions'.
coordinates of the first entry of the catalogue.
inputBinding:
prefix: --mode
separate: true
requirements:
requirements:
- class: InlineJavascriptRequirement
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: prep_delay.py
entry: |
import json
from TargetListToCoords import plugin_main as targetListToCoords
inputs = json.loads(r"""$(inputs)""")
target_file = inputs['delay_calibrator']['path']
mode = inputs['mode']
output = targetListToCoords(target_file=target_file, mode=mode)
with open('./out.json', 'w') as fp:
json.dump(output, fp)
hints:
hints:
- class: DockerRequirement
- class: DockerRequirement
...
...
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