Skip to content
Snippets Groups Projects
Commit 1d456555 authored by Jakob Maljaars's avatar Jakob Maljaars
Browse files

Merge branch 'fix-lofargrid-bug' into 'master'

Fix lofargrid bug

See merge request !52
parents 77102ab0 6f4dda4c
No related branches found
No related tags found
1 merge request!52Fix lofargrid bug
Pipeline #3324 passed
......@@ -16,7 +16,7 @@ clang-format:
image: everybeam_base:${CI_COMMIT_SHORT_SHA}
before_script:
- apt-get -y install python3-pip
- pip3 install clang-format
- pip3 install clang-format==9.0.0
script:
- ./scripts/run-clang-format.sh
......
......@@ -18,7 +18,8 @@ namespace everybeam {
namespace coords {
/**
* @brief Class providing utilities for coordinate transformations
* to and from ITRF (International Terrestrial Reference Frame)
* to and from ITRF (International Terrestrial Reference Frame).
* NOTE: this class is not thread-safe due to casacore dependencies.
*
*/
class ITRFConverter {
......
......@@ -33,19 +33,20 @@ void LOFARGrid::CalculateStation(std::complex<float>* buffer, double time,
lane_ = &lane;
SetITRFVectors(time);
double sb_freq = use_channel_frequency_ ? frequency : subband_frequency_;
// Dummy calculation of gain matrix, needed for multi-threading
inverse_central_gain_.resize(1);
matrix22c_t gain_matrix = lofartelescope.GetStation(station_idx)
->Response(time, frequency, diff_beam_centre_,
sb_freq, station0_, tile0_);
inverse_central_gain_[0][0] = gain_matrix[0][0];
inverse_central_gain_[0][1] = gain_matrix[0][1];
inverse_central_gain_[0][2] = gain_matrix[1][0];
inverse_central_gain_[0][3] = gain_matrix[1][1];
if (!inverse_central_gain_[0].Invert()) {
inverse_central_gain_[0] = aocommon::MC2x2F::Zero();
if (lofartelescope.GetOptions().use_differential_beam) {
double sb_freq = use_channel_frequency_ ? frequency : subband_frequency_;
inverse_central_gain_.resize(1);
matrix22c_t gain_matrix = lofartelescope.GetStation(station_idx)
->Response(time, frequency, diff_beam_centre_,
sb_freq, station0_, tile0_);
inverse_central_gain_[0][0] = gain_matrix[0][0];
inverse_central_gain_[0][1] = gain_matrix[0][1];
inverse_central_gain_[0][2] = gain_matrix[1][0];
inverse_central_gain_[0][3] = gain_matrix[1][1];
if (!inverse_central_gain_[0].Invert()) {
inverse_central_gain_[0] = aocommon::MC2x2F::Zero();
}
}
for (size_t i = 0; i != nthreads_; ++i) {
......@@ -70,14 +71,12 @@ void LOFARGrid::CalculateAllStations(std::complex<float>* buffer, double time,
SetITRFVectors(time);
double sb_freq = use_channel_frequency_ ? frequency : subband_frequency_;
// Dummy loop, needed for multi-threading
inverse_central_gain_.resize(lofartelescope.GetNrStations());
for (size_t i = 0; i != lofartelescope.GetNrStations(); ++i) {
matrix22c_t gain_matrix = lofartelescope.GetStation(i)->Response(
time, frequency, diff_beam_centre_, sb_freq, station0_, tile0_);
if (lofartelescope.GetOptions().use_differential_beam) {
if (lofartelescope.GetOptions().use_differential_beam) {
double sb_freq = use_channel_frequency_ ? frequency : subband_frequency_;
inverse_central_gain_.resize(lofartelescope.GetNrStations());
for (size_t i = 0; i != lofartelescope.GetNrStations(); ++i) {
matrix22c_t gain_matrix = lofartelescope.GetStation(i)->Response(
time, frequency, diff_beam_centre_, sb_freq, station0_, tile0_);
inverse_central_gain_[i][0] = gain_matrix[0][0];
inverse_central_gain_[i][1] = gain_matrix[0][1];
inverse_central_gain_[i][2] = gain_matrix[1][0];
......
......@@ -92,6 +92,12 @@ class LOFARGrid final : public GriddedResponse {
};
aocommon::Lane<Job>* lane_;
/**
* @brief Method for computing the ITRF-vectors.
* NOTE: method not thread-safe due to casacore dependencies.
*
* @param time
*/
void SetITRFVectors(double time);
void CalcThread(std::complex<float>* buffer, double time, double frequency);
......
......@@ -9,6 +9,9 @@
# "./scripts/run-clang-format.sh" to .git/hooks/pre-commit
# and make sure pre-commit is an executable shell script.
# Disable globbing
set -e -f
#Script configuration for this repo. Adjust it when copying to a different repo.
#The directory that contains the source files, which clang-format should format.
......@@ -23,10 +26,15 @@ SOURCE_EXT=(*.cc *.h)
#End script configuration.
set -e
# Detect run environment.
if [ -n "$CI" ]; then
DRYRUN=" (dry run on CI)"
elif [ -n "$GIT_AUTHOR_DATE" ]; then
DRYRUN=" (dry run in git hook)"
fi
# print in bold-face
echo -e "\e[1mRunning clang-format...\e[0m"
echo -e "\e[1mRunning clang-format$DRYRUN...\e[0m"
# Convert SOURCE_EXT into "-name ext1 -o -name ext2 -o name ext3 ..."
FIND_NAMES="-name ${SOURCE_EXT[0]}"
......@@ -41,15 +49,23 @@ for e in ${EXCLUDE_DIRS[*]}; do
done
cd $SOURCE_DIR
find . $FIND_EXCLUDES -type f \( $FIND_NAMES \) \
-exec clang-format -i -style=file \{\} +
FILES=$(find . $FIND_EXCLUDES -type f \( $FIND_NAMES \) -print)
if git diff --exit-code --quiet; then
if [ -n "$DRYRUN" ]; then
# If the xml has no replacement entries, all files are formatted.
if clang-format -style=file --output-replacements-xml $FILES |
grep -q "<replacement "; then
# Print in bold-face red
echo -e "\e[1m\e[31mAt least one file is not properly formatted!\e[0m"
echo -e "\e[1m\e[31mRun $0 for formatting all files!\e[0m"
exit 1;
else
# print in bold-face green
echo -e "\e[1m\e[32mGreat job, git shows no changed files!\e[0m"
echo -e "\e[1m\e[32mGreat job, all files are properly formatted!\e[0m"
exit 0;
fi
else
# Print in bold-face red
echo -e "\e[1m\e[31mGit shows at least one changed file now!\e[0m"
exit 1;
fi
clang-format -i -style=file $FILES
# print in bold-face
echo -e "\e[1mSuccessfully formatted all files.\e[0m"
fi
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment