Skip to content

Commit 11867e1

Browse files
committed
Added ASCII format support to gennoise and genmap
1 parent 6f87380 commit 11867e1

File tree

4 files changed

+40
-27
lines changed

4 files changed

+40
-27
lines changed

doc/EGG.pdf

202 Bytes
Binary file not shown.

doc/doc-egg-gennoise.tex

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
\subsubsection{Basic usage}
22

3-
These two tools can be used to create the images corresponding to a given mock catalog created by \bashinline{egg-gencat}. They provide a simple alternative to \skymaker, with the added limitation that galaxies are all considered as point sources. This is usually fine for long wavelength images (\spitzer MIPS and \herschel, typically) in cosmological deep fields. In addition, more control is given relative to the noise properties.
3+
These two tools can be used to create the images corresponding to a given mock catalog created by \bashinline{egg-gencat} (custom catalogs are also supported, see below). They provide a simple alternative to \skymaker, with the added limitation that galaxies are all considered as point sources. This is usually fine for long wavelength images (\spitzer MIPS and \herschel, typically) in cosmological deep fields. In addition, more control is given relative to the noise properties.
44

55
The typical call sequence consists of two steps: creating the noise map with \bashinline{egg-gennoise}, then painting the galaxies on top of it with \bashinline{egg-genmap}. The standard way to use \bashinline{egg-gennoise} is the following:
66
\begin{bashcode}
@@ -31,7 +31,7 @@ \subsubsection{Basic usage}
3131
3232
\subsubsection{Using a custom astrometry and image dimensions}
3333
34-
The tool \bashinline{egg-gennoise} can compute automatically a suitable astrometry and image dimensions according the input catalog. However, you also have the possibility to copy the astrometry and image properties of an existing file. To do so, just use the \bashinline{astro} command line argument and make it point to the FITS image you want to copy the data from:
34+
The tool \bashinline{egg-gennoise} can compute automatically a suitable astrometry and image dimensions according to the input catalog. However, you also have the possibility to copy the astrometry and image dimensions of an existing file. To do so, just use the \bashinline{astro} command line argument and make it point to the FITS image you want to copy the data from:
3535
\begin{bashcode}
3636
egg-gennoise cat=egg-20151201.fits out=pacs160-noise.fits \
3737
psf=herschel-pacs160.fits rms=1.68e-5 verbose \
@@ -70,14 +70,16 @@ \subsubsection{Generate error and coverage maps}
7070
7171
\subsubsection{Using a custom noise map}
7272
73-
The whole point of separating the map-making process into two steps is that one can be used without the other. Indeed, \bashinline{egg-genmap} can work with noise map, provided that it contains valid WCS astrometry. The tool can handle sources outside of the map, so it is fine if the provided noise map does not overlap perfectly with the input catalog. Just make sure that the PSF you provide is tabulated on the same pixel scale as your noise map. If you use the \bashinline{beam_smoothed} option, note that the noise map must be provided \emph{unfiltered} (i.e., before beam convolution).
73+
The whole point of separating the map-making process into two steps is that one can be used without the other. Indeed, \bashinline{egg-genmap} can work with any noise map, provided that it contains valid WCS astrometry. The tool can handle sources outside of the map, so it is fine if the provided noise map does not overlap perfectly with the input catalog. Just make sure that the PSF you provide is tabulated on the same pixel scale as your noise map. If you use the \bashinline{beam_smoothed} option, note that the noise map must be provided \emph{unfiltered} (i.e., before beam convolution).
7474
7575
For example, realistic \herschel noise maps can be obtained by jackknifing the observed data, and provide noise statistics (correlation, amplitude, etc.) that match very well the real images. Such kind of map can be fed naturally to \bashinline{egg-genmap} through the \bashinline{noise_map} argument.
7676
7777
7878
\subsubsection{Using a custom flux catalog}
7979
80-
Similarly, both tools can work with input catalogs that were not produced by \bashinline{egg-gencat}. They only need a limited set of columns: \cppinline{"ra"} and \cppinline{"dec"} to know the position of each galaxy on the sky, and \cppinline{"flux"} and \cppinline{"bands"} to know their flux. The format of these columns must be the same as that created by \bashinline{egg-gencat}, but this can be easily achieved in any language. Alternatively, the program can also work with a \cppinline{"flux"} column containing a single band (i.e., a 1D vector column), in which case the \cppinline{"bands"} column and the \bashinline{band} command line argument are useless and can be omitted.
80+
Similarly, both tools can work with input catalogs that were not produced by \bashinline{egg-gencat}. They only need a limited set of columns: \cppinline{"ra"} and \cppinline{"dec"} to know the position of each galaxy on the sky, and \cppinline{"flux"} must contain the flux of each galaxy in $\uJy$.
81+
82+
Catalogs produced by \bashinline{egg-gencat} contain multiple fluxes per galaxy, so in this case you also need the \cppinline{"bands"} column and the \bashinline{band} command line argument to identify the correct flux. Alternatively, the program can also work with a \cppinline{"flux"} column containing a single band (i.e., a 1D vector column), in which case the \cppinline{"bands"} column and the \bashinline{band} command line argument can be omitted. If you prefer to use ASCII format, the order of the columns must be \cppinline{"ra"}, \cppinline{"dec"} and \cppinline{"flux"} (1D only).
8183
8284
8385
\subsubsection{Adjusting accuracy and speed}

src/egg-genmap.cpp

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,33 +86,40 @@ int main(int argc, char* argv[]) {
8686
vec1s bands;
8787
} cat;
8888

89-
fits::input_table table(cat_file);
90-
table.read_columns(ftable(cat.ra, cat.dec));
91-
table.read_column(fits::dim_promote, "flux", cat.flux);
89+
uint_t idb;
90+
if (end_with(cat_file, ".fits")) {
91+
fits::input_table table(cat_file);
92+
table.read_columns(ftable(cat.ra, cat.dec));
93+
table.read_column(fits::dim_promote, "flux", cat.flux);
9294

93-
if (cat.flux.dims[1] > 1) {
94-
table.read_column("bands", cat.bands);
95-
} else {
96-
table.read_column(fits::missing, "bands", cat.bands);
97-
}
95+
if (cat.flux.dims[1] > 1) {
96+
table.read_column("bands", cat.bands);
97+
} else {
98+
table.read_column(fits::missing, "bands", cat.bands);
99+
}
98100

99-
table.close();
101+
table.close();
100102

101-
// Find the band we are looking for
102-
uint_t idb;
103-
if (cat.bands.empty() || (cat.bands.size() == 1 && band.empty())) {
104-
idb = 0;
105-
} else {
106-
vec1u ids = where(cat.bands == band);
107-
if (ids.empty()) {
108-
warning("no band named '", band, "' in this catalog");
109-
return 1;
110-
} else if (ids.size() > 1) {
111-
warning("multiple bands matching '", band, "'");
112-
return 1;
103+
// Find the band we are looking for
104+
if (cat.bands.empty() || (cat.bands.size() == 1 && band.empty())) {
105+
idb = 0;
106+
} else {
107+
vec1u ids = where(cat.bands == band);
108+
if (ids.empty()) {
109+
warning("no band named '", band, "' in this catalog");
110+
return 1;
111+
} else if (ids.size() > 1) {
112+
warning("multiple bands matching '", band, "'");
113+
return 1;
114+
}
115+
116+
idb = ids[0];
113117
}
118+
} else {
119+
file::read_table(cat_file, file::find_skip(cat_file),
120+
cat.ra, cat.dec, file::columns(1,cat.flux));
114121

115-
idb = ids[0];
122+
idb = 0;
116123
}
117124

118125
// Read the PSF

src/egg-gennoise.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ int main(int argc, char* argv[]) {
9292
vec1d ra, dec;
9393
} cat;
9494

95-
fits::read_table(cat_file, ftable(cat.ra, cat.dec));
95+
if (end_with(cat_file, ".fits")) {
96+
fits::read_table(cat_file, ftable(cat.ra, cat.dec));
97+
} else {
98+
file::read_table(cat_file, file::find_skip(cat_file), cat.ra, cat.dec);
99+
}
96100

97101
// Read the PSF
98102
if (verbose) note("reading and normalizing PSF...");

0 commit comments

Comments
 (0)