gaia-dpci / GaiaXPy

Gaia BP/RP spectra package
BSD 3-Clause "New" or "Revised" License
36 stars 9 forks source link

Error instead of warning when error_correction cannot be applied (GaiaXPy 2.1.1) #103

Closed druzm closed 4 months ago

druzm commented 4 months ago

The generator tool can only apply error correction over built-in systems (this is systems shipped with the package) as a correction table file is required to correct the errors. In previous versions of the package, trying to apply error correction over an additional system (one loaded by the user via the load_additional_systems function) would result in a user warning ("UserWarning: System USER_AnAdditionalSystem does not have a correction table. The program will not apply error correction over this system."), but the program would still run successfully and would apply the error correction exclusively over the systems with a correction table, leaving the systems without a correction table 'untouched'.

In the latest version of the package (2.1.1), an error is raised instead. This is problematic when a user wants to generate synthetic photometry for different systems at once but some of the systems are built-in and some others are not.

To reproduce, simply run:

from gaiaxpy import generate, PhotometricSystem, load_additional_systems

PhotometricSystem = load_additional_systems('/path/to/systems/')

generate(input, photometric_system=PhotometricSystem.USER_AnAdditionalSystem, error_correction=True)

Trace:

File "...gaiaxpy/generator/generator.py", line 49, in generate
  return _generate(input_object=input_object, photometric_system=ps, output_path=op,
File "...GaiaXPy/installed/2.1.1/gaiaxpy/generator/generator.py", line 92, in _generate
  validate_error_correction(internal_phot_system, error_correction)
File "...GaiaXPy/installed/2.1.1/gaiaxpy/core/generic_functions.py", line 352, in validate_error_correction
  raise ValueError('Photometry is requested for a non-built-in system, but error_correction is set to True. '
ValueError: Photometry is requested for a non-built-in system, but error_correction is set to True.
Error correction is only implemented for built-in systems.
druzm commented 4 months ago

Close with merge #105