diff --git a/CHANGELOG b/CHANGELOG index 656d4bf..b5f3f9b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,10 @@ +v1.x.0 (25/08/2023) +====== + +Features: + - Added option OUTPUT_PRECISION to control the numerical precision in the output catalog + + v1.4.0 (11/08/2023) ====== diff --git a/README.md b/README.md index d46d16d..b531e90 100644 --- a/README.md +++ b/README.md @@ -324,6 +324,7 @@ To get the closest behavior to that of FAST-IDL, you should set ```C_INTERVAL=68 * ```'la2t'```: (only for gridded SFH) the log10 of the ratio of age to SF timescale * ... plus any of the rest-frame magnitudes listed in ```REST_MAG``` (see above) * ... plus any of the custom SFH parameters (see ```CUSTOM_SFH``` below) + * ```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. * ```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. * ```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. * ```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. diff --git a/example/cosmos-20115/fast.param b/example/cosmos-20115/fast.param index 12cb7b0..87eab89 100644 --- a/example/cosmos-20115/fast.param +++ b/example/cosmos-20115/fast.param @@ -286,6 +286,15 @@ SPEC_LSF_FILE = '' # an empty array (default), then all available parameters are written # in the file (except lldust, llion, and lmform). # +# o OUTPUT_PRECISION: define the numerical precision to use when printing +# values in the output catalog. The default (0) means to use the +# standard precision, which is 1e-4 for the redshift and metallicity, +# and 1e-2 for everything else. If set to any other power of ten +# between zero and one (excluded), 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. +# #----------------------------------------------------------------------- OUTPUT_DIR = '' @@ -306,6 +315,7 @@ REST_MAG = [] # [140,142,161] for UVJ colors CONTINUUM_INDICES = '' SFH_QUANTITIES = ['tsf','past_sfr','sfr10','brate10','tquench10','tform50'] OUTPUT_COLUMNS = [] # ['id','Av','lmass','lsfr', ...] +OUTPUT_PRECISION = 0 # 0 / 0.01 / 0.0001 / 1e-6 #--- CHOOSE STELLAR POPULATIONS LIBRARY -------------------------------- diff --git a/example/hdfn_fs99/fast.param b/example/hdfn_fs99/fast.param index 7f9d717..b71383e 100644 --- a/example/hdfn_fs99/fast.param +++ b/example/hdfn_fs99/fast.param @@ -286,6 +286,15 @@ SPEC_LSF_FILE = '' # an empty array (default), then all available parameters are written # in the file (except lldust, llion, and lmform). # +# o OUTPUT_PRECISION: define the numerical precision to use when printing +# values in the output catalog. The default (0) means to use the +# standard precision, which is 1e-4 for the redshift and metallicity, +# and 1e-2 for everything else. If set to any other power of ten +# between zero and one (excluded), 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. +# #----------------------------------------------------------------------- OUTPUT_DIR = '' @@ -306,6 +315,7 @@ REST_MAG = [] # [140,142,161] for UVJ colors CONTINUUM_INDICES = '' SFH_QUANTITIES = [] # ['tquench10','tform50','brate10', ...] OUTPUT_COLUMNS = [] # ['id','Av','lmass','lsfr', ...] +OUTPUT_PRECISION = 0 # 0 / 0.01 / 0.0001 / 1e-6 #--- CHOOSE STELLAR POPULATIONS LIBRARY -------------------------------- diff --git a/src/fast++-read_input.cpp b/src/fast++-read_input.cpp index 794dfd5..aa8e86b 100644 --- a/src/fast++-read_input.cpp +++ b/src/fast++-read_input.cpp @@ -168,6 +168,7 @@ bool read_params(options_t& opts, input_state_t& state, const std::string& filen PARSE_OPTION(continuum_indices) PARSE_OPTION(sfh_quantities) PARSE_OPTION(interval_from_chi2) + PARSE_OPTION(output_precision) PARSE_OPTION(a_v_bc_min) PARSE_OPTION(a_v_bc_max) PARSE_OPTION(a_v_bc_step) @@ -356,6 +357,17 @@ bool read_params(options_t& opts, input_state_t& state, const std::string& filen } } + if (opts.output_precision < 0.0 || opts.output_precision >= 0.5) { + warning("'OUTPUT_PRECISION' must be between zero and one; using default precision (0)"); + opts.output_precision = 0.0; + } + + double nearest_precision = e10(round(log10(opts.output_precision))); + if (opts.output_precision > 0.0 && abs(log10(opts.output_precision) - log10(nearest_precision)) > 1e-3) { + warning("'OUTPUT_PRECISION' must be an exact power of ten (e.g., 0.1, 0.01); using nearest (", nearest_precision, ")"); + opts.output_precision = nearest_precision; + } + if (!opts.best_from_sim && opts.interval_from_chi2 && !opts.save_sim && opts.n_sim != 0) { warning("with the current setup, Monte Carlo simulations are not used; setting 'N_SIM=0'"); opts.n_sim = 0; diff --git a/src/fast++-write_output.cpp b/src/fast++-write_output.cpp index 0efc346..64421f5 100644 --- a/src/fast++-write_output.cpp +++ b/src/fast++-write_output.cpp @@ -208,7 +208,9 @@ void write_catalog(const options_t& opts, const input_state_t& input, const grid value = -2.5*log10(value) + 23.9; } - float precision = output.param_precision.safe[iparam[ic]]; + float precision = opts.output_precision > 0 ? + opts.output_precision : output.param_precision.safe[iparam[ic]]; + value = round(value/precision)*precision; if (!is_nan(value) && !is_finite(value)) { if (value < 0) { diff --git a/src/fast++.hpp b/src/fast++.hpp index 6074ec0..24c5cc5 100644 --- a/src/fast++.hpp +++ b/src/fast++.hpp @@ -134,6 +134,7 @@ struct options_t { vec1u rest_mag; std::string continuum_indices; bool interval_from_chi2 = false; + float output_precision = 0.0; // Custom SFH std::string custom_sfh;