sxs 2024.0.7__py3-none-any.whl → 2024.0.9__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.
sxs/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2024.0.7"
1
+ __version__ = "2024.0.9"
sxs/handlers.py CHANGED
@@ -256,10 +256,10 @@ def load(location, download=None, cache=None, progress=None, truepath=None, **kw
256
256
  json_path = path.with_suffix('.json')
257
257
 
258
258
  if not path.exists():
259
- if truepath and (testpath := pathlib.Path(truepath).expanduser()).exists():
259
+ if truepath and (testpath := pathlib.Path(sxs_path_to_system_path(truepath)).expanduser()).exists():
260
260
  path = testpath
261
261
 
262
- elif truepath and (testpath := cache_path / truepath).exists():
262
+ elif truepath and (testpath := cache_path / sxs_path_to_system_path(truepath)).exists():
263
263
  path = testpath
264
264
 
265
265
  elif _safe_resolve_exists(h5_path):
@@ -271,7 +271,7 @@ def load(location, download=None, cache=None, progress=None, truepath=None, **kw
271
271
  elif "scheme" in url.parse(location):
272
272
  m = url.parse(location)
273
273
  truepath = truepath or urllib.request.url2pathname(f"{m['host']}/{m['port']}/{m['resource']}")
274
- path = cache_path / truepath
274
+ path = cache_path / sxs_path_to_system_path(truepath)
275
275
  if not path.resolve().exists():
276
276
  if download is False: # Again, we want literal False, not casting to False
277
277
  raise ValueError(f"File '{truepath}' not found in cache, but downloading turned off")
@@ -298,7 +298,7 @@ def load(location, download=None, cache=None, progress=None, truepath=None, **kw
298
298
  paths = []
299
299
  for sxs_path, file_info in selections.items():
300
300
  truepath = truepath or sxs_path_to_system_path(file_info.get("truepath", sxs_path))
301
- path = cache_path / truepath
301
+ path = cache_path / sxs_path_to_system_path(truepath)
302
302
  if not path.resolve().exists():
303
303
  download_url = file_info["download"]
304
304
  download_file(download_url, path, progress=progress)
@@ -96,7 +96,6 @@ def Simulation(location, *args, **kwargs):
96
96
 
97
97
  """
98
98
  from .. import load, sxs_directory
99
- from ..utilities import sxs_path_to_system_path
100
99
 
101
100
  # Extract the simulation ID, version, and Lev from the location string
102
101
  simulation_id, input_version = sxs_id_and_version(location)
@@ -299,16 +298,17 @@ class SimulationBase:
299
298
  self.deprecated = kwargs.get("deprecated", False)
300
299
 
301
300
  def __repr__(self):
302
- chi1 = self.metadata.reference_dimensionless_spin1
303
- chi2 = self.metadata.reference_dimensionless_spin2
301
+ chi1 = self.series["reference_dimensionless_spin1"]
302
+ chi2 = self.series["reference_dimensionless_spin2"]
303
+ e = self.metadata.reference_eccentricity
304
304
  construction = f"""{type(self).__qualname__}("{self.location}")\n# """
305
305
  if self.deprecated:
306
306
  construction += "DEPRECATED "
307
- construction += f"{self.metadata.number_of_orbits:.3g}-orbit "
307
+ construction += f"n_orbits={self.metadata.number_of_orbits:.3g} "
308
308
  construction += f"q={self.metadata.reference_mass_ratio:.3g} "
309
309
  construction += f"""chi1=[{", ".join(f"{c:.3g}" for c in chi1)}] """
310
310
  construction += f"""chi2=[{", ".join(f"{c:.3g}" for c in chi2)}] """
311
- construction += f"e={self.metadata.reference_eccentricity:.3g} simulation"
311
+ construction += f"e={e:.3g} simulation" if type(e) is float else f"{e=} simulation"
312
312
  return construction
313
313
 
314
314
  def __str__(self):
@@ -332,14 +332,16 @@ class SimulationBase:
332
332
 
333
333
  def load_horizons(self):
334
334
  from .. import load
335
- sxs_id_path = Path(sxs_path_to_system_path(self.sxs_id))
335
+ sxs_id_path = Path(self.sxs_id)
336
336
  horizons_path = self.horizons_path
337
337
  horizons_location = self.files.get(horizons_path)["link"]
338
- horizons_truepath = sxs_id_path / sxs_path_to_system_path(horizons_path)
338
+ horizons_truepath = Path(sxs_path_to_system_path(sxs_id_path / horizons_path))
339
339
  return load(horizons_location, truepath=horizons_truepath)
340
340
 
341
341
  @property
342
342
  def horizons(self):
343
+ if self.horizons_path not in self.files:
344
+ raise ValueError(f"Horizons data is not available for simulation {self.sxs_id}")
343
345
  if not hasattr(self, "_horizons"):
344
346
  self._horizons = self.load_horizons()
345
347
  return self._horizons
@@ -427,7 +429,7 @@ class Simulation_v1(SimulationBase):
427
429
 
428
430
  def load_horizons(self):
429
431
  from .. import load
430
- sxs_id_path = Path(sxs_path_to_system_path(self.sxs_id))
432
+ sxs_id_path = Path(self.sxs_id)
431
433
  horizons_path = self.horizons_path
432
434
  if horizons_path in self.files:
433
435
  horizons_location = self.files.get(horizons_path)["link"]
@@ -436,7 +438,7 @@ class Simulation_v1(SimulationBase):
436
438
  horizons_location = self.files.get(extended_horizons_path)["link"]
437
439
  else:
438
440
  raise ValueError(f"File '{horizons_path}' not found in simulation files")
439
- horizons_truepath = sxs_id_path / sxs_path_to_system_path(horizons_path)
441
+ horizons_truepath = Path(sxs_path_to_system_path(sxs_id_path / horizons_path))
440
442
  return load(horizons_location, truepath=horizons_truepath)
441
443
 
442
444
  @property
@@ -472,8 +474,8 @@ class Simulation_v1(SimulationBase):
472
474
  location = self.files.get(extended_file_name)["link"]
473
475
  else:
474
476
  raise ValueError(f"File '{file_name}' not found in simulation files")
475
- sxs_id_path = Path(sxs_path_to_system_path(self.sxs_id))
476
- truepath = sxs_id_path / sxs_path_to_system_path(file_name)
477
+ sxs_id_path = Path(self.sxs_id)
478
+ truepath = Path(sxs_path_to_system_path(sxs_id_path / file_name))
477
479
  w = load(location, truepath=truepath, extrapolation_order=group)
478
480
  w.metadata = self.metadata
479
481
  return w
@@ -517,15 +519,15 @@ class Simulation_v2(SimulationBase):
517
519
  def load_waveform(self, file_name, group):
518
520
  from .. import load
519
521
  # Note that `name` should not have the file ending on input,
520
- # but we will strip it regardless with `.stem`.
521
- file_name = Path(file_name).stem
522
- sxs_id_path = Path(sxs_path_to_system_path(self.sxs_id))
523
- h5_path = f"{file_name}.h5"
524
- json_path = f"{file_name}.json"
522
+ # but we will replace it regardless with `.with_suffix`.
523
+ file_name = Path(file_name)
524
+ sxs_id_path = Path(self.sxs_id)
525
+ h5_path = str(file_name.with_suffix(".h5"))
526
+ json_path = str(file_name.with_suffix(".json"))
525
527
  h5_location = self.files.get(h5_path)["link"]
526
528
  json_location = self.files.get(json_path)["link"]
527
- h5_truepath = sxs_id_path / sxs_path_to_system_path(h5_path)
528
- json_truepath = sxs_id_path / sxs_path_to_system_path(json_path)
529
+ h5_truepath = Path(sxs_path_to_system_path(sxs_id_path / h5_path))
530
+ json_truepath = Path(sxs_path_to_system_path(sxs_id_path / json_path))
529
531
  if not json_truepath.exists():
530
532
  if not read_config("download", True):
531
533
  raise ValueError(f"{json_truepath} not found and download is disabled")
@@ -54,7 +54,8 @@ class Simulations(collections.OrderedDict):
54
54
  remote_timestamp = datetime.strptime(
55
55
  response.headers["Last-Modified"], "%a, %d %b %Y %H:%M:%S GMT"
56
56
  ).replace(tzinfo=timezone.utc)
57
- except:
57
+ except Exception as e:
58
+ print("Got exception while trying to get the remote timestamp:", e)
58
59
  failed = True
59
60
  if failed:
60
61
  print(
sxs/utilities/__init__.py CHANGED
@@ -19,6 +19,7 @@ from .sxs_identifiers import (
19
19
  lev_regex, lev_re,
20
20
  sxs_id_version_lev_regex, sxs_id_version_lev_re,
21
21
  sxs_id_version_lev_exact_regex, sxs_id_version_lev_exact_re,
22
+ sxs_path_regex, sxs_path_re,
22
23
  sxs_id, sxs_id_and_version,
23
24
  lev_number, simulation_title, sxs_id_to_url,
24
25
  )
@@ -3,9 +3,8 @@
3
3
  import re
4
4
  import platform
5
5
  import functools
6
- from .sxs_identifiers import sxs_identifier_regex
6
+ from .sxs_identifiers import sxs_path_re
7
7
 
8
- _sxs_identifier_regex = re.compile(sxs_identifier_regex)
9
8
  _platform_system = platform.system()
10
9
 
11
10
 
@@ -215,12 +214,14 @@ def sxs_directory(directory_type, persistent=True):
215
214
 
216
215
 
217
216
  def sxs_path_to_system_path(path):
218
- """Translate SXS path to a system-compatible path
217
+ r"""Translate SXS path to a system-compatible path
219
218
 
220
219
  Parameters
221
220
  ----------
222
221
  path : str
223
- SXS-style path to a file — for example, "SXS:BBH:0123/Lev4/Horizons.h5"
222
+ SXS-style path to a file — for example, r"SXS:BBH:0123\Lev4:Horizons.h5"
223
+ becomes r"SXS_BBH_0123\Lev4_Horizons.h5" on Windows. Other systems can
224
+ handle the original path, so are not changed.
224
225
 
225
226
  Notes
226
227
  -----
@@ -230,7 +231,7 @@ def sxs_path_to_system_path(path):
230
231
 
231
232
  """
232
233
  if _platform_system == "Windows":
233
- return _sxs_identifier_regex.sub(lambda s: s.group(0).replace(":", "_"), str(path))
234
+ return sxs_path_re.sub(lambda s: s.group(0).replace(":", "_"), str(path))
234
235
  else:
235
236
  return path
236
237
 
@@ -1,19 +1,26 @@
1
1
  """Simple regexes to understand SXS IDs"""
2
2
 
3
3
  import re
4
+ import os
5
+
6
+ sep_regex = r"(:|/)" if os.sep == "/" else r"(:|/|\\)"
4
7
 
5
8
  sxs_identifier_regex = (
6
9
  r"(?P<sxs_identifier>SXS:(?P<simulation_type>BBH|BHNS|NSNS)(?:_ExtCCE)?:"
7
10
  r"(?P<sxs_number>[0-9]+))(?:(v|V)(?P<version>[0-9.]+))?"
8
11
  )
9
12
  lev_regex = r"Lev(?P<lev>-?[0-9]+)"
10
- sxs_id_version_lev_regex = sxs_identifier_regex + rf"(?:(:|/){lev_regex})?"
13
+ sxs_id_version_lev_regex = sxs_identifier_regex + rf"(?:{sep_regex}{lev_regex})?"
11
14
  sxs_id_version_lev_exact_regex = f"^{sxs_id_version_lev_regex}$"
12
15
 
16
+ file_regex = r"(?P<file>[a-zA-Z0-9_]+\.[a-zA-Z0-9]+)"
17
+ sxs_path_regex = sxs_id_version_lev_regex + rf"(?:{sep_regex}{file_regex})?"
18
+
13
19
  sxs_identifier_re = re.compile(sxs_identifier_regex)
14
20
  lev_re = re.compile(lev_regex)
15
21
  sxs_id_version_lev_re = re.compile(sxs_id_version_lev_regex)
16
22
  sxs_id_version_lev_exact_re = re.compile(sxs_id_version_lev_exact_regex)
23
+ sxs_path_re = re.compile(sxs_path_regex)
17
24
 
18
25
  def sxs_id(s, default="", include_version=False):
19
26
  """Return the SXS ID contained in the input string
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sxs
3
- Version: 2024.0.7
3
+ Version: 2024.0.9
4
4
  Summary: Interface to data produced by the Simulating eXtreme Spacetimes collaboration
5
5
  Project-URL: Homepage, https://github.com/sxs-collaboration/sxs
6
6
  Project-URL: Documentation, https://sxs.readthedocs.io/
@@ -166,23 +166,24 @@ horizons = sxs_bbh_1234.horizons
166
166
  h = sxs_bbh_1234.h
167
167
  ```
168
168
 
169
- [The `catalog`
170
- object](https://sxs.readthedocs.io/en/main/api/sxs.catalog.catalog/#sxs.catalog.catalog.Catalog)
171
- contains information about every simulation in the catalog, including all
172
- available data files, and information about how to get them. You probably
173
- don't need to actually know about details like where to get the data, but
174
- `catalog` can help you find the simulations you care about. Most importantly,
175
- `catalog.simulations` is a `dict` object, where the keys are names of
176
- simulations (like "SXS:BBH:0123") and the values are the same types as [the
169
+ [The `simulations`
170
+ object](https://sxs.readthedocs.io/en/main/api/simulations/) contains
171
+ information about every simulation in the catalog, including all
172
+ available data files, and information about how to get them. You
173
+ probably don't need to actually know about details like where to get
174
+ the data, but `simulations` can help you find the simulations you care
175
+ about. It is a `dict` object, where the keys are names of simulations
176
+ (like "SXS:BBH:0123") and the values are the same types as [the
177
177
  `metadata`
178
178
  object](https://sxs.readthedocs.io/en/main/api/sxs.metadata.metadata/#sxs.metadata.metadata.Metadata),
179
- which contains metadata about that simulation — things like mass ratio, spins,
180
- etc. This `metadata` reflects the actual output of the simulations, which
181
- leads to some inconsistencies in their formats. A more consistent interface
182
- (though it is biased toward returning NaNs where a human might glean more
183
- information) is provided by `catalog.table`, which returns a
184
- [`pandas`](https://pandas.pydata.org/docs/) `DataFrame` with specific data
185
- types for each column.
179
+ which contains metadata about that simulation — things like mass
180
+ ratio, spins, etc. This `metadata` reflects the actual output of the
181
+ simulations, which leads to some inconsistencies in their formats. A
182
+ more consistent interface (though it is biased toward returning NaNs
183
+ where a human might glean more information) is provided by
184
+ `simulations.dataframe`, which returns a
185
+ [`pandas`](https://pandas.pydata.org/docs/) `DataFrame` with specific
186
+ data types for each column.
186
187
 
187
188
  The actual data itself is primarily contained in the next two objects. [The
188
189
  `horizons`
@@ -1,6 +1,6 @@
1
1
  sxs/__init__.py,sha256=51_F8xiD6cdE2kIq9dPyHxNQVsp4oCvtR1wQQQ0VS2A,2577
2
- sxs/__version__.py,sha256=j01pd3i6foxRb99xUCzpe724QNlPfN7SMCX-DnRdfAc,25
3
- sxs/handlers.py,sha256=mEPkqvFmmt-kfX8fLhwhozrgh7RxnUIX3-UcswtIBNw,24896
2
+ sxs/__version__.py,sha256=9IK_DALADrNA_ngG3KVGbjZ4pGFi6693UppmvILnfQI,25
3
+ sxs/handlers.py,sha256=-bFGH2Zt5qzKzq6AYGeh_kR5Xi1GD6zV71aPL2ijUY8,24996
4
4
  sxs/juliapkg.json,sha256=higH1UDu30K_PN6-o7lAz0j1xjgYEiCCYBAc-Iaw1Iw,178
5
5
  sxs/time_series.py,sha256=OKaLg8tFyrtKcef7900ri-a0C6A8wKxA68KovZXvH6I,41081
6
6
  sxs/caltechdata/__init__.py,sha256=s-RXyBiImKsQenqJIU6NAjlsjOX7f1MkIIW9rPtWYyg,14761
@@ -18,9 +18,9 @@ sxs/julia/__init__.py,sha256=uSLP_xfU-GZG7IO5vs0TEkCR4LH8aBYMF-852wDY3kI,3490
18
18
  sxs/metadata/__init__.py,sha256=KCvJ9Cf1WhIZp-z28UzarKcmUAzV2BOv2gqKiorILjo,149
19
19
  sxs/metadata/metadata.py,sha256=y6X7LcsJKiZFjBPTwRHGtsT2uHf2s0r0OG_EGjD27pE,27663
20
20
  sxs/simulations/__init__.py,sha256=sl-sDI5N2A03lAfzMig8Jm_Beri_v65qjlIOeGGX9XM,72
21
- sxs/simulations/simulation.py,sha256=uHp36DfMsh3o_8hUJK-D_tl4LnunL9YfRUTZGjOkcIs,23049
22
- sxs/simulations/simulations.py,sha256=a-L9xDYNySw2DO5vf5gtRFNr4UrEvIvf9BeqpnIbdLU,17013
23
- sxs/utilities/__init__.py,sha256=YTyrKYkiDZV4EoT4IHXGBsc_j6RU0aK1c3HERyshVq0,4760
21
+ sxs/simulations/simulation.py,sha256=fly3i55Wq3Jw7TfQV7kNge1uU7m7mHHbx-jkgVITxfg,23168
22
+ sxs/simulations/simulations.py,sha256=s20HdjEIcoG3vsgJcC4CwjfhICVwKWNABOYYucPEfSs,17108
23
+ sxs/utilities/__init__.py,sha256=KTtsBKblP02t20anSzV_7tucRUw_bFObY5my5ZuJEBU,4793
24
24
  sxs/utilities/bitwise.py,sha256=G9ZNYgwDQRhq5wbDf-p2HcUqkEP_IRDiQoXW4KyU17k,13205
25
25
  sxs/utilities/dicts.py,sha256=CCpm3upG_9SRj9gjawukSUfaJ5asF-XRG2ausEXhYyg,695
26
26
  sxs/utilities/downloads.py,sha256=iBceWfahHKxslUuI3p2-jRDoqGhP7q2A-La9g6XtMGg,4488
@@ -31,8 +31,8 @@ sxs/utilities/monotonicity.py,sha256=YVwj3Tjew8dkpJJ9TReyuISD2ul5HJfkEJgCoiLru5Q
31
31
  sxs/utilities/pretty_print.py,sha256=ZDHR3uvkzQ3Whk_eIp3BB7Abh796nqyrVsQRa68zgGc,1473
32
32
  sxs/utilities/select.py,sha256=UgoEQIvkm8NBe6sD5O2gK0g9Pep-xvWoYQ3b7RxI-Ww,6727
33
33
  sxs/utilities/smooth_functions.py,sha256=apoz3cDay10ozYiBAkj0Z6Bmksz7htKI9cr_Wa1Idp0,9077
34
- sxs/utilities/sxs_directories.py,sha256=DWHTa7GwLN7twoIa_xssXk0agtZUencbvA68AoaQRM8,9676
35
- sxs/utilities/sxs_identifiers.py,sha256=hssdPzivFWBNyqWhVaoaNQNzvO4TY-1EcWDpHiIR2ts,3795
34
+ sxs/utilities/sxs_directories.py,sha256=g6QoYSiqiP-qp97qSYbB9d25lQZRdyhzFHwF8fhvlak,9736
35
+ sxs/utilities/sxs_identifiers.py,sha256=9zRAztSNXHmCc-UpynfMCW0HKz-2sgKT45dvpruezhM,4040
36
36
  sxs/utilities/url.py,sha256=dH73Vrtjy4AKqazoeP2EZNdknzhkXQLzMaFZCr9ocjY,1904
37
37
  sxs/utilities/decimation/__init__.py,sha256=aE1p-NLwfd5nI4i6POT7Tttk0kZ2RUFuZf0Wjm-4W10,1336
38
38
  sxs/utilities/decimation/greedy_spline.py,sha256=NVnwoEFIFkcqrNIoV3sssOyB-BrM8G7I4ldKhWqwQQw,4335
@@ -78,7 +78,7 @@ sxs/zenodo/api/__init__.py,sha256=EM_eh4Q8R5E0vIfMhyIR1IYFfOBu6vA0UTasgX9gHys,21
78
78
  sxs/zenodo/api/deposit.py,sha256=J4RGvGjh0cEOrN4bBZWEDcPAhNscqB2fzLlvRZ5HTHM,36948
79
79
  sxs/zenodo/api/login.py,sha256=Yz0ytgi81_5BpDzhrS0WPMXlvU2qUaCK8yn8zxfEbko,18007
80
80
  sxs/zenodo/api/records.py,sha256=nKkhoHZ95CTztHF9Zzaug5p7IiUCJG4Em1i-l-WqH6U,3689
81
- sxs-2024.0.7.dist-info/METADATA,sha256=QhRUbtPaWuv0iFgPc2yfCcrW1iXYgCnulp6DiMJkcoU,9301
82
- sxs-2024.0.7.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
83
- sxs-2024.0.7.dist-info/licenses/LICENSE,sha256=ptVOd5m7LDM5ZF0x32cxb8c2Nd5NDmAhy6DX7xt_7VA,1080
84
- sxs-2024.0.7.dist-info/RECORD,,
81
+ sxs-2024.0.9.dist-info/METADATA,sha256=bSsX_jp4rMS5e4SZYo2YEDjnxF1Nv-fnT3Ws4qKEtrs,9244
82
+ sxs-2024.0.9.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
83
+ sxs-2024.0.9.dist-info/licenses/LICENSE,sha256=ptVOd5m7LDM5ZF0x32cxb8c2Nd5NDmAhy6DX7xt_7VA,1080
84
+ sxs-2024.0.9.dist-info/RECORD,,
File without changes