Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lst-analysis
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Alice Donini
lst-analysis
Commits
4e8adb8a
Commit
4e8adb8a
authored
2 years ago
by
Alice Donini
Browse files
Options
Downloads
Patches
Plain Diff
update utils.py
parent
39bd319a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils.py
+39
-9
39 additions, 9 deletions
utils.py
with
39 additions
and
9 deletions
utils.py
+
39
−
9
View file @
4e8adb8a
...
...
@@ -156,7 +156,7 @@ def get_runs_database(args, database):
if
args
.
tcuname
is
not
None
:
selection
=
database
.
loc
[
database
[
'
Target
'
]].
isin
([
args
.
tcuname
])
if
args
.
verbose
:
print
(
"
Selection of runs based on the TCU name
"
,
args
.
tcuname
,
"
. Only run with the name in the TCU are kept
"
)
print
(
"
Selection of runs based on the TCU name
"
,
args
.
tcuname
,
"
. Only run
s
with the name in the TCU are kept
"
)
print
(
selection
.
index
)
# if args.night[0] != 'all':
...
...
@@ -175,12 +175,12 @@ def get_runs_database(args, database):
databaseRuns
=
np
.
array
(
selection
.
index
)
if
args
.
runlist
is
not
None
:
rl
=
np
.
loadtxt
(
args
.
runlist
,
unpack
=
True
,
dtype
=
int
)
rl
=
np
.
loadtxt
(
os
.
environ
.
get
(
'
CONFIG_FOLDER
'
)
+
'
/
'
+
args
.
runlist
,
unpack
=
True
,
dtype
=
int
)
#databaseRuns = np.array([a for a in rl if a in databaseRuns])
databaseRuns
=
np
.
array
([
a
for
a
in
rl
])
if
args
.
verbose
:
print
(
"
Final run selection
"
,
databaseRuns
)
print
(
"
Final run selection
:
"
,
databaseRuns
)
return
databaseRuns
...
...
@@ -276,7 +276,7 @@ def get_coordinates(args):
"""
returns the name and the Ra/Dec of the source
"""
success
=
False
if
args
.
source_name
is
None
:
raise
ValueError
(
"
Please provide the name of the analysed source by using --source_name
"
)
...
...
@@ -286,13 +286,43 @@ def get_coordinates(args):
c
=
SkyCoord
.
from_name
(
args
.
source_name
)
ra
=
c
.
ra
.
value
dec
=
c
.
dec
.
value
success
=
True
if
args
.
verbose
:
print
(
"
Coordinates of
"
,
args
.
source_name
,
"
found using Astropy: RA
"
,
ra
,
"
, Dec
"
,
dec
)
except
:
print
(
"
Cannot resolve target name
"
,
args
.
source_name
,
"
using Astropy. Switch to the Ra and Dec provided.
"
)
if
args
.
ra
>=
0
and
args
.
ra
<
360
and
args
.
dec
>=
-
90
and
args
.
dec
<
90
:
ra
=
args
.
ra
dec
=
args
.
dec
print
(
"
Using user provided RA and Dec.
"
)
print
(
"
Cannot resolve target name
"
,
args
.
source_name
,
"
using Astropy. Switch to the Ra and Dec provided by the user.
"
)
if
all
(
item
is
not
None
for
item
in
[
args
.
ra
,
args
.
dec
]):
if
args
.
ra
>=
0
and
args
.
ra
<
360
and
args
.
dec
>=
-
90
and
args
.
dec
<
90
:
ra
=
args
.
ra
dec
=
args
.
dec
if
args
.
verbose
:
print
(
"
Coordinates provided by the user: RA
"
,
ra
,
"
, Dec
"
,
dec
)
else
:
print
(
"
Please provide RA and Dec values by using --ra and --dec
"
)
exit
(
0
)
if
(
success
is
True
and
args
.
ra
and
args
.
dec
):
if
args
.
ra
!=
ra
or
args
.
dec
!=
dec
:
print
(
f
"
WARNING! Astropy coordinates RA
{
ra
}
, Dec
{
dec
}
are different than the ones provided by the user RA
{
args
.
ra
}
, Dec
{
args
.
dec
}
.
"
)
return
ra
,
dec
def
print_runs
(
table
,
mask
,
by_date
=
False
):
"""
function to print out the run numbers that survive a certain set of cuts
"""
print
(
f
"
{
mask
.
sum
()
}
wobble runs for the selected source
"
)
print
(
f
"
Observation time:
{
table
[
'
elapsed_time
'
][
mask
].
sum
()
/
3600
:
.
2
f
}
hours
"
)
print
()
print
(
np
.
array2string
(
np
.
array
(
table
[
'
runnumber
'
][
mask
]),
separator
=
'
,
'
))
if
by_date
:
print
()
print
()
dates
=
[
datetime
.
utcfromtimestamp
(
t
-
0.5
*
86400
).
date
()
for
t
in
table
[
'
time
'
][
mask
]]
for
i
,
date
in
enumerate
(
np
.
unique
(
dates
)):
rr
=
[]
for
d
,
run
in
zip
(
dates
,
table
[
'
runnumber
'
][
mask
]):
if
d
!=
date
:
continue
rr
.
append
(
run
)
print
(
i
+
1
,
"
:
"
,
date
,
"
:
"
,
rr
)
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