void Galaxy::assign_bin (double min_value, double bin_size) {
  // Assign redshift bin to Galaxy instance.
  if (min_value < 0)
    throw BadArgumentException("Galaxy::assign_bin", "min_value", ">= 0.0");
  if (bin_size <= 0)
    throw BadArgumentException("Galaxy::assign_bin", "bin_size", "> 0.0");
  bin = astro.find_bin(z, min_value, bin_size);
}
void Galaxy::assign_dist (double c, double H0, double Omega_M, double Omega_L) {
  // Calculate angular diameter distance for Galaxy instance;
  if (c <= 0)
    throw BadArgumentException("Galaxy::assign_dist", "c", "> 0.0");
  if (H0 <= 0)
    throw BadArgumentException("Galaxy::assign_dist", "H0", "> 0.0");
  cosmo.set_up(Omega_M, Omega_L);
  da = ((c / H0) * cosmo.angdidis(z));
}
void Galaxy::assign_bins (double min_value, double bin_size, double delta_z) {
  // Assign redshift bin to Galaxy instance.
  if (min_value < 0)
    throw BadArgumentException("Galaxy::assign_bin", "min_value", ">= 0.0");
  if (bin_size <= 0)
    throw BadArgumentException("Galaxy::assign_bin", "bin_size", "> 0.0");
  for(double x = z - delta_z * z_err; x <= z + delta_z * z_err; x += bin_size)
    if(x >= min_value) bins.push_back(astro.find_bin(x, min_value, bin_size));
}
Exemple #4
0
    TileCombined(int part, int width, int height,
                 const std::string& tilePositionsX, const std::string& tilePositionsY,
                 int tileWidth, int tileHeight, int ver = -1,
                 const std::string& imgSizes = "", int id = -1) :
        _part(part),
        _width(width),
        _height(height),
        _tileWidth(tileWidth),
        _tileHeight(tileHeight),
        _ver(ver),
        _id(id)
    {
        if (_part < 0 ||
            _width <= 0 ||
            _height <= 0 ||
            _tileWidth <= 0 ||
            _tileHeight <= 0)
        {
            throw BadArgumentException("Invalid tilecombine descriptor.");
        }

        Poco::StringTokenizer positionXtokens(tilePositionsX, ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
        Poco::StringTokenizer positionYtokens(tilePositionsY, ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
        Poco::StringTokenizer sizeTokens(imgSizes, ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);

        const auto numberOfPositions = positionYtokens.count();

        // check that number of positions for X and Y is the same
        if (numberOfPositions != positionXtokens.count() || (!imgSizes.empty() && numberOfPositions != sizeTokens.count()))
        {
            throw BadArgumentException("Invalid tilecombine descriptor. Uneven number of tiles.");
        }

        for (size_t i = 0; i < numberOfPositions; ++i)
        {
            int x = 0;
            if (!LOOLProtocol::stringToInteger(positionXtokens[i], x))
            {
                throw BadArgumentException("Invalid tilecombine descriptor.");
            }

            int y = 0;
            if (!LOOLProtocol::stringToInteger(positionYtokens[i], y))
            {
                throw BadArgumentException("Invalid tilecombine descriptor.");
            }

            int size = 0;
            if (sizeTokens.count() && !LOOLProtocol::stringToInteger(sizeTokens[i], size))
            {
                throw BadArgumentException("Invalid tilecombine descriptor.");
            }

            _tiles.emplace_back(_part, _width, _height, x, y, _tileWidth, _tileHeight, ver, size, id);
        }
    }
Exemple #5
0
void Cosmo::set_up(double OmegaM_val, double OmegaL_val) {
  if (OmegaM_val < 0 || OmegaM_val > 1.0)
    throw BadArgumentException("Cosmo::set_up", "OmegaM_val", "in the range 0.0 <= OmegaM_val <= 1.0");
  if (OmegaL_val < 0 || OmegaL_val > 1.0)
    throw BadArgumentException("Cosmo::set_up", "OmegaL_val", "in the range 0.0 <= OmegaL_val <= 1.0");
  if (std::abs(1.0 - OmegaM_val - OmegaL_val) > std::numeric_limits<double>::epsilon()) 
    throw DomainException("Cosmo::set_up", "OmegaM_val and OmegaL_val must sum to 1.0");
  OmegaM = OmegaM_val;
  OmegaL = OmegaL_val;
}
 /**
  * Initialise Galaxy instance. [FoF mode: "phot"]
  * @param[in] num_val Integer value.
  * @param[in] id_val Galaxy ID.
  * @param[in] ra_val Galaxy right ascension.
  * @param[in] dec_val Galaxy declination.
  * @param[in] z_val Galaxy photometric redshift.
  * @param[in] dz_val Galaxy photometric redshift error.
  */
 Galaxy(int num_val,  unsigned long id_val, double ra_val, double dec_val,
         double z_val, double dz_val) {
     if (z_val < 0)
         throw BadArgumentException("Galaxy", "z_val", ">= 0.0");
     if (dz_val < 0)
         throw BadArgumentException("Galaxy", "dz_val", ">= 0.0");
     num = num_val;
     id = id_val;
     P.P[0] = ra_val;
     P.P[1] = dec_val;
     z = z_val;
     dz = dz_val;
     da = 0;
     bin = 0;
 };
void Galaxy::set_cluster_status (int nbins) {
  // Set the initial cluster status for each redshift bin to false.
  if (nbins <= 0)
    throw BadArgumentException("Galaxy::set_cluster_status", "nbins", "> 0.0");
  for(int i = 0; i < nbins; i++)
    in_cluster.push_back(false);
}
 /** 
  * Initialise Zbin instance.
  * @param[in] num_val Integer value.
  * @param[in] z_val Redshift.
  * @param[in] z_bin_size Redshift bin size.
  */
 Zbin(int num_val, double z_val, double z_bin_size) { 
   /**< Initialise Zbin instance. */
   if (z_val <= 0)
     throw BadArgumentException("Zbin", "z_val", "> 0.0");
   if (z_bin_size <= 0)
     throw BadArgumentException("Zbin", "z_bin_size", "> 0.0");
   num = num_val;
   z = z_val;
   dz = z_bin_size;
   count = 0;
   da = 0;
   dvdz = 0;
   dndz = 0;
   dndv = 0;
   link_r = 0;
   rfriend = 0;
 };
Exemple #9
0
void
checkForUndefinedArguments(const std::string & theMethodName, uintN argc, jsval *argv) {
for (unsigned i = 0; i < argc; ++i) {
    if (JSVAL_IS_VOID(argv[i])) {
        throw BadArgumentException(theMethodName + ": Argument " + asl::as_string(i) + " is undefined.", PLUS_FILE_LINE);
    }
}
}
Exemple #10
0
void
checkArguments(const std::string & theMethodName, uintN argc, jsval *argv,
        unsigned theRequiredArguments)
{
    if (argc != theRequiredArguments) {
        throw BadArgumentException(theMethodName + ": Wrong number of arguments. Got " +
            asl::as_string(argc) + ", expected " + asl::as_string(theRequiredArguments) + ".", PLUS_FILE_LINE);
    }

    checkForUndefinedArguments(theMethodName, argc, argv);
}
Exemple #11
0
/* ----------------------------------------------------------------------------
   comdis
-------------------------------------------------------------------------------
   This function calculates the line-of-sight comoving distance d_C as
   a function of z, Omega_M and Omega_L in a matter-dominated
   universe, using dcomdisdz().  H0=c=1.
---------------------------------------------------------------------------- */
double Cosmo::comdis(double z) {
  if (z < 0.0)
    throw BadArgumentException("Cosmo::comdis", "z", ">= 0.0");
  int nsteps;
  double dz, dC, zz;
  nsteps = ((int) (z / MINSTEP)) + 1;
  dz = z / ((double) nsteps) ;
  dC = 0.0 ;
  for(zz = 0.5 * dz; zz < z; zz += dz) dC += dz * dcomdisdz(zz);
  return dC ;
}
Exemple #12
0
/* ----------------------------------------------------------------------------
   angdidis2
-------------------------------------------------------------------------------
   This function calculates the angular diameter distance d_A from z1
   to z2 as a function of Omega_M and Omega_L in a matter-dominated
   universe, using the function propmotdis().  H0=c=1.
---------------------------------------------------------------------------- */
double Cosmo::angdidis2(double z1, double z2) {
  if (z2 <= z1)
    throw BadArgumentException("Cosmo::angdidis2", "z2", "> z1");
  double y1, y2, y12, OmegaR;
  OmegaR = 1.0 - OmegaM - OmegaL;
  if(OmegaR <- TINY) printf("WARNING: angdidis2() does not work at Omega_R<0!");
  y1 = propmotdis(z1);
  y2 = propmotdis(z2);
  y12 = y2*sqrt(1.0 + y1 * y1 * OmegaR) - y1 * sqrt(1.0 + y2 * y2 * OmegaR);
  return y12 / (1.0 + z2) ;
}
Exemple #13
0
/* ----------------------------------------------------------------------------
   propmotdis
-------------------------------------------------------------------------------
   This function calculates the proper motion distance d_M as a
   function of z, Omega_M and Omega_L in a matter-dominated universe.
   Formulae from Carrol, Press & Turner, 1992, Kolb \& Turner, 1990,
   and my own derivation.  Makes use of comdis().  H0=c=1.
---------------------------------------------------------------------------- */
double Cosmo::propmotdis(double z) {
  if (z < 0.0)
    throw BadArgumentException("Cosmo::propmotdis", "z", ">= 0.0");
  double dM, q0, OmegaK, sqrtOmegaK;
  if(fabs(OmegaM) < TINY && fabs(OmegaL) < TINY) {
    dM = (z + 0.5 * z * z) / (1.0 + z);
  }
  else if(fabs(OmegaL) < TINY) {
    q0 = 0.5 * OmegaM;
    dM = (z * q0 + (q0 - 1.0) * (sqrt(2.0 * q0 * z + 1.0) - 1.0)) / (q0 * q0 * (1.0 + z));
  }
  else {
    dM = comdis(z);
    OmegaK = 1.0 - OmegaM - OmegaL;
    sqrtOmegaK = sqrt(fabs(OmegaK));
    if(OmegaK < -TINY) dM = sin(sqrtOmegaK * dM) / sqrtOmegaK;
    else if(OmegaK > TINY) dM = sinh(sqrtOmegaK * dM) / sqrtOmegaK;
  }
  return dM;
}
Exemple #14
0
 TileDesc(int part, int width, int height, int tilePosX, int tilePosY, int tileWidth, int tileHeight, int ver = -1, int imgSize = 0, int id = -1) :
     _part(part),
     _width(width),
     _height(height),
     _tilePosX(tilePosX),
     _tilePosY(tilePosY),
     _tileWidth(tileWidth),
     _tileHeight(tileHeight),
     _ver(ver),
     _imgSize(imgSize),
     _id(id)
 {
     if (_part < 0 ||
         _width <= 0 ||
         _height <= 0 ||
         _tilePosX < 0 ||
         _tilePosY < 0 ||
         _tileWidth <= 0 ||
         _tileHeight <= 0 ||
         _imgSize < 0)
     {
         throw BadArgumentException("Invalid tile descriptor.");
     }
 }
Exemple #15
0
/* ----------------------------------------------------------------------------
   doptdepthdz
-------------------------------------------------------------------------------
   This function calculates the change in optical depth dtau/dz with
   redshift z as a function of z, Omega_M and Omega_L in a
   matter-dominated universe.  Formula from Peebles, 1993.
   H0=c=sigma=n=1.
---------------------------------------------------------------------------- */
double Cosmo::doptdepthdz(double z) {
  if (z < 0.0)
    throw BadArgumentException("Cosmo::doptdepthdz", "z", ">= 0.0");
  return (1.0 + z) * (1.0 + z) / sqrt((1.0 + z) * (1.0 + z) * (1.0 + OmegaM * z) - 
				      z * (2.0 + z) * OmegaL);
}
Exemple #16
0
/* ----------------------------------------------------------------------------
   dlookbackdz
-------------------------------------------------------------------------------
   This function calculates the change in lookback time dt/dz with
   redshift z as a function of z, Omega_M and Omega_L in a
   matter-dominated universe.  Formula from Carrol, Press & Turner,
   1992.  H0=c=1.
---------------------------------------------------------------------------- */
double Cosmo::dlookbackdz(double z) {
  if (z < 0.0)
    throw BadArgumentException("Cosmo::dlookbackdz", "z", ">= 0.0");
  return 1.0 / ((1.0 + z) * sqrt((1.0 + z) * (1.0 + z) * (1.0 + OmegaM * z) - z * 
				 (2.0 + z) * OmegaL));
}