Skip to content

Commit 9d68e81

Browse files
[SSOFT] Integrate SOCCA (#203)
* Remove abs value for lambda * Rename SSHG1G2 into SOCCA * Rename SSHG1G2 into SOCCA * Fix name
1 parent 1680a34 commit 9d68e81

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

fink_utils/sso/periods.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
from fink_utils.sso.spins import (
1818
estimate_sso_params,
19-
func_sshg1g2,
20-
func_hg1g2_with_spin,
19+
func_socca,
20+
func_shg1g2,
2121
func_hg1g2,
2222
func_hg12,
2323
func_hg,
@@ -110,17 +110,17 @@ def compute_residuals(
110110
filters: array of int
111111
Filter ID for each observation
112112
flavor: str
113-
Model flavor: SHG1G2, HG1G2, HG12, or HG
113+
Model flavor: SOCCA, SHG1G2, HG1G2, HG12, or HG
114114
phyparam: dict
115115
Dictionary containing reduced chi2, and estimated parameters and
116116
error on each parameters.
117117
ra: array of float, optional
118-
Array of RA angles, in degree. Only used for flavor in ["SHG1G2", "SSHG1G2"]
118+
Array of RA angles, in degree. Only used for flavor in ["SHG1G2", "SOCCA"]
119119
dec: array of float, optional
120-
Array of Dec angles, in degree. Only used for flavor in ["SHG1G2", "SSHG1G2"]
120+
Array of Dec angles, in degree. Only used for flavor in ["SHG1G2", "SOCCA"]
121121
times: array of float, optional
122122
Array of times, in JD with light travel correction applied.
123-
Only used for flavor="SSHG1G2"
123+
Only used for flavor="SOCCA"
124124
125125
Returns
126126
-------
@@ -133,14 +133,14 @@ def compute_residuals(
133133
# continue
134134
cond = filters == filtnum
135135

136-
if flavor == "SSHG1G2":
136+
if flavor == "SOCCA":
137137
pha = [
138138
np.deg2rad(phase[cond]),
139139
np.deg2rad(ra[cond]),
140140
np.deg2rad(dec[cond]),
141141
times[cond],
142142
]
143-
preds = func_sshg1g2(
143+
preds = func_socca(
144144
pha,
145145
phyparam["H_{}".format(filtnum)],
146146
phyparam["G1_{}".format(filtnum)],
@@ -158,7 +158,7 @@ def compute_residuals(
158158
np.deg2rad(ra[cond]),
159159
np.deg2rad(dec[cond]),
160160
]
161-
preds = func_hg1g2_with_spin(
161+
preds = func_shg1g2(
162162
pha,
163163
phyparam["H_{}".format(filtnum)],
164164
phyparam["G1_{}".format(filtnum)],

fink_utils/sso/spins.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def func_hg1g2(ph, h, g1, g2):
154154
return h + func1
155155

156156

157-
def func_hg1g2_with_spin(pha, h, g1, g2, R, alpha0, delta0):
157+
def func_shg1g2(pha, h, g1, g2, R, alpha0, delta0):
158158
"""Return f(H, G1, G2, R, alpha0, delta0) part of the lightcurve in mag space
159159
160160
Parameters
@@ -273,7 +273,7 @@ def subobserver_longitude(ra, dec, ra0, dec0, W):
273273
return W - np.arctan2(x, y)
274274

275275

276-
def func_sshg1g2(pha, h, g1, g2, alpha0, delta0, period, a_b, a_c, phi0):
276+
def func_socca(pha, h, g1, g2, alpha0, delta0, period, a_b, a_c, phi0):
277277
"""Return f(H, G1, G2, alpha0, delta0, period, a_b, a_c, phi0) part of the lightcurve in mag space
278278
279279
Parameters
@@ -389,8 +389,8 @@ def sfhg1g2_error_fun(params, phas, mags):
389389
return func_sfhg1g2(phas, params[0], params[1], params[2:]) - mags
390390

391391

392-
def func_sshg1g2_terminator(pha, h, g1, g2, alpha0, delta0, period, a_b, a_c, phi0):
393-
"""Extension of the ssHG1G2 model with correction for the non-illuminated part
392+
def func_socca_terminator(pha, h, g1, g2, alpha0, delta0, period, a_b, a_c, phi0):
393+
"""Extension of the SOCCA model with correction for the non-illuminated part
394394
395395
Notes
396396
-----
@@ -430,7 +430,7 @@ def func_sshg1g2_terminator(pha, h, g1, g2, alpha0, delta0, period, a_b, a_c, ph
430430
-------
431431
out: array of floats
432432
H - 2.5 log(f(G1G2)) - 2.5 log(f(spin, shape))
433-
Similar to the ssHG1G2 model, but including the correction for the non-illuminated part of the asteroid
433+
Similar to the SOCCA model, but including the correction for the non-illuminated part of the asteroid
434434
"""
435435
ph = pha[0]
436436
ra = pha[1]
@@ -770,7 +770,7 @@ def build_eqs_for_spins(x, filters, ph, ra, dec, rhs):
770770
mask = filters == filtername
771771

772772
myfunc = (
773-
func_hg1g2_with_spin(
773+
func_shg1g2(
774774
np.vstack([ph[mask].tolist(), ra[mask].tolist(), dec[mask].tolist()]),
775775
params_per_band[index][0],
776776
params_per_band[index][1],
@@ -857,7 +857,7 @@ def build_eqs_for_spin_shape(
857857
mask = filters == filtername
858858

859859
myfunc = (
860-
func_sshg1g2(
860+
func_socca(
861861
np.vstack([
862862
ph[mask].tolist(),
863863
ra[mask].tolist(),
@@ -883,7 +883,7 @@ def build_eqs_for_spin_shape(
883883
mask = filters == filtername
884884

885885
myfunc = (
886-
func_sshg1g2_terminator(
886+
func_socca_terminator(
887887
np.vstack([
888888
ph[mask].tolist(),
889889
ra[mask].tolist(),
@@ -966,10 +966,10 @@ def estimate_sso_params(
966966
dec: optional, array
967967
Declination [rad]. Required for SHG1G2 model.
968968
jd: options, array
969-
Observing time (JD), corrected for the light travel. Required for SSHG1G2 model.
969+
Observing time (JD), corrected for the light travel. Required for SOCCA model.
970970
model: str
971971
Parametric function. Currently supported:
972-
- SSHG1G2
972+
- SOCCA
973973
- SHG1G2 (default)
974974
- HG1G2
975975
- HG12
@@ -983,7 +983,7 @@ def estimate_sso_params(
983983
bounds: tuple of lists
984984
Parameters boundaries ([all_mins], [all_maxs]).
985985
Lists should be ordered as:
986-
- SSHG1G2: (H, G1, G2, alpha, delta, period, a_b, a_c, phi0)
986+
- SOCCA: (H, G1, G2, alpha, delta, period, a_b, a_c, phi0)
987987
- SHG1G2 (default): (H, G1, G2, R, alpha, delta)
988988
- HG1G2: (H, G1, G2)
989989
- HG12: (H, G12)
@@ -1068,17 +1068,17 @@ def estimate_sso_params(
10681068
... normalise_to_V=False)
10691069
>>> assert len(shg1g2) == 41, "Found {} parameters: {}".format(len(shg1g2), shg1g2)
10701070
1071-
>>> sshg1g2 = estimate_sso_params(
1071+
>>> socca = estimate_sso_params(
10721072
... pdf['i:magpsf_red'].values,
10731073
... pdf['i:sigmapsf'].values,
10741074
... np.deg2rad(pdf['Phase'].values),
10751075
... pdf['i:fid'].values,
10761076
... np.deg2rad(pdf['i:ra'].values),
10771077
... np.deg2rad(pdf['i:dec'].values),
10781078
... pdf['i:jd'].values,
1079-
... model='SSHG1G2',
1079+
... model='SOCCA',
10801080
... normalise_to_V=False)
1081-
>>> assert len(sshg1g2) == 45, "Found {} parameters: {}".format(len(sshg1g2), sshg1g2)
1081+
>>> assert len(socca) == 45, "Found {} parameters: {}".format(len(socca), socca)
10821082
10831083
# You can also combine data into single V band
10841084
>>> shg1g2 = estimate_sso_params(
@@ -1103,7 +1103,7 @@ def estimate_sso_params(
11031103
... model='toto',
11041104
... normalise_to_V=True) # doctest: +IGNORE_EXCEPTION_DETAIL
11051105
Traceback (most recent call last):
1106-
AssertionError: model toto is not understood. Please choose among: SSHG1G2, SHG1G2, HG1G2, HG12, HG
1106+
AssertionError: model toto is not understood. Please choose among: SOCCA, SHG1G2, HG1G2, HG12, HG
11071107
"""
11081108
if normalise_to_V:
11091109
color = compute_color_correction(filters)
@@ -1112,7 +1112,7 @@ def estimate_sso_params(
11121112
else:
11131113
ydata = magpsf_red
11141114

1115-
if model in ["SSHG1G2", "SHG1G2"]:
1115+
if model in ["SOCCA", "SHG1G2"]:
11161116
outdic = fit_spin(
11171117
ydata,
11181118
sigmapsf,
@@ -1143,7 +1143,7 @@ def estimate_sso_params(
11431143
)
11441144
else:
11451145
raise AssertionError(
1146-
"model {} is not understood. Please choose among: SSHG1G2, SHG1G2, sfHG1G2, HG1G2, HG12, HG".format(
1146+
"model {} is not understood. Please choose among: SOCCA, SHG1G2, sfHG1G2, HG1G2, HG12, HG".format(
11471147
model
11481148
)
11491149
)
@@ -1179,7 +1179,7 @@ def fit_legacy_models(
11791179
- func_hg
11801180
bounds: tuple of lists
11811181
Parameters boundaries for `func` ([all_mins], [all_maxs]).
1182-
Defaults are given for `func_hg1g2_with_spin`: (H, G1, G2, R, alpha0, delta0).
1182+
Defaults are given for `func_shg1g2`: (H, G1, G2, R, alpha0, delta0).
11831183
11841184
Returns
11851185
-------
@@ -1452,7 +1452,7 @@ def fit_spin(
14521452
"""Fit for phase curve parameters
14531453
14541454
SHG1G2: (H^b, G_1^b, G_2^b, alpha, delta, R)
1455-
SSHG1G2: (H^b, G_1^b, G_2^b, alpha, delta, period, a_b, a_c, phi0, t0)
1455+
SOCCA: (H^b, G_1^b, G_2^b, alpha, delta, period, a_b, a_c, phi0, t0)
14561456
14571457
Code for quality `fit`:
14581458
0: success
@@ -1494,12 +1494,12 @@ def fit_spin(
14941494
dec_s: optional, np.array
14951495
Array of size N containing the solar DEC (radian), required if terminator=True
14961496
jd: optional, array
1497-
Observing time (JD), corrected for the light travel. Required for SSHG1G2 model.
1497+
Observing time (JD), corrected for the light travel. Required for SOCCA model.
14981498
p0: list
14991499
Initial guess for parameters. Note that even if
15001500
there is several bands `b`, we take the same initial guess for all (H^b, G1^b, G2^b).
15011501
bounds: tuple of lists
1502-
Parameters boundaries for `func_hg1g2_with_spin` ([all_mins], [all_maxs]).
1502+
Parameters boundaries for `func_shg1g2` ([all_mins], [all_maxs]).
15031503
Lists should be ordered as: (H, G1, G2, R, alpha, delta). Note that even if
15041504
there is several bands `b`, we take the same bounds for all (H^b, G1^b, G2^b).
15051505
@@ -1509,12 +1509,12 @@ def fit_spin(
15091509
Dictionary containing reduced chi2, and estimated parameters and
15101510
error on each parameters.
15111511
"""
1512-
assert model in ["SHG1G2", "SSHG1G2"], model
1512+
assert model in ["SHG1G2", "SOCCA"], model
15131513

15141514
if p0 is None:
15151515
if model == "SHG1G2":
15161516
p0 = [15.0, 0.15, 0.15, 0.8, np.pi, 0.0]
1517-
elif model == "SSHG1G2":
1517+
elif model == "SOCCA":
15181518
p0 = [15.0, 0.15, 0.15, np.pi, 0.0, 1, 1.05, 1.05, 0.0]
15191519

15201520
if bounds is None:
@@ -1523,7 +1523,7 @@ def fit_spin(
15231523
[-3, 0, 0, 3e-1, 0, -np.pi / 2],
15241524
[30, 1, 1, 1, 2 * np.pi, np.pi / 2],
15251525
)
1526-
elif model == "SSHG1G2":
1526+
elif model == "SOCCA":
15271527
bounds = (
15281528
[-3, 0, 0, 0, -np.pi / 2, 2.2 / 24.0, 1, 1, -np.pi / 2],
15291529
[30, 1, 1, 2 * np.pi, np.pi / 2, 1000, 5, 5, np.pi / 2],
@@ -1532,7 +1532,7 @@ def fit_spin(
15321532
ufilters = np.unique(filters)
15331533
if model == "SHG1G2":
15341534
params = ["R", "alpha0", "delta0"]
1535-
elif model == "SSHG1G2":
1535+
elif model == "SOCCA":
15361536
params = ["alpha0", "delta0", "period", "a_b", "a_c", "phi0"]
15371537

15381538
phase_params = ["H", "G1", "G2"]
@@ -1559,7 +1559,7 @@ def fit_spin(
15591559
if model == "SHG1G2":
15601560
func = build_eqs_for_spins
15611561
args = (filters, phase, ra, dec, magpsf_red)
1562-
elif model == "SSHG1G2":
1562+
elif model == "SOCCA":
15631563
func = build_eqs_for_spin_shape
15641564
if not terminator:
15651565
args = (filters, phase, ra, dec, jd, magpsf_red)
@@ -1618,9 +1618,9 @@ def fit_spin(
16181618
)
16191619
outdic = {
16201620
"chi2red": chisq_red,
1621-
"min_cos_lambda": np.min(np.abs(geo)),
1622-
"mean_cos_lambda": np.mean(np.abs(geo)),
1623-
"max_cos_lambda": np.max(np.abs(geo)),
1621+
"min_cos_lambda": np.min(geo),
1622+
"mean_cos_lambda": np.mean(geo),
1623+
"max_cos_lambda": np.max(geo),
16241624
"status": res_lsq.status,
16251625
"fit": 0,
16261626
}

fink_utils/sso/ssoft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
"version": {"type": "str", "description": "Version of the SSOFT YYYY.MM"},
157157
}
158158

159-
COLUMNS_SSHG1G2 = {
159+
COLUMNS_SOCCA = {
160160
"G1_1": {
161161
"type": "double",
162162
"description": "G1 phase parameter for the ZTF filter band g",

0 commit comments

Comments
 (0)