glenco / SLsimLib

Library for Gravitational Lensing Simulations
MIT License
2 stars 1 forks source link

Generate field of halos in the whole light-cone #138

Closed rbmetcalf closed 7 years ago

rbmetcalf commented 7 years ago

Addressing issue #137

Added a function Lens::GenerateFieldHalos() so that the light cone can be filled with a realisation of the expected halos without a parameter file. test0

Here is some sample code using it:

#include <slsimlib.h>
#include <sstream>
#include <iomanip>
#include <omp.h>
#include <thread>
#include <mutex>

#include "gridmap.h"

using namespace std;

int main(int arg,char **argv){
  long seed = -189273;

  COSMOLOGY cosmo;

  Lens lens(&seed,2);

  double minimum_mass = 1.0e10;  // solar masses
  double field_of_view = 0.01;   // in deg^2
  int number_of_lens_planes = 20;

  lens.GenerateFieldHalos(minimum_mass,ShethTormen,field_of_view
                          ,number_of_lens_planes,nfw_lens);

  auto sph_center = lens.getCenter();
  Point_2d center(sph_center.phi,sph_center.theta);

  lens.ResetSourcePlane(3);

  GridMap grid(&lens,512,center.x,degreesTOradians*2*sqrt(lens.getfov()/pi));
  PixelMap map = grid.writePixelMapUniform(KAPPA);
  map.printFITS("!test0.fits");

  for(int i=1 ; i < 2 ; ++i){
    lens.resetFieldHalos();
    GridMap grid(&lens,512,center.x,degreesTOradians*2*sqrt(lens.getfov()/pi));
    grid.writePixelMapUniform(map,KAPPA);
    map.printFITS("!test" + std::to_string(i) + ".fits");
  }
  return 0;
}
rbmetcalf commented 7 years ago

@jwhsueh I fixed the default constructor for LensHaloNFW so that a vector of them can be made of properly initialised objects.

rbmetcalf commented 7 years ago

I assume these changes are working well. I'll merge.