A step-by-step guide to using the package

Code
from datetime import timedelta
from space_analysis.utils.speasy import get_polars_ldf
from discontinuitypy.mission.wind import WindConfigBase, wi_mfi_h2_bgse
from discontinuitypy.config import SpeasyIDsConfig
from discontinuitypy.core.pipeline import ids_finder
from discontinuitypy.detection import detect_variance, detect_gradient
from speasy.core.requests_scheduling.request_dispatch import init_cdaweb
from rich import print

init_cdaweb()
/home/runner/work/discontinuitypy/discontinuitypy/.pixi/envs/default/lib/python3.12/subprocess.py:1885: RuntimeWarning: Using fork() can cause Polars to deadlock in the child process.
In addition, using fork() with Python in general is a recipe for mysterious
deadlocks and crashes.

The most likely reason you are seeing this error is because you are using the
multiprocessing module on Linux, which uses fork() by default. This will be
fixed in Python 3.14. Until then, you want to use the "spawn" context instead.

See https://docs.pola.rs/user-guide/misc/multiprocessing/ for details.

  self.pid = _fork_exec(
2024-11-22 20:06:05,674 INFO worker.py:1819 -- Started a local Ray instance.
Code
timerange = ["2021-05-03", "2021-05-04"]
tau = timedelta(seconds=30)
Code
data = get_polars_ldf(wi_mfi_h2_bgse, 'cda', timerange)
data
/home/runner/work/discontinuitypy/discontinuitypy/.pixi/envs/default/lib/python3.12/site-packages/speasy/core/data_containers.py:17: UserWarning: no explicit representation of timezones available for np.datetime64
  return np.searchsorted(time, np.datetime64(key, 'ns'), side='left')
naive plan: (run LazyFrame.explain(optimized=True) to see the optimized plan)

DF ["Bx (GSE)", "By (GSE)", "Bz (GSE)", "time"]; PROJECT */4 COLUMNS; SELECTION: None
Code
detect_kwargs = {"tau": tau}
ids_finder(data, detect_kwargs=detect_kwargs)
2024-11-22 20:06:20.684 | INFO     | discontinuitypy.detection.variance:_time_resolution:284 - Time resolution not provided. Using median time difference: 0:00:00.092000
shape: (179, 33)
time index_diff len std index_std index_fluctuation tstart tstop t_us t_ds fit.vars.amplitude fit.vars.sigma t.d_time d_star fit.vars.c fit.stat.rsquared fit.stat.chisqr e_max e_min b_mag b_n B.vec.before B.vec.after B.before B.after db_mag bn_over_b db_over_b db_over_b_max dB_lmn dB n_cross duration
datetime[μs] f64 u32 f64 f64 f64 datetime[ns] datetime[μs] datetime[ns] datetime[ns] f64 f64 datetime[ns] f64 f64 f64 f64 array[f64, 3] array[f64, 3] f64 f64 array[f64, 3] array[f64, 3] f64 f64 f64 f64 f64 f64 array[f64, 3] array[f64, 3] array[f64, 3] f64
2021-05-03 00:30:30 0.125344 326 0.6324 2.345717 1.298162 2021-05-03 00:30:15 2021-05-03 00:30:45 2021-05-03 00:30:24.214500 2021-05-03 00:30:38.658500 1.313742 1.476119 2021-05-03 00:30:31.730145047 0.222499 5.899705 0.959526 1.720214 [-0.673699, 0.228118, 0.702916] [0.456659, -0.619326, 0.638669] 9.71777 -0.531629 [5.675399, -7.288656, -0.50505] [7.440135, -6.891409, -0.574069] 9.251473 10.157593 0.90612 -0.054707 0.093244 0.105107 [-1.764736, -0.397247, 0.069019] [-1.45123, 0.146876, 1.072016] [0.443778, -0.582931, 0.680626] 2.952238
2021-05-03 00:34:30 0.208116 326 0.992148 2.78534 1.870381 2021-05-03 00:34:15 2021-05-03 00:34:45 2021-05-03 00:34:23.414500 2021-05-03 00:34:40.894500 -6.408313 10.905394 2021-05-03 00:34:28.029424257 -0.146907 2.743311 0.816297 21.829383 [-0.816711, -0.489086, 0.306232] [-0.356477, 0.84494, 0.398748] 9.750112 8.781124 [1.063286, 4.503267, 8.553347] [-2.962921, 3.783238, 8.59017] 9.724698 9.842907 0.118209 0.900618 0.012124 0.097433 [4.026207, 0.720029, -0.036822] [2.948395, 2.156157, -1.840676] [-0.690227, 0.48683, -0.535336] 21.810788
2021-05-03 00:39:45 0.552096 326 2.190388 5.495312 4.506598 2021-05-03 00:39:30 2021-05-03 00:40:00 2021-05-03 00:39:30.418500 2021-05-03 00:39:55.350500 7.710203 6.123306 2021-05-03 00:39:46.375026413 0.314789 -3.437745 0.86063 148.377987 [-0.616492, -0.671008, 0.411929] [-0.374726, 0.710173, 0.596016] 11.34035 10.858305 [-3.969673, 1.634949, 10.270444] [3.180624, 2.280405, 10.644852] 11.131638 11.341494 0.209856 0.957493 0.018505 0.059703 [-7.150297, -0.645457, -0.374409] [-4.101444, -4.669544, 3.613455] [0.796464, -0.288207, 0.531584] 12.246613
2021-05-03 00:47:00 0.201195 326 0.764962 2.750701 1.5489 2021-05-03 00:46:45 2021-05-03 00:47:15 2021-05-03 00:46:57.998500 2021-05-03 00:47:14.926500 5.052715 7.302624 2021-05-03 00:47:01.640399350 0.172976 -3.231779 0.775804 28.786461 [-0.133932, -0.662663, 0.736845] [-0.207375, 0.745823, 0.633043] 12.379368 12.345059 [-2.449219, 0.500697, 12.196131] [1.716941, -0.054783, 12.269261] 12.449698 12.388933 -0.060765 0.997229 0.004909 0.018874 [-4.166161, 0.55548, -0.07313] [-1.111435, -2.743999, 2.984289] [0.945615, -0.030835, 0.323822] 14.605248
2021-05-03 00:52:00 0.16337 326 1.164931 2.635435 1.224977 2021-05-03 00:51:45 2021-05-03 00:52:15 2021-05-03 00:51:58.654500 2021-05-03 00:52:02.610500 3.296497 0.13873 2021-05-03 00:51:58.997959953 5.940484 -2.456942 0.99365 0.172111 [-0.041939, -0.824516, 0.564282] [-0.407089, 0.529874, 0.743984] 12.286048 12.170159 [-2.230594, 1.312538, 12.16445] [0.953278, 1.477694, 12.157318] 12.436726 12.283839 -0.152887 0.990567 0.012444 0.016755 [-3.183873, -0.165156, 0.007132] [0.020068, -2.596148, 1.850402] [0.954578, 0.177797, 0.2391] 0.27746
2021-05-03 21:38:15 0.466696 326 0.887063 2.105667 1.89228 2021-05-03 21:38:00 2021-05-03 21:38:30 2021-05-03 21:38:00.422500 2021-05-03 21:38:11.186500 -2.160909 0.245154 2021-05-03 21:38:09.971531761 -2.203624 0.442165 0.769161 14.877331 [0.529513, 0.158648, 0.833335] [-0.847946, 0.070547, 0.525367] 4.760393 0.244848 [1.415673, 4.550119, 0.197403] [-2.0199, 4.405272, 0.257623] 4.769348 4.853121 0.083773 0.051435 0.017598 0.085579 [3.435572, 0.144847, -0.06022] [-1.866688, -0.683444, -2.806448] [-0.835162, 0.024889, 0.549441] 0.490308
2021-05-03 22:33:30 0.170299 326 0.545855 2.079462 1.260535 2021-05-03 22:33:15 2021-05-03 22:33:45 2021-05-03 22:33:24.750500 2021-05-03 22:33:34.686500 3.048572 4.436167 2021-05-03 22:33:28.742676129 0.171802 -1.759264 0.945931 1.342413 [-0.935648, -0.242784, 0.256162] [-0.227557, 0.969783, 0.087972] 4.718245 4.621603 [-0.863235, -0.828505, 4.613656] [0.798578, -0.774968, 4.605322] 4.766279 4.737858 -0.028421 0.979517 0.006024 0.033057 [-1.661812, -0.053538, 0.008334] [-1.538531, -0.41283, 0.476497] [0.255627, 0.149739, 0.955109] 8.872334
2021-05-03 22:50:45 0.32467 326 0.907223 2.209682 1.208073 2021-05-03 22:50:30 2021-05-03 22:51:00 2021-05-03 22:50:33.954500 2021-05-03 22:50:53.090500 -2.033492 0.718609 2021-05-03 22:50:39.467709402 -0.70744 1.189105 0.942473 8.871784 [0.994594, 0.003999, 0.103763] [-0.004575, 0.999975, 0.005322] 4.878452 4.786009 [1.533312, 0.102907, 4.677923] [-1.405932, -0.108679, 4.694377] 4.923881 4.901595 -0.022286 0.981051 0.004568 0.056296 [2.939245, 0.211586, -0.016454] [-2.94538, 0.00348, -0.094455] [-0.03206, -0.007056, 0.999461] 1.437219
2021-05-03 22:52:45 0.310895 326 0.797825 3.197615 1.347189 2021-05-03 22:52:30 2021-05-03 22:53:00 2021-05-03 22:52:36.590500 2021-05-03 22:52:46.066500 -2.489106 1.558663 2021-05-03 22:52:40.073399098 -0.399237 1.207817 0.949772 3.125453 [-0.556024, -0.026706, 0.830737] [-0.009756, 0.999625, 0.025605] 4.98287 4.878115 [0.997896, 0.097368, 4.806209] [-1.603642, 0.642649, 4.67341] 4.909676 4.982512 0.072836 0.978977 0.014617 0.048194 [2.601538, -0.545281, 0.132799] [1.901002, -0.066617, -1.861377] [-0.696347, 0.074434, -0.713835] 3.117326
2021-05-03 23:40:30 0.430462 326 0.926707 2.399418 1.270198 2021-05-03 23:40:15 2021-05-03 23:40:45 2021-05-03 23:40:15.766500 2021-05-03 23:40:40.054500 -3.682839 4.194496 2021-05-03 23:40:20.731550908 -0.219504 2.464244 0.962084 8.113988 [-0.720814, -0.370653, 0.585699] [0.667771, -0.597827, 0.443492] 5.361672 -3.940375 [1.937234, -3.358265, -3.662144] [-1.431728, -3.455101, -3.837568] 5.333115 5.358591 0.025476 -0.734915 0.004751 0.049321 [3.368961, 0.096836, 0.175424] [2.329242, 1.422418, -1.985299] [-0.596089, -0.129799, -0.792357] 8.388992
Code
class WindConfig(WindConfigBase, SpeasyIDsConfig):
    pass
    
config = WindConfig(
    timerange = timerange,
    detect_kwargs=detect_kwargs,
)
Code
result, path = config.produce_or_load()
/home/runner/work/discontinuitypy/discontinuitypy/.pixi/envs/default/lib/python3.12/site-packages/speasy/core/data_containers.py:17: UserWarning: no explicit representation of timezones available for np.datetime64
  return np.searchsorted(time, np.datetime64(key, 'ns'), side='left')
2024-11-22 20:06:23.955 | INFO     | discontinuitypy.config:_get_mag_data:143 - Setting time resolution to 0:00:00.092000
File /home/runner/work/discontinuitypy/discontinuitypy/data/Wind_tr=20210503-20210504_detect_func=detect_variance_detect_kwargs=(tau=0:00:30,ts=0:00:00.092000)_method=fit.arrow does not exist. Producing it now...
2024-11-22 20:06:32.632 | INFO     | discontinuitypy.integration:update_events_with_temp_data:193 - Ion temperature data is not available.
2024-11-22 20:06:32.632 | INFO     | discontinuitypy.integration:update_events_with_temp_data:201 - Electron temperature data is not available.
Could not save file. Error: No such file or directory (os error 2)
File /home/runner/work/discontinuitypy/discontinuitypy/data/Wind_tr=20210503-20210504_updated_detect_func=detect_variance_detect_kwargs=(tau=0:00:30,ts=0:00:00.092000)_method=fit.arrow does not exist. Producing it now...
Could not save file. Error: No such file or directory (os error 2)

Inspecting the magnetic data…

Code
config.mag_meta.data[0].plot()