Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
schaapcommon
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ResearchAndDevelopment
schaapcommon
Commits
e9982c38
Commit
e9982c38
authored
1 day ago
by
Bas van der Tol
Browse files
Options
Downloads
Patches
Plain Diff
Add SolTab::GetSubArray() generalization
parent
63ca1d27
No related branches found
Branches containing commit
No related tags found
1 merge request
!167
Add SolTab::GetSubArray() generalization
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.clang-tidy
+1
-1
1 addition, 1 deletion
.clang-tidy
include/schaapcommon/h5parm/soltab.h
+15
-4
15 additions, 4 deletions
include/schaapcommon/h5parm/soltab.h
src/h5parm/soltab.cc
+69
-12
69 additions, 12 deletions
src/h5parm/soltab.cc
with
85 additions
and
17 deletions
.clang-tidy
+
1
−
1
View file @
e9982c38
...
...
@@ -29,7 +29,7 @@ CheckOptions:
- key: modernize-make-shared.MakeSmartPtrFunction
value: 'std::make_shared'
- key: modernize-loop-convert.UseCxx20ReverseRanges
value: '
tru
e'
value: '
fals
e'
- key: modernize-use-override.FinalSpelling
value: final
- key: modernize-use-using.IgnoreMacros
...
...
This diff is collapsed.
Click to expand it.
include/schaapcommon/h5parm/soltab.h
+
15
−
4
View file @
e9982c38
...
...
@@ -197,10 +197,17 @@ class SolTab : private H5::Group {
size_t
pol
,
size_t
dir
,
bool
nearest
)
const
;
/// Get the values or weights of this SolTab for a given antenna given an
/// antenna name, a direction index, and a (range of) times and frequencies.
/// In the returned vector, the freq will be the fastest changing index,
/// irrespective of the axis ordering in the underlying h5 data structure.
std
::
tuple
<
int
,
int
,
int
,
int
,
int
>
GetSubArray
(
const
std
::
string
&
val_or_weight
,
const
size_t
start_antenna_index
,
const
size_t
n_antennas
,
const
size_t
antenna_step
,
const
size_t
start_time_index
,
const
size_t
n_times
,
const
size_t
time_step
,
const
size_t
start_freq_index
,
const
size_t
n_freqs
,
const
size_t
freq_step
,
const
size_t
start_polarization_index
,
const
size_t
n_polarizations
,
const
size_t
polarization_step
,
const
size_t
start_direction_index
,
const
size_t
n_directions
,
const
size_t
direction_step
,
std
::
vector
<
double
>&
buffer
)
const
;
std
::
vector
<
double
>
GetSubArray
(
const
std
::
string
&
val_or_weight
,
const
std
::
string
&
antenna_name
,
size_t
start_time_index
,
size_t
n_times
,
...
...
@@ -212,6 +219,10 @@ class SolTab : private H5::Group {
const
std
::
string
&
value_or_weight
,
const
size_t
n_axes
,
const
std
::
array
<
size_t
,
5
>&
size_axis
)
const
;
/// Get the values or weights of this SolTab for a given antenna given an
/// antenna name, a direction index, and a (range of) times and frequencies.
/// In the returned vector, the freq will be the fastest changing index,
/// irrespective of the axis ordering in the underlying h5 data structure.
std
::
vector
<
double
>
GetValuesOrWeights
(
const
std
::
string
&
val_or_weight
,
const
std
::
string
&
antenna_name
,
const
std
::
vector
<
double
>&
times
,
...
...
This diff is collapsed.
Click to expand it.
src/h5parm/soltab.cc
+
69
−
12
View file @
e9982c38
...
...
@@ -411,12 +411,15 @@ TimesAndFrequencies SolTab::GetTimesAndFrequencies(
return
tf
;
}
std
::
vector
<
double
>
SolTab
::
GetSubArray
(
const
std
::
string
&
val_or_weight
,
const
std
::
string
&
antenna_name
,
std
::
tuple
<
int
,
int
,
int
,
int
,
int
>
SolTab
::
GetSubArray
(
const
std
::
string
&
val_or_weight
,
const
size_t
start_antenna_index
,
const
size_t
n_antennas
,
const
size_t
antenna_step
,
const
size_t
start_time_index
,
const
size_t
n_times
,
const
size_t
time_step
,
const
size_t
start_freq_index
,
const
size_t
n_freqs
,
const
size_t
freq_step
,
const
size_t
polarization
,
const
size_t
direction
)
const
{
std
::
vector
<
double
>
res
(
n_times
*
n_freqs
);
const
size_t
start_polarization_index
,
const
size_t
n_polarizations
,
const
size_t
polarization_step
,
const
size_t
start_direction_index
,
const
size_t
n_directions
,
const
size_t
direction_step
,
std
::
vector
<
double
>&
buffer
)
const
{
H5
::
DataSet
val
=
openDataSet
(
val_or_weight
);
// Set offsets and strides
...
...
@@ -432,34 +435,64 @@ std::vector<double> SolTab::GetSubArray(
for
(
const
AxisInfo
&
axis_info
:
axes_
)
{
hsize_t
stride
=
1
;
hsize_t
count
=
1
;
hsize_t
memdim
=
1
;
hsize_t
offset
=
0
;
if
(
axis_info
.
name
==
"time"
)
{
offset
=
start_time_index
;
stride
=
time_step
;
count
=
n_times
;
memdim
=
n_times
;
}
else
if
(
axis_info
.
name
==
"freq"
)
{
offset
=
start_freq_index
;
stride
=
freq_step
;
count
=
n_freqs
;
memdim
=
n_freqs
;
}
else
if
(
axis_info
.
name
==
"ant"
)
{
offset
=
GetAntIndex
(
antenna_name
);
offset
=
start_antenna_index
;
stride
=
antenna_step
;
count
=
n_antennas
;
}
else
if
(
axis_info
.
name
==
"dir"
)
{
offset
=
direction
;
offset
=
start_direction_index
;
stride
=
direction_step
;
count
=
n_directions
;
}
else
if
(
axis_info
.
name
==
"pol"
)
{
offset
=
polarization
;
offset
=
start_polarization_index
;
stride
=
polarization_step
;
count
=
n_polarizations
;
}
else
if
(
axis_info
.
size
!=
1
)
{
throw
std
::
runtime_error
(
"Axis
\"
"
+
axis_info
.
name
+
"
\"
in H5Parm is not understood"
);
}
memdims
.
push_back
(
memdim
);
memdims
.
push_back
(
count
);
offsets
.
push_back
(
offset
);
counts
.
push_back
(
count
);
strides
.
push_back
(
stride
);
}
size_t
antenna_stride
=
0
;
size_t
time_stride
=
0
;
size_t
freq_stride
=
0
;
size_t
polarization_stride
=
0
;
size_t
direction_stride
=
0
;
size_t
stride
=
1
;
for
(
auto
axis_info
=
axes_
.
rbegin
();
axis_info
!=
axes_
.
rend
();
++
axis_info
)
{
if
(
axis_info
->
name
==
"time"
)
{
time_stride
=
stride
;
stride
*=
n_times
;
}
else
if
(
axis_info
->
name
==
"freq"
)
{
freq_stride
=
stride
;
stride
*=
n_freqs
;
}
else
if
(
axis_info
->
name
==
"ant"
)
{
antenna_stride
=
stride
;
stride
*=
n_antennas
;
}
else
if
(
axis_info
->
name
==
"dir"
)
{
direction_stride
=
stride
;
stride
*=
n_directions
;
}
else
if
(
axis_info
->
name
==
"pol"
)
{
polarization_stride
=
stride
;
stride
*=
n_polarizations
;
}
}
buffer
.
resize
(
stride
);
H5
::
DataSpace
dataspace
=
val
.
getSpace
();
dataspace
.
selectHyperslab
(
H5S_SELECT_SET
,
counts
.
data
(),
offsets
.
data
(),
...
...
@@ -467,12 +500,36 @@ std::vector<double> SolTab::GetSubArray(
// Setup memory dataspace
H5
::
DataSpace
memspace
(
axes_
.
size
(),
memdims
.
data
());
try
{
val
.
read
(
res
.
data
(),
H5
::
PredType
::
NATIVE_DOUBLE
,
memspace
,
dataspace
);
val
.
read
(
buffer
.
data
(),
H5
::
PredType
::
NATIVE_DOUBLE
,
memspace
,
dataspace
);
}
catch
(
H5
::
DataSetIException
&
e
)
{
e
.
printErrorStack
();
throw
std
::
runtime_error
(
"Could not read data"
);
}
return
{
antenna_stride
,
time_stride
,
freq_stride
,
polarization_stride
,
direction_stride
};
}
std
::
vector
<
double
>
SolTab
::
GetSubArray
(
const
std
::
string
&
val_or_weight
,
const
std
::
string
&
antenna_name
,
const
size_t
start_time_index
,
const
size_t
n_times
,
const
size_t
time_step
,
const
size_t
start_freq_index
,
const
size_t
n_freqs
,
const
size_t
freq_step
,
const
size_t
polarization
,
const
size_t
direction
)
const
{
std
::
vector
<
double
>
res
(
n_times
*
n_freqs
);
size_t
antenna_index
=
0
;
try
{
antenna_index
=
GetAntIndex
(
antenna_name
);
}
catch
(
const
std
::
runtime_error
&
error
)
{
// A SolTab does not necessarily have an "ant" table.
// In that case just leave antenna_index at 0.
}
GetSubArray
(
val_or_weight
,
antenna_index
,
1
,
1
,
start_time_index
,
n_times
,
time_step
,
start_freq_index
,
n_freqs
,
freq_step
,
polarization
,
1
,
1
,
direction
,
1
,
1
,
res
);
return
res
;
}
...
...
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