solyaris 0.1.0__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.
solyaris-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Khaled Al Moulla
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.1
2
+ Name: solyaris
3
+ Version: 0.1.0
4
+ Summary: Order-by-order radial-velocity extraction and differential-extinction correction of Sun-as-a-star observations.
5
+ Home-page: https://github.com/almoulla/solyaris
6
+ Author: Khaled Al Moulla
7
+ Author-email: khaled.almoulla@gmail.com
8
+ License: MIT License
9
+ Classifier: Development Status :: 1 - Planning
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: astropy>=7.0.0
17
+ Requires-Dist: barycorrpy>=0.4.4
18
+ Requires-Dist: iCCF>=0.4.15
19
+ Requires-Dist: numpy>=2.2.4
20
+ Requires-Dist: pandas>=2.2.3
21
+ Requires-Dist: tqdm>=4.67.1
22
+
23
+ <p align="center">
24
+ <img width="500" src="https://github.com/almoulla/solyaris/blob/main/solyaris_logo.png?raw=true"/>
25
+ </p>
26
+
27
+ `solyaris` facilitates order-by-order radial-velocity extraction and differential-extinction correction of Sun-as-a-star observations.
28
+
29
+ ## Installation
30
+
31
+ ```
32
+ pip install solyaris
33
+ ```
@@ -0,0 +1,11 @@
1
+ <p align="center">
2
+ <img width="500" src="https://github.com/almoulla/solyaris/blob/main/solyaris_logo.png?raw=true"/>
3
+ </p>
4
+
5
+ `solyaris` facilitates order-by-order radial-velocity extraction and differential-extinction correction of Sun-as-a-star observations.
6
+
7
+ ## Installation
8
+
9
+ ```
10
+ pip install solyaris
11
+ ```
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,28 @@
1
+ from setuptools import find_packages, setup
2
+
3
+ with open('README.md') as file:
4
+ long_description = file.read()
5
+
6
+ setup(
7
+ name='solyaris',
8
+ version='0.1.0',
9
+ author='Khaled Al Moulla',
10
+ author_email='khaled.almoulla@gmail.com',
11
+ description='Order-by-order radial-velocity extraction and differential-extinction correction of Sun-as-a-star observations.',
12
+ long_description=long_description,
13
+ long_description_content_type='text/markdown',
14
+ url='https://github.com/almoulla/solyaris',
15
+ license='MIT License',
16
+ packages=find_packages(),
17
+ python_requires='>=3.10',
18
+ install_requires=['astropy>=7.0.0' ,
19
+ 'barycorrpy>=0.4.4',
20
+ 'iCCF>=0.4.15' ,
21
+ 'numpy>=2.2.4' ,
22
+ 'pandas>=2.2.3' ,
23
+ 'tqdm>=4.67.1' ],
24
+ classifiers=["Development Status :: 1 - Planning" ,
25
+ "Intended Audience :: Science/Research" ,
26
+ "License :: OSI Approved :: MIT License",
27
+ "Programming Language :: Python :: 3" ]
28
+ )
@@ -0,0 +1,8 @@
1
+ __version__ = '0.1.0'
2
+ __author__ = 'Khaled Al Moulla'
3
+
4
+ from .solyaris import SOLYARIS
5
+ from .solyaris import save
6
+ from .solyaris import load
7
+
8
+ __all__ = ['SOLYARIS', 'save', 'load']
@@ -0,0 +1,34 @@
1
+ import astropy.constants as ac
2
+ from astropy.time import Time
3
+ import barycorrpy
4
+ import numpy as np
5
+ from tqdm import tqdm
6
+ import warnings
7
+ warnings.filterwarnings('ignore')
8
+
9
+ def compute_berv_and_herv(obsname, date_obs, exp_time, photocen):
10
+
11
+ # Nr. of observations
12
+ Nobs = len(date_obs)
13
+
14
+ # Empty arrays
15
+ berv_val = np.empty(Nobs, dtype=float)*np.nan
16
+ herv_val = np.empty(Nobs, dtype=float)*np.nan
17
+
18
+ # Loop observations
19
+ print('Computing BERV and HERV ...')
20
+ for i in tqdm(range(Nobs)):
21
+
22
+ # Compute gravitational redshift of the Sun
23
+ gr_sun = (ac.G.value * ac.M_sun.value) / (ac.R_sun.value * ac.c.value)
24
+
25
+ # Compute BERV and HERV
26
+ jd_utc_cen = Time(date_obs[i], format='isot').jd + exp_time[i]*photocen[i]/(60*60*24)
27
+ berv_val[i] = barycorrpy.get_BC_vel(JDUTC=jd_utc_cen, obsname=obsname, SolSystemTarget='Sun' )[0][0]
28
+ herv_val[i] = barycorrpy.get_BC_vel(JDUTC=jd_utc_cen, obsname=obsname, SolSystemTarget='Sun', predictive=True)[0][0] + berv_val[i] - gr_sun
29
+
30
+ # Convert from m/s to km/s
31
+ berv_val *= 1e-3
32
+ herv_val *= 1e-3
33
+
34
+ return berv_val, herv_val
@@ -0,0 +1,51 @@
1
+ from astropy import units as u
2
+ from astropy.coordinates import AltAz, Angle, EarthLocation, get_body, solar_system_ephemeris
3
+ from astropy.time import Time
4
+ from datetime import datetime, timedelta
5
+ import numpy as np
6
+ from tqdm import tqdm
7
+ import warnings
8
+ warnings.filterwarnings('ignore')
9
+
10
+ def compute_solar_coordinates(obsname, date_obs, exp_time, photocen):
11
+
12
+ # Nr. of observations
13
+ Nobs = len(date_obs)
14
+
15
+ # Empty arrays
16
+ alph_val = np.empty(Nobs, dtype=float)*np.nan
17
+ delt_val = np.empty(Nobs, dtype=float)*np.nan
18
+ airm_val = np.empty(Nobs, dtype=float)*np.nan
19
+
20
+ # Loop observations
21
+ print('Computing solar coordinates ...')
22
+ for i in tqdm(range(Nobs)):
23
+
24
+ # Get date at start, end and photocenter of observation
25
+ date_start = datetime.strptime(date_obs[i], '%Y-%m-%dT%H:%M:%S.%f')
26
+ date_end = date_start + timedelta(days=0, seconds=exp_time[i])
27
+ date_photocenter = date_start + timedelta(days=0, seconds=exp_time[i]*photocen[i])
28
+
29
+ # Get Sun coordinates
30
+ solar_system_ephemeris.set('de432s') # use JPL ephemeredis
31
+ loc = EarthLocation.of_site(obsname)
32
+ obstime = Time(date_photocenter)
33
+ sun_coord = get_body('sun', obstime, loc)
34
+ sun_coord_string = sun_coord.to_string('hmsdms')
35
+ alpha = sun_coord_string.split('s')[0]
36
+ delta = sun_coord_string.split('s')[1].strip().replace('d',':').replace('m',':').replace('+', '')
37
+
38
+ # Convert alpha and delta to decimal degrees
39
+ alph_val[i] = Angle(alpha, unit=u.hour ).to(u.degree).value
40
+ delt_val[i] = Angle(delta, unit=u.degree) .value
41
+
42
+ # Compute airmass
43
+ time_start = Time(date_start)
44
+ time_end = Time(date_end)
45
+ sun_altaz_start = sun_coord.transform_to(AltAz(obstime=time_start, location=loc))
46
+ sun_altaz_end = sun_coord.transform_to(AltAz(obstime=time_end, location=loc))
47
+ airm_start = sun_altaz_start.secz.value
48
+ airm_end = sun_altaz_end.secz.value
49
+ airm_val[i] = airm_start*(1-photocen[i]) + airm_end*photocen[i]
50
+
51
+ return alph_val, delt_val, airm_val
@@ -0,0 +1,24 @@
1
+ from astropy.io import fits
2
+ import numpy as np
3
+ import warnings
4
+ warnings.filterwarnings('ignore')
5
+
6
+ def extract_ccf(file, instrument):
7
+
8
+ # ESPRESSO
9
+ if instrument == 'espresso':
10
+
11
+ # Load FITS file
12
+ with fits.open(file) as hdul:
13
+
14
+ # Header
15
+ header = hdul[0].header
16
+
17
+ # Extract CCF data
18
+ ccf_val = hdul[1].data
19
+ ccf_err = hdul[2].data
20
+ vstart = header['HIERARCH ESO RV START']
21
+ vstep = header['HIERARCH ESO RV STEP' ]
22
+ vgrid = vstart + vstep * np.arange(ccf_val.shape[1])
23
+
24
+ return vgrid, ccf_val, ccf_err
@@ -0,0 +1,52 @@
1
+ from astropy.io import fits
2
+ import pandas as pd
3
+ from tqdm import tqdm
4
+ import warnings
5
+ warnings.filterwarnings('ignore')
6
+
7
+ def extract_header_keywords(files, instrument, Norder):
8
+
9
+ # Nr. of files
10
+ Nfile = len(files)
11
+
12
+ # Loop files
13
+ print(f'Extracting header keywords ...')
14
+ for i in tqdm(range(Nfile)):
15
+
16
+ # Load FITS file
17
+ with fits.open(files[i]) as hdul:
18
+
19
+ # Header
20
+ header = hdul[0].header
21
+
22
+ # ESPRESSO
23
+ if instrument == 'espresso':
24
+
25
+ # Extract header keywords
26
+ header_dict = {}
27
+ header_dict['file' ] = header['ARCFILE' ]
28
+ header_dict['targ' ] = header['HIERARCH ESO OBS TARG NAME' ]
29
+ header_dict['date' ] = header['DATE-OBS' ][:10]
30
+ header_dict['date_obs'] = header['DATE-OBS' ]
31
+ header_dict['ins_mode'] = header['HIERARCH ESO INS MODE' ]
32
+ header_dict['obj_type'] = header['HIERARCH ESO PRO REC1 RAW1 CATG' ]
33
+ header_dict['exp_time'] = header['EXPTIME' ]
34
+ header_dict['photocen'] = header['HIERARCH ESO QC TMMEAN USED' ]
35
+ header_dict['alph_val'] = header['HIERARCH ESO TEL5 TARG ALPHA' ]
36
+ header_dict['delt_val'] = header['HIERARCH ESO TEL5 TARG DELTA' ]
37
+ header_dict['airm_val'] = header['HIERARCH ESO TEL5 AIRM START' ]*(1-header_dict['photocen']) + header['HIERARCH ESO TEL5 AIRM END']*header_dict['photocen']
38
+ header_dict['berv_val'] = header['HIERARCH ESO QC BERV' ]
39
+ header_dict['time_jdb'] = header['HIERARCH ESO QC BJD' ]
40
+ header_dict['vrad_val'] = header['HIERARCH ESO QC CCF RV' ]
41
+ header_dict['vrad_err'] = header['HIERARCH ESO QC CCF RV ERROR' ]
42
+ for j in range(Norder):
43
+ header_dict[f'snr_{j+1}'] = header[f'HIERARCH ESO QC ORDER{j+1} SNR' ]
44
+
45
+ # Initiate DataFrame
46
+ if i == 0:
47
+ df = pd.DataFrame(columns=header_dict.keys())
48
+
49
+ # Populate DataFrame
50
+ df.loc[i] = header_dict
51
+
52
+ return df
@@ -0,0 +1,32 @@
1
+ import iCCF
2
+ import numpy as np
3
+ from tqdm import tqdm
4
+ import warnings
5
+ warnings.filterwarnings('ignore')
6
+
7
+ from .extract_ccf import extract_ccf
8
+
9
+ def extract_order_by_order_rv(files, instrument, Norder):
10
+
11
+ # Nr. of files and orders
12
+ Nfile = len(files)
13
+ Norder = Norder
14
+
15
+ # Empty arrays
16
+ vrad_val_ord = np.empty((Nfile, Norder+1), dtype=float)*np.nan
17
+ vrad_err_ord = np.empty((Nfile, Norder+1), dtype=float)*np.nan
18
+
19
+ # Loop files
20
+ print('Extracting order-by-order RV ...')
21
+ for i in tqdm(range(Nfile)):
22
+
23
+ # Extract order-by-order CCF
24
+ vgrid, ccf_val, ccf_err = extract_ccf(files[i], instrument)
25
+
26
+ # Extract order-by-order RV
27
+ for j in range(Norder+1):
28
+ iccf = iCCF.Indicators(vgrid, ccf_val[j], ccf_err[j])
29
+ vrad_val_ord[i,j] = iccf.RV
30
+ vrad_err_ord[i,j] = iccf.RVerror
31
+
32
+ return vrad_val_ord, vrad_err_ord
@@ -0,0 +1,81 @@
1
+ import pickle
2
+
3
+ from .compute_berv_and_herv import compute_berv_and_herv
4
+ from .compute_solar_coordinates import compute_solar_coordinates
5
+ from .extract_header_keywords import extract_header_keywords
6
+ from .extract_order_by_order_rv import extract_order_by_order_rv
7
+
8
+ class SOLYARIS:
9
+
10
+ def __init__(self, instrument, id=None):
11
+
12
+ # Instrument and SOLYARIS object ID
13
+ self.instrument = instrument
14
+ if id is None:
15
+ self.id = instrument
16
+
17
+ # ESPRESSO
18
+ if self.instrument == 'espresso':
19
+ self.Norder = 170
20
+ self.obsname = 'Paranal Observatory'
21
+
22
+ def add_data(self, files=None):
23
+
24
+ self.files = files
25
+
26
+ return None
27
+
28
+ def extract_header_keywords(self):
29
+
30
+ self.table = extract_header_keywords(self.files, self.instrument, self.Norder)
31
+
32
+ return None
33
+
34
+ def extract_order_by_order_rv(self):
35
+
36
+ vrad_val_ord, vrad_err_ord = extract_order_by_order_rv(self.files, self.instrument, self.Norder)
37
+
38
+ for j in range(self.Norder+1):
39
+ self.table[f'vrad_val_{j+1}'] = vrad_val_ord[:,j]
40
+ self.table[f'vrad_err_{j+1}'] = vrad_err_ord[:,j]
41
+
42
+ return None
43
+
44
+ def compute_solar_coordinates(self):
45
+
46
+ alph_val, delt_val, airm_val = compute_solar_coordinates(self.obsname, self.table.date_obs.values, self.table.exp_time.values, self.table.photocen.values)
47
+
48
+ self.table.rename(columns={'alph_val': 'alph_drs'}, inplace=True)
49
+ self.table.rename(columns={'delt_val': 'delt_drs'}, inplace=True)
50
+ self.table.rename(columns={'airm_val': 'airm_drs'}, inplace=True)
51
+
52
+ self.table.insert(self.table.columns.get_loc('alph_drs')+1, 'alph_val', alph_val)
53
+ self.table.insert(self.table.columns.get_loc('delt_drs')+1, 'delt_val', delt_val)
54
+ self.table.insert(self.table.columns.get_loc('airm_drs')+1, 'airm_val', airm_val)
55
+
56
+ return None
57
+
58
+ def compute_berv_and_herv(self):
59
+
60
+ berv_val, herv_val = compute_berv_and_herv(self.obsname, self.table.date_obs.values, self.table.exp_time.values, self.table.photocen.values)
61
+
62
+ self.table.rename(columns={'berv_val': 'berv_drs'}, inplace=True)
63
+
64
+ self.table.insert(self.table.columns.get_loc('berv_drs')+1, 'berv_val', berv_val)
65
+ self.table.insert(self.table.columns.get_loc('berv_drs')+2, 'herv_val', herv_val)
66
+
67
+ return None
68
+
69
+ def export_table(self):
70
+
71
+ self.table.to_csv(self.id+'.csv', index=False)
72
+
73
+ return None
74
+
75
+ def save(solyaris):
76
+
77
+ return pickle.dump(solyaris, open(solyaris.id+'.solyaris', 'wb'))
78
+
79
+ def load(solyaris):
80
+
81
+ return pickle.load(open(solyaris, 'rb'))
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.1
2
+ Name: solyaris
3
+ Version: 0.1.0
4
+ Summary: Order-by-order radial-velocity extraction and differential-extinction correction of Sun-as-a-star observations.
5
+ Home-page: https://github.com/almoulla/solyaris
6
+ Author: Khaled Al Moulla
7
+ Author-email: khaled.almoulla@gmail.com
8
+ License: MIT License
9
+ Classifier: Development Status :: 1 - Planning
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: astropy>=7.0.0
17
+ Requires-Dist: barycorrpy>=0.4.4
18
+ Requires-Dist: iCCF>=0.4.15
19
+ Requires-Dist: numpy>=2.2.4
20
+ Requires-Dist: pandas>=2.2.3
21
+ Requires-Dist: tqdm>=4.67.1
22
+
23
+ <p align="center">
24
+ <img width="500" src="https://github.com/almoulla/solyaris/blob/main/solyaris_logo.png?raw=true"/>
25
+ </p>
26
+
27
+ `solyaris` facilitates order-by-order radial-velocity extraction and differential-extinction correction of Sun-as-a-star observations.
28
+
29
+ ## Installation
30
+
31
+ ```
32
+ pip install solyaris
33
+ ```
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ solyaris/__init__.py
5
+ solyaris/compute_berv_and_herv.py
6
+ solyaris/compute_solar_coordinates.py
7
+ solyaris/extract_ccf.py
8
+ solyaris/extract_header_keywords.py
9
+ solyaris/extract_order_by_order_rv.py
10
+ solyaris/solyaris.py
11
+ solyaris.egg-info/PKG-INFO
12
+ solyaris.egg-info/SOURCES.txt
13
+ solyaris.egg-info/dependency_links.txt
14
+ solyaris.egg-info/requires.txt
15
+ solyaris.egg-info/top_level.txt
@@ -0,0 +1,6 @@
1
+ astropy>=7.0.0
2
+ barycorrpy>=0.4.4
3
+ iCCF>=0.4.15
4
+ numpy>=2.2.4
5
+ pandas>=2.2.3
6
+ tqdm>=4.67.1
@@ -0,0 +1 @@
1
+ solyaris