diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..bfa1a8d198bfb1d8df520af5b72dce63d60b5e4d --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# Files +# +# Directories +.vscode/ +build/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bf560c716bfe80d42f8b9f93a3d902a940890837..1d0fe94804b22fbfbd0414ae3cf2fb6de60ed9e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ stages: - build-base - - clang-format - - build-lofarbeam + - format-and-test + - build-everybeam - build-doc - deploy-doc # - build-dependency @@ -16,20 +16,39 @@ build-base: docker build --build-arg CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA --tag $CI_REGISTRY_IMAGE:base - -f ./test/Dockerfile-base . + -f ./docker/Dockerfile-base . - docker push $CI_REGISTRY_IMAGE:base clang-format: - stage: clang-format + stage: format-and-test image: $CI_REGISTRY_IMAGE:base - script: - # - apt-get update && apt-get -y install clang-format + before_script: - apt-get -y install python3-pip - pip3 install clang-format + script: - ./scripts/clang-format-check.sh -build-lofarbeam: - stage: build-lofarbeam +# Build a debug version of EveryBeam from the base image +test-and-coverage: + stage: format-and-test + image: $CI_REGISTRY_IMAGE:base + dependencies: + - build-base + before_script: + - apt-get -y install python3-pip + - pip3 install gcovr + script: + - mkdir -p /opt/everybeam/build + - cd /opt/everybeam && git clone https://git.astron.nl/RD/EveryBeam.git EveryBeam + - cd /opt/everybeam/EveryBeam && git checkout ${CI_COMMIT_SHORT_SHA} + - cd /opt/everybeam/build + - cmake -DCMAKE_INSTALL_PREFIX=.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-coverage" -DCMAKE_EXE_LINKER_FLAGS="-coverage" ../EveryBeam/ + - make install -j8 + - ctest -T test + - gcovr -r .. -e '.*/external/.*' -e '.*/CompilerIdCXX/.*' -e '.*/test/.*' -e '.*/demo/.*' + +build-everybeam: + stage: build-everybeam script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - > @@ -37,7 +56,7 @@ build-lofarbeam: --build-arg CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE --build-arg CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA - -f ./test/Dockerfile-lofarbeam . + -f ./docker/Dockerfile-everybeam . - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA build-doc: @@ -46,10 +65,10 @@ build-doc: - > docker run --name $CI_COMMIT_SHORT_SHA - --workdir /opt/lofarbeam/build/ + --workdir /opt/everybeam/build/ $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA sh -c 'make doc' - - docker cp $CI_COMMIT_SHORT_SHA:/opt/lofarbeam/build/doc/html htmldoc + - docker cp $CI_COMMIT_SHORT_SHA:/opt/everybeam/build/doc/html htmldoc - docker rm $CI_COMMIT_SHORT_SHA artifacts: paths: @@ -79,7 +98,7 @@ deploy-doc: # --build-arg CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE # --build-arg CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA # --tag $CI_REGISTRY_IMAGE:dp3-$CI_COMMIT_SHORT_SHA -# -f ./test/Dockerfile-dp3 . +# -f ./docker/Dockerfile-dp3 . # - docker push $CI_REGISTRY_IMAGE:dp3-$CI_COMMIT_SHORT_SHA # build-wsclean: @@ -91,7 +110,7 @@ deploy-doc: # --build-arg CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE # --build-arg CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA # --tag $CI_REGISTRY_IMAGE:wsclean-$CI_COMMIT_SHORT_SHA -# -f ./test/Dockerfile-wsclean . +# -f ./docker/Dockerfile-wsclean . # - docker push $CI_REGISTRY_IMAGE:wsclean-$CI_COMMIT_SHORT_SHA # test-dp3: @@ -103,7 +122,7 @@ deploy-doc: # - > # docker run # $CI_REGISTRY_IMAGE:dp3-$CI_COMMIT_SHORT_SHA -# /opt/lofarbeam/lofarbeam/test/tDockerDP3 +# /opt/everybeam/everybeam/docker/tDockerDP3 # test-wsclean: # variables: diff --git a/CMake/config.h.in b/CMake/config.h.in index cec47a529d04bb70cf5c321682bc249ffe94be14..5a723152fcc198436161117ddbc88c1a4cfe28c6 100644 --- a/CMake/config.h.in +++ b/CMake/config.h.in @@ -1,7 +1,7 @@ -#ifndef LOFARBEAM_CONFIG_H_ -#define LOFARBEAM_CONFIG_H_ +#ifndef EVERYBEAM_CONFIG_H_ +#define EVERYBEAM_CONFIG_H_ -#define LOFARBEAM_DATA_DIR "@CMAKE_INSTALL_DATA_DIR@" +#define EVERYBEAM_DATA_DIR "@CMAKE_INSTALL_DATA_DIR@" #define TEST_MEASUREMENTSET "@TEST_MEASUREMENTSET@" #endif diff --git a/CMakeLists.txt b/CMakeLists.txt index 7feb4f23007499e2b8c1d798816bdb7865183ca4..257feac911acf56ecb457d7e4a693449b5c2db09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,105 +1,74 @@ +#------------------------------------------------------------------------------ +# Top level CMakeLists.txt file for EveryBeam cmake_minimum_required(VERSION 3.0.0) -project(EveryBeam) +#------------------------------------------------------------------------------ +# Set project name and version number +project(EveryBeam VERSION 5.0.0) string(TOLOWER ${CMAKE_PROJECT_NAME} projectname ) +# Set the path to CMake modules +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake) + # Configure directory for data files set(CMAKE_INSTALL_DATA_DIR "${CMAKE_INSTALL_PREFIX}/share/${projectname}") message("Storing data in: " ${CMAKE_INSTALL_DATA_DIR}) configure_file(${CMAKE_SOURCE_DIR}/CMake/config.h.in ${CMAKE_BINARY_DIR}/config.h) -add_subdirectory(external) +# Find and include HDF5 +find_package(HDF5 COMPONENTS C CXX REQUIRED) +add_definitions(${HDF5_DEFINITIONS}) +include_directories(${HDF5_INCLUDE_DIR}) +# Find and include Casacore +set(CASACORE_MAKE_REQUIRED_EXTERNALS_OPTIONAL TRUE) +find_package(Casacore REQUIRED COMPONENTS casa ms tables measures fits) +include_directories(${CASACORE_INCLUDE_DIR}) + +# Find and include OpenMP +find_package(OpenMP REQUIRED) + +#------------------------------------------------------------------------------ +# Set CMake and compiler options if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) endif() -# Add tests -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(test) -endif() - if (POLICY CMP0074) cmake_policy(SET CMP0074 NEW) endif() -find_package(HDF5 COMPONENTS C CXX REQUIRED) -add_definitions(${HDF5_DEFINITIONS}) -include_directories(${HDF5_INCLUDE_DIR}) +# Set compile options +add_compile_options(-std=c++11 "${OpenMP_CXX_FLAGS}" -Wall -DNDEBUG -Wl,--no-undefined) -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake) +#------------------------------------------------------------------------------ +# Find/load top level dependencies +add_subdirectory(external) -set(CASACORE_MAKE_REQUIRED_EXTERNALS_OPTIONAL TRUE) -find_package(Casacore REQUIRED COMPONENTS casa ms tables measures fits) -include_directories(${CASACORE_INCLUDE_DIR}) +#------------------------------------------------------------------------------ +# Add source +add_subdirectory(cpp) -# Add element models -add_subdirectory(hamaker) -add_subdirectory(lobes) -add_subdirectory(oskar) - -add_compile_options(-std=c++11 -Wall -DNDEBUG -Wl,--no-undefined) - -add_library(everybeam SHARED - Antenna.cc - ElementResponse.cc - BeamFormer.cc - Element.cc - ITRFConverter.cc - ITRFDirection.cc - LofarMetaDataUtil.cc - MathUtil.cc - Station.cc - Types.cc -) - -set_target_properties(everybeam PROPERTIES - CXX_STANDARD 17 - VERSION 3 -) - -target_include_directories(everybeam PUBLIC ${CASACORE_INCLUDE_DIR}) - -target_link_libraries(everybeam PUBLIC ${CASACORE_LIBRARIES}) - -target_link_libraries(everybeam PUBLIC hamaker lobes oskar) - -install ( - TARGETS everybeam - EXPORT EveryBeamTargets - DESTINATION lib) - -install (FILES - Antenna.h - BeamFormer.h - Constants.h - Element.h - ElementResponse.h - LofarMetaDataUtil.h - MathUtil.h - MutablePtr.h - Station.h - Types.h - ITRFConverter.h - ITRFDirection.h -DESTINATION "include/${CMAKE_PROJECT_NAME}") - -install( - EXPORT EveryBeamTargets - FILE EveryBeamConfig.cmake - NAMESPACE EveryBeam:: - DESTINATION "lib/${projectname}" -) +#------------------------------------------------------------------------------ +# Add tests +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) + add_subdirectory(cpp/test) + # TODO: compiling the demos should probably be a different cmake project + # in which we use find_package(EveryBeam) + add_subdirectory(demo) +endif() +#------------------------------------------------------------------------------ +# Documentation find_package(Doxygen) if(DOXYGEN_FOUND) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) add_custom_target(doc - ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating developer API documentation with Doxygen" VERBATIM) + ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating developer API documentation with Doxygen" VERBATIM) elseif(DOXYGEN_FOUND) endif(DOXYGEN_FOUND) diff --git a/MathUtil.cc b/MathUtil.cc deleted file mode 100644 index 005e08974f4213647633088830cd08003e35ae08..0000000000000000000000000000000000000000 --- a/MathUtil.cc +++ /dev/null @@ -1,25 +0,0 @@ -// MathUtil.cc: Various mathematical operations on vectors and matrices. -// -// Copyright (C) 2013 -// ASTRON (Netherlands Institute for Radio Astronomy) -// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -// -// This file is part of the LOFAR software suite. -// The LOFAR software suite is free software: you can redistribute it and/or -// modify it under the terms of the GNU General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The LOFAR software suite 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -// -// $Id$ - -#include "MathUtil.h" - -namespace everybeam {} // namespace everybeam diff --git a/Types.cc b/Types.cc deleted file mode 100644 index f75ae16544a909d24828216d8c11a85bec002566..0000000000000000000000000000000000000000 --- a/Types.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Types.cc: Declaration of types used in this library. -// -// Copyright (C) 2013 -// ASTRON (Netherlands Institute for Radio Astronomy) -// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -// -// This file is part of the LOFAR software suite. -// The LOFAR software suite is free software: you can redistribute it and/or -// modify it under the terms of the GNU General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The LOFAR software suite 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 General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -// -// $Id$ - -#include "Types.h" - -namespace everybeam {} // namespace everybeam diff --git a/lobes/CS302_coords.mat b/coeffs/CS302_coords.mat similarity index 100% rename from lobes/CS302_coords.mat rename to coeffs/CS302_coords.mat diff --git a/hamaker/HamakerHBACoeff.h5 b/coeffs/HamakerHBACoeff.h5 similarity index 100% rename from hamaker/HamakerHBACoeff.h5 rename to coeffs/HamakerHBACoeff.h5 diff --git a/hamaker/HamakerLBACoeff.h5 b/coeffs/HamakerLBACoeff.h5 similarity index 100% rename from hamaker/HamakerLBACoeff.h5 rename to coeffs/HamakerLBACoeff.h5 diff --git a/hamaker/element_beam_HBA.coeff b/coeffs/element_beam_HBA.coeff similarity index 100% rename from hamaker/element_beam_HBA.coeff rename to coeffs/element_beam_HBA.coeff diff --git a/hamaker/element_beam_LBA.coeff b/coeffs/element_beam_LBA.coeff similarity index 100% rename from hamaker/element_beam_LBA.coeff rename to coeffs/element_beam_LBA.coeff diff --git a/Antenna.cc b/cpp/Antenna.cc similarity index 92% rename from Antenna.cc rename to cpp/Antenna.cc index 7316941b86cc243110803620779fc0b7645491be..4d5f7e4c01dd465d1e5889df819edfe762a81797 100644 --- a/Antenna.cc +++ b/cpp/Antenna.cc @@ -1,6 +1,6 @@ #include "Antenna.h" -#include "MathUtil.h" +#include "common/MathUtil.h" namespace everybeam { vector3r_t Antenna::transform_to_local_direction(const vector3r_t &direction) { diff --git a/Antenna.h b/cpp/Antenna.h similarity index 99% rename from Antenna.h rename to cpp/Antenna.h index 0d1f69ded126671ba757b7810369703d6c9aeec7..87b603e1f19cdbcfc08998a5dc5988542c54de61 100644 --- a/Antenna.h +++ b/cpp/Antenna.h @@ -5,7 +5,7 @@ #include <memory> #include <iostream> -#include "Types.h" +#include "common/Types.h" namespace everybeam { diff --git a/BeamFormer.cc b/cpp/BeamFormer.cc similarity index 97% rename from BeamFormer.cc rename to cpp/BeamFormer.cc index 8f63c24c49f64324fe37472e9337e4021d8b5f7f..c436f057e5a9799a65773358b59efa2bda9c94c8 100644 --- a/BeamFormer.cc +++ b/cpp/BeamFormer.cc @@ -1,7 +1,7 @@ #include "BeamFormer.h" -#include "MathUtil.h" -#include "Constants.h" +#include "common/Constants.h" +#include "common/MathUtil.h" #include <cmath> @@ -33,7 +33,7 @@ std::vector<std::complex<double>> BeamFormer::compute_geometric_response( direction[2] * (antenna->m_phase_reference_position[2] - m_local_phase_reference_position[2]); - double phase = -2 * M_PI * dl / (constants::c / freq); + double phase = -2 * M_PI * dl / (common::c / freq); result.push_back({std::sin(phase), std::cos(phase)}); } return result; diff --git a/BeamFormer.h b/cpp/BeamFormer.h similarity index 99% rename from BeamFormer.h rename to cpp/BeamFormer.h index 38b1bb1517b59a9634976db706d27ef30c9df6b8..f57c8bd151272cb7b95e250e934aba3543a6f7bf 100644 --- a/BeamFormer.h +++ b/cpp/BeamFormer.h @@ -5,7 +5,7 @@ #include <vector> #include "Element.h" -#include "Types.h" +#include "common/Types.h" namespace everybeam { class BeamFormer : public Antenna { diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..81b81be4dc69b0132e8834192608e77b5e40cd4d --- /dev/null +++ b/cpp/CMakeLists.txt @@ -0,0 +1,48 @@ +#------------------------------------------------------------------------------ +# Add relevant subdirs +add_subdirectory(common) +add_subdirectory(coords) + +add_subdirectory(hamaker) +add_subdirectory(lobes) +add_subdirectory(oskar) + +#------------------------------------------------------------------------------ +add_library(everybeam SHARED + Antenna.cc + ElementResponse.cc + BeamFormer.cc + Element.cc + coords/ITRFConverter.cc + coords/ITRFDirection.cc + LofarMetaDataUtil.cc + Station.cc +) + +target_include_directories(everybeam PUBLIC ${CASACORE_INCLUDE_DIR}) +target_link_libraries(everybeam PUBLIC ${CASACORE_LIBRARIES}) +target_link_libraries(everybeam PUBLIC hamaker lobes oskar) + +install ( + TARGETS everybeam + EXPORT EveryBeamTargets + DESTINATION lib) + +#------------------------------------------------------------------------------ +# Install headers +install (FILES + Antenna.h + BeamFormer.h + Element.h + ElementResponse.h + LofarMetaDataUtil.h + Station.h +DESTINATION "include/${CMAKE_PROJECT_NAME}") + +install( + EXPORT EveryBeamTargets + FILE EveryBeamConfig.cmake + NAMESPACE EveryBeam:: + DESTINATION "lib/${projectname}" +) + diff --git a/Element.cc b/cpp/Element.cc similarity index 97% rename from Element.cc rename to cpp/Element.cc index cfa6be3c0388c13dd757ec3ec271428406a70438..6b5c640e9d07465dd631133a1772c9540d47e6d9 100644 --- a/Element.cc +++ b/cpp/Element.cc @@ -1,5 +1,5 @@ #include "Element.h" -#include "MathUtil.h" +#include "common/MathUtil.h" namespace everybeam { matrix22c_t Element::local_response(real_t time, real_t freq, diff --git a/Element.h b/cpp/Element.h similarity index 98% rename from Element.h rename to cpp/Element.h index ad5acf35ea8cce7e84978051291db94f4cfeb8f8..60af4ac19745cb086ed45af67c4bea92c1d5dec5 100644 --- a/Element.h +++ b/cpp/Element.h @@ -6,7 +6,7 @@ #include "Antenna.h" #include "ElementResponse.h" -#include "Types.h" +#include "common/Types.h" namespace everybeam { diff --git a/ElementResponse.cc b/cpp/ElementResponse.cc similarity index 100% rename from ElementResponse.cc rename to cpp/ElementResponse.cc diff --git a/ElementResponse.h b/cpp/ElementResponse.h similarity index 91% rename from ElementResponse.h rename to cpp/ElementResponse.h index 8ac85f1557f0efe82e527cb294d646ed2eec9ddd..3ca690cb05d980121a8f743a6cf0a7d7f183d8fe 100644 --- a/ElementResponse.h +++ b/cpp/ElementResponse.h @@ -4,10 +4,15 @@ #include <complex> #include <ostream> -#include "MutablePtr.h" +#include "common/MutablePtr.h" namespace everybeam { +namespace common { +template <typename T> +class MutablePtr; +} + enum ElementResponseModel { Unknown, Hamaker, @@ -25,7 +30,7 @@ std::ostream& operator<<(std::ostream& os, ElementResponseModel model); */ class ElementResponse { public: - typedef MutablePtr<ElementResponse> + typedef common::MutablePtr<ElementResponse> Ptr; //!< Pointer to ElementResponse object /** diff --git a/LofarMetaDataUtil.cc b/cpp/LofarMetaDataUtil.cc similarity index 98% rename from LofarMetaDataUtil.cc rename to cpp/LofarMetaDataUtil.cc index fc151d333a1fa5474da4e486709c731acf6057f1..1a5572a3c350eefd954d9afc367a08c75491c109 100644 --- a/LofarMetaDataUtil.cc +++ b/cpp/LofarMetaDataUtil.cc @@ -22,11 +22,7 @@ // $Id$ #include "LofarMetaDataUtil.h" -// #include "AntennaFieldLBA.h" -// #include "AntennaFieldHBA.h" -#include "MathUtil.h" -// #include "TileAntenna.h" -// #include "DualDipoleAntenna.h" +#include "common/MathUtil.h" #include <casacore/measures/Measures/MDirection.h> #include <casacore/measures/Measures/MPosition.h> @@ -95,11 +91,13 @@ Table getSubTable(const Table &table, const string &name) { TileConfig readTileConfig(const Table &table, unsigned int row) { ROArrayQuantColumn<Double> c_tile_offset(table, "TILE_ELEMENT_OFFSET", "m"); - // Read tile configuration for HBA antenna fields. + // Read tile configuration for HBA antenna fields, assert validity of aips + // offset. Matrix<Quantity> aips_offset = c_tile_offset(row); - assert(aips_offset.ncolumn() == TileAntenna::TileConfig::size()); TileConfig config; + assert(aips_offset.ncolumn() == config.size()); + for (unsigned int i = 0; i < config.size(); ++i) { config[i][0] = aips_offset(0, i).getValue(); config[i][1] = aips_offset(1, i).getValue(); diff --git a/LofarMetaDataUtil.h b/cpp/LofarMetaDataUtil.h similarity index 100% rename from LofarMetaDataUtil.h rename to cpp/LofarMetaDataUtil.h diff --git a/Station.cc b/cpp/Station.cc similarity index 97% rename from Station.cc rename to cpp/Station.cc index bf611b885e2c1c4415035159bbeaeb494e9a8ab3..e5f3a22c4af3f4d09324a89a71e6b1c37b6d2b6b 100644 --- a/Station.cc +++ b/cpp/Station.cc @@ -21,15 +21,13 @@ // $Id$ #include "Station.h" -#include "MathUtil.h" +#include "common/MathUtil.h" #include "hamaker/HamakerElementResponse.h" #include "oskar/OSKARElementResponse.h" #include "lobes/LOBESElementResponse.h" -// #include "DualDipoleAntenna.h" -// #include "TileAntenna.h" -namespace everybeam { +using namespace everybeam; Station::Station(const std::string &name, const vector3r_t &position, const ElementResponseModel model) @@ -39,9 +37,9 @@ Station::Station(const std::string &name, const vector3r_t &position, itsElementResponse(nullptr) { setModel(model); vector3r_t ncp = {{0.0, 0.0, 1.0}}; - itsNCP.reset(new ITRFDirection(ncp)); + itsNCP.reset(new coords::ITRFDirection(ncp)); vector3r_t ncppol0 = {{1.0, 0.0, 0.0}}; - itsNCPPol0.reset(new ITRFDirection(ncppol0)); + itsNCPPol0.reset(new coords::ITRFDirection(ncppol0)); } void Station::setModel(const ElementResponseModel model) { @@ -235,5 +233,3 @@ matrix22r_t Station::rotation(real_t time, const vector3r_t &direction) const { vector3r_t Station::ncp(real_t time) const { return itsNCP->at(time); } vector3r_t Station::ncppol0(real_t time) const { return itsNCPPol0->at(time); } - -} // namespace everybeam diff --git a/Station.h b/cpp/Station.h similarity index 99% rename from Station.h rename to cpp/Station.h index c0b9bb26ec9a6f484688bd51b42d44d124552fb2..978efe5e1f7b718cac1eea675774d06e9aecadb4 100644 --- a/Station.h +++ b/cpp/Station.h @@ -29,13 +29,14 @@ #include "ElementResponse.h" #include "Antenna.h" #include "BeamFormer.h" -#include "ITRFDirection.h" -#include "Types.h" +#include "coords/ITRFDirection.h" +#include "common/Types.h" #include <memory> #include <vector> namespace everybeam { + class Station { public: typedef std::shared_ptr<Station> Ptr; @@ -350,7 +351,7 @@ class Station { Antenna::Ptr itsAntenna; - ITRFDirection::Ptr itsNCP; + coords::ITRFDirection::Ptr itsNCP; /** Reference direction for NCP observations. * * NCP pol0 is the direction used as reference in the coordinate system @@ -361,7 +362,7 @@ class Station { * * Added by Maaijke Mevius, December 2018. */ - ITRFDirection::Ptr itsNCPPol0; + coords::ITRFDirection::Ptr itsNCPPol0; }; // ------------------------------------------------------------------------- // diff --git a/cpp/common/CMakeLists.txt b/cpp/common/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..656f29ab61c6286a304b495f6ac8a13e5bcfc575 --- /dev/null +++ b/cpp/common/CMakeLists.txt @@ -0,0 +1,8 @@ +#------------------------------------------------------------------------------ +# Install headers +install (FILES + Constants.h + MathUtil.h + MutablePtr.h + Types.h +DESTINATION "include/${CMAKE_PROJECT_NAME}/common") \ No newline at end of file diff --git a/Constants.h b/cpp/common/Constants.h similarity index 92% rename from Constants.h rename to cpp/common/Constants.h index e335df7f13478782d70d6325fd1e31e9cd103819..4abe366f69fd383b4916e8fbe2e5587e0b2f13b3 100644 --- a/Constants.h +++ b/cpp/common/Constants.h @@ -29,12 +29,10 @@ #include "Types.h" namespace everybeam { - -/** %Constants used in this library. */ -namespace constants { +namespace common { /** Speed of light (m/s) */ const real_t c = 2.99792458e+08; -} // namespace constants +} // namespace common } // namespace everybeam #endif diff --git a/MathUtil.h b/cpp/common/MathUtil.h similarity index 100% rename from MathUtil.h rename to cpp/common/MathUtil.h diff --git a/MutablePtr.h b/cpp/common/MutablePtr.h similarity index 98% rename from MutablePtr.h rename to cpp/common/MutablePtr.h index c8affd893f3d33d11fffc61b391875fec1fc687a..264f685dc6d7df1f4975f01d6d094d0a5d493a97 100644 --- a/MutablePtr.h +++ b/cpp/common/MutablePtr.h @@ -26,7 +26,7 @@ #include <memory> namespace everybeam { - +namespace common { /*! * \brief MutablePtr is a mutable smart pointer derived from std::shared_ptr. * @@ -83,5 +83,6 @@ class MutablePtr : public std::shared_ptr<std::shared_ptr<T>> { void set(std::shared_ptr<T> ptr) { *(this->get()) = ptr; } explicit operator bool() const noexcept { return **this; } }; +} // namespace common } // namespace everybeam #endif diff --git a/Singleton.h b/cpp/common/Singleton.h similarity index 92% rename from Singleton.h rename to cpp/common/Singleton.h index e0b80efaad65945fac3bce708fd2befa572f7af8..c5e8897c4d19aa59549755d96ba77bd26a8b877b 100644 --- a/Singleton.h +++ b/cpp/common/Singleton.h @@ -1,5 +1,5 @@ namespace everybeam { - +namespace common { template <typename T> class Singleton { public: @@ -16,4 +16,5 @@ class Singleton { Singleton(Singleton const&) = delete; void operator=(Singleton const&) = delete; }; +} // namespace common } // namespace everybeam diff --git a/Types.h b/cpp/common/Types.h similarity index 100% rename from Types.h rename to cpp/common/Types.h diff --git a/cpp/coords/CMakeLists.txt b/cpp/coords/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6022220e85a991796410b1c5c269e11a53dcf83b --- /dev/null +++ b/cpp/coords/CMakeLists.txt @@ -0,0 +1,6 @@ +#------------------------------------------------------------------------------ +# Install headers +install (FILES + ITRFConverter.h + ITRFDirection.h +DESTINATION "include/${CMAKE_PROJECT_NAME}/coords") diff --git a/ITRFConverter.cc b/cpp/coords/ITRFConverter.cc similarity index 96% rename from ITRFConverter.cc rename to cpp/coords/ITRFConverter.cc index e51b7aed95d048eff4d3b9e5b5e54128baf3bcf9..bada341ff5a960b2b9c8d6ce0635ff369f1744e9 100644 --- a/ITRFConverter.cc +++ b/cpp/coords/ITRFConverter.cc @@ -7,7 +7,9 @@ #include <casacore/measures/Measures/MDirection.h> #include <casacore/measures/Measures/MEpoch.h> -namespace everybeam { +// namespace everybeam { +using namespace everybeam; +using namespace everybeam::coords; // TODO: Initialize converter with a time (and fixed position) and convert // specific directions. @@ -79,4 +81,4 @@ casacore::MDirection ITRFConverter::toDirection( return itsConverter(direction); } -} // namespace everybeam +// } // namespace everybeam diff --git a/ITRFConverter.h b/cpp/coords/ITRFConverter.h similarity index 94% rename from ITRFConverter.h rename to cpp/coords/ITRFConverter.h index 706d6ead515b2402417dab01b65d9fe50d3cbe64..78e7c57d5e3d3e739c6323f3f0d9ff6c18a8530d 100644 --- a/ITRFConverter.h +++ b/cpp/coords/ITRFConverter.h @@ -6,7 +6,7 @@ // \file // Functor that maps J2000 to an ITRF direction. -#include "Types.h" +#include "./../common/Types.h" #include <casacore/measures/Measures/MeasFrame.h> #include <casacore/measures/Measures/MeasConvert.h> @@ -15,7 +15,7 @@ #include <memory> namespace everybeam { - +namespace coords { /** * @brief Class providing utilities for coordinate transformations * to and from ITRF (International Terrestrial Reference Frame) @@ -40,5 +40,6 @@ class ITRFConverter { casacore::MeasFrame itsFrame; mutable casacore::MDirection::Convert itsConverter; }; +} // namespace coords } // namespace everybeam #endif diff --git a/ITRFDirection.cc b/cpp/coords/ITRFDirection.cc similarity index 96% rename from ITRFDirection.cc rename to cpp/coords/ITRFDirection.cc index 50fe889dd800bdd7ecfcf0ba49c50eaa4895f11d..e5a736b15cad6fd1d21f954bbdd4b690f9097666 100644 --- a/ITRFDirection.cc +++ b/cpp/coords/ITRFDirection.cc @@ -26,7 +26,9 @@ #include <casacore/measures/Measures/MDirection.h> #include <casacore/measures/Measures/MEpoch.h> -namespace everybeam { +// namespace everybeam { +using namespace everybeam; +using namespace everybeam::coords; // ITRF position of CS002LBA, just to use a fixed reference const vector3r_t ITRFDirection::itsLOFARPosition = { @@ -90,4 +92,4 @@ vector3r_t ITRFDirection::at(real_t time) const { return itrf; } -} // namespace everybeam +// } // namespace everybeam diff --git a/ITRFDirection.h b/cpp/coords/ITRFDirection.h similarity index 96% rename from ITRFDirection.h rename to cpp/coords/ITRFDirection.h index 4dc8e43b6942751d1bc49bbd977cbe8483c0822d..633532fa664ed2c047941af0e514597d6ec994b2 100644 --- a/ITRFDirection.h +++ b/cpp/coords/ITRFDirection.h @@ -26,7 +26,7 @@ // \file // Functor that maps time to an ITRF direction. -#include "Types.h" +#include "./../common/Types.h" #include <casacore/measures/Measures/MeasFrame.h> #include <casacore/measures/Measures/MeasConvert.h> @@ -36,7 +36,7 @@ #include <mutex> namespace everybeam { - +namespace coords { class ITRFDirection { public: typedef std::shared_ptr<ITRFDirection> Ptr; @@ -59,7 +59,7 @@ class ITRFDirection { mutable casacore::MDirection::Convert itsConverter; mutable std::mutex itsMutex; }; - +} // namespace coords } // namespace everybeam #endif diff --git a/hamaker/CMakeLists.txt b/cpp/hamaker/CMakeLists.txt similarity index 70% rename from hamaker/CMakeLists.txt rename to cpp/hamaker/CMakeLists.txt index 6043cfd0a01eb883e1e0c6f594dad74848a70555..08934498ec23e079c865faade9d42bd32d2f382c 100644 --- a/hamaker/CMakeLists.txt +++ b/cpp/hamaker/CMakeLists.txt @@ -16,5 +16,5 @@ install( # install coefficients message("install hamaker in: " ${CMAKE_INSTALL_DATA_DIR}) -install(FILES "${CMAKE_SOURCE_DIR}/hamaker/HamakerHBACoeff.h5" DESTINATION ${CMAKE_INSTALL_DATA_DIR}) -install(FILES "${CMAKE_SOURCE_DIR}/hamaker/HamakerLBACoeff.h5" DESTINATION ${CMAKE_INSTALL_DATA_DIR}) +install(FILES "${CMAKE_SOURCE_DIR}/coeffs/HamakerHBACoeff.h5" DESTINATION ${CMAKE_INSTALL_DATA_DIR}) +install(FILES "${CMAKE_SOURCE_DIR}/coeffs/HamakerLBACoeff.h5" DESTINATION ${CMAKE_INSTALL_DATA_DIR}) diff --git a/hamaker/HamakerCoeff.cc b/cpp/hamaker/HamakerCoeff.cc similarity index 100% rename from hamaker/HamakerCoeff.cc rename to cpp/hamaker/HamakerCoeff.cc diff --git a/hamaker/HamakerCoeff.h b/cpp/hamaker/HamakerCoeff.h similarity index 100% rename from hamaker/HamakerCoeff.h rename to cpp/hamaker/HamakerCoeff.h diff --git a/hamaker/HamakerElementResponse.cc b/cpp/hamaker/HamakerElementResponse.cc similarity index 95% rename from hamaker/HamakerElementResponse.cc rename to cpp/hamaker/HamakerElementResponse.cc index f48ad4a804f0aec5df5beb98b414136a3e928c92..4b97940b15a6a52d30d26cea09fbefb5cc1e8b01 100644 --- a/hamaker/HamakerElementResponse.cc +++ b/cpp/hamaker/HamakerElementResponse.cc @@ -7,17 +7,17 @@ #include "config.h" #include "HamakerElementResponse.h" -#include "../Singleton.h" +#include "../common/Singleton.h" namespace everybeam { std::shared_ptr<HamakerElementResponse> HamakerElementResponse::getInstance( const std::string& name) { if (name.find("LBA") != std::string::npos) { - return Singleton<HamakerElementResponseLBA>::getInstance(); + return common::Singleton<HamakerElementResponseLBA>::getInstance(); } if (name.find("HBA") != std::string::npos) { - return Singleton<HamakerElementResponseHBA>::getInstance(); + return common::Singleton<HamakerElementResponseHBA>::getInstance(); } throw std::invalid_argument( "HamakerElementResponse::getInstance: name should end in either 'LBA' or " @@ -26,7 +26,7 @@ std::shared_ptr<HamakerElementResponse> HamakerElementResponse::getInstance( std::string HamakerElementResponse::get_path(const char* filename) const { std::stringstream ss; - ss << LOFARBEAM_DATA_DIR << "/"; + ss << EVERYBEAM_DATA_DIR << "/"; ss << filename; return ss.str(); } @@ -122,5 +122,4 @@ HamakerElementResponseLBA::HamakerElementResponseLBA() { std::string path = get_path("HamakerLBACoeff.h5"); m_coeffs.reset(new HamakerCoefficients(path)); } - } // namespace everybeam diff --git a/hamaker/HamakerElementResponse.h b/cpp/hamaker/HamakerElementResponse.h similarity index 100% rename from hamaker/HamakerElementResponse.h rename to cpp/hamaker/HamakerElementResponse.h diff --git a/cpp/lobes/CMakeLists.txt b/cpp/lobes/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7e9d077831c55463a53c9a2bcfecaef7342a7cc4 --- /dev/null +++ b/cpp/lobes/CMakeLists.txt @@ -0,0 +1,34 @@ +#------------------------------------------------------------------------------ +# Required packages for lobes +# pybind and eigen not required here, will be moved to python dir with pybindings +# find_package(pybind11 REQUIRED) +# find_package (Eigen3 REQUIRED NO_MODULE) + +# pybind11_add_module(pylobes SHARED lobes.cc ElementResponse.cc LOBESElementResponse.cc) +# target_link_libraries (pylobes PUBLIC Eigen3::Eigen ${HDF5_LIBRARIES}) + +add_library(lobes SHARED LOBESElementResponse.cc) +string(TOLOWER ${CMAKE_PROJECT_NAME} projectname ) +set_target_properties(lobes PROPERTIES LIBRARY_OUTPUT_NAME "${projectname}-lobes") + +#------------------------------------------------------------------------------ +# Install +install( + TARGETS lobes + EXPORT EveryBeamTargets + DESTINATION lib) + +#------------------------------------------------------------------------------ +# TODO: can't we remove all this? +set(MISC_DIR ${CMAKE_SOURCE_DIR}/scripts/misc) +configure_file(${MISC_DIR}/test_lobes.py ${CMAKE_CURRENT_BINARY_DIR}/test_lobes.py COPYONLY) + +configure_file(${MISC_DIR}/F4far_new.py ${CMAKE_CURRENT_BINARY_DIR}/F4far_new.py COPYONLY) +configure_file(${MISC_DIR}/calc_modes_1deg_noback.py ${CMAKE_CURRENT_BINARY_DIR}/calc_modes_1deg_noback.py COPYONLY) +configure_file(${MISC_DIR}/hamaker_vs_lobes.py ${CMAKE_CURRENT_BINARY_DIR}/hamaker_vs_lobes.py COPYONLY) +configure_file(${MISC_DIR}/test_beam_model.py ${CMAKE_CURRENT_BINARY_DIR}/test_beam_model.py COPYONLY) + +configure_file(${CMAKE_SOURCE_DIR}/coeffs/CS302_coords.mat ${CMAKE_CURRENT_BINARY_DIR}/CS302_coords.mat COPYONLY) + +# TODO Too large for git repo, get file from somewhere else +# configure_file(LBA_CS302_fine.mat LBA_CS302_fine.mat COPYONLY) diff --git a/lobes/DefaultCoeffHBA.cc b/cpp/lobes/DefaultCoeffHBA.cc similarity index 100% rename from lobes/DefaultCoeffHBA.cc rename to cpp/lobes/DefaultCoeffHBA.cc diff --git a/lobes/DefaultCoeffLBA.cc b/cpp/lobes/DefaultCoeffLBA.cc similarity index 100% rename from lobes/DefaultCoeffLBA.cc rename to cpp/lobes/DefaultCoeffLBA.cc diff --git a/lobes/ElementResponse.cc b/cpp/lobes/ElementResponse.cc similarity index 100% rename from lobes/ElementResponse.cc rename to cpp/lobes/ElementResponse.cc diff --git a/lobes/ElementResponse.h b/cpp/lobes/ElementResponse.h similarity index 100% rename from lobes/ElementResponse.h rename to cpp/lobes/ElementResponse.h diff --git a/lobes/LOBESElementResponse.cc b/cpp/lobes/LOBESElementResponse.cc similarity index 100% rename from lobes/LOBESElementResponse.cc rename to cpp/lobes/LOBESElementResponse.cc diff --git a/lobes/LOBESElementResponse.h b/cpp/lobes/LOBESElementResponse.h similarity index 100% rename from lobes/LOBESElementResponse.h rename to cpp/lobes/LOBESElementResponse.h diff --git a/makeresponseimage.cc b/cpp/makeresponseimage.cc similarity index 100% rename from makeresponseimage.cc rename to cpp/makeresponseimage.cc diff --git a/oskar/CMakeLists.txt b/cpp/oskar/CMakeLists.txt similarity index 59% rename from oskar/CMakeLists.txt rename to cpp/oskar/CMakeLists.txt index f8f3f56b5adba3803b9727b0dae1da3adf65ab70..4a166f999559a903173cce7f2a4bd118644d0b34 100644 --- a/oskar/CMakeLists.txt +++ b/cpp/oskar/CMakeLists.txt @@ -1,6 +1,8 @@ +#------------------------------------------------------------------------------ # directory for config.h include_directories(${CMAKE_BINARY_DIR}) +#------------------------------------------------------------------------------ # build liboskar.so add_library(oskar SHARED OSKARElementResponse.cc @@ -12,8 +14,11 @@ add_library(oskar SHARED string(TOLOWER ${CMAKE_PROJECT_NAME} projectname ) set_target_properties(oskar PROPERTIES LIBRARY_OUTPUT_NAME "${projectname}-oskar") -target_link_libraries(oskar ${HDF5_LIBRARIES} ${HDF5_CXX_LIBRARIES}) +#------------------------------------------------------------------------------ +# Link against HDF5 and OpenMP +target_link_libraries(oskar ${HDF5_LIBRARIES} ${HDF5_CXX_LIBRARIES} ${OpenMP_CXX_FLAGS}) +#------------------------------------------------------------------------------ # install libeverybeam-oskar.so install( TARGETS oskar diff --git a/oskar/OSKARDatafile.cc b/cpp/oskar/OSKARDatafile.cc similarity index 100% rename from oskar/OSKARDatafile.cc rename to cpp/oskar/OSKARDatafile.cc diff --git a/oskar/OSKARDatafile.h b/cpp/oskar/OSKARDatafile.h similarity index 100% rename from oskar/OSKARDatafile.h rename to cpp/oskar/OSKARDatafile.h diff --git a/oskar/OSKARDataset.cc b/cpp/oskar/OSKARDataset.cc similarity index 100% rename from oskar/OSKARDataset.cc rename to cpp/oskar/OSKARDataset.cc diff --git a/oskar/OSKARDataset.h b/cpp/oskar/OSKARDataset.h similarity index 100% rename from oskar/OSKARDataset.h rename to cpp/oskar/OSKARDataset.h diff --git a/oskar/OSKARElementResponse.cc b/cpp/oskar/OSKARElementResponse.cc similarity index 98% rename from oskar/OSKARElementResponse.cc rename to cpp/oskar/OSKARElementResponse.cc index 69891d1a81a44a70f246dbc349f1e8ddc09e4a6d..175c8d780add72f376dadc2f5220c6ce8df4c0f2 100644 --- a/oskar/OSKARElementResponse.cc +++ b/cpp/oskar/OSKARElementResponse.cc @@ -54,7 +54,7 @@ void OSKARElementResponseSphericalWave::response( std::string OSKARElementResponseSphericalWave::get_path( const char* filename) const { std::stringstream ss; - ss << LOFARBEAM_DATA_DIR << "/"; + ss << EVERYBEAM_DATA_DIR << "/"; ss << filename; return ss.str(); } diff --git a/oskar/OSKARElementResponse.h b/cpp/oskar/OSKARElementResponse.h similarity index 86% rename from oskar/OSKARElementResponse.h rename to cpp/oskar/OSKARElementResponse.h index 4ff3f20ce0f79ad0cd0aac2ba5fa612b93dfe113..b7e175b80e620ae88d211a858a1a2ad0fd6fa087 100644 --- a/oskar/OSKARElementResponse.h +++ b/cpp/oskar/OSKARElementResponse.h @@ -2,7 +2,7 @@ #define OSKAR_ELEMENTRESPONSE_H #include "../ElementResponse.h" -#include "../Singleton.h" +#include "../common/Singleton.h" #include "OSKARDatafile.h" @@ -14,7 +14,7 @@ namespace everybeam { class OSKARElementResponseDipole : public ElementResponse { public: static std::shared_ptr<OSKARElementResponseDipole> getInstance() { - return Singleton<OSKARElementResponseDipole>::getInstance(); + return common::Singleton<OSKARElementResponseDipole>::getInstance(); } virtual void response( @@ -26,7 +26,7 @@ class OSKARElementResponseDipole : public ElementResponse { class OSKARElementResponseSphericalWave : public ElementResponse { public: static std::shared_ptr<OSKARElementResponseSphericalWave> getInstance() { - return Singleton<OSKARElementResponseSphericalWave>::getInstance(); + return common::Singleton<OSKARElementResponseSphericalWave>::getInstance(); } OSKARElementResponseSphericalWave(); diff --git a/oskar/oskar.h b/cpp/oskar/oskar.h similarity index 100% rename from oskar/oskar.h rename to cpp/oskar/oskar.h diff --git a/oskar/oskar_evaluate_dipole_pattern.cc b/cpp/oskar/oskar_evaluate_dipole_pattern.cc similarity index 100% rename from oskar/oskar_evaluate_dipole_pattern.cc rename to cpp/oskar/oskar_evaluate_dipole_pattern.cc diff --git a/oskar/oskar_evaluate_spherical_wave_sum.cc b/cpp/oskar/oskar_evaluate_spherical_wave_sum.cc similarity index 100% rename from oskar/oskar_evaluate_spherical_wave_sum.cc rename to cpp/oskar/oskar_evaluate_spherical_wave_sum.cc diff --git a/oskar/oskar_helper.h b/cpp/oskar/oskar_helper.h similarity index 100% rename from oskar/oskar_helper.h rename to cpp/oskar/oskar_helper.h diff --git a/oskar/oskar_vector_types.h b/cpp/oskar/oskar_vector_types.h similarity index 100% rename from oskar/oskar_vector_types.h rename to cpp/oskar/oskar_vector_types.h diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eb6fe9169889d5ca03a5980c3fefd78fb605230 --- /dev/null +++ b/cpp/test/CMakeLists.txt @@ -0,0 +1,9 @@ +#------------------------------------------------------------------------------ +# Add executable(s) +add_executable(tstation tstation.cc) +target_link_libraries(tstation PUBLIC everybeam) +target_link_libraries(tstation PUBLIC OpenMP::OpenMP_CXX) + +#------------------------------------------------------------------------------ +# Add test +add_test(station-tests tstation) \ No newline at end of file diff --git a/cpp/test/tstation.cc b/cpp/test/tstation.cc new file mode 100644 index 0000000000000000000000000000000000000000..f9ced6450b06eb1af514de48b562589708243fc2 --- /dev/null +++ b/cpp/test/tstation.cc @@ -0,0 +1,39 @@ +#include "./../Station.h" + +int main() { + const everybeam::vector3r_t position = {{1.0, 2.0, 3.0}}; + + std::string name = "station0_LBA"; + auto model = everybeam::ElementResponseModel::Hamaker; + + // Create station. + everybeam::Station::Ptr station( + new everybeam::Station(name, position, model)); + + auto element_response = station->get_element_response(); + + double freq = 50e6; + double theta = 0.0; + double phi = 0.0; + std::complex<double> response[2][2]; + + constexpr int N = 100; + std::vector<std::complex<double>> result(N * N * 2 * 2); + typedef std::complex<double> result_arr_t[N][N][2][2]; + + result_arr_t &result_arr = *(result_arr_t *)result.data(); + + for (int i = 0; i < N; ++i) { + double x = (2.0 * i) / (N - 1) - 1.0; + for (int j = 0; j < N; ++j) { + double y = (2.0 * j) / (N - 1) - 1.0; + double theta = asin(sqrt(x * x + y * y)); + double phi = atan2(y, x); + + double az = M_PI - phi; + double el = M_PI_2 - theta; + element_response->response(0, freq, theta, phi, result_arr[i][j]); + } + } + return 0; +} diff --git a/test/CMakeLists.txt b/demo/CMakeLists.txt similarity index 72% rename from test/CMakeLists.txt rename to demo/CMakeLists.txt index dcfd18e3a5e5f184ae25980eed2b8d0c691318ea..afcb9d069c7179e44c0c2242bf692767a1c74af8 100644 --- a/test/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -1,6 +1,3 @@ -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake) -find_package(Casacore REQUIRED COMPONENTS casa ms tables measures) - set(TEST_MEASUREMENTSET CACHE STRING "measurement set used for testing") if (TEST_MEASUREMENTSET) @@ -48,7 +45,7 @@ if (CFITSIO_FOUND) target_include_directories(beamhelper PUBLIC ${CFITSIO_INCLUDE_DIR}) target_link_libraries(beamhelper PUBLIC everybeam) target_link_libraries(beamhelper PUBLIC ${CFITSIO_LIBRARY}) - + add_executable(tStationBeamHamaker tStationBeamHamaker.cc) target_link_libraries(tStationBeamHamaker PUBLIC beamhelper) target_include_directories(tStationBeamHamaker PUBLIC ${CMAKE_BINARY_DIR}) @@ -73,21 +70,20 @@ if (CFITSIO_FOUND) target_link_libraries(tElementBeamOSKARSphericalWave PUBLIC beamhelper) target_include_directories(tElementBeamOSKARSphericalWave PUBLIC ${CMAKE_BINARY_DIR}) - find_package(OpenMP) - if (OpenMP_CXX_FOUND) - target_link_libraries(tStationBeamHamaker PUBLIC OpenMP::OpenMP_CXX) - target_link_libraries(tStationBeamOSKARDipole PUBLIC OpenMP::OpenMP_CXX) - target_link_libraries(tStationBeamOSKARSphericalWave PUBLIC OpenMP::OpenMP_CXX) - target_link_libraries(tElementBeamHamaker PUBLIC OpenMP::OpenMP_CXX) - target_link_libraries(tElementBeamOSKARDipole PUBLIC OpenMP::OpenMP_CXX) - target_link_libraries(tElementBeamOSKARSphericalWave PUBLIC OpenMP::OpenMP_CXX) - endif() - - add_test(stationbeam-hamaker tStationBeamHamaker) - add_test(stationbeam-oskardipole tStationBeamOSKARDipole) - add_test(stationbeam-oskarsphericalwave tStationBeamOSKARSphericalWave) - add_test(elementbeam-hamaker tElementBeamHamaker) - add_test(elementbeam-oskardipole tElementBeamOSKARDipole) - add_test(elementbeam-oskarsphericalwave tElementBeamOSKARSphericalWave) - + target_link_libraries(tStationBeamHamaker PUBLIC OpenMP::OpenMP_CXX) + target_link_libraries(tStationBeamOSKARDipole PUBLIC OpenMP::OpenMP_CXX) + target_link_libraries(tStationBeamOSKARSphericalWave PUBLIC OpenMP::OpenMP_CXX) + target_link_libraries(tElementBeamHamaker PUBLIC OpenMP::OpenMP_CXX) + target_link_libraries(tElementBeamOSKARDipole PUBLIC OpenMP::OpenMP_CXX) + target_link_libraries(tElementBeamOSKARSphericalWave PUBLIC OpenMP::OpenMP_CXX) + + # These are not "tests" in the strict sense of the word, so don't add them to test stack + # NOTE: tests should go to cpp/test + + # add_test(stationbeam-hamaker tStationBeamHamaker) + # add_test(stationbeam-oskardipole tStationBeamOSKARDipole) + # add_test(stationbeam-oskarsphericalwave tStationBeamOSKARSphericalWave) + # add_test(elementbeam-hamaker tElementBeamHamaker) + # add_test(elementbeam-oskardipole tElementBeamOSKARDipole) + # add_test(elementbeam-oskarsphericalwave tElementBeamOSKARSphericalWave) endif() diff --git a/test/beam-helper.cpp b/demo/beam-helper.cpp similarity index 97% rename from test/beam-helper.cpp rename to demo/beam-helper.cpp index bb771a46dc9e8af9d1b29d9ed32a64a9a6f43214..f5b804b51f00e811ad4ab8171bfeead093a1c5c9 100644 --- a/test/beam-helper.cpp +++ b/demo/beam-helper.cpp @@ -2,7 +2,9 @@ #include <fitsio.h> -#include "MathUtil.h" +#include "./../cpp/common/MathUtil.h" +// #include "./../cpp/coords/ITRFDirection.h" +#include "./../cpp/coords/ITRFConverter.h" void GetPhaseCentreInfo( casacore::MeasurementSet& ms, @@ -85,7 +87,7 @@ void GetITRFDirections( const casacore::Unit radUnit("rad"); - ITRFConverter itrfConverter(time); + coords::ITRFConverter itrfConverter(time); casacore::MDirection lDir(casacore::MVDirection( casacore::Quantity(ra + M_PI/2, radUnit), diff --git a/test/beam-helper.h b/demo/beam-helper.h similarity index 94% rename from test/beam-helper.h rename to demo/beam-helper.h index 5566fa0e25593c9a94d591cea1cc349393ed74c6..4bfbab9e13b6694d2bf44515d2c160c94e7991ce 100644 --- a/test/beam-helper.h +++ b/demo/beam-helper.h @@ -1,8 +1,6 @@ -#include <ITRFDirection.h> -#include <ITRFConverter.h> -#include <ElementResponse.h> -#include <Station.h> -#include <LofarMetaDataUtil.h> +#include "./../cpp/ElementResponse.h" +#include "./../cpp/Station.h" +#include "./../cpp/LofarMetaDataUtil.h" #include <casacore/measures/Measures/MPosition.h> #include <casacore/measures/Measures/MEpoch.h> diff --git a/test/tDockerDP3 b/demo/tDockerDP3 similarity index 100% rename from test/tDockerDP3 rename to demo/tDockerDP3 diff --git a/test/tElementBeamCommon.h b/demo/tElementBeamCommon.h similarity index 100% rename from test/tElementBeamCommon.h rename to demo/tElementBeamCommon.h diff --git a/test/tElementBeamHamaker.cc b/demo/tElementBeamHamaker.cc similarity index 100% rename from test/tElementBeamHamaker.cc rename to demo/tElementBeamHamaker.cc diff --git a/test/tElementBeamOSKARDipole.cc b/demo/tElementBeamOSKARDipole.cc similarity index 100% rename from test/tElementBeamOSKARDipole.cc rename to demo/tElementBeamOSKARDipole.cc diff --git a/test/tElementBeamOSKARSphericalWave.cc b/demo/tElementBeamOSKARSphericalWave.cc similarity index 100% rename from test/tElementBeamOSKARSphericalWave.cc rename to demo/tElementBeamOSKARSphericalWave.cc diff --git a/test/tStation.cc b/demo/tStation.cc similarity index 100% rename from test/tStation.cc rename to demo/tStation.cc diff --git a/test/tStationBeamCommon.h b/demo/tStationBeamCommon.h similarity index 100% rename from test/tStationBeamCommon.h rename to demo/tStationBeamCommon.h diff --git a/test/tStationBeamHamaker.cc b/demo/tStationBeamHamaker.cc similarity index 100% rename from test/tStationBeamHamaker.cc rename to demo/tStationBeamHamaker.cc diff --git a/test/tStationBeamOSKARDipole.cc b/demo/tStationBeamOSKARDipole.cc similarity index 100% rename from test/tStationBeamOSKARDipole.cc rename to demo/tStationBeamOSKARDipole.cc diff --git a/test/tStationBeamOSKARSphericalWave.cc b/demo/tStationBeamOSKARSphericalWave.cc similarity index 100% rename from test/tStationBeamOSKARSphericalWave.cc rename to demo/tStationBeamOSKARSphericalWave.cc diff --git a/test/Dockerfile-base b/docker/Dockerfile-base similarity index 100% rename from test/Dockerfile-base rename to docker/Dockerfile-base diff --git a/test/Dockerfile-dp3 b/docker/Dockerfile-dp3 similarity index 100% rename from test/Dockerfile-dp3 rename to docker/Dockerfile-dp3 diff --git a/docker/Dockerfile-everybeam b/docker/Dockerfile-everybeam new file mode 100644 index 0000000000000000000000000000000000000000..123e43e27bdfe2b8e28b80b9dd821cef363d55fb --- /dev/null +++ b/docker/Dockerfile-everybeam @@ -0,0 +1,18 @@ +# +# base +# +ARG CI_REGISTRY_IMAGE +FROM ${CI_REGISTRY_IMAGE}:base +ENV INSTALLDIR /opt + +# +# install-everybeam +# +ARG CI_COMMIT_SHORT_SHA +ENV EVERYBEAM_COMMIT ${CI_COMMIT_SHORT_SHA} +RUN mkdir -p ${INSTALLDIR}/everybeam/build +RUN cd ${INSTALLDIR}/everybeam && git clone https://git.astron.nl/RD/EveryBeam.git EveryBeam +RUN cd ${INSTALLDIR}/everybeam/EveryBeam && git checkout ${EVERYBEAM_COMMIT} +RUN cd ${INSTALLDIR}/everybeam/build && cmake -DCMAKE_INSTALL_PREFIX=${INSTALLDIR}/everybeam ../EveryBeam +RUN cd ${INSTALLDIR}/everybeam/build && make -j 8 +RUN cd ${INSTALLDIR}/everybeam/build && make install diff --git a/test/Dockerfile-wsclean b/docker/Dockerfile-wsclean similarity index 100% rename from test/Dockerfile-wsclean rename to docker/Dockerfile-wsclean diff --git a/Doxyfile.in b/docs/Doxyfile.in similarity index 100% rename from Doxyfile.in rename to docs/Doxyfile.in diff --git a/lobes/CMakeLists.txt b/lobes/CMakeLists.txt deleted file mode 100644 index 926d772384ddf35de5a7f16dd0e434f03a772ed6..0000000000000000000000000000000000000000 --- a/lobes/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -find_package(pybind11 REQUIRED) -find_package (Eigen3 REQUIRED NO_MODULE) -find_package(HDF5 COMPONENTS C CXX REQUIRED) - -# pybind11_add_module(pylobes SHARED lobes.cc ElementResponse.cc LOBESElementResponse.cc) -# target_link_libraries (pylobes PUBLIC Eigen3::Eigen ${HDF5_LIBRARIES}) - -add_library(lobes SHARED LOBESElementResponse.cc) -string(TOLOWER ${CMAKE_PROJECT_NAME} projectname ) -set_target_properties(lobes PROPERTIES LIBRARY_OUTPUT_NAME "${projectname}-lobes") - -install( - TARGETS lobes - EXPORT EveryBeamTargets - DESTINATION lib) - -configure_file(test.py test.py COPYONLY) - -configure_file(F4far_new.py F4far_new.py COPYONLY) -configure_file(calc_modes_1deg_noback.py calc_modes_1deg_noback.py COPYONLY) -configure_file(hamaker_vs_lobes.py hamaker_vs_lobes.py COPYONLY) -configure_file(test_beam_model.py test_beam_model.py COPYONLY) - -configure_file(CS302_coords.mat CS302_coords.mat COPYONLY) - -# TODO Too large for git repo, get file from somewhere else -# configure_file(LBA_CS302_fine.mat LBA_CS302_fine.mat COPYONLY) diff --git a/lobes/lobes.cc b/python/lobes/lobes.cc similarity index 100% rename from lobes/lobes.cc rename to python/lobes/lobes.cc diff --git a/lobes/lobes.h b/python/lobes/lobes.h similarity index 100% rename from lobes/lobes.h rename to python/lobes/lobes.h diff --git a/python/placeholder.md b/python/placeholder.md new file mode 100644 index 0000000000000000000000000000000000000000..ed8b205f65a2e02efb8996039f1338e45d51b7dc --- /dev/null +++ b/python/placeholder.md @@ -0,0 +1 @@ +# Python bindings go here \ No newline at end of file diff --git a/pyeverybeam.cc b/python/pyeverybeam.cc.tmp similarity index 100% rename from pyeverybeam.cc rename to python/pyeverybeam.cc.tmp diff --git a/hamaker/convert_coeff.py b/scripts/coeff_scripts/convert_coeff.py similarity index 94% rename from hamaker/convert_coeff.py rename to scripts/coeff_scripts/convert_coeff.py index 562c47126b4b4c3a6f05cc8c76e14e6e3275e53a..4d909ba98d583ba655cf786240bf181ebe6e8089 100755 --- a/hamaker/convert_coeff.py +++ b/scripts/coeff_scripts/convert_coeff.py @@ -55,6 +55,15 @@ def regex(name, type, signed = True): return "(?P<%s>%s)" % (name, expr) def main(args): + """ + Main function for the conversion of of a coefficient file to a *.cc file. Typical usage is + ./convert_coeff.py [FILE_IN] [FILE_OUT] [TYPE] + + Examples: + + ./convert_coeff.py element_beam_LBA.coeff DefaultCoeffLBA.cc default_lba + ./convert_coeff.py element_beam_HBA.coeff DefaultCoeffHBA.cc default_hba + """ print "converting %s -> %s (variable name: %s)" % (args[0], args[1], args[2]) HEADER, COEFF = range(2) diff --git a/oskar/oskar_matlab_to_csv.m b/scripts/coeff_scripts/oskar_matlab_to_csv.m similarity index 100% rename from oskar/oskar_matlab_to_csv.m rename to scripts/coeff_scripts/oskar_matlab_to_csv.m diff --git a/oskar/oskar_matlab_to_hdf5.py b/scripts/coeff_scripts/oskar_matlab_to_hdf5.py similarity index 100% rename from oskar/oskar_matlab_to_hdf5.py rename to scripts/coeff_scripts/oskar_matlab_to_hdf5.py diff --git a/lobes/F4far_new.py b/scripts/misc/F4far_new.py similarity index 100% rename from lobes/F4far_new.py rename to scripts/misc/F4far_new.py diff --git a/lobes/calc_modes_1deg_noback.py b/scripts/misc/calc_modes_1deg_noback.py similarity index 100% rename from lobes/calc_modes_1deg_noback.py rename to scripts/misc/calc_modes_1deg_noback.py diff --git a/lobes/hamaker_vs_lobes.py b/scripts/misc/hamaker_vs_lobes.py similarity index 100% rename from lobes/hamaker_vs_lobes.py rename to scripts/misc/hamaker_vs_lobes.py diff --git a/lobes/test_beam_model.py b/scripts/misc/test_beam_model.py similarity index 100% rename from lobes/test_beam_model.py rename to scripts/misc/test_beam_model.py diff --git a/lobes/test.py b/scripts/misc/test_lobes.py similarity index 100% rename from lobes/test.py rename to scripts/misc/test_lobes.py diff --git a/test/Dockerfile-lofarbeam b/test/Dockerfile-lofarbeam deleted file mode 100644 index b4e6613b903b4ae1441e9a6ac58ba3f44b8d1f5a..0000000000000000000000000000000000000000 --- a/test/Dockerfile-lofarbeam +++ /dev/null @@ -1,18 +0,0 @@ -# -# base -# -ARG CI_REGISTRY_IMAGE -FROM ${CI_REGISTRY_IMAGE}:base -ENV INSTALLDIR /opt - -# -# install-lofarbeam -# -ARG CI_COMMIT_SHORT_SHA -ENV LOFARBEAM_COMMIT ${CI_COMMIT_SHORT_SHA} -RUN mkdir -p ${INSTALLDIR}/lofarbeam/build -RUN cd ${INSTALLDIR}/lofarbeam && git clone https://git.astron.nl/RD/LOFARBeam.git lofarbeam -RUN cd ${INSTALLDIR}/lofarbeam/lofarbeam && git checkout ${LOFARBEAM_COMMIT} -RUN cd ${INSTALLDIR}/lofarbeam/build && cmake -DCMAKE_INSTALL_PREFIX=${INSTALLDIR}/lofarbeam ../lofarbeam -RUN cd ${INSTALLDIR}/lofarbeam/build && make -j 8 -RUN cd ${INSTALLDIR}/lofarbeam/build && make install