This repository has been archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from ICRAR/cgray_refactor_phaserotate
- Loading branch information
Showing
23 changed files
with
897 additions
and
791 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/icrar/leap-accelerate/algorithm/casa/PhaseMatrixFunction.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/** | ||
* ICRAR - International Centre for Radio Astronomy Research | ||
* (c) UWA - The University of Western Australia | ||
* Copyright by UWA(in the framework of the ICRAR) | ||
* All rights reserved | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
* MA 02111 - 1307 USA | ||
*/ | ||
|
||
#include "PhaseMatrixFunction.h" | ||
|
||
#include <icrar/leap-accelerate/math/math.h> | ||
#include <icrar/leap-accelerate/math/cpu/vector.h> | ||
#include <icrar/leap-accelerate/math/casacore_helper.h> | ||
#include <icrar/leap-accelerate/math/casa/matrix.h> | ||
|
||
#include <casacore/casa/Arrays/Matrix.h> | ||
#include <casacore/casa/Arrays/Vector.h> | ||
|
||
#include <set> | ||
|
||
using namespace casacore; | ||
|
||
namespace icrar | ||
{ | ||
namespace casalib | ||
{ | ||
std::pair<casacore::Matrix<double>, casacore::Vector<std::int32_t>> PhaseMatrixFunction( | ||
const casacore::Vector<std::int32_t>& a1, | ||
const casacore::Vector<std::int32_t>& a2, | ||
int refAnt) | ||
{ | ||
if(a1.size() != a2.size()) | ||
{ | ||
throw std::invalid_argument("a1 and a2 must be equal size"); | ||
} | ||
|
||
auto unique = std::set<std::int32_t>(a1.cbegin(), a1.cend()); | ||
unique.insert(a2.cbegin(), a2.cend()); | ||
int nAnt = unique.size(); | ||
if(refAnt >= nAnt - 1) | ||
{ | ||
throw std::invalid_argument("RefAnt out of bounds"); | ||
} | ||
|
||
Matrix<double> A = Matrix<double>(a1.size() + 1, std::max(icrar::ArrayMax(a1), icrar::ArrayMax(a2)) + 1); | ||
A = 0.0; | ||
|
||
Vector<int> I = Vector<int>(a1.size() + 1); | ||
I = -1; | ||
|
||
int STATIONS = A.shape()[1]; //TODO verify correctness | ||
int k = 0; | ||
|
||
for(size_t n = 0; n < a1.size(); n++) | ||
{ | ||
if(a1(n) != a2(n)) | ||
{ | ||
if((refAnt < 0) || ((refAnt >= 0) && ((a1(n) == refAnt) || (a2(n) == refAnt)))) | ||
{ | ||
A(k, a1(n)) = 1.0; // set scalear | ||
A(k, a2(n)) = -1.0; // set scalear | ||
I(k) = n; //set scalear | ||
k++; | ||
} | ||
} | ||
} | ||
if(refAnt < 0) | ||
{ | ||
refAnt = 0; | ||
} | ||
|
||
A(k, refAnt) = 1; | ||
k++; | ||
|
||
auto Atemp = casacore::Matrix<double>(k, STATIONS); | ||
Atemp = A(Slice(0, k), Slice(0, STATIONS)); | ||
A.resize(0,0); | ||
A = Atemp; | ||
|
||
auto Itemp = casacore::Vector<int>(k); | ||
Itemp = I(Slice(0, k)); | ||
I.resize(0); | ||
I = Itemp; | ||
|
||
return std::make_pair(A, I); | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/icrar/leap-accelerate/algorithm/casa/PhaseMatrixFunction.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* ICRAR - International Centre for Radio Astronomy Research | ||
* (c) UWA - The University of Western Australia | ||
* Copyright by UWA(in the framework of the ICRAR) | ||
* All rights reserved | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
* MA 02111 - 1307 USA | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <casacore/casa/Arrays/Matrix.h> | ||
#include <casacore/casa/Arrays/Vector.h> | ||
|
||
#include <utility> | ||
|
||
namespace icrar | ||
{ | ||
namespace casalib | ||
{ | ||
/** | ||
* @brief Form Phase Matrix | ||
* Given the antenna lists from MS and (optionally) RefAnt & Map: | ||
* If non-negative RefAnt is provided it only forms the matrix for baselines with that antenna. | ||
* If True Map is provided it returns the index map for the matrix (only useful if RefAnt set). | ||
* | ||
* This function generates and returns the linear matrix for the phase calibration (only) | ||
* @param a1 indexes of 1st antenna of each baselines | ||
* @param a2 indexes of 2nd antenna of each baselines | ||
* @param refAnt the reference antenna (0, 1), -1 | ||
* @return std::pair<casacore::Matrix<double>, casacore::Vector<std::int32_t>> | ||
*/ | ||
std::pair<casacore::Matrix<double>, casacore::Vector<std::int32_t>> PhaseMatrixFunction( | ||
const casacore::Vector<std::int32_t>& a1, | ||
const casacore::Vector<std::int32_t>& a2, | ||
int refAnt); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.