igmhub / picca

set of tools for continuum fitting, correlation function calculation, cosmological fits...
GNU General Public License v3.0
31 stars 21 forks source link

Protect do_xcf against empty in_dir #341

Closed jmarclegoff closed 6 years ago

jmarclegoff commented 6 years ago

If in_dir is empty, the user gets a cryptic message :

File "../../picca/bin/do_xcf.py", line 206, in <module>
    d_min_pix = cosmo.r_comoving(z_min_pix)
File "/global/u2/l/legoff/.conda/envs/myenv/lib/python2.7/sitepackages/scipy/interpolate/polyint.py", line 79, in __call__
    y = self._evaluate(x)
  File "/global/u2/l/legoff/.conda/envs/myenv/lib/python2.7/sitepackages/scipy/interpolate/interpolate.py", line 610, in _evaluate
    below_bounds, above_bounds = self._check_bounds(x_new)
  File "/global/u2/l/legoff/.conda/envs/myenv/lib/python2.7/sitepackages/scipy/interpolate/interpolate.py", line 642, in _check_bounds
    raise ValueError("A value in x_new is above the interpolation "
ValueError: A value in x_new is above the interpolation range.

I suggest adding after line 149 of do_xcf.py, something like :

    if (len(fi) == 0) :
        print "no file found in in_dir"
        exit(0)
londumas commented 6 years ago

@jmarclegoff, with @ngbusca we want to move reading the files to py/picca/io.py at some point. That is where the test should be at the end.