DAS-OATs / astrocook

8 stars 4 forks source link

Fix the convolution #312

Open gcupani opened 1 year ago

gcupani commented 1 year ago

Astrocook convolves the model with a LSF which is sub-optimally sampled at the wavelength grid of the spectrum. It should be oversampled to avoid mis-evaluating the model at the spectrum wavelengths.

Possible strategy: edit the convolution function to over-sample the spectrum and the LSF 10 times more finely and integrate their convolution into the original wavelength step. This new function should be accepted by Lmfit.

gcupani commented 1 year ago

Issue is almost solved; still an error message that appears when calling "Fit systems":

Traceback (most recent call last):                                                                                                                                   
  File "/Volumes/GoogleDrive-110625037481089626894/My Drive/GitHub/astrocook/astrocook/gui_dialog.py", line 134, in _on_run
    out = m(**p_l)
  File "/Volumes/GoogleDrive-110625037481089626894/My Drive/GitHub/astrocook/astrocook/cookbook_absorbers.py", line 1290, in systs_fit
    self._systs_cycle(mod=_mod, verbose=False)
  File "/Volumes/GoogleDrive-110625037481089626894/My Drive/GitHub/astrocook/astrocook/cookbook_absorbers.py", line 724, in _systs_cycle
    self._mods_recreate(mod_new=mod, verbose=verbose)
  File "/Volumes/GoogleDrive-110625037481089626894/My Drive/GitHub/astrocook/astrocook/cookbook_absorbers.py", line 308, in _mods_recreate
    return self._mods_recreate2(**kwargs)
  File "/Volumes/GoogleDrive-110625037481089626894/My Drive/GitHub/astrocook/astrocook/cookbook_absorbers.py", line 470, in _mods_recreate2
    N_tot=N_tot, N_tot_specs=N_tot_specs)
  File "/Volumes/GoogleDrive-110625037481089626894/My Drive/GitHub/astrocook/astrocook/syst_model.py", line 671, in _new_voigt
    self._make_lines_psf(N_tot)
  File "/Volumes/GoogleDrive-110625037481089626894/My Drive/GitHub/astrocook/astrocook/syst_model.py", line 478, in _make_lines_psf
    d['resol'] = self._spec.t['resol'][c]
  File "/Users/guido/opt/anaconda3/envs/astrocook/lib/python3.7/site-packages/astropy/table/table.py", line 1867, in __getitem__
    return self.columns[item]
  File "/Users/guido/opt/anaconda3/envs/astrocook/lib/python3.7/site-packages/astropy/table/table.py", line 246, in __getitem__
    return OrderedDict.__getitem__(self, item)
KeyError: 'resol'

Apparently the resol column, which was full of good data, becomes filled with NaNs.