arvi 0.2.5__tar.gz → 0.2.6__tar.gz

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 arvi might be problematic. Click here for more details.

Files changed (64) hide show
  1. {arvi-0.2.5/arvi.egg-info → arvi-0.2.6}/PKG-INFO +1 -1
  2. {arvi-0.2.5 → arvi-0.2.6}/arvi/gaia_wrapper.py +2 -2
  3. {arvi-0.2.5 → arvi-0.2.6}/arvi/instrument_specific.py +1 -8
  4. {arvi-0.2.5 → arvi-0.2.6}/arvi/simbad_wrapper.py +18 -0
  5. arvi-0.2.6/arvi/sophie_wrapper.py +111 -0
  6. {arvi-0.2.5 → arvi-0.2.6}/arvi/timeseries.py +30 -13
  7. {arvi-0.2.5 → arvi-0.2.6}/arvi/utils.py +5 -2
  8. {arvi-0.2.5 → arvi-0.2.6/arvi.egg-info}/PKG-INFO +1 -1
  9. {arvi-0.2.5 → arvi-0.2.6}/arvi.egg-info/SOURCES.txt +1 -0
  10. {arvi-0.2.5 → arvi-0.2.6}/.github/dependabot.yml +0 -0
  11. {arvi-0.2.5 → arvi-0.2.6}/.github/workflows/docs-gh-pages.yml +0 -0
  12. {arvi-0.2.5 → arvi-0.2.6}/.github/workflows/install.yml +0 -0
  13. {arvi-0.2.5 → arvi-0.2.6}/.github/workflows/python-publish.yml +0 -0
  14. {arvi-0.2.5 → arvi-0.2.6}/.gitignore +0 -0
  15. {arvi-0.2.5 → arvi-0.2.6}/LICENSE +0 -0
  16. {arvi-0.2.5 → arvi-0.2.6}/README.md +0 -0
  17. {arvi-0.2.5 → arvi-0.2.6}/arvi/HZ.py +0 -0
  18. {arvi-0.2.5 → arvi-0.2.6}/arvi/__init__.py +0 -0
  19. {arvi-0.2.5 → arvi-0.2.6}/arvi/ariadne_wrapper.py +0 -0
  20. {arvi-0.2.5 → arvi-0.2.6}/arvi/berv.py +0 -0
  21. {arvi-0.2.5 → arvi-0.2.6}/arvi/binning.py +0 -0
  22. {arvi-0.2.5 → arvi-0.2.6}/arvi/config.py +0 -0
  23. {arvi-0.2.5 → arvi-0.2.6}/arvi/dace_wrapper.py +0 -0
  24. {arvi-0.2.5 → arvi-0.2.6}/arvi/data/extra/HD86226_PFS1.rdb +0 -0
  25. {arvi-0.2.5 → arvi-0.2.6}/arvi/data/extra/HD86226_PFS2.rdb +0 -0
  26. {arvi-0.2.5 → arvi-0.2.6}/arvi/data/extra/metadata.json +0 -0
  27. {arvi-0.2.5 → arvi-0.2.6}/arvi/data/info.svg +0 -0
  28. {arvi-0.2.5 → arvi-0.2.6}/arvi/data/obs_affected_ADC_issues.dat +0 -0
  29. {arvi-0.2.5 → arvi-0.2.6}/arvi/data/obs_affected_blue_cryostat_issues.dat +0 -0
  30. {arvi-0.2.5 → arvi-0.2.6}/arvi/exofop_wrapper.py +0 -0
  31. {arvi-0.2.5 → arvi-0.2.6}/arvi/extra_data.py +0 -0
  32. {arvi-0.2.5 → arvi-0.2.6}/arvi/headers.py +0 -0
  33. {arvi-0.2.5 → arvi-0.2.6}/arvi/kima_wrapper.py +0 -0
  34. {arvi-0.2.5 → arvi-0.2.6}/arvi/lbl_wrapper.py +0 -0
  35. {arvi-0.2.5 → arvi-0.2.6}/arvi/nasaexo_wrapper.py +0 -0
  36. {arvi-0.2.5 → arvi-0.2.6}/arvi/plots.py +0 -0
  37. {arvi-0.2.5 → arvi-0.2.6}/arvi/programs.py +0 -0
  38. {arvi-0.2.5 → arvi-0.2.6}/arvi/reports.py +0 -0
  39. {arvi-0.2.5 → arvi-0.2.6}/arvi/setup_logger.py +0 -0
  40. {arvi-0.2.5 → arvi-0.2.6}/arvi/spectra.py +0 -0
  41. {arvi-0.2.5 → arvi-0.2.6}/arvi/stats.py +0 -0
  42. {arvi-0.2.5 → arvi-0.2.6}/arvi/stellar.py +0 -0
  43. {arvi-0.2.5 → arvi-0.2.6}/arvi/translations.py +0 -0
  44. {arvi-0.2.5 → arvi-0.2.6}/arvi.egg-info/dependency_links.txt +0 -0
  45. {arvi-0.2.5 → arvi-0.2.6}/arvi.egg-info/requires.txt +0 -0
  46. {arvi-0.2.5 → arvi-0.2.6}/arvi.egg-info/top_level.txt +0 -0
  47. {arvi-0.2.5 → arvi-0.2.6}/docs/API.md +0 -0
  48. {arvi-0.2.5 → arvi-0.2.6}/docs/detailed.ipynb +0 -0
  49. {arvi-0.2.5 → arvi-0.2.6}/docs/downloading_data.md +0 -0
  50. {arvi-0.2.5 → arvi-0.2.6}/docs/index.md +0 -0
  51. {arvi-0.2.5 → arvi-0.2.6}/docs/logo/detective.png +0 -0
  52. {arvi-0.2.5 → arvi-0.2.6}/docs/logo/logo.png +0 -0
  53. {arvi-0.2.5 → arvi-0.2.6}/docs/stylesheets/extra.css +0 -0
  54. {arvi-0.2.5 → arvi-0.2.6}/mkdocs.yml +0 -0
  55. {arvi-0.2.5 → arvi-0.2.6}/pyproject.toml +0 -0
  56. {arvi-0.2.5 → arvi-0.2.6}/setup.cfg +0 -0
  57. {arvi-0.2.5 → arvi-0.2.6}/setup.py +0 -0
  58. {arvi-0.2.5 → arvi-0.2.6}/tests/HD10700-Bcor_ESPRESSO18.rdb +0 -0
  59. {arvi-0.2.5 → arvi-0.2.6}/tests/test_binning.py +0 -0
  60. {arvi-0.2.5 → arvi-0.2.6}/tests/test_config.py +0 -0
  61. {arvi-0.2.5 → arvi-0.2.6}/tests/test_create_RV.py +0 -0
  62. {arvi-0.2.5 → arvi-0.2.6}/tests/test_import_object.py +0 -0
  63. {arvi-0.2.5 → arvi-0.2.6}/tests/test_simbad.py +0 -0
  64. {arvi-0.2.5 → arvi-0.2.6}/tests/test_stats.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arvi
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: The Automated RV Inspector
5
5
  Author-email: João Faria <joao.faria@unige.ch>
6
6
  License: MIT
@@ -3,8 +3,6 @@ from io import StringIO
3
3
  from csv import DictReader
4
4
  import requests
5
5
 
6
- from astropy.coordinates import SkyCoord
7
-
8
6
  DATA_PATH = os.path.dirname(__file__)
9
7
  DATA_PATH = os.path.join(DATA_PATH, 'data')
10
8
 
@@ -78,6 +76,8 @@ class gaia:
78
76
  Args:
79
77
  star (str): The name of the star to query simbad
80
78
  """
79
+ from astropy.coordinates import SkyCoord
80
+
81
81
  self.star = star
82
82
 
83
83
  if simbad is None:
@@ -107,14 +107,7 @@ def divide_HARPS(self):
107
107
 
108
108
 
109
109
  def check(self, instrument):
110
- logger = setup_logger()
111
- instruments = self._check_instrument(instrument)
112
- if instruments is None:
113
- if self.verbose:
114
- logger.error(f"HARPS_fiber_commissioning: no data from {instrument}")
115
- return None
116
- return instruments
117
-
110
+ return self._check_instrument(instrument)
118
111
 
119
112
  # HARPS commissioning
120
113
  def HARPS_commissioning(self, mask=True, plot=True):
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import requests
3
3
  from dataclasses import dataclass
4
+ from functools import partial
4
5
 
5
6
  import numpy as np
6
7
 
@@ -63,6 +64,23 @@ JOIN ident ON oidref = oid
63
64
  WHERE id = '{star}';
64
65
  """
65
66
 
67
+ HD_GJ_HIP_QUERY = """
68
+ SELECT id2.id
69
+ FROM ident AS id1 JOIN ident AS id2 USING(oidref)
70
+ WHERE id1.id = '{star}' AND id2.id LIKE '{name}%';
71
+ """
72
+
73
+ def find_identifier(identifier, star):
74
+ response = run_query(HD_GJ_HIP_QUERY.format(name=identifier, star=star))
75
+ if identifier in response:
76
+ return response.split('"')[1]
77
+ raise ValueError(f'no {identifier} identifier found for "{star}"')
78
+
79
+ find_HD = partial(find_identifier, 'HD')
80
+ find_GJ = partial(find_identifier, 'GJ')
81
+ find_HIP = partial(find_identifier, 'HIP')
82
+
83
+
66
84
  @dataclass
67
85
  class Measurements:
68
86
  teff: list
@@ -0,0 +1,111 @@
1
+ from multiprocessing.pool import ThreadPool
2
+ import re
3
+ import requests
4
+ from io import StringIO
5
+
6
+ import numpy as np
7
+
8
+ from .setup_logger import setup_logger
9
+
10
+ URL_CCF = "http://atlas.obs-hp.fr/sophie/sophie.cgi?n=sophiecc&ob=date&a=t&o={target}"
11
+ URL_HEADER = "http://atlas.obs-hp.fr/sophie/sophie.cgi?n=sophiecc&c=i&z=fd&a=t&o=sophie:[ccf,{seq},{mask},0]"
12
+
13
+ def extract_keyword(keyword, text, raise_error=True):
14
+ for line in text.splitlines():
15
+ if keyword in line:
16
+ value = re.findall(fr'{keyword}\s+([\'\w\d.]+)', line)[0]
17
+ value = value.replace("'", "")
18
+ try:
19
+ return float(value)
20
+ except ValueError:
21
+ return value
22
+ if raise_error:
23
+ raise KeyError(f'Keyword {keyword} not found')
24
+
25
+ def query_sophie_archive(star: str, verbose=True):
26
+ from .timeseries import RV
27
+ logger = setup_logger()
28
+
29
+ resp = requests.get(URL_CCF.format(target=star))
30
+ if 'leda did not return a position for the name' in resp.text:
31
+ raise ValueError(f'no SOPHIE observations for {star}')
32
+
33
+ data = np.genfromtxt(StringIO(resp.text), dtype=None, usecols=(0, 4),
34
+ names=("seq", "mask"))
35
+
36
+ if verbose:
37
+ logger.info(f'found {len(data)} SOPHIE observations for {star}')
38
+
39
+ urls = [URL_HEADER.format(seq=seq, mask=mask) for seq, mask in data]
40
+ with ThreadPool(8) as pool:
41
+ responses = pool.map(requests.get, urls)
42
+
43
+ bjd, vrad, svrad = [], [], []
44
+ fwhm, contrast = [], []
45
+ ccf_mask = []
46
+ _quantities = []
47
+ errors = []
48
+
49
+ for i, resp in enumerate(responses):
50
+ if resp.text == '':
51
+ errors.append(i)
52
+ continue
53
+
54
+ try:
55
+ t, v = map(lambda k: extract_keyword(k, resp.text),
56
+ ("OHP DRS BJD", "OHP DRS CCF RV"))
57
+ except KeyError:
58
+ errors.append(i)
59
+ continue
60
+ else:
61
+ bjd.append(t)
62
+ vrad.append(v)
63
+
64
+ try:
65
+ svrad.append(extract_keyword("OHP DRS CCF ERR", resp.text))
66
+ except KeyError:
67
+ try:
68
+ svrad.append(1e-3 * extract_keyword("OHP DRS DVRMS", resp.text))
69
+ except KeyError:
70
+ bjd.pop(-1)
71
+ vrad.pop(-1)
72
+ errors.append(i)
73
+ continue
74
+
75
+ fwhm.append(extract_keyword('OHP DRS CCF FWHM', resp.text))
76
+ _quantities.append('fwhm')
77
+
78
+ contrast.append(extract_keyword('OHP DRS CCF CONTRAST', resp.text))
79
+ _quantities.append('contrast')
80
+
81
+ ccf_mask.append(extract_keyword('OHP DRS CCF MASK', resp.text))
82
+ _quantities.append('ccf_mask')
83
+
84
+ if len(errors) > 0:
85
+ logger.warning(f'Could not retrieve {len(errors)} observation'
86
+ f'{"s" if len(errors) > 1 else ""}')
87
+
88
+ bjd = np.array(bjd) - 2400000.5
89
+
90
+ s = RV.from_arrays(star, bjd, vrad, svrad, 'SOPHIE',
91
+ fwhm=fwhm, fwhm_err=2*np.array(svrad),
92
+ contrast=contrast,
93
+ ccf_mask=ccf_mask)
94
+ s.units = 'km/s'
95
+
96
+ # strings
97
+ for q in ['date_night', 'prog_id', 'raw_file', 'pub_reference']:
98
+ setattr(s, q, np.full(bjd.size, ''))
99
+ _quantities.append(q)
100
+
101
+ s._quantities = np.array(_quantities)
102
+
103
+ setattr(s, 'SOPHIE', s)
104
+ s._child = False
105
+ s.verbose = False
106
+ s._build_arrays()
107
+ s.change_units('m/s')
108
+ s.verbose = verbose
109
+
110
+ return s
111
+
@@ -64,19 +64,21 @@ class RV(ISSUES, REPORTS):
64
64
  only_latest_pipeline: bool = field(init=True, repr=False, default=True)
65
65
  load_extra_data: Union[bool, str] = field(init=True, repr=False, default=False)
66
66
  check_drs_qc: bool = field(init=True, repr=False, default=True)
67
- user: bool = field(init=True, repr=False, default=None)
67
+ check_sophie_archive: bool = field(init=True, repr=False, default=False)
68
+ user: Union[str, None] = field(init=True, repr=False, default=None)
68
69
  #
69
70
  units = 'm/s'
70
71
  _child: bool = field(init=True, repr=False, default=False)
71
- _did_secular_acceleration: bool = field(init=False, repr=False, default=False)
72
- _did_sigma_clip: bool = field(init=False, repr=False, default=False)
73
- _did_adjust_means: bool = field(init=False, repr=False, default=False)
74
- _did_simbad_query: bool = field(init=False, repr=False, default=False)
75
- _did_gaia_query: bool = field(init=False, repr=False, default=False)
76
- _did_toi_query: bool = field(init=False, repr=False, default=False)
77
- _raise_on_error: bool = field(init=True, repr=False, default=True)
78
- __masked_numbers: bool = field(init=False, repr=False, default=False)
79
- #
72
+ #
73
+ _did_secular_acceleration : bool = field(init=False, repr=False, default=False)
74
+ _did_sigma_clip : bool = field(init=False, repr=False, default=False)
75
+ _did_adjust_means : bool = field(init=False, repr=False, default=False)
76
+ _did_simbad_query : bool = field(init=False, repr=False, default=False)
77
+ _did_gaia_query : bool = field(init=False, repr=False, default=False)
78
+ _did_toi_query : bool = field(init=False, repr=False, default=False)
79
+ _raise_on_error : bool = field(init=True, repr=False, default=True)
80
+ __masked_numbers : bool = field(init=False, repr=False, default=False)
81
+ #
80
82
  _simbad = None
81
83
  _gaia = None
82
84
  _toi = None
@@ -104,7 +106,7 @@ class RV(ISSUES, REPORTS):
104
106
 
105
107
  if self._child:
106
108
  return None
107
-
109
+
108
110
  if self._did_simbad_query:
109
111
  return None
110
112
 
@@ -288,6 +290,21 @@ class RV(ISSUES, REPORTS):
288
290
  # all other quantities
289
291
  self._build_arrays()
290
292
 
293
+ # self.actin = get_actin_data(self, verbose=self.verbose)
294
+
295
+
296
+ # check for SOPHIE observations
297
+ cond = not self._child
298
+ cond = cond and self.instrument is None
299
+ cond = cond and self.check_sophie_archive
300
+ if cond:
301
+ try:
302
+ from arvi.sophie_wrapper import query_sophie_archive
303
+ self.__add__(query_sophie_archive(self.star, verbose=self.verbose),
304
+ inplace=True)
305
+ except Exception as e:
306
+ print(e)
307
+
291
308
  # do clip_maxerror, secular_acceleration, sigmaclip, adjust_means
292
309
  if not self._child:
293
310
  if self.do_maxerror:
@@ -1376,7 +1393,7 @@ class RV(ISSUES, REPORTS):
1376
1393
  instrument_index = self.obs[index]
1377
1394
  np.array(self.instruments)[instrument_index - 1]
1378
1395
  except IndexError:
1379
- logger.errors(f'index {index} is out of bounds for N={self.N}')
1396
+ logger.error(f'index {index} is out of bounds for N={self.N}')
1380
1397
  return
1381
1398
 
1382
1399
  if self.verbose:
@@ -1408,7 +1425,7 @@ class RV(ISSUES, REPORTS):
1408
1425
  instrument_index = self.obs[index]
1409
1426
  np.array(self.instruments)[instrument_index - 1]
1410
1427
  except IndexError:
1411
- logger.errors(f'index {index} is out of bounds for N={self.N}')
1428
+ logger.error(f'index {index} is out of bounds for N={self.N}')
1412
1429
  return
1413
1430
 
1414
1431
  if self.verbose:
@@ -79,14 +79,17 @@ def timer(name=None):
79
79
  if name is None:
80
80
  logger.debug('starting timer')
81
81
  else:
82
- logger.debug(f'starting timer: {name}')
82
+ logger.debug(f'{name}: starting timer')
83
83
 
84
84
  start = time.time()
85
85
  try:
86
86
  yield
87
87
  finally:
88
88
  end = time.time()
89
- logger.debug(f'elapsed time: {end - start:.2f} seconds')
89
+ if name is None:
90
+ logger.debug(f'elapsed time {end - start:.2f} seconds')
91
+ else:
92
+ logger.debug(f'{name}: elapsed time {end - start:.2f} seconds')
90
93
 
91
94
 
92
95
  def sanitize_path(path):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arvi
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: The Automated RV Inspector
5
5
  Author-email: João Faria <joao.faria@unige.ch>
6
6
  License: MIT
@@ -28,6 +28,7 @@ arvi/programs.py
28
28
  arvi/reports.py
29
29
  arvi/setup_logger.py
30
30
  arvi/simbad_wrapper.py
31
+ arvi/sophie_wrapper.py
31
32
  arvi/spectra.py
32
33
  arvi/stats.py
33
34
  arvi/stellar.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes