KeyError: 'flux'
Hi,
in /src/pampelmuse/core/aperture.py, run_ap(...)
expects data to contain a column flux
:
valid = np.isfinite(data['flux'])
.
This leads to a key error because get_layer
(from /src/pampelmuse/instruments/instrument.py), called in AperPhoto
.call, only provides a column called values
instead of flux
.
return pd.DataFrame(columns=['x', 'y', 'value', 'variance'], dtype=np.float64)
04/26/2024 14:03:59[INFO ]: Initializing aperture spectrophotometry for possible PSF stars...
04/26/2024 14:03:59[WARNING ]: Data frame containing IFS coordinates not sorted. Reordering ...
04/26/2024 14:03:59[INFO ]: Using following stars in aperture spectrophotometry:
04/26/2024 14:03:59[INFO ]: ID x y
04/26/2024 14:03:59[INFO ]: 7 7.1 80.7
04/26/2024 14:03:59[INFO ]: 264 27.5 16.5
04/26/2024 14:03:59[INFO ]: 310 68.5 78.8
04/26/2024 14:03:59[INFO ]: Initializing aperture photometry, validating input...
04/26/2024 14:03:59[INFO ]: Centroids for 3 source(s) provided.
04/26/2024 14:03:59[INFO ]: Starting calculation with the following setup:
04/26/2024 14:03:59[INFO ]: aperture radius [pixel]: 3.0
04/26/2024 14:03:59[INFO ]: range of considered layers: 0 - 3722,
04/26/2024 14:03:59[INFO ]: binning factor of input data: 1
04/26/2024 14:03:59[INFO ]: pixel threshold [sigma]: 3.0
04/26/2024 14:03:59[INFO ]: calculating moments?: True
04/26/2024 14:03:59[INFO ]: background estimation: local
04/26/2024 14:03:59[INFO ]: number of CPUs: 1
04/26/2024 14:03:59[INFO ]: Processing layer 1/3722
Traceback (most recent call last):
File "/usr/users/jdammann/miniconda3/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
return self._engine.get_loc(casted_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
File "index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 7081, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 7089, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'flux'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/users/jdammann/miniconda3/bin/PampelMuse", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/users/jdammann/miniconda3/lib/python3.11/site-packages/pampelmuse/routines/run_pampelmuse.py", line 243, in main
args.func(config=config)
File "/usr/users/jdammann/miniconda3/lib/python3.11/site-packages/pampelmuse/routines/initfit.py", line 230, in initfit
selector.run_aperture_photometry(start=first_layer, stop=last_layer, n_cpu=n_cpu,
File "/usr/users/jdammann/miniconda3/lib/python3.11/site-packages/pampelmuse/core/source_selector.py", line 1310, in run_aperture_photometry
results, background = aperture(r_aper=radius, layer_range=(start, stop), background="local", n_cpu=n_cpu,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/users/jdammann/miniconda3/lib/python3.11/site-packages/pampelmuse/core/aperture.py", line 408, in __call__
_results.append(run_ap(input_data[0]))
^^^^^^^^^^^^^^^^^^^^^
File "/usr/users/jdammann/miniconda3/lib/python3.11/site-packages/pampelmuse/core/aperture.py", line 147, in run_ap
valid = np.isfinite(data['flux'])
~~~~^^^^^^^^
File "/usr/users/jdammann/miniconda3/lib/python3.11/site-packages/pandas/core/frame.py", line 4090, in __getitem__
indexer = self.columns.get_loc(key)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/users/jdammann/miniconda3/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3812, in get_loc
raise KeyError(key) from err
KeyError: 'flux'