Skip to content
Snippets Groups Projects
Select Git revision
  • b95d973fa290ba1df93f3d00549c46d936de586b
  • master default protected
  • RAP-203_Build_binary_wheels
  • ast-919-readthedocs
  • ncp_fix
  • workaround-wsclean-issue-83
  • ast-645-add-beam-normalisation-mode-preapplied
  • ast-645-add-beam-normalisation-mode-jm
  • activate-oskar-pybindings
  • disable-element-beam-1
  • submodulesync
  • fix-eigen
  • ncp_check
  • random-fixes
  • lobes-se607-1
  • test-schaapcommon
  • just-testing
  • extend-add_beaminfo-script
  • extend-telescope-interface-to-support-dp3
  • lobes-investigation
  • debugging-ci-newer-pip
  • v0.4.0
  • v0.3.1
  • v0.3.0
  • v0.2.0
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
29 results

OSKARElementResponse.cc

Blame
  • Forked from ResearchAndDevelopment / EveryBeam
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    OSKARElementResponse.cc 2.36 KiB
    #include "OSKARElementResponse.h"
    #include "oskar.h"
    #include "config.h"
    #include <iostream>
    
    namespace everybeam {
    
    void OSKARElementResponseDipole::response(
        double freq, double theta, double phi,
        std::complex<double> (&response)[2][2]) const {
      double dipole_length_m = 1;  // TODO
      std::complex<double>* response_ptr = (std::complex<double>*)response;
    
      double phi_x = phi;
      double phi_y = phi + M_PI_2;
      oskar_evaluate_dipole_pattern_double(1, &theta, &phi_x, freq, dipole_length_m,
                                           response_ptr);
      oskar_evaluate_dipole_pattern_double(1, &theta, &phi_y, freq, dipole_length_m,
                                           response_ptr + 2);
    }
    
    OSKARElementResponseSphericalWave::OSKARElementResponseSphericalWave() {
      std::string path = get_path("oskar.h5");
      m_datafile.reset(new Datafile(path));
    }
    
    OSKARElementResponseSphericalWave::OSKARElementResponseSphericalWave(
        const std::string& path) {
      m_datafile.reset(new Datafile(path));
    }
    
    void OSKARElementResponseSphericalWave::response(
        double freq, double theta, double phi,
        std::complex<double> (&response)[2][2]) const {
      // This ElementResponse model is element specific, so an element_id is
      // required to know for what element the response needs to be evaluated A
      // std::invalid_argument exception is thrown although strictly speaking it are
      // not the given arguments that are invalid, but the response(...) method with
      // a different signature should have been called.
      throw std::invalid_argument(
          "OSKARElementResponseSphericalWave: missing argument element_id");
    }
    
    void OSKARElementResponseSphericalWave::response(
        int element_id, double freq, double theta, double phi,
        std::complex<double> (&response)[2][2]) const {
      auto dataset = m_datafile->get(freq);
      auto l_max = dataset->get_l_max();
    
      std::complex<double>* response_ptr = (std::complex<double>*)response;
      std::complex<double>* alpha_ptr = dataset->get_alpha_ptr(element_id);
    
      double phi_x = phi;
      double phi_y = phi + M_PI_2;
      oskar_evaluate_spherical_wave_sum_double(1, &theta, &phi_x, &phi_y, l_max,
                                               alpha_ptr, response_ptr);
    }
    
    std::string OSKARElementResponseSphericalWave::get_path(
        const char* filename) const {
      std::stringstream ss;
      ss << EVERYBEAM_DATA_DIR << "/";
      ss << filename;
      return ss.str();
    }
    
    }  // namespace everybeam