Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lofar_uvw_generator
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
Container registry
Model registry
Operate
Environments
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
VirtualObservatory
lofar_uvw_generator
Commits
08fd33a6
Commit
08fd33a6
authored
3 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
Fix various issues
parent
85438fb8
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lofardatagenerator/coords.py
+12
-7
12 additions, 7 deletions
lofardatagenerator/coords.py
lofargen_from_file.py
+18
-23
18 additions, 23 deletions
lofargen_from_file.py
with
30 additions
and
30 deletions
lofardatagenerator/coords.py
+
12
−
7
View file @
08fd33a6
...
@@ -71,14 +71,19 @@ def generate_uvw_per_observation(array_x, array_y, array_z, ra, dec, start_time,
...
@@ -71,14 +71,19 @@ def generate_uvw_per_observation(array_x, array_y, array_z, ra, dec, start_time,
uvw
[
i
,
:,
0
]
=
u
uvw
[
i
,
:,
0
]
=
u
uvw
[
i
,
:,
1
]
=
v
uvw
[
i
,
:,
1
]
=
v
uvw
[
i
,
:,
2
]
=
w
uvw
[
i
,
:,
2
]
=
w
u
,
v
,
w
=
uvw
[:,
:,
0
].
flatten
(),
\
u
,
v
,
w
=
uvw
[:,
:,
0
].
flatten
(),
\
uvw
[:,
:,
1
].
flatten
(),
\
uvw
[:,
:,
1
].
flatten
(),
\
uvw
[:,
:,
2
].
flatten
()
uvw
[:,
:,
2
].
flatten
()
points_array
=
numpy
.
zeros
((
len
(
u
),
3
),
dtype
=
numpy
.
float32
)
uvw_size
=
len
(
u
)
points_array
[:,
0
]
=
u
points_array
[:,
1
]
=
v
points_array
=
numpy
.
zeros
((
2
*
uvw_size
,
3
),
dtype
=
numpy
.
float32
)
points_array
[:,
2
]
=
w
points_array
[:
uvw_size
,
0
]
=
u
points_array
[:
uvw_size
,
1
]
=
v
points_array
[:
uvw_size
,
2
]
=
w
points_array
[
uvw_size
:,
0
]
=
-
u
points_array
[
uvw_size
:,
1
]
=
-
v
points_array
[
uvw_size
:,
2
]
=
-
w
return
points_array
return
points_array
...
@@ -88,7 +93,7 @@ def rotate_ellipse_points(uvw):
...
@@ -88,7 +93,7 @@ def rotate_ellipse_points(uvw):
pca
=
PCA
(
n_components
=
3
)
pca
=
PCA
(
n_components
=
3
)
mean_uvw
=
numpy
.
mean
(
uvw
,
axis
=
0
)
mean_uvw
=
numpy
.
me
di
an
(
uvw
,
axis
=
0
)
mean_uvw
=
uvw
-
mean_uvw
mean_uvw
=
uvw
-
mean_uvw
principal_components
=
pca
.
fit_transform
(
mean_uvw
.
T
)
principal_components
=
pca
.
fit_transform
(
mean_uvw
.
T
)
...
@@ -198,7 +203,7 @@ def make_baseline_hist_plot(uvw, sampling):
...
@@ -198,7 +203,7 @@ def make_baseline_hist_plot(uvw, sampling):
def
make_plots
(
original_uvw
,
rotated_uvw
,
sampling
,
frequency_in_mhz
,
pca
,
r_pca
,
path
):
def
make_plots
(
original_uvw
,
rotated_uvw
,
sampling
,
frequency_in_mhz
,
pca
,
r_pca
,
path
):
plt
.
figure
(
'
original_uvw
'
)
plt
.
figure
(
'
original_uvw
'
)
make_uv_hist_plot
(
original_uvw
,
sampling
,
pca
)
make_uv_hist_plot
(
original_uvw
,
sampling
,
pca
)
plt
.
show
()
plt
.
savefig
(
path
+
'
/original_uvw.png
'
)
plt
.
savefig
(
path
+
'
/original_uvw.png
'
)
plt
.
close
()
plt
.
close
()
...
...
This diff is collapsed.
Click to expand it.
lofargen_from_file.py
+
18
−
23
View file @
08fd33a6
...
@@ -4,7 +4,7 @@ from argparse import ArgumentParser
...
@@ -4,7 +4,7 @@ from argparse import ArgumentParser
import
json
import
json
from
lofardatagenerator.coords
import
*
from
lofardatagenerator.coords
import
*
import
logging
import
logging
import
numpy
as
np
logging
.
basicConfig
(
format
=
'
%(asctime)-15s %(levelname)s %(message)s
'
)
logging
.
basicConfig
(
format
=
'
%(asctime)-15s %(levelname)s %(message)s
'
)
logger
=
logging
.
getLogger
(
'
LOFAR generator
'
)
logger
=
logging
.
getLogger
(
'
LOFAR generator
'
)
logger
.
setLevel
(
logging
.
DEBUG
)
logger
.
setLevel
(
logging
.
DEBUG
)
...
@@ -15,6 +15,8 @@ __MINUTE_IN_SECONDS = 60
...
@@ -15,6 +15,8 @@ __MINUTE_IN_SECONDS = 60
def
parse_arguments
():
def
parse_arguments
():
parser
=
ArgumentParser
(
'
Generate uvw and compute eccentricity and
'
parser
=
ArgumentParser
(
'
Generate uvw and compute eccentricity and
'
'
filling factor of the uvw plane
'
)
'
filling factor of the uvw plane
'
)
parser
.
add_argument
(
'
station_field
'
,
parser
.
add_argument
(
'
station_field
'
,
type
=
str
,
type
=
str
,
help
=
'
coordinate list of the array elements
'
)
help
=
'
coordinate list of the array elements
'
)
...
@@ -24,6 +26,9 @@ def parse_arguments():
...
@@ -24,6 +26,9 @@ def parse_arguments():
help
=
'
table with the observation information
'
)
help
=
'
table with the observation information
'
)
parser
.
add_argument
(
'
--make_uvw_plot
'
,
action
=
'
store_true
'
)
parser
.
add_argument
(
'
--make_uvw_plot
'
,
action
=
'
store_true
'
)
parser
.
add_argument
(
'
--print_n_rows
'
,
action
=
'
store_true
'
,
help
=
'
print nrows and exits
'
)
parser
.
add_argument
(
'
--start_row
'
,
type
=
int
,
default
=
0
)
parser
.
add_argument
(
'
--end_row
'
,
type
=
int
,
default
=-
1
)
parser
.
add_argument
(
'
--save_image_to
'
,
type
=
str
,
default
=
'
.
'
)
parser
.
add_argument
(
'
--save_image_to
'
,
type
=
str
,
default
=
'
.
'
)
parser
.
add_argument
(
'
--full_table
'
,
type
=
str
,
default
=
'
summary.csv
'
)
parser
.
add_argument
(
'
--full_table
'
,
type
=
str
,
default
=
'
summary.csv
'
)
...
@@ -81,13 +86,24 @@ def main():
...
@@ -81,13 +86,24 @@ def main():
DataFrame
(
columns
=
[
'
sas_id
'
,
'
beam
'
,
'
start_time
'
,
'
end_time
'
,
DataFrame
(
columns
=
[
'
sas_id
'
,
'
beam
'
,
'
start_time
'
,
'
end_time
'
,
'
duration
'
,
'
ra
'
,
'
dec
'
,
'
e
'
,
'
filling_factor
'
,
'
average_coverage
'
,
'
duration
'
,
'
ra
'
,
'
dec
'
,
'
e
'
,
'
filling_factor
'
,
'
average_coverage
'
,
'
average_scale
'
])
'
average_scale
'
])
for
index
,
row
in
observation_table
.
iterrows
():
nrows
=
len
(
observation_table
.
index
)
if
(
arguments
.
print_n_rows
):
print
(
'
number of rows are
'
,
nrows
)
raise
SystemExit
()
start_index
=
arguments
.
start_row
end_index
=
arguments
.
end_row
if
arguments
.
end_row
>
0
else
nrows
for
index
in
range
(
start_index
,
end_index
):
row
=
observation_table
.
iloc
[
index
]
logger
.
info
(
'
processing observation %s/%s
'
,
index
,
nrows
)
ra
,
dec
=
row
[
'
RIGHTASCENSION
'
],
row
[
'
DECLINATION
'
]
ra
,
dec
=
row
[
'
RIGHTASCENSION
'
],
row
[
'
DECLINATION
'
]
ra
,
dec
=
ra_dec_into_radians
(
ra
,
dec
)
ra
,
dec
=
ra_dec_into_radians
(
ra
,
dec
)
station_list
=
row
[
'
STATIONS
'
].
split
(
'
,
'
)
station_list
=
row
[
'
STATIONS
'
].
split
(
'
,
'
)
start_time
:
datetime
.
datetime
=
row
[
'
STARTTIME
'
]
start_time
:
datetime
.
datetime
=
row
[
'
STARTTIME
'
]
end_time
:
datetime
.
datetime
=
row
[
'
ENDTIME
'
]
end_time
:
datetime
.
datetime
=
row
[
'
ENDTIME
'
]
observation_duration_in_seconds
=
(
end_time
-
start_time
).
seconds
observation_duration_in_seconds
=
(
end_time
-
start_time
).
seconds
if
not
observation_duration_in_seconds
:
if
not
observation_duration_in_seconds
:
continue
continue
filter
=
row
[
'
FILTER
'
]
filter
=
row
[
'
FILTER
'
]
...
@@ -125,26 +141,5 @@ def main():
...
@@ -125,26 +141,5 @@ def main():
gc
.
collect
()
gc
.
collect
()
# ra, dec = coords_into_radians(arguments.source_coordinates)
# uvw = generate_uvw_per_observation(array_x, array_y, array_z, ra, dec,
# start_time,
# observation_duration_in_seconds)
# uvw = select_baseline_length(uvw, arguments.max_baseline_length)
# logger.debug("UVW generated")
# rotated_uvw, pca, r_pca = rotate_ellipse_points(uvw)
# ecc, filling_factor, sampling, mean_coverage, mean_d = compute_parameters(rotated_uvw)
# if(arguments.make_uvw_plot):
# make_plots(uvw, rotated_uvw, sampling, arguments.frequency, pca, r_pca, arguments.save_image_to)
# data = dict(frequency=arguments.frequency, duration=observation_duration_in_seconds,
# ra=ra, dec=dec, out_dir=arguments.save_image_to, e=ecc,
# filling_factor=filling_factor, average_coverage=mean_coverage,
# average_scale=mean_d)
# with open(arguments.save_image_to + '/parameters.json', 'w') as f_out:
# json.dump(data, f_out)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
main
()
main
()
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