igmhub / picca

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

continuum fitting struggling with really noiseless mocks #819

Open alxogm opened 2 years ago

alxogm commented 2 years ago

picca_deltas.py breaks at the first iteration of continuum fitting for noiseless mocks (exptime~1e10), with the following error:

Continuum fitting: ending iteration 0 of 5
 Mean quantities in observer-frame
 loglam    eta      var_lss  fudge    chi2     num_pix 
 3.561e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.570e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.579e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.589e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.598e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.607e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.616e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.625e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.635e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.644e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.653e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.662e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.671e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.681e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.690e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.699e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.708e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.717e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.727e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
 3.736e+00 1.00e+00 1.00e-01 1.00e-07 0.00e+00 0 
Traceback (most recent call last):
  File "/global/homes/a/alxogm/desi/code/igmhub/picca/bin/picca_deltas.py", line 1025, in <module>
    main(cmdargs)
  File "/global/homes/a/alxogm/desi/code/igmhub/picca/bin/picca_deltas.py", line 721, in main
    Forest.get_eta = interp1d(log_lambda[w],
  File "/global/homes/a/alxogm/.conda/envs/picca/lib/python3.8/site-packages/scipy/interpolate/interpolate.py", line 467, in __init__
    self._y = self._reshape_yi(self.y)
  File "/global/homes/a/alxogm/.conda/envs/picca/lib/python3.8/site-packages/scipy/interpolate/polyint.py", line 110, in _reshape_yi
    return yi.reshape((yi.shape[0], -1))
ValueError: cannot reshape array of size 0 into shape (0,newaxis)

This is traced back to this line, https://github.com/igmhub/picca/blob/bbada92ee03376b1dae7adb1054d0d10dd6d93a4/py/picca/prep_del.py#L118

since the var_pipe calculated is below this limit, and therefore no bins are retained. A simple fix is to lower down this min value for mocks, I'm not sure is a good idea to lower it down in general, but I think it would better to allow eta and fudge be fixed for mocks (as @andreufont has been requesting for a while I think)... @iprafols @Waelthus any thoughts?

andreufont commented 2 years ago

Exactly, we have to be able to run the analysis without fudge or eta varying, or with a value of sigma_lss that is provided by the user. The amount of optional arguments in picca_deltas is always growing, so hopefully we can also use some sort of configuration file to specify all these options.

Waelthus commented 2 years ago

I'd guess changing var_pipe_min globally would also change all results produced by picca_deltas subtly, which would be annoying at least for the tests (changing jointly with num_var_bins might work if we never had pixels below the minimum before). If having the user provide a value for eta, fudge, var_lss is enough, it could easily be added (similarly to e.g. use_constant_weights which skips the compute_var_stats function). If we want to compute some of those values and fix others, I guess we'd run into the same problem @alxogm described above without additional changes...

andreufont commented 2 years ago

There is another clear case where "user provided" values for these global functions would be useful. I'm now analysing 10 realisations of mocks that are equal in everythin except the random seed. Computing these global functions 10 times is a waste of time, we know that they are going to be very similar. We should be able to recycle the global functions computed from the first iteration for all N-1 remaining analyses

iprafols commented 1 year ago

I think this was addressed by the introduction of the classes Dr16ExpectedFluxFixedEta and similar. @alxogm do you agree? If so, we can close this issue