@@ -753,20 +753,6 @@ bool read_fluxes(const options_t& opts, input_state_t& state) {
753753 ++gid;
754754 }
755755
756- if (col_zspec != npos) {
757- // Check that zspecs are covered by the redshift grid
758- if (min (state.zspec ) < opts.z_min ) {
759- error (" the smallest z_spec is outside of the grid (" , min (state.zspec ),
760- " vs. " , opts.z_min , " )" );
761- return false ;
762- }
763- if (max (state.zspec ) > opts.z_max ) {
764- error (" the largest z_spec is outside of the grid (" , max (state.zspec ),
765- " vs. " , opts.z_max , " )" );
766- return false ;
767- }
768- }
769-
770756 // Convert photometry from [catalog unit] to [uJy]
771757 float abzp = e10 (0.4 *(23.9 - opts.ab_zeropoint ));
772758 // Convert photometry from fnu [uJy] to flambda [1e-19 x erg/s/cm2/A]
@@ -1255,30 +1241,6 @@ bool read_photoz(const options_t& opts, input_state_t& state) {
12551241 return false ;
12561242 }
12571243
1258- // Check that zspecs are covered by the redshift grid
1259- if (min (state.zspec ) < opts.z_min ) {
1260- error (" the smallest z_spec is outside of the grid " , min (state.zspec ),
1261- " vs. " , opts.z_min , " )" );
1262- return false ;
1263- }
1264- if (max (state.zspec ) > opts.z_max ) {
1265- error (" the largest z_spec is outside of the grid " , max (state.zspec ),
1266- " vs. " , opts.z_max , " )" );
1267- return false ;
1268- }
1269-
1270- // Check that zphots are covered by the redshift grid
1271- if (min (state.zphot (_,0 )) < opts.z_min ) {
1272- error (" the smallest z_phot is outside of the grid " , min (state.zphot (_,0 )),
1273- " vs. " , opts.z_min , " )" );
1274- return false ;
1275- }
1276- if (max (state.zphot (_,0 )) > opts.z_max ) {
1277- error (" the largest z_phot is outside of the grid " , max (state.zphot (_,0 )),
1278- " vs. " , opts.z_max , " )" );
1279- return false ;
1280- }
1281-
12821244 return true ;
12831245}
12841246
@@ -1401,6 +1363,58 @@ bool read_template_error(const options_t& opts, input_state_t& state) {
14011363 return true ;
14021364}
14031365
1366+ bool check_input (options_t & opts, input_state_t & state) {
1367+ if (!state.zspec .empty ()) {
1368+ // Check that zspecs are covered by the redshift grid
1369+ vec1u idb = where (state.zspec < opts.z_min );
1370+ if (!idb.empty ()) {
1371+ warning (" found " , idb.size (), " galaxies with z_spec lower than "
1372+ " the minimum value of the grid (z < " , opts.z_min , " )" );
1373+ warning (" will put them at z=" , opts.z_min );
1374+
1375+ state.zspec [idb] = opts.z_min ;
1376+ }
1377+
1378+ idb = where (state.zspec > opts.z_max );
1379+ if (!idb.empty ()) {
1380+ warning (" found " , idb.size (), " galaxies with z_spec lower than "
1381+ " the minimum value of the grid (z < " , opts.z_min , " )" );
1382+ warning (" will put them at z=" , opts.z_min );
1383+
1384+ state.zspec [idb] = opts.z_max ;
1385+ }
1386+ }
1387+
1388+ if (!state.zphot .empty ()) {
1389+ // Check that zphots are covered by the redshift grid
1390+ for (uint_t c : range (state.zphot .dims [1 ])) {
1391+ vec1u idb = where (state.zphot (_,c) < opts.z_min );
1392+ if (!idb.empty ()) {
1393+ if (c == 0 ) {
1394+ warning (" found " , idb.size (), " galaxies with z_phot lower than "
1395+ " the minimum value of the grid (z < " , opts.z_min , " )" );
1396+ warning (" will put them at z=" , opts.z_min );
1397+ }
1398+
1399+ state.zphot (idb,c) = opts.z_min ;
1400+ }
1401+
1402+ idb = where (state.zphot (_,c) > opts.z_max );
1403+ if (!idb.empty ()) {
1404+ if (c == 0 ) {
1405+ warning (" found " , idb.size (), " galaxies with z_phot lower than "
1406+ " the minimum value of the grid (z < " , opts.z_min , " )" );
1407+ warning (" will put them at z=" , opts.z_min );
1408+ }
1409+
1410+ state.zphot (idb,c) = opts.z_max ;
1411+ }
1412+ }
1413+ }
1414+
1415+ return true ;
1416+ }
1417+
14041418bool read_input (options_t & opts, input_state_t & state, const std::string& filename) {
14051419 // First read options from the parameter file
14061420 if (!read_params (opts, state, filename)) {
@@ -1432,5 +1446,10 @@ bool read_input(options_t& opts, input_state_t& state, const std::string& filena
14321446 return false ;
14331447 }
14341448
1449+ // Check and adjust input
1450+ if (!check_input (opts, state)) {
1451+ return false ;
1452+ }
1453+
14351454 return true ;
14361455}
0 commit comments