ACID-code 2.0.0a3__py3-none-any.whl → 2.0.0a4__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.
ACID_code/acid.py CHANGED
@@ -60,9 +60,9 @@ class Acid:
60
60
 
61
61
  Important note: All defaults in the signature are None, meaning if any values are input, they will override the default :py:class:`Config` and/or :py:class:`Data` values or
62
62
  any values that have already been input. The defaults within the config are written below. The config defaults can also be accessed via
63
- :py:attr:`ACID_code.Config.defaults` (returning a dictionary of defaults for both initialisation and run_acid).
63
+ :py:attr:`ACID_code.Config.defaults` (returning a dictionary of defaults for both initialisation and the ACID method).
64
64
 
65
- All parameters below and in run_ACID are stored in the :py:class:`Config` instance, unless explicitly stated to be in the :py:class:`Data` instance.
65
+ All parameters below and in the ACID method are stored in the :py:class:`Config` instance, unless explicitly stated to be in the :py:class:`Data` instance.
66
66
  The :py:class:`Config` instance is for runtime settings and the :py:class:`Data` instance is for storing data and any calculations.
67
67
 
68
68
  Parameters
@@ -73,12 +73,11 @@ class Acid:
73
73
  choose your own velocity grid, by default None, stored in the Data instance.
74
74
  linelist : :py:type:`Array2D | str` | :py:class:`LineList` | dict`, optional
75
75
  The linelist to use for LSD. The linelist should have wavelengths in angstroms and relative depths between 0 and 1.
76
- This is a required parameter if linelist_wl and linelist_depths are not provided. It can be of the forms:
76
+ This is a required parameter. It can be of the forms:
77
77
  - String: A path to a VALD linelist in string format. Support for other linelists may be added in the future or on request.
78
78
  - :py:type:`Array2D`: A 2D array-like object indexed such that 0 is wavelengths and 1 is depths.
79
79
  - dict: A dictionary with keys "wavelengths" and "depths", each containing array-like objects for the wavelengths and depths respectively.
80
80
  - :py:class:`LineList`: The :py:class:`LineList` class is used to expose the linelist for masking or getting/plotting the linelist. You can input an instance if you have one.
81
- - If None, linelist_wl and linelist_depths must be provided (see below), by default None, stored in the Data instance.
82
81
  order : :py:type:`IntLike`, optional
83
82
  If this ACID instance is intended as a run on a specific order, then you can designate this instance for that order. This will allow
84
83
  the resulting Data instance to track of which order the profiles correspond to. Note that orders can be indexed by the correct indexing
@@ -117,7 +116,7 @@ class Acid:
117
116
  The path to save the sampler HDF5 backend file to.
118
117
  If None, the sampler is not saved and only stored in memory. By default None.
119
118
  Note that if your path points to an existing file, it will be overwritten on Acid initialization.
120
- If True, we use the emcee HDF5 backend to store and load the sampler.
119
+ If existing, we use the emcee HDF5 backend to store and load the sampler.
121
120
  Should be a valid file path that ends with ".h5". If the directory containing it does not exist, it will be created.
122
121
  Note that if you later try and save the sampler through the data class, it is converted to a HD5 backend.
123
122
  data : :py:class:`Data` | :py:class:`DataList`, optional
@@ -315,6 +314,9 @@ class Acid:
315
314
  skips : :py:type:`IntLike`, optional
316
315
  An option to only run acid on one in every n pixels, where n is the integer argument. This is only useful for
317
316
  testing to get a quicker result especially for larger wavelength ranges or datasets, by default 1 (no skipping)
317
+ od : :py:type:`bool`, optional
318
+ If True, runs ACID in optical depth, otherwise, the LSD methods and ACID fitting is performed in flux. By default None which defaults to True.
319
+ Note that the whole point of ACID is to run LSD in OD, we highly recommend leaving this unless you specifically want to compare.
318
320
  sampler_type : :py:type:`str`, optional
319
321
  If you really try to wish to use the dynesty nested sampler, you can set this to "dynesty". It is almost entirely unsupported
320
322
  by the rest of the code other than to just get a finished result object, and much slower. We highly recommend using None or "emcee" (default).
ACID_code/data.py CHANGED
@@ -436,6 +436,7 @@ class Config:
436
436
  If return_fig is True, returns a tuple of (fig, ax) where fig is the matplotlib figure object and ax is the axis object.
437
437
  Otherwise, returns None and shows the plot.
438
438
  """
439
+ # TODO: SORT out the colours and looks of this and the below continuum fit plot
439
440
  fig, ax = plt.subplots(figsize=(10, 6))
440
441
  for i, (name, line_data) in enumerate(self.masking_lines):
441
442
  for line, width in zip(line_data["lines"], line_data["widths"]):
@@ -646,7 +647,9 @@ class Data:
646
647
 
647
648
  Parameters
648
649
  ----------
649
- See :py:class:`Acid` for the accepted linelist formats and parameters.
650
+ linelist : Array2D, str, LineList, dict[str, Array1D], or None
651
+ The linelist to be set, which can be in various formats for convenience.
652
+ See :py:class:`Acid` init for the accepted linelist formats and parameters.
650
653
  """
651
654
  # Check if linelist already exists, override with new inputs if provided
652
655
  if linelist is not None:
@@ -1212,16 +1215,6 @@ class Data:
1212
1215
  """
1213
1216
  Converts the data object to a dictionary payload for saving. This is used internally in the save method,
1214
1217
  but can also be used for debugging or other purposes.
1215
-
1216
- Parameters
1217
- ----------
1218
- store_sampler : bool, optional
1219
- Whether to include the MCMC sampler in the dictionary payload, by default True.
1220
- size_limit : Scalar | None, optional
1221
- A hard size limit to the sampler in GB.
1222
- If the sampler exceeds this size, it will not be stored regardless of the store_sampler flag.
1223
- This is to avoid accidentally storing very large samplers. If None, no limit is set. Default is 1GB.
1224
- A warning will be printed if this size_limit forces the store_sampler to be False if store_sampler was set to True.
1225
1218
  """
1226
1219
  if self.sampler is not None and self.config.sampler_type == "dynesty":
1227
1220
  raise ValueError("Storing the sampler is not currently supported for dynesty samplers.\n" \
@@ -1322,10 +1315,6 @@ class LineList:
1322
1315
  ----------
1323
1316
  linelist : str, dict, LineList, list, or np.ndarray
1324
1317
  See :py:class:`Acid`.
1325
- linelist_wl : array-like, optional
1326
- See :py:class:`Acid`.
1327
- linelist_depths : array-like, optional
1328
- See :py:class:`Acid`.
1329
1318
 
1330
1319
  Returns
1331
1320
  -------
@@ -1356,8 +1345,6 @@ class LineList:
1356
1345
  raise ValueError("If 'linelist' is a list or array, it must have length 2, with index 0 being wavelengths and index 1 being depths")
1357
1346
  linelist_wl = linelist[0]
1358
1347
  linelist_depths = linelist[1]
1359
- elif linelist_wl is not None and linelist_depths is not None:
1360
- pass # linelist_wl and linelist_depths already set, will be processed below
1361
1348
  else:
1362
1349
  raise ValueError(f"'linelist' must be a string path to a VALD linelist, a dictionary with keys 'wavelengths' and 'depths', \n" \
1363
1350
  "a LineList object, or a list/array indexed such that 0 is wavelengths and 1 is depths.")
@@ -1429,8 +1416,7 @@ class DataList:
1429
1416
  strictly necessary to run ACID over multiple orders, you can handle the multiple instances yourself.
1430
1417
 
1431
1418
  The DataList class works with a required root directory specified by the user to access to the same data across parallel processes,
1432
- and also to save intermediate results and figures per order. It also can save the whole sampler if you specify save_sampler=True in the run_ACID method,
1433
- which will save the sampler with Data in result to the save_dir after running ACID for each order but take up much more disk space.
1419
+ and also to save intermediate results and figures per order.
1434
1420
  """
1435
1421
 
1436
1422
  def __init__(
@@ -1524,11 +1510,6 @@ class DataList:
1524
1510
  f"The idea is that you can input a Load object which has its own tools to pull s2d data from common "\
1525
1511
  f"instruments such as ESPRESSO, HARPS, etc. \nIf you want to use this feature, please open an issue or "\
1526
1512
  f"contribute a pull request with the implementation.")
1527
- from .load import Load
1528
- if not isinstance(load, Load):
1529
- raise ValueError("load must be an instance of the Load class. Got: {load!r}")
1530
- wavelengths, flux, errors, sn = load.get_data()
1531
- order_range = load.order_range
1532
1513
 
1533
1514
  # Configure verbosity
1534
1515
  self.verbose = Config(verbose=verbose).verbose
@@ -1864,6 +1845,10 @@ class DataList:
1864
1845
  if nworkers > 1:
1865
1846
  orders = np.array_split(orders, nworkers)[worker]
1866
1847
 
1848
+ # Check if linelist or velocities were in kwargs and remove them now once if so
1849
+ ll = kwargs.pop("linelist", None)
1850
+ vel = kwargs.pop("velocities", None)
1851
+
1867
1852
  iterable = tqdm(orders, "Running ACID on orders", unit="order") if self.verbose > 1 else orders
1868
1853
  for order in iterable:
1869
1854
 
@@ -1884,11 +1869,9 @@ class DataList:
1884
1869
 
1885
1870
  # Handling if any kwargs were input
1886
1871
  # Only overwrite if overwrite_kwargs is True, otherwise keep the existing linelist/velocities in the Data instance
1887
- if "linelist" in kwargs:
1888
- ll = kwargs.pop("linelist")
1872
+ if ll is not None:
1889
1873
  data.linelist = ll if overwrite_kwargs else data.linelist
1890
- if "velocities" in kwargs:
1891
- vel = kwargs.pop("velocities")
1874
+ if vel is not None:
1892
1875
  data.velocities = vel if overwrite_kwargs else data.velocities
1893
1876
  if overwrite_kwargs:
1894
1877
  data.config.update_hipri(**kwargs)
ACID_code/result.py CHANGED
@@ -87,7 +87,7 @@ class Result:
87
87
  the Result object for methods that do not require the profiles attribute, such as
88
88
  continue_sampling() or plot_walkers(). This requires a Data object with the necessary attributes,
89
89
  and a sampler object in the initialisation, or an Acid object with the necessary attributes already set.
90
- By default, None.
90
+ By default, True.
91
91
  verbose : :py:type:`IntLike | bool | str`, optional
92
92
  Verbosity level, works exactly the same as :py:class:`Acid`, if not provided
93
93
  defaults to provided :py:class:`Acid`/:py:class:`Data` class verbosity (which itself defaults to 2).
@@ -112,7 +112,10 @@ class Result:
112
112
  # Handle the sampler if input, initiate if one exists
113
113
  self.sampler = sampler if sampler is not None else self.sampler # update sampler if provided, otherwise keep the same
114
114
  if self.sampler is not None:
115
- self.dynesty = isinstance(self.sampler, Sampler)
115
+ if Sampler is not None: # ie, only if dynesty is installed do this cheeck
116
+ self.dynesty = isinstance(self.sampler, Sampler)
117
+ else:
118
+ self.dynesty = False
116
119
  self.initiate_sampler(self.sampler) # set internal variables based on sampler, sets sampler_initialiated to True
117
120
 
118
121
  if not self.data.complete:
@@ -259,7 +262,7 @@ class Result:
259
262
  # Tuples allow for array-like indexing of the list
260
263
  if len(item) == 3:
261
264
  _order, frame, velocity = item
262
- return self.data.alphaprofiles[frame][velocity]
265
+ return self.data.profiles[frame][velocity]
263
266
  elif len(item) == 2:
264
267
  return self.data.profiles[item[0]][item[1]]
265
268
  elif len(item) == 1:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ACID_code
3
- Version: 2.0.0a3
3
+ Version: 2.0.0a4
4
4
  Summary: Returns line profiles from input spectra by fitting the stellar continuum and performing LSD
5
5
  Author: Lucy Dolan
6
6
  Author-email: Benjamin Cadell <bcadell01@qub.ac.uk>
@@ -1,15 +1,15 @@
1
1
  ACID_code/__init__.py,sha256=-cmUx-kDheDBhk8ZlleWVRrWZyXZRVe-dwciVV9ZxLg,655
2
- ACID_code/acid.py,sha256=hibDm91O0_HLO3d50I2Q137rXi_xmXdcJSb9KcDNLCs,75532
3
- ACID_code/data.py,sha256=qaLGYFDPyK7XlXg09b1AZO4xGMZCmrYd7t04SU3LknA,114575
2
+ ACID_code/acid.py,sha256=oRc5JrJlaWkjSl4eldnoKalInsoyZySRnj8R6k9CZ5o,75702
3
+ ACID_code/data.py,sha256=xXms6yzpdtRwKyv-M1qGqcr468DGNQc7iQGkXBuqotY,113469
4
4
  ACID_code/errors.py,sha256=qqG44x_rVpi5njLIoRkwvw_6owy33wejvsFuAZ-XKKM,525
5
5
  ACID_code/load.py,sha256=3gzIZpAv7flgX5ekWdRDI95hkPTxvtp2F1liygpivOQ,5453
6
6
  ACID_code/lsd.py,sha256=VfdB-mN2uH20N6jT6lGKhEaepOwB2bJQepyZfIpqM9U,21521
7
7
  ACID_code/mcmc.py,sha256=PjGuxUhq-oFRkKKQmQPdSp82NyueG9FPwr7kpLgLk0U,14314
8
8
  ACID_code/profiles.py,sha256=KkVsJjCLXx_wjRBialfmnlGwjWsROy0GkggdPPYLelc,17103
9
- ACID_code/result.py,sha256=itDNK0zxgtNH8-Igqip-zFi6StK5ZyuMS47UYVooSq8,42141
9
+ ACID_code/result.py,sha256=tMumOLz4wwG62uvUoh1owuKQDEcaGzHTcgapJ3-hJnY,42281
10
10
  ACID_code/utils.py,sha256=Xt24WrhV6bKW-NiNl1FsNiJ2krntCJeCUL-hzIQAdLA,27637
11
- acid_code-2.0.0a3.dist-info/licenses/LICENSE,sha256=L6dUgqjvHmRoobrBCPSHKC4UtRM5Ldp1DJBC4bnLk3w,1070
12
- acid_code-2.0.0a3.dist-info/METADATA,sha256=XFBGmLrD4od1XTRY4SRGN3Cg-RAvM21VUEClyV6paIQ,2999
13
- acid_code-2.0.0a3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
14
- acid_code-2.0.0a3.dist-info/top_level.txt,sha256=O4OaSabv1ebFYQmHgftr1PGAv6BvC2l81Y3HjgNehQI,10
15
- acid_code-2.0.0a3.dist-info/RECORD,,
11
+ acid_code-2.0.0a4.dist-info/licenses/LICENSE,sha256=L6dUgqjvHmRoobrBCPSHKC4UtRM5Ldp1DJBC4bnLk3w,1070
12
+ acid_code-2.0.0a4.dist-info/METADATA,sha256=ehz0pcO49ONL8_XkLyj5k_K0ft_oi5i6BXkMuyGrrg4,2999
13
+ acid_code-2.0.0a4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
14
+ acid_code-2.0.0a4.dist-info/top_level.txt,sha256=O4OaSabv1ebFYQmHgftr1PGAv6BvC2l81Y3HjgNehQI,10
15
+ acid_code-2.0.0a4.dist-info/RECORD,,