fits2csv module

This module provides utilities to convert FITS catalog files into Pandas DataFrames and CSV files. It handles parsing of FITS extensions, cleaning of array columns, and integration of external DNN predictions into the dataset.

fits2csv.add_prediction(catalog_path=PosixPath('/home/runner/work/Progetto_Computings/Progetto_Computings/files/gll_psc.csv'), input_dataframe=None, prediction_path=PosixPath('/home/runner/work/Progetto_Computings/Progetto_Computings/dnn/keras_models/prediction.npy'))[source]

Integrates the neural network predictions into the dataframe.

It adds a ‘CLASS_DNN’ column to the dataframe based on the predictions stored in the numpy file.

Parameters:
  • catalog_path (str or pathlib.Path, optional) – Path to the CSV catalog to load if input_dataframe is not provided. Defaults to custom_paths.csv_path.

  • input_dataframe (pandas.DataFrame, optional) – An existing DataFrame to modify. If provided, catalog_path is ignored.

  • prediction_path (str or pathlib.Path, optional) – Path to the numpy file (.npy) containing predictions. Defaults to custom_paths.prediction_path.

Returns:

The DataFrame with the added ‘CLASS_DNN’ column.

Return type:

pandas.DataFrame

fits2csv.fits_to_pandas(fits_file_path=PosixPath('/home/runner/work/Progetto_Computings/Progetto_Computings/files/gll_psc_v35.fit'), prediction_path=PosixPath('/home/runner/work/Progetto_Computings/Progetto_Computings/dnn/keras_models/prediction.npy'))[source]

Parses a FITS file and converts it into a clean Pandas DataFrame.

This function extracts data from the FITS extension, expands array columns (e.g., Flux_Band) into individual columns, normalizes string columns, and maps class codes to generic descriptions. It also optionally loads and merges DNN predictions.

Parameters:
  • fits_file_path (str or pathlib.Path) – Path to the input FITS catalog file. Defaults to custom_paths.fits_path.

  • prediction_path (str or pathlib.Path) – Path to the prediction file to integrate. Defaults to custom_paths.prediction_path.

Returns:

A cleaned and formatted DataFrame containing the catalog data.

Return type:

pandas.DataFrame