tsp 1.4.9__py3-none-any.whl → 1.5.3__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.

Potentially problematic release.


This version of tsp might be problematic. Click here for more details.

Files changed (44) hide show
  1. tsp/__init__.py +3 -2
  2. tsp/__meta__.py +1 -1
  3. tsp/core.py +15 -8
  4. tsp/dataloggers/FG2.py +13 -0
  5. tsp/dataloggers/GP5W.py +14 -1
  6. tsp/dataloggers/RBRXL800.py +190 -0
  7. tsp/dataloggers/RBRXR420.py +307 -0
  8. tsp/dataloggers/test_files/004448.DAT +2543 -0
  9. tsp/dataloggers/test_files/004531.DAT +17106 -0
  10. tsp/dataloggers/test_files/004531.HEX +3587 -0
  11. tsp/dataloggers/test_files/004534.HEX +3587 -0
  12. tsp/dataloggers/test_files/010252.dat +1731 -0
  13. tsp/dataloggers/test_files/010252.hex +1740 -0
  14. tsp/dataloggers/test_files/010274.hex +1292 -0
  15. tsp/dataloggers/test_files/010278.hex +3545 -0
  16. tsp/dataloggers/test_files/012064.dat +1286 -0
  17. tsp/dataloggers/test_files/012064.hex +1294 -0
  18. tsp/dataloggers/test_files/012081.hex +3533 -0
  19. tsp/dataloggers/test_files/062834_20220904_2351.rsk +0 -0
  20. tsp/dataloggers/test_files/062834_20220904_2351.xlsx +0 -0
  21. tsp/dataloggers/test_files/07B1592.DAT +1483 -0
  22. tsp/dataloggers/test_files/07B1592.HEX +1806 -0
  23. tsp/dataloggers/test_files/07B4450.DAT +2234 -0
  24. tsp/dataloggers/test_files/07B4450.HEX +2559 -0
  25. tsp/dataloggers/test_files/rbr_001.dat +1133 -0
  26. tsp/dataloggers/test_files/rbr_001.hex +1140 -0
  27. tsp/dataloggers/test_files/rbr_001_no_comment.dat +1132 -0
  28. tsp/dataloggers/test_files/rbr_001_no_comment.hex +1139 -0
  29. tsp/dataloggers/test_files/rbr_002.dat +1179 -0
  30. tsp/dataloggers/test_files/rbr_002.hex +1186 -0
  31. tsp/dataloggers/test_files/rbr_003.hex +1292 -0
  32. tsp/dataloggers/test_files/rbr_003.xls +0 -0
  33. tsp/dataloggers/test_files/rbr_xl_001.DAT +1105 -0
  34. tsp/dataloggers/test_files/rbr_xl_002.DAT +1126 -0
  35. tsp/dataloggers/test_files/rbr_xl_003.DAT +4622 -0
  36. tsp/dataloggers/test_files/rbr_xl_003.HEX +3587 -0
  37. tsp/physics.py +5 -10
  38. tsp/readers.py +64 -6
  39. tsp/utils.py +1 -1
  40. {tsp-1.4.9.dist-info → tsp-1.5.3.dist-info}/METADATA +4 -1
  41. {tsp-1.4.9.dist-info → tsp-1.5.3.dist-info}/RECORD +44 -13
  42. {tsp-1.4.9.dist-info → tsp-1.5.3.dist-info}/WHEEL +1 -1
  43. {tsp-1.4.9.dist-info → tsp-1.5.3.dist-info}/LICENSE +0 -0
  44. {tsp-1.4.9.dist-info → tsp-1.5.3.dist-info}/top_level.txt +0 -0
tsp/physics.py CHANGED
@@ -3,11 +3,11 @@ from typing import Optional
3
3
 
4
4
 
5
5
  def analytical_fourier(depths: "np.ndarray", times: "np.ndarray",
6
- Q:"Optional[float]"=0.2,
7
- c:"Optional[float]"=1.6e6,
8
- k:"Optional[float]"=2.5,
9
- A:"Optional[float]"=6,
10
- MAGST:"Optional[float]"=-0.5) -> "np.ndarray":
6
+ Q:float=0.2,
7
+ c:float=1.6e6,
8
+ k:float=2.5,
9
+ A:float=6,
10
+ MAGST:float=-0.5) -> "np.ndarray":
11
11
  """Create sinusoidal synthetic data for examples and testing
12
12
 
13
13
  Parameters
@@ -32,13 +32,8 @@ def analytical_fourier(depths: "np.ndarray", times: "np.ndarray",
32
32
  TSP
33
33
  _description_
34
34
  """
35
- Q = 0.2 # [W m-2]
36
- c = 1.6e6 # J m-3 K-1
37
- k = 2.5 # [W m-1 K-1]
38
35
  tau = 31536000 # [s]
39
36
  w = 2 * np.pi / tau # []
40
- A = 6 # [C]
41
- MAGST = -0.5 # [C]
42
37
  alpha = k / c
43
38
 
44
39
  initial = initial_analytic(MAGST, Q, k, depths)
tsp/readers.py CHANGED
@@ -15,6 +15,8 @@ from typing import Union, Optional
15
15
  from tsp.dataloggers.Geoprecision import detect_geoprecision_type
16
16
  from tsp.dataloggers.HOBO import HOBO, HOBOProperties
17
17
  from tsp.dataloggers.logr import LogR, guessed_depths_ok
18
+ from tsp.dataloggers.RBRXL800 import RBRXL800
19
+ from tsp.dataloggers.RBRXR420 import RBRXR420
18
20
 
19
21
  from tsp.core import TSP, IndexedTSP
20
22
  from tsp.misc import _is_depth_column
@@ -161,7 +163,21 @@ def read_geotop(file: str) -> TSP:
161
163
 
162
164
  t._depths *= 0.001 # Convert to [m]
163
165
 
164
- return t
166
+ # Only use last simulation period
167
+ # TODO: this could be improved
168
+ raw = pd.read_csv(file)
169
+ last_run = np.logical_and(raw['Simulation_Period'] == max( raw['Simulation_Period'] ),
170
+ raw['Run'] == max( raw['Run'] ))
171
+
172
+ last = TSP(times = t.times[last_run],
173
+ depths = t.depths,
174
+ values = t.values[last_run, :],
175
+ metadata={"Simulation_Period": max(raw['Simulation_Period']),
176
+ "Run": max( raw['Run'] )
177
+ }
178
+ )
179
+
180
+ return last
165
181
 
166
182
 
167
183
  def read_gtpem(file: str) -> "list[TSP]":
@@ -343,16 +359,17 @@ def read_geoprecision(filepath: str) -> IndexedTSP:
343
359
  IndexedTSP
344
360
  An IndexedTSP
345
361
  """
346
- reader = detect_geoprecision_type(filepath)
362
+ Reader = detect_geoprecision_type(filepath)
347
363
 
348
- if reader is None:
364
+ if Reader is None:
349
365
  raise RuntimeError("Could not detect type of geoprecision file (GP5W or FG2 missing from header")
350
-
351
- data = reader().read(filepath)
352
-
366
+ reader = Reader()
367
+
368
+ data = reader.read(filepath)
353
369
  t = IndexedTSP(times=data['TIME'].dt.to_pydatetime(),
354
370
  values=data.drop("TIME", axis=1).values)
355
371
 
372
+ t.metadata = reader.META
356
373
  return t
357
374
 
358
375
 
@@ -476,3 +493,44 @@ def read_classic(filepath: str, init_file: "Optional[str]"=None) -> TSP:
476
493
  t.set_depths(depths)
477
494
 
478
495
  return t
496
+
497
+
498
+ def read_rbr(file_path: str) -> IndexedTSP:
499
+ """
500
+
501
+ Parameters
502
+ ----------
503
+ filepath
504
+
505
+ Returns
506
+ -------
507
+
508
+ """
509
+ file_extention = Path(file_path).suffix.lower()
510
+ if file_extention in [".dat", ".hex"]:
511
+ with open(file_path, "r") as f:
512
+ first_line = f.readline()
513
+ model = first_line.split()[1]
514
+ if model == "XL-800":
515
+ r = RBRXL800()
516
+ elif model in ["XR-420", "XR-420-T8"]:
517
+ r = RBRXR420()
518
+ else:
519
+ raise ValueError(f"logger model {model} unsupported")
520
+ data = r.read(file_path)
521
+ elif file_extention in [".xls", ".xlsx", ".rsk"]:
522
+ r = RBRXR420()
523
+ data = r.read(file_path)
524
+ else:
525
+ raise IOError("File is not .dat, .hex, .xls, .xlsx, or .rsk")
526
+
527
+ times = data['TIME'].dt.to_pydatetime()
528
+ channels = pd.Series(data.columns).str.match("^ch")
529
+ values = data.loc[:, channels.to_numpy()]
530
+
531
+ t = IndexedTSP(times=times, values=values.values)
532
+ if "utc offset" in list(r.META.keys()):
533
+ t.set_utc_offset(r.META["utc offset"])
534
+
535
+ return t
536
+
tsp/utils.py CHANGED
@@ -85,7 +85,7 @@ def _strip_duplicate_time(t: TSP):
85
85
  def _average_duplicate_time(t: TSP):
86
86
  singleton = t.wide[~t.wide.index.duplicated(keep=False)]
87
87
  duplicated = t.wide[t.wide.index.duplicated(keep=False)].drop(['time'], axis=1).reset_index()
88
- averaged = duplicated.groupby(duplicated['index']).apply(lambda x: x[~x.isna()].mean()) # TODO: replace with newer pandas .mean()
88
+ averaged = duplicated.groupby(duplicated['index']).apply(lambda x: x[~x.isna()].mean(numeric_only=True))
89
89
  averaged.insert(0, 'time',averaged.index)
90
90
 
91
91
  df = pd.concat([singleton, averaged], ignore_index=False).sort_index()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tsp
3
- Version: 1.4.9
3
+ Version: 1.5.3
4
4
  Summary: Making permafrost data effortless
5
5
  Home-page: https://gitlab.com/permafrostnet/teaspoon
6
6
  Author: Nick Brown
@@ -28,6 +28,9 @@ Requires-Dist: pfit (==0.2.1) ; extra == 'nc'
28
28
  Provides-Extra: plotting
29
29
  Requires-Dist: matplotlib ; extra == 'plotting'
30
30
  Requires-Dist: scipy ; extra == 'plotting'
31
+ Provides-Extra: rbr
32
+ Requires-Dist: pyrsktools ; extra == 'rbr'
33
+ Requires-Dist: openpyxl ; extra == 'rbr'
31
34
 
32
35
  # Teaspoon
33
36
 
@@ -1,23 +1,42 @@
1
- tsp/__init__.py,sha256=txeQiOv87P8Jsartlzx8o6yGhgLMzmLshJiqj-7m4BU,368
2
- tsp/__meta__.py,sha256=aJoYzKMTLxsj_ebew1nK76WJBzXRkt7Vr9-d6GBJABw,93
3
- tsp/core.py,sha256=zVITPQPYLeEh5_-DlqN9PzcJRkja0gADBvkrbFFm8IY,30354
1
+ tsp/__init__.py,sha256=Ye8YN7QIbwkk6qMB_D0gB_F39JHY7WHsKKpNmE41g-U,380
2
+ tsp/__meta__.py,sha256=YRWJbWvRef7F7Aeph-Cv-keq14LjWDj1ytAoDCkHp58,93
3
+ tsp/core.py,sha256=zXIxGnQE8BIbGbAq672aFiIOOhp2RRx59Uf0R9fVefk,30720
4
4
  tsp/gtnp.py,sha256=kIxhLq_ve_cxU9v4_nDebc8jy6l7KQ87MOg8vK8lih4,3991
5
5
  tsp/misc.py,sha256=18w41G-umRi69lswXhpvJwrx4hqQ6r3bsvnmeKtpMU4,107
6
- tsp/physics.py,sha256=vUVsZdQOYaaWJ65VcHm1piuTem0I7xg4MtsJm8Uf33w,2877
7
- tsp/readers.py,sha256=2Z1tdvzgllbjSmqQtwFme6SNGmSrR3YFzu3R9kRtni8,16726
6
+ tsp/physics.py,sha256=hgVOGU0Bj1g-gxBNhLEl7Gm3VXJKIHHu35uPvgVMOxE,2699
7
+ tsp/readers.py,sha256=AR2__iJIDW4MGUd11B9RF3kPCEZAQ0xzNOHSrpgd-yM,18520
8
8
  tsp/time.py,sha256=82h7nxM-iXs2XwetF-alLtNvUm0qRtAA111gTMp5SY4,1379
9
- tsp/utils.py,sha256=ilJebXiiKcLhL7FQMJxU8TjnSpKoRtN_WrK1_peQfAQ,2956
9
+ tsp/utils.py,sha256=sOJSZLmfv7sh4X971_gNgtZvXtS8ZwGmUdqnUybcVE4,2932
10
10
  tsp/data/2023-01-06_755-test-Dataset_2031-Constant_Over_Interval-Hourly-Ground_Temperature-Thermistor_Automated.timeserie.csv,sha256=Q3Ssnoo_kiSn9_orZHjtMxQ02YbrjCAEQKs5sHPFJCg,171
11
11
  tsp/data/2023-01-06_755-test.metadata.txt,sha256=Ux1YGqmAmRQmMIqqK8-OloQXflg4Y45FRwdT-WgCg8c,5686
12
12
  tsp/data/example_geotop.csv,sha256=rgVP7_tGEvUtn1K_KI98VVgm275D7qt8YegKMe3Vjw4,262289
13
13
  tsp/data/example_gtnp.csv,sha256=E5km06-cWlWMwzF-Qo7v0ZrlAvCTpyWIKY6hpzln4sc,191812
14
14
  tsp/dataloggers/AbstractReader.py,sha256=YsmESWrmH2jdL-Oli9pwjaFmPCEfJxjm4wx16FoRxpY,1777
15
- tsp/dataloggers/FG2.py,sha256=Qud2aAEEF8EBvUiluVJDk3REJUF2wJFVEfyxKmJCEY0,2947
16
- tsp/dataloggers/GP5W.py,sha256=q3yqxLtHCnW_SOIE40Vw-WIC2yuFwRdFiVJ1KvgrnNs,2975
15
+ tsp/dataloggers/FG2.py,sha256=kvfjMQtoSs5ZzV7hc1lJ_SaDuSOOTONfI_nw2VaihO8,3281
16
+ tsp/dataloggers/GP5W.py,sha256=dJ7I-P4_bIDDGb9zIdOf9vbxbxlcT3ZJ09HKLfRA6a0,3312
17
17
  tsp/dataloggers/Geoprecision.py,sha256=pDljZDasj7PNdiI5lOEpHZ9n7CZJ1aGlX96rN4cuPHI,916
18
18
  tsp/dataloggers/HOBO.py,sha256=xr5PvdMh_AO4CSsqdGLvtdVgfphc91Nl34Qs-AiP-wQ,33472
19
+ tsp/dataloggers/RBRXL800.py,sha256=NjS6g_-grnC8BmLLW7qUppeOBYAOUJODNR-GwahnI7Y,8538
20
+ tsp/dataloggers/RBRXR420.py,sha256=PIY46cjJnngul3OI4mZQ1TtlcFNTJmXmyxmex6TEEeI,13908
19
21
  tsp/dataloggers/__init__.py,sha256=4QcIctP5hoVfraU3PwhkTIca-4JIWH9u6-j4CQWoW1g,410
20
22
  tsp/dataloggers/logr.py,sha256=4IaqP6debop3QYnKWAyCzRxgve25txcr1itmtCciKkY,2665
23
+ tsp/dataloggers/test_files/004448.DAT,sha256=1eJg5PtOrwlbzitp1XB5uE64ksqQHIIjTNgKIDn7zkI,201018
24
+ tsp/dataloggers/test_files/004531.DAT,sha256=8Pag_PnR-3dK4rhr7os6kyQXVe8i1N5w1_ACefT9G4s,331292
25
+ tsp/dataloggers/test_files/004531.HEX,sha256=0qJio9SvecR2MS4-nkjcZwqLh8h0sKdB6js_6yKqy5k,118535
26
+ tsp/dataloggers/test_files/004534.HEX,sha256=cWMHCZ7JOu08RM2sjqay2aZiud35LY7NSsmBhjheGRI,118531
27
+ tsp/dataloggers/test_files/010252.dat,sha256=_f9rvVq6U3ms3YQlN05doiy46PaNwqjeDlVCZK9NeU0,171935
28
+ tsp/dataloggers/test_files/010252.hex,sha256=3o-A8c7v-KyQr0OR1CftJW1e7c6tyvY16MsZb_s0N74,84712
29
+ tsp/dataloggers/test_files/010274.hex,sha256=4nB6jBzsP3XsraXZ_87IZZbZCqLQRtWcQ2mvR4R1c0I,62720
30
+ tsp/dataloggers/test_files/010278.hex,sha256=8IOkmg1EC5mTj6vLECc9_t-Nb66Yp_dxcFCs6YzkCqo,173117
31
+ tsp/dataloggers/test_files/012064.dat,sha256=LgwK9p0uzV0f7Gt1kIJWQSZWmG25i3vOJmTaG2jQ9gM,127062
32
+ tsp/dataloggers/test_files/012064.hex,sha256=O2VReAh3xW-Rg-z8EJ0cR7aoVqvEfL6TpPkt5FXfagY,62921
33
+ tsp/dataloggers/test_files/012081.hex,sha256=MwCQT5VLWiUVCmQGlzAMjZMwvdKolPAgtIIIvB2Z4sU,172576
34
+ tsp/dataloggers/test_files/062834_20220904_2351.rsk,sha256=2DJa-wnrms1N_fJ9QmvcNFH5JMIBdBhcb-nXtUMp70k,1007616
35
+ tsp/dataloggers/test_files/062834_20220904_2351.xlsx,sha256=z2sE1P--zcQJ1FoVJu43kXoxs1wIhwXGBukwzt1nIbc,308908
36
+ tsp/dataloggers/test_files/07B1592.DAT,sha256=KalPKVVgzKTJrVQU8_3pmIJbEV1QJgXDUcJVwHnyYrY,107655
37
+ tsp/dataloggers/test_files/07B1592.HEX,sha256=Eav6F_ExQ7qfg-mBMkZqrsASgWLM1RafNW43o8H4vEE,59683
38
+ tsp/dataloggers/test_files/07B4450.DAT,sha256=1CpQviX4xhtkXL6wHENMmNvmJNarOAm6UcGL2G4AMZ8,162502
39
+ tsp/dataloggers/test_files/07B4450.HEX,sha256=MyjYMf9EwWi7c91JwrNd4n0cPyAYZT1w719MygMQWO4,84576
21
40
  tsp/dataloggers/test_files/FG2_399.csv,sha256=Uonw_fFY3TUZ1O-XFtjRrV1yLr2iqUyBOlJM_wdZQGA,648322
22
41
  tsp/dataloggers/test_files/GP5W.csv,sha256=2mQl3YfzFVtvi3pdkEfyw9Cam3TzeHqAMnY06JSU6co,36948
23
42
  tsp/dataloggers/test_files/GP5W_260.csv,sha256=AbLBA12XLQLlNXpvht7Jy_DrvCUqhC1cQdFGnNYVXg0,68696
@@ -46,10 +65,22 @@ tsp/dataloggers/test_files/hobo_1_AB_var3.csv,sha256=xwtPv3llA-LReippxcOUE20cBb_
46
65
  tsp/dataloggers/test_files/logR_ULogC16-32_1.csv,sha256=0HcCjf_jEBDpgpyTqiJC1oIoJsnt5Qdk4qV_s_KfuTQ,21966
47
66
  tsp/dataloggers/test_files/logR_ULogC16-32_2.csv,sha256=MU58RvTSwFrhJIbaKPSSKf51tPyZC9_ZXgPCCfk9p4M,19066
48
67
  tsp/dataloggers/test_files/mon_3_Ta_2010-08-18_2013-02-08.txt,sha256=Sqv23n-r1KLLdSsjjVeDvS-sX061Ivklhv5sDwRMwpA,734009
68
+ tsp/dataloggers/test_files/rbr_001.dat,sha256=pS1QV_he33ccbfUpZMWm54AYDekez5us4MxS917wh0g,111570
69
+ tsp/dataloggers/test_files/rbr_001.hex,sha256=HNrSlP05Y2LUqtvlzX_5O7rQrTGItUlZpMswra-dJpc,55293
70
+ tsp/dataloggers/test_files/rbr_001_no_comment.dat,sha256=s_-tc-ShQfYqc4ObMh35xr8tQBHDxwjuBLDftX6Pc9U,111547
71
+ tsp/dataloggers/test_files/rbr_001_no_comment.hex,sha256=HKG-sl7kw1A_Z3melKKT2xgVEAayv2fvCKzCFNM4LXA,55270
72
+ tsp/dataloggers/test_files/rbr_002.dat,sha256=tUIX8InqQHObWzDVZrv1vTmY02zpIeepbKDpv4p5cpA,93525
73
+ tsp/dataloggers/test_files/rbr_002.hex,sha256=W29e__jot7deVVC2XDtXwAgqfmvHzU7qi-7yQb4_mz0,57536
74
+ tsp/dataloggers/test_files/rbr_003.hex,sha256=cjUaYWGm39WthiPvdzQKaOQ5FEKj3U9rCIe_0my7v2M,62703
75
+ tsp/dataloggers/test_files/rbr_003.xls,sha256=PRxsKD88dTQEYOqz5z1FrkPox1jCkYyiBBZK0Kg-7tQ,263680
76
+ tsp/dataloggers/test_files/rbr_xl_001.DAT,sha256=yZXKaClXMtYWDCs1cD2xTVdGj6LBMLKSjKnTgB4qPio,80057
77
+ tsp/dataloggers/test_files/rbr_xl_002.DAT,sha256=JQNHL6X9z4Rp6IDqDBYx8vWsUU6oigl8nC23rMa3Enk,81601
78
+ tsp/dataloggers/test_files/rbr_xl_003.DAT,sha256=ZEKheCvB1CiubY2kMngigY0NNhWTYAiC_hmQhzODPYw,221656
79
+ tsp/dataloggers/test_files/rbr_xl_003.HEX,sha256=sunCD5C1t8l5y4p1b9iiHNsZUznYIuBLz4uwoGkZh3E,118459
49
80
  tsp/plots/__init__.py,sha256=i5AhpNwyuT6il7uk2Vtc4YBjVnZ0ifvHNXw19rvDtsM,71
50
81
  tsp/plots/static.py,sha256=hH-FkazPMKgqI74NtGUn_D_avo6ts9ZmzWgov2GLmEU,9448
51
- tsp-1.4.9.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
52
- tsp-1.4.9.dist-info/METADATA,sha256=_iyP8WbiCvHDWsbxi1F7AJrqE5f328G1F_qXLJo-JZg,2731
53
- tsp-1.4.9.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
54
- tsp-1.4.9.dist-info/top_level.txt,sha256=7tOR6y7BarphfWD2D7QFi_3F1jxagUZpHG8zwJIw4ck,30
55
- tsp-1.4.9.dist-info/RECORD,,
82
+ tsp-1.5.3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
83
+ tsp-1.5.3.dist-info/METADATA,sha256=nObnySvS_vS3145_sZ9CBKEB5gSMeaxx72A5y2amAeU,2835
84
+ tsp-1.5.3.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
85
+ tsp-1.5.3.dist-info/top_level.txt,sha256=7tOR6y7BarphfWD2D7QFi_3F1jxagUZpHG8zwJIw4ck,30
86
+ tsp-1.5.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.40.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
File without changes