From 4370ce89b04a3490f3dbb18dcb98c44e01378bfe Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 10 Aug 2023 09:29:14 +0200 Subject: [PATCH] Split columns for each flavor (#28) * Split columns for each flavor * PEP8 --- fink_spins/generate_data.py | 2 -- fink_spins/ssoft.py | 57 +++++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/fink_spins/generate_data.py b/fink_spins/generate_data.py index e3c4215..b119859 100644 --- a/fink_spins/generate_data.py +++ b/fink_spins/generate_data.py @@ -17,10 +17,8 @@ import argparse import logging import io -import sys import os -import numpy as np import pandas as pd import rocks diff --git a/fink_spins/ssoft.py b/fink_spins/ssoft.py index 0ece0e6..27a071b 100644 --- a/fink_spins/ssoft.py +++ b/fink_spins/ssoft.py @@ -43,26 +43,8 @@ 'last_jd': {'type': 'double', 'description': 'Julian Date for the last detection in Fink, in UTC'}, 'H_1': {'type': 'double', 'description': 'Absolute magnitude for the ZTF filter band g'}, 'H_2': {'type': 'double', 'description': 'Absolute magnitude for the ZTF filter band r'}, - 'G1_1': {'type': 'double', 'description': 'G1 phase parameter for the ZTF filter band g'}, - 'G1_2': {'type': 'double', 'description': 'G1 phase parameter for the ZTF filter band r'}, - 'G2_1': {'type': 'double', 'description': 'G2 phase parameter for the ZTF filter band g'}, - 'G2_2': {'type': 'double', 'description': 'G2 phase parameter for the ZTF filter band r'}, - 'R': {'type': 'double', 'description': 'Oblateness of the object'}, - 'alpha0': {'type': 'double', 'description': 'Right ascension of the spin axis (EQJ2000), in degree'}, - 'delta0': {'type': 'double', 'description': 'Declination of the spin axis (EQJ2000), in degree'}, - 'obliquity': {'type': 'double', 'description': 'Obliquity of the spin axis, in degree'}, 'err_H_1': {'type': 'double', 'description': 'Uncertainty on the absolute magnitude for the ZTF filter band g'}, 'err_H_2': {'type': 'double', 'description': 'Uncertainty on the absolute magnitude for the ZTF filter band r'}, - 'err_G1_1': {'type': 'double', 'description': 'Uncertainty on the G1 phase parameter for the ZTF filter band g'}, - 'err_G1_2': {'type': 'double', 'description': 'Uncertainty on the G1 phase parameter for the ZTF filter band r'}, - 'err_G2_1': {'type': 'double', 'description': 'Uncertainty on the G2 phase parameter for the ZTF filter band g'}, - 'err_G2_2': {'type': 'double', 'description': 'Uncertainty on the G2 phase parameter for the ZTF filter band r'}, - 'err_R': {'type': 'double', 'description': 'Uncertainty on the oblateness'}, - 'err_alpha0': {'type': 'double', 'description': 'Uncertainty on the right ascension of the spin axis (EQJ2000), in degree'}, - 'err_delta0': {'type': 'double', 'description': 'Uncertainty on the declination of the spin axis (EQJ2000), in degree'}, - 'max_cos_lambda': {'type': 'double', 'description': 'Maximum of the absolute value of the cosine for the aspect angle'}, - 'mean_cos_lambda': {'type': 'double', 'description': 'Mean of the absolute value of the cosine for the aspect angle'}, - 'min_cos_lambda': {'type': 'double', 'description': 'Minimum of the absolute value of the cosine for the aspect angle'}, 'min_phase': {'type': 'double', 'description': 'Minimum phase angle of the observations used to compute the phase function, in degree'}, 'min_phase_1': {'type': 'double', 'description': 'Minimum phase angle of the observations used to compute the phase function for the ZTF filter band g, in degree'}, 'min_phase_2': {'type': 'double', 'description': 'Minimum phase angle of the observations used to compute the phase function for the ZTF filter band r, in degree'}, @@ -89,6 +71,45 @@ 'version': {'type': 'str', 'description': 'Version of the SSOFT YYYY.MM'}, } +COLUMNS_SHG1G2 = { + 'G1_1': {'type': 'double', 'description': 'G1 phase parameter for the ZTF filter band g'}, + 'G1_2': {'type': 'double', 'description': 'G1 phase parameter for the ZTF filter band r'}, + 'G2_1': {'type': 'double', 'description': 'G2 phase parameter for the ZTF filter band g'}, + 'G2_2': {'type': 'double', 'description': 'G2 phase parameter for the ZTF filter band r'}, + 'R': {'type': 'double', 'description': 'Oblateness of the object'}, + 'alpha0': {'type': 'double', 'description': 'Right ascension of the spin axis (EQJ2000), in degree'}, + 'delta0': {'type': 'double', 'description': 'Declination of the spin axis (EQJ2000), in degree'}, + 'obliquity': {'type': 'double', 'description': 'Obliquity of the spin axis, in degree'}, + 'err_G1_1': {'type': 'double', 'description': 'Uncertainty on the G1 phase parameter for the ZTF filter band g'}, + 'err_G1_2': {'type': 'double', 'description': 'Uncertainty on the G1 phase parameter for the ZTF filter band r'}, + 'err_G2_1': {'type': 'double', 'description': 'Uncertainty on the G2 phase parameter for the ZTF filter band g'}, + 'err_G2_2': {'type': 'double', 'description': 'Uncertainty on the G2 phase parameter for the ZTF filter band r'}, + 'err_R': {'type': 'double', 'description': 'Uncertainty on the oblateness'}, + 'err_alpha0': {'type': 'double', 'description': 'Uncertainty on the right ascension of the spin axis (EQJ2000), in degree'}, + 'err_delta0': {'type': 'double', 'description': 'Uncertainty on the declination of the spin axis (EQJ2000), in degree'}, + 'max_cos_lambda': {'type': 'double', 'description': 'Maximum of the absolute value of the cosine for the aspect angle'}, + 'mean_cos_lambda': {'type': 'double', 'description': 'Mean of the absolute value of the cosine for the aspect angle'}, + 'min_cos_lambda': {'type': 'double', 'description': 'Minimum of the absolute value of the cosine for the aspect angle'}, +} + +COLUMNS_HG1G2 = { + 'G1_1': {'type': 'double', 'description': 'G1 phase parameter for the ZTF filter band g'}, + 'G1_2': {'type': 'double', 'description': 'G1 phase parameter for the ZTF filter band r'}, + 'G2_1': {'type': 'double', 'description': 'G2 phase parameter for the ZTF filter band g'}, + 'G2_2': {'type': 'double', 'description': 'G2 phase parameter for the ZTF filter band r'}, + 'err_G1_1': {'type': 'double', 'description': 'Uncertainty on the G1 phase parameter for the ZTF filter band g'}, + 'err_G1_2': {'type': 'double', 'description': 'Uncertainty on the G1 phase parameter for the ZTF filter band r'}, + 'err_G2_1': {'type': 'double', 'description': 'Uncertainty on the G2 phase parameter for the ZTF filter band g'}, + 'err_G2_2': {'type': 'double', 'description': 'Uncertainty on the G2 phase parameter for the ZTF filter band r'}, +} + +COLUMNS_HG = { + 'G_1': {'type': 'double', 'description': 'G phase parameter for the ZTF filter band g'}, + 'G_2': {'type': 'double', 'description': 'G phase parameter for the ZTF filter band r'}, + 'err_G_1': {'type': 'double', 'description': 'Uncertainty on the G phase parameter for the ZTF filter band g'}, + 'err_G_2': {'type': 'double', 'description': 'Uncertainty on the G phase parameter for the ZTF filter band r'}, +} + @pandas_udf(MapType(StringType(), FloatType()), PandasUDFType.SCALAR) def estimate_sso_params_spark(ssnamenr, magpsf, sigmapsf, jd, fid, ra, dec, method, model): """ Extract phase and spin parameters from Fink alert data using Apache Spark