mboquien / cigale

10 stars 0 forks source link

Attribute error on SaveFluxes #78

Open pedro-acunha opened 3 months ago

pedro-acunha commented 3 months ago

Hi,

When switching from the pdfanalysis to savefluxes I ran into an attribute error:

AttributeError: 'NoneType' object has no attribute 'from_index'

I have went through the source code on gitlab and I think that I managed to find the culprit behind this. On pdf_analysis/init.py we have:

# Store the grid of parameters in a manager to facilitate the
        # computation of the models
        params = ParametersManager(conf)

        # Store the observations in a manager which sanitises the data, checks
        # all the required fluxes are present, adding errors if needed,
        # discarding invalid fluxes, etc.
        obs = ObservationsManager(conf, params)
        obs.save("observations")

        results = self._compute(conf, obs, params)

On the other hand, "savefluxes" does not pass the "params" input parameter to "ObservationsManager":

observations = ObservationsManager(conf)

  # The parameters manager allows us to retrieve the models parameters
  # from a 1D index. This is useful in that we do not have to create
  # a list of parameters as they are computed on-the-fly. It also has
  # nice goodies such as finding the index of the first parameter to
  # have changed between two indices or the number of models.
  params = ParametersManager(conf)

  self._compute_models(conf, observations, params)

It seems that the straightforward fix to this is to update the savefluxes.SaveFluxes function to be like the former one:

        params = ParametersManager(conf)

observations = ObservationsManager(conf, params)
  self._compute_models(conf, observations, params)

However, I am not sure if this would break the logic behind the code. Would this work as a fix or am I missing something else?

mboquien commented 3 months ago

Thanks for the report. Could you apply the following patch and let me know if that fixes the issue? https://gitlab.lam.fr/cigale/cigale/-/commit/f406bf0249ba385251ce7a8a1731588dcde699bf Thanks!

pedro-acunha commented 3 months ago

It fixed the issue. Thanks!

Just to report that warnings appeared for the entire list of sed modules, when savefluxes is called for the first time. Here is an example:

WARNING: VerifyWarning: Keyword name 'universe.age' is greater than 8 characters or contains characters not allowed by the FITS standard; a HIERARCH card will be created.