asteroid_spinprops 0.2.32__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. asteroid_spinprops/ssolib/dataprep.py +0 -346
  2. asteroid_spinprops/ssolib/modelfit.py +143 -252
  3. asteroid_spinprops/ssolib/periodest.py +126 -158
  4. asteroid_spinprops/ssolib/utils.py +164 -211
  5. asteroid_spinprops-1.0.1.dist-info/METADATA +186 -0
  6. asteroid_spinprops-1.0.1.dist-info/RECORD +10 -0
  7. asteroid_spinprops/ssolib/.ruff_cache/.gitignore +0 -2
  8. asteroid_spinprops/ssolib/.ruff_cache/0.13.2/1980339045096230685 +0 -0
  9. asteroid_spinprops/ssolib/.ruff_cache/CACHEDIR.TAG +0 -1
  10. asteroid_spinprops/ssolib/pipetools.py +0 -167
  11. asteroid_spinprops/ssolib/testing/atlas_x_ztf_testing/test_pqfile_1.parquet +0 -0
  12. asteroid_spinprops/ssolib/testing/atlas_x_ztf_testing/test_pqfile_2.parquet +0 -0
  13. asteroid_spinprops/ssolib/testing/ephemeris_testing/2000 WL152 +0 -1702
  14. asteroid_spinprops/ssolib/testing/ephemeris_testing/2001 PC +0 -94
  15. asteroid_spinprops/ssolib/testing/ephemeris_testing/2001 SG276 +0 -111
  16. asteroid_spinprops/ssolib/testing/ephemeris_testing/2008 GX32 +0 -93
  17. asteroid_spinprops/ssolib/testing/ephemeris_testing/2009 BE185 +0 -130
  18. asteroid_spinprops/ssolib/testing/ephemeris_testing/2011 EY17 +0 -101
  19. asteroid_spinprops/ssolib/testing/ephemeris_testing/2134 T-1 +0 -352
  20. asteroid_spinprops/ssolib/testing/ephemeris_testing/Bellmore +0 -2657
  21. asteroid_spinprops/ssolib/testing/ephemeris_testing/Dermott +0 -2971
  22. asteroid_spinprops/ssolib/testing/ephemeris_testing/Duke +0 -2026
  23. asteroid_spinprops/ssolib/testing/ephemeris_testing/Izenberg +0 -2440
  24. asteroid_spinprops/ssolib/testing/ephemeris_testing/Lermontov +0 -2760
  25. asteroid_spinprops/ssolib/testing/ephemeris_testing/Poullain +0 -1272
  26. asteroid_spinprops/ssolib/testing/ephemeris_testing/Sonneberga +0 -2756
  27. asteroid_spinprops/ssolib/testing/testing_ssoname_keys.pkl +0 -0
  28. asteroid_spinprops-0.2.32.dist-info/METADATA +0 -77
  29. asteroid_spinprops-0.2.32.dist-info/RECORD +0 -31
  30. {asteroid_spinprops-0.2.32.dist-info → asteroid_spinprops-1.0.1.dist-info}/WHEEL +0 -0
@@ -1,167 +0,0 @@
1
- import pandas as pd
2
- from tqdm import tqdm
3
- import rocks
4
- import numpy as np
5
-
6
- from asteroid_spinprops.ssolib.dataprep import filter_sso_data
7
- from asteroid_spinprops.ssolib.modelfit import get_fit_params, make_residuals_df
8
- from asteroid_spinprops.ssolib.periodest import (
9
- get_period_estimate,
10
- perform_residual_resampling,
11
- )
12
- from asteroid_spinprops.ssolib.utils import read_clean_data
13
-
14
-
15
- def process_single_sso(name: str, path_args: list, filtering=True) -> tuple | None:
16
- """
17
- Process a single Solar System Object to extract period estimation metrics.
18
-
19
- Parameters
20
- ----------
21
- name : str
22
- Name of the SSO to be processed.
23
- path_args : list
24
- Arguments required to locate and load SSO data,
25
- paths to parquet files and ephemeris cache.
26
-
27
- Returns
28
- -------
29
- tuple or None
30
- A tuple containing:
31
- - signal (tuple): Periodogram signal information (power, frequency and the 5 highest peaks).
32
- - window (tuple): Window function data (power, frequency and the 5 highest peaks).
33
- - noise (float): Signal noise level.
34
- - name (str): SSO name.
35
- - Nbs (int): Bootstrap score.
36
- - npts (int): Number of data points.
37
- Returns None if processing fails.
38
- """
39
- try:
40
- if filtering is True:
41
- data, _ = filter_sso_data(name, *path_args)
42
- else:
43
- data = read_clean_data(name, *path_args, return_rejects=False)
44
- mparams = get_fit_params(data=data, flavor="SHG1G2")
45
- resid_df = make_residuals_df(data, mparams)
46
- signal, window, noise = get_period_estimate(resid_df)
47
- _, Nbs = perform_residual_resampling(resid_df=resid_df)
48
- npts = len(data["Phase"].values[0])
49
- return signal, window, noise, name, Nbs, npts
50
- except Exception:
51
- return None
52
-
53
-
54
- def load_light_curve_data(file_path: str) -> pd.DataFrame:
55
- """
56
- Load a LCDB CSV file and return a dataframe containing objects periods.
57
-
58
- Parameters
59
- ----------
60
- file_path : str
61
- Path to the CSV file containing light curve details.
62
-
63
- Returns
64
- -------
65
- pd.DataFrame
66
- A DataFrame containing cleaned and filtered light curve data,
67
- with the 'Period' column converted to float and initial metadata rows skipped.
68
- """
69
- lc = pd.read_csv(file_path, skiprows=range(16))
70
- lc = lc[5:]
71
- lc["Period"] = lc["Period"].astype(float)
72
- return lc
73
-
74
-
75
- def fill_missing_periods_and_powers(periods, powers):
76
- """
77
- Replace incomplete period or power arrays with NaN-filled placeholders.
78
-
79
- Parameters
80
- ----------
81
- periods : list of array-like
82
- List of period arrays estimated for each SSO.
83
- powers : list of array-like
84
- List of power arrays associated with each estimated period.
85
-
86
- Returns
87
- -------
88
- None
89
- The input lists are modified in place.
90
- """
91
- filler = np.full(5, np.nan)
92
- for i in range(len(periods)):
93
- if len(periods[i]) < 5:
94
- periods[i] = filler
95
- if len(powers[i]) < 5:
96
- powers[i] = filler
97
-
98
-
99
- def collect_rocks_periods(names: list[str]) -> list[np.ndarray]:
100
- """
101
- Retrieve known periods from the SsODNet service for a list of SSOs.
102
-
103
- Parameters
104
- ----------
105
- names : list of str
106
- List of SSO names to query.
107
-
108
- Returns
109
- -------
110
- list of np.ndarray
111
- Each element is an array of known periods for the corresponding SSO & method.
112
- If no valid periods are found, returns two arrays with a single NaN.
113
- """
114
- periods = []
115
- methods = []
116
- for sso in tqdm(names, desc="Querying rocks"):
117
- r = rocks.Rock(sso, datacloud="spins")
118
- try:
119
- values = r.spins["period"].values.astype(np.float64)
120
- method = r.spins["method"].values
121
-
122
- if (values == [None] * len(values)).all():
123
- periods.append(np.array([np.nan]))
124
- methods.append(np.array([np.nan]))
125
- else:
126
- periods.append(values[~np.isnan(values)])
127
- methods.append(method[~np.isnan(values)])
128
- except Exception:
129
- periods.append(np.array([np.nan]))
130
- methods.append(np.array([np.nan]))
131
- return periods, methods
132
-
133
-
134
- def match_true_period(Ps, Procks, Pmethods):
135
- """
136
- Match the closest known period from SsODNet to each estimated period.
137
-
138
- Parameters
139
- ----------
140
- Ps : array-like
141
- Array of estimated periods
142
- Procks : list of np.ndarray
143
- List of known periods from Rocks for each SSO.
144
-
145
- Returns
146
- -------
147
- list
148
- The closest known period from Rocks for each estimate & method.
149
- Returns NaN if no valid match exists.
150
- """
151
- matched = []
152
- method = []
153
- for p_est, p_true, m_true in zip(Ps, Procks, Pmethods):
154
- if isinstance(p_true, float) or len(p_true) == 0 or np.isnan(p_true).all():
155
- matched.append(np.nan)
156
- method.append(np.nan)
157
- else:
158
- diffs = np.abs(p_est - p_true[:, None]) / p_true[:, None]
159
- min_idx = np.argmin(diffs, axis=0)
160
- matched.append(p_true[min_idx[0]])
161
- method.append(m_true[min_idx[0]])
162
- return matched, method
163
-
164
-
165
- def filter_sso_name(name, path_args):
166
- clean_data, rejects = filter_sso_data(name, *path_args, lc_filtering=False)
167
- return name, clean_data, rejects