Skip to content
Snippets Groups Projects
Select Git revision
  • cbb0c20f162e1a97a0977f4982253bf5e4ed4364
  • master default protected
  • zhang-master-patch-34807
  • add-single-element-interface
  • 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
  • v0.3.1
  • v0.3.0
  • v0.2.0
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
28 results

make_element_response_image.cpp

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.
    make_element_response_image.cpp 1.06 KiB
    #include <cmath>
    #include <iostream>
    #include <cstdlib>
    
    #include <oskarelementresponse.h>
    
    #include "../../external/npy.hpp"   // to save arrays in numpy format
    
    int main(int argc, char** argv){
    // int main() {
        everybeam::OSKARElementResponseSphericalWave element_response("oskar.h5");
        double freq = 50e6;
    
        int N;
        if (argc == 1){
            N = 256;
        }
        else{
            N = atoi(argv[1]);
        }
    
        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);
                element_response.Response(0, freq, theta, phi, result_arr[i][j]);
            }
        }
    
        const long unsigned leshape [] = {(long unsigned int) N, (long unsigned int) N, 2, 2};
        npy::SaveArrayAsNumpy("response.npy", false, 4, leshape, result);
    }