GLAMERDOC++
Gravitational Lensing Code Library
Loading...
Searching...
No Matches
sourceAnaGalaxy.h
1/*
2 * souceAnaLens.h
3 *
4 * Created on: Aug 13, 2012
5 * Author: bmetcalf
6 */
7
8#ifndef SOURCE_ANA_H_
9#define SOURCE_ANA_H_
10
11#include "source.h"
12#include "overzier_source.h"
13#include "simpleTreeVec.h"
14#include "utilities.h"
15
33public:
34 SourceMultiAnaGalaxy(PosType mag,PosType mag_bulge,Band band,PosType zero_point, PosType Reff, PosType Rdisk, PosType PA, PosType inclination,PosType my_z,PosType *my_theta
37 //SourceMultiAnaGalaxy(InputParams& params,Utilities::RandomNumbers_NR &ran);
39
41 PosType SurfaceBrightness(const PosType* x) const {
42 PosType sb = galaxies[index].SurfaceBrightness(x);
43 if (sb < sb_limit) return 0.;
44 return sb;
45 }
46
48 PosType getTotalFlux() const {return mag_to_flux(galaxies[index].getMag(),mag_zero_point);}
49
50 void printSource();
51 // Add a pre-constructed galaxy to the source collection
52 void AddAGalaxy(SourceOverzierPlus *my_galaxy){galaxies.push_back(*my_galaxy);}
53
57 SourceOverzierPlus& setIndex (std::size_t i){
58 if(i < galaxies.size())
59 index = i;
60 return galaxies[index];
61 }
66 if(i < galaxies.size())
67 return galaxies[i];
68 return galaxies[index];
69 }
70
71 const SourceOverzierPlus& operator[] (std::size_t i) const {
72 if(i < galaxies.size())
73 return galaxies[i];
74 return galaxies[index];
75 }
76
77 SourceOverzierPlus& CurrentGalaxy(){
78 return galaxies[index];
79 }
80
82 //PosType getZ() const {return galaxies[index].getZ();}
83 PosType getZ() const {return galaxies[index].getZ();}
84 //PosType getRadius() const {return max(galaxies[index]->Reff,galaxies[index]->Rdisk);}
85 PosType getRadius() const {return galaxies[index].getRadius();}
87 void setZ(PosType my_z){ galaxies[index].setZ(my_z);}
88 void resetBand(Band my_band){
89 for(size_t i=0;i<galaxies.size();++i) galaxies[i].changeBand(my_band);
90 band = my_band;
91 }
92
93 unsigned long getID(){return galaxies[index].getID();}
94
95
97 Point_2d getTheta() const{return galaxies[index].getTheta();}
99 void setTheta(PosType my_theta[2]){galaxies[index].setTheta(my_theta);}
100 void setTheta(PosType my_x,PosType my_y){galaxies[index].setTheta(my_x, my_y);}
101 void setTheta(const Point_2d &p){galaxies[index].setTheta(p);}
102
103 std::size_t getNumberOfGalaxies() const {return galaxies.size();}
104
105 void multiplier(PosType z,PosType mag_cut,int Multiplicity,Utilities::RandomNumbers_NR &ran);
106 void sortInRedshift();
107 void sortInMag(Band tmp_band);
108 void sortInID();
110 PosType getFOV(){return (rangex[1]-rangex[0])*(rangey[1]-rangey[0])*180*180/PI/PI;}
111
115 std::size_t findclosestonsky(PosType theta[],PosType *radius){
116 size_t index;
117 searchtree->NearestNeighbor(theta,*radius,index);
118 return index;
119 }
120
123 void findclosestonsky(PosType theta[],std::vector<PosType> &radius,std::vector<size_t> &indexes){
124 indexes.resize(radius.size());
125 searchtree->NearestNeighbors(theta,radius.size(),radius,indexes);
126 return;
127 }
128
130 void findonsky(PosType theta[],float radius,std::list<size_t> &indexes){
131 indexes.clear();
132 searchtree->PointsWithinCircle(theta,radius,indexes);
133 return;
134 }
135
137 void findnear(PosType theta[],float radius,std::list<size_t> &indexes,PosType z_range[]){
138 indexes.clear();
139 searchtree->PointsWithinCircle(theta,radius,indexes);
140
141 PosType z;
142 // make redshift cut for lens sources
143 for(std::list<size_t>::iterator itt = indexes.begin();
144 itt != indexes.end(); ++itt){
145 z = galaxies[*itt].getZ();
146 if(z < z_range[0] || z > z_range[1]){
147 indexes.erase(itt);
148 if(itt != indexes.begin()) --itt;
149 }
150 }
151
152 return;
153 }
154
155private:
156 // make it uncopyable
157 //SourceMultiAnaGalaxy(SourceMultiAnaGalaxy &s){};
158 SourceMultiAnaGalaxy & operator=(SourceMultiAnaGalaxy &s){return s;}
159
160 Band band;
161 float mag_limit;
162 std::size_t index;
163
164 std::vector<SourceOverzierPlus> galaxies;
166 std::string input_gal_file;
167
168 void readDataFileMillenn(std::map<Band,double> zeropoints,Utilities::RandomNumbers_NR &ran);
169 void assignParams(InputParams& params);
170
171 PosType rangex[2],rangey[2];
172};
173
174bool redshiftcompare(SourceOverzierPlus s1,SourceOverzierPlus s2);
175bool magcompare(SourceOverzierPlus s1,SourceOverzierPlus s2);
176bool idcompare(SourceOverzierPlus s1,SourceOverzierPlus s2);
177
185public:
186
187 //SourceMultiShapelets(InputParams& params);
188
189 SourceMultiShapelets(double mag_zero_point):Source(0,Point_2d(0,0),0,-1,mag_zero_point){};
190
192 SourceMultiShapelets(const std::string &my_shapelets_folder
193 ,Band my_band
194 ,double my_max_mag_limit
195 ,double my_min_mag_limit
196 ,double my_z_max
197 ,double my_sb_limit
198 ,double maximum_radius
199 ,double zero_point
200 );
201
202 void input(const std::string &my_shapelets_folder
203 ,Band my_band
204 ,double my_max_mag_limit
205 ,double my_min_mag_limit
206 ,double my_z_max
207 ,double my_sb_limit
208 ,double maximum_radius
209 ,double zero_point
210 );
211
213 void sortInRedshift();
214 void sortInMag();
216 PosType SurfaceBrightness(const PosType* x)const {
217 PosType sb = galaxies[index].SurfaceBrightness(x);
218 if (sb < sb_limit) return 0.;
219 return sb;
220 }
221
222 void printSource();
223 std::size_t getNumberOfGalaxies() const {return galaxies.size();}
225 std::size_t size() const {return galaxies.size();}
226
228 PosType getTotalFlux() const {return mag_to_flux(galaxies[index].getMag(),mag_zero_point);}
229
231 Point_2d getTheta() const {return galaxies[index].getTheta();}
233 void setTheta(PosType my_theta[2]){galaxies[index].setTheta(my_theta);}
234 void setTheta(PosType my_x,PosType my_y){galaxies[index].setTheta(my_x, my_y);}
235 void setTheta(const Point_2d &p){galaxies[index].setTheta(p);}
236
238 PosType getZ() const {return galaxies[index].getZ();}
239 //PosType getRadius() const {return max(galaxies[index]->Reff,galaxies[index]->Rdisk);}
240 PosType getRadius() const {return galaxies[index].getRadius();}
241
245 SourceShapelets& setIndex (std::size_t i){
246 if(i < galaxies.size())
247 index = i;
248 return galaxies[index];
249 }
250 size_t getIndex() const {return index;}
251
256 if(i < galaxies.size())
257 return galaxies[i];
258 return galaxies[index];
259 }
260
261 SourceShapelets& back(){
262 return galaxies.back();
263 }
264
265 const SourceShapelets& operator[] (std::size_t i) const {
266 if(i < galaxies.size())
267 return galaxies[i];
268 return galaxies[index];
269 }
270
271 SourceShapelets& CurrentGalaxy(){
272 return galaxies[index];
273 }
274
276 SourceShapelets& setBand (Band b,double zeropoint){
277 band = b;
278 for (int i = 0; i < galaxies.size(); i++)
279 galaxies[i].setActiveBand(band);
280 return galaxies[index];
281 }
282
284 int locateZ(PosType z) const {
285 return Utilities::locate<SourceShapelets,PosType>(galaxies, z, [](PosType z,const SourceShapelets &s){return (z < s.getZ());});
286 }
287
288 int getCurrentID(){
289 return galaxies[index].id;
290 }
291
292 std::vector<SourceShapelets> galaxies;
293
294private:
295 void assignParams(InputParams& params);
296 std::size_t index;
297 float max_mag_limit;
298 float min_mag_limit;
299 float z_max; // maximum redshift allowed
300 Band band;
301 double radius_max;
302
303 void readCatalog();
304 std::string shapelets_folder;
305};
306
307bool redshiftcompare_shap(SourceShapelets s1,SourceShapelets s2);
308bool magcompare_shap(SourceShapelets s1,SourceShapelets s2);
309
310#endif /* SOURCE_H_ */
Band
Photometric bands.
Definition InputParams.h:79
Structure for reading and writing parameters to and from a parameter file as well as a container for ...
Definition InputParams.h:99
Base class for all sources.
Definition source.h:44
PosType getZ() const
Redshift of source.
Definition source.h:100
Source(PosType r, Point_2d x, PosType z, PosType SBlimit, PosType zero_point)
shell constructor
Definition source.h:48
Source that represents an analytic galaxy surface brightness model. It encapsulates a OverzierSource ...
Definition sourceAnaGalaxy.h:32
void findonsky(PosType theta[], float radius, std::list< size_t > &indexes)
finds objects within radios of theta[] on umlensed sky.
Definition sourceAnaGalaxy.h:130
Point_2d getTheta() const
Return angular position of current source.
Definition sourceAnaGalaxy.h:97
void setTheta(PosType my_theta[2])
Set angular position of current source.
Definition sourceAnaGalaxy.h:99
PosType getTotalFlux() const
Total flux coming from the current galaxy in erg/sec/Hz/cm^2.
Definition sourceAnaGalaxy.h:48
SourceMultiAnaGalaxy(PosType mag, PosType mag_bulge, Band band, PosType zero_point, PosType Reff, PosType Rdisk, PosType PA, PosType inclination, PosType my_z, PosType *my_theta, Utilities::RandomNumbers_NR &ran)
Source model for a single analytic galaxy model.
Definition sourceAnaGalaxy.cpp:15
void sortInMag(Band tmp_band)
Sort the sources by magnitude in assending order.
Definition sourceAnaGalaxy.cpp:391
void findnear(PosType theta[], float radius, std::list< size_t > &indexes, PosType z_range[])
finds objects within radios of theta[] on unlensed sky and within a redshift range.
Definition sourceAnaGalaxy.h:137
void printSource()
Print info on current source parameters.
Definition sourceAnaGalaxy.cpp:430
void multiplier(PosType z, PosType mag_cut, int Multiplicity, Utilities::RandomNumbers_NR &ran)
Artificially increase the number of sources to increase the incidence of strong lenses.
Definition sourceAnaGalaxy.cpp:336
SourceOverzierPlus & operator[](std::size_t i)
The indexing operator can be used to change the "current" source that is returned when the surface br...
Definition sourceAnaGalaxy.h:65
void setZ(PosType my_z)
Set redshift of current source. Only changes the redshift while leaving position fixed.
Definition sourceAnaGalaxy.h:87
PosType SurfaceBrightness(const PosType *x) const
Surface brightness of current galaxy.
Definition sourceAnaGalaxy.h:41
PosType getZ() const
Return redshift of current source.
Definition sourceAnaGalaxy.h:83
PosType getFOV()
returns field-of-view in deg^2 assuming region is square
Definition sourceAnaGalaxy.h:110
void sortInRedshift()
Sort the sources by redshift in assending order.
Definition sourceAnaGalaxy.cpp:380
SourceOverzierPlus & setIndex(std::size_t i)
Used to change the "current" source that is returned when the surface brightness is subsequently call...
Definition sourceAnaGalaxy.h:57
std::size_t findclosestonsky(PosType theta[], PosType *radius)
Finds the closest source to the position theta[] on the sky in Cartesian distance....
Definition sourceAnaGalaxy.h:115
void sortInID()
Sort the sources by magnitude in assending order.
Definition sourceAnaGalaxy.cpp:413
void findclosestonsky(PosType theta[], std::vector< PosType > &radius, std::vector< size_t > &indexes)
finds closest sources to theta on umlensed sky. "radius" should have a size equal ti the number wante...
Definition sourceAnaGalaxy.h:123
Class for reading in and handling an array of SourceShapelets, made on the model of SourceMultiAnaGal...
Definition sourceAnaGalaxy.h:184
int locateZ(PosType z) const
If the sources are already sorted by redshift this will find the index of the first galaxy with redsh...
Definition sourceAnaGalaxy.h:284
SourceShapelets & operator[](std::size_t i)
Definition sourceAnaGalaxy.h:255
void printSource()
Print info on current source parameters.
Definition source.cpp:922
void sortInMag()
Sort the sources by magnitude in assending order.
Definition source.cpp:935
void sortInRedshift()
Sort the sources by redshift in assending order.
Definition source.cpp:927
PosType getTotalFlux() const
Total flux coming from the current galaxy in erg/sec/Hz/cm^2.
Definition sourceAnaGalaxy.h:228
void setTheta(PosType my_theta[2])
Set angular position of current source.
Definition sourceAnaGalaxy.h:233
std::size_t size() const
number of galaxies
Definition sourceAnaGalaxy.h:225
SourceShapelets & setIndex(std::size_t i)
Definition sourceAnaGalaxy.h:245
PosType getZ() const
Return redshift of current source.
Definition sourceAnaGalaxy.h:238
PosType SurfaceBrightness(const PosType *x) const
Surface brightness of current galaxy.
Definition sourceAnaGalaxy.h:216
Point_2d getTheta() const
Return angular position of current source.
Definition sourceAnaGalaxy.h:231
SourceShapelets & setBand(Band b, double zeropoint)
Sets the active band for all the objects.
Definition sourceAnaGalaxy.h:276
void input(const std::string &my_shapelets_folder, Band my_band, double my_max_mag_limit, double my_min_mag_limit, double my_z_max, double my_sb_limit, double maximum_radius, double zero_point)
Definition source.cpp:751
Adds some extra features to the SourceOverzier source like spiral arms, and randomizations.
Definition overzier_source.h:155
Class for sources described by shapelets.
Definition source.h:365
A tree for doing quick searches in multidimensional space. A pointer to an array of objects type T is...
Definition simpleTreeVec.h:22
void NearestNeighbor(D *ray, D &radius, IndexType &neighbor)
finds the nearest neighbors in whatever dimensions tree is defined in
Definition simpleTreeVec.h:531
void NearestNeighbors(D *ray, int Nneighbors, std::vector< D > &radii, std::vector< IndexType > &neighbors)
Finds the nearest N neighbors and puts their index numbers in an array, also returns the distance to ...
Definition simpleTreeVec.h:464
void PointsWithinCircle(D center[2], float radius, std::list< unsigned long > &neighborkist)
Finds the points within a circle around center and puts their index numbers in a list.
Definition simpleTreeVec.h:316
This is a class for generating random numbers. It simplifies and fool proofs initialization and allow...
Definition utilities_slsim.h:1059
long locate(const std::vector< T > &v, const T x)
Definition utilities.h:76
Class for representing points or vectors in 2 dimensions. Not that the dereferencing operator is over...
Definition point.h:48