Skip to content

Commit 3fc080a

Browse files
committed
Added OUTPUT_PRECISON
1 parent 6fb551a commit 3fc080a

File tree

7 files changed

+44
-1
lines changed

7 files changed

+44
-1
lines changed

CHANGELOG

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v1.x.0 (25/08/2023)
2+
======
3+
4+
Features:
5+
- Added option OUTPUT_PRECISION to control the numerical precision in the output catalog
6+
7+
18
v1.4.0 (11/08/2023)
29
======
310

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ To get the closest behavior to that of FAST-IDL, you should set ```C_INTERVAL=68
324324
* ```'la2t'```: (only for gridded SFH) the log10 of the ratio of age to SF timescale
325325
* ... plus any of the rest-frame magnitudes listed in ```REST_MAG``` (see above)
326326
* ... plus any of the custom SFH parameters (see ```CUSTOM_SFH``` below)
327+
* ```OUTPUT_PRECISION```: possible values are any power of ten between zero (included) and one (excluded), which defines the numerical precision to use when printing values in the output catalog. The default is ```0```, and means to use the standard precision, which is 1e-4 for the redshift and metallicity, and 1e-2 for everything else. Otherwise, this value will be used to round the outputs. Note, this only affects the output catalog (.fout); all other outputs (including grid files) are always stored in full precision.
327328
* ```INTRINSIC_BEST_FIT```: possible values are ```0``` or ```1```. The default is ```0```. If set to ```1``` and ```BEST_FIT``` is also set to ```1```, the program will output the intrinsic best-fit SED of a galaxy (i.e., the SED of the galaxy prior to attenuation by dust) alongside the best-fitting template. The intrinsic model will be added as the extra column `fl_nodust` in the `best_fits/*.fit` file.
328329
* ```LSF_BEST_FIT```: possible values are ```0``` or ```1```. The default is ```0```. If set to ```1``` and ```BEST_FIT``` is also set to ```1```, the program will output the LSF-convolved best-fit SED of a galaxy alongside the best-fitting template. This is only useful if an LSF file is provided, see ```SPEC_LSF_FILE```. The LSF-convolved model will be added as the extra column `fl_lsf` in the `best_fits/*.fit` file.
329330
* ```BEST_SFHS```: possible values are ```0``` or ```1```. The default is ```0```. If set to ```1```, the program will output the best fit star formation history (SFH) to a file, in the ```best_fits``` directory (as for the best fit SEDs). If Monte Carlo simulations are enabled, the program will also output confidence intervals on the SFH for each time step, as well as the median SFH among all Monte Carlo simulations. This median may not correspond to any analytical form allowed by your chosen SFH model.

example/cosmos-20115/fast.param

+10
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,15 @@ SPEC_LSF_FILE = ''
286286
# an empty array (default), then all available parameters are written
287287
# in the file (except lldust, llion, and lmform).
288288
#
289+
# o OUTPUT_PRECISION: define the numerical precision to use when printing
290+
# values in the output catalog. The default (0) means to use the
291+
# standard precision, which is 1e-4 for the redshift and metallicity,
292+
# and 1e-2 for everything else. If set to any other power of ten
293+
# between zero and one (excluded), this value will be used to round
294+
# the outputs. Note, this only affects the output catalog (.fout);
295+
# all other outputs (including grid files) are always stored in full
296+
# precision.
297+
#
289298
#-----------------------------------------------------------------------
290299

291300
OUTPUT_DIR = ''
@@ -306,6 +315,7 @@ REST_MAG = [] # [140,142,161] for UVJ colors
306315
CONTINUUM_INDICES = ''
307316
SFH_QUANTITIES = ['tsf','past_sfr','sfr10','brate10','tquench10','tform50']
308317
OUTPUT_COLUMNS = [] # ['id','Av','lmass','lsfr', ...]
318+
OUTPUT_PRECISION = 0 # 0 / 0.01 / 0.0001 / 1e-6
309319

310320

311321
#--- CHOOSE STELLAR POPULATIONS LIBRARY --------------------------------

example/hdfn_fs99/fast.param

+10
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,15 @@ SPEC_LSF_FILE = ''
286286
# an empty array (default), then all available parameters are written
287287
# in the file (except lldust, llion, and lmform).
288288
#
289+
# o OUTPUT_PRECISION: define the numerical precision to use when printing
290+
# values in the output catalog. The default (0) means to use the
291+
# standard precision, which is 1e-4 for the redshift and metallicity,
292+
# and 1e-2 for everything else. If set to any other power of ten
293+
# between zero and one (excluded), this value will be used to round
294+
# the outputs. Note, this only affects the output catalog (.fout);
295+
# all other outputs (including grid files) are always stored in full
296+
# precision.
297+
#
289298
#-----------------------------------------------------------------------
290299

291300
OUTPUT_DIR = ''
@@ -306,6 +315,7 @@ REST_MAG = [] # [140,142,161] for UVJ colors
306315
CONTINUUM_INDICES = ''
307316
SFH_QUANTITIES = [] # ['tquench10','tform50','brate10', ...]
308317
OUTPUT_COLUMNS = [] # ['id','Av','lmass','lsfr', ...]
318+
OUTPUT_PRECISION = 0 # 0 / 0.01 / 0.0001 / 1e-6
309319

310320

311321
#--- CHOOSE STELLAR POPULATIONS LIBRARY --------------------------------

src/fast++-read_input.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ bool read_params(options_t& opts, input_state_t& state, const std::string& filen
168168
PARSE_OPTION(continuum_indices)
169169
PARSE_OPTION(sfh_quantities)
170170
PARSE_OPTION(interval_from_chi2)
171+
PARSE_OPTION(output_precision)
171172
PARSE_OPTION(a_v_bc_min)
172173
PARSE_OPTION(a_v_bc_max)
173174
PARSE_OPTION(a_v_bc_step)
@@ -356,6 +357,17 @@ bool read_params(options_t& opts, input_state_t& state, const std::string& filen
356357
}
357358
}
358359

360+
if (opts.output_precision < 0.0 || opts.output_precision >= 0.5) {
361+
warning("'OUTPUT_PRECISION' must be between zero and one; using default precision (0)");
362+
opts.output_precision = 0.0;
363+
}
364+
365+
double nearest_precision = e10(round(log10(opts.output_precision)));
366+
if (opts.output_precision > 0.0 && abs(log10(opts.output_precision) - log10(nearest_precision)) > 1e-3) {
367+
warning("'OUTPUT_PRECISION' must be an exact power of ten (e.g., 0.1, 0.01); using nearest (", nearest_precision, ")");
368+
opts.output_precision = nearest_precision;
369+
}
370+
359371
if (!opts.best_from_sim && opts.interval_from_chi2 && !opts.save_sim && opts.n_sim != 0) {
360372
warning("with the current setup, Monte Carlo simulations are not used; setting 'N_SIM=0'");
361373
opts.n_sim = 0;

src/fast++-write_output.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ void write_catalog(const options_t& opts, const input_state_t& input, const grid
208208
value = -2.5*log10(value) + 23.9;
209209
}
210210

211-
float precision = output.param_precision.safe[iparam[ic]];
211+
float precision = opts.output_precision > 0 ?
212+
opts.output_precision : output.param_precision.safe[iparam[ic]];
213+
212214
value = round(value/precision)*precision;
213215
if (!is_nan(value) && !is_finite(value)) {
214216
if (value < 0) {

src/fast++.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ struct options_t {
134134
vec1u rest_mag;
135135
std::string continuum_indices;
136136
bool interval_from_chi2 = false;
137+
float output_precision = 0.0;
137138

138139
// Custom SFH
139140
std::string custom_sfh;

0 commit comments

Comments
 (0)