ReflectX 1.0.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.
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.4
2
+ Name: ReflectX
3
+ Version: 1.0.0
4
+ Summary: Reflected Light planet models
5
+ Home-page: https://reflectx.readthedocs.io/en/latest/
6
+ Author: Logan Pearce
7
+ Author-email: Logan Pearce <lapearce@umich.edu>
8
+ Project-URL: Documentation, https://reflectx.readthedocs.io
9
+ Project-URL: Homepage, https://reflectx.readthedocs.io
10
+ Project-URL: Repository, https://github.com/logan-pearce/ReflectX
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/x-rst
13
+ Requires-Dist: numpy
14
+ Requires-Dist: astropy
15
+ Requires-Dist: scipy
16
+ Requires-Dist: matplotlib
17
+ Requires-Dist: corner
18
+ Requires-Dist: h5py
19
+ Requires-Dist: xarray
20
+ Requires-Dist: h5netcdf
21
+ Dynamic: author
22
+ Dynamic: home-page
23
+
24
+ ReflectX Model Suite of Exoplanet Reflected Light Spectra
25
+ =========================================================
26
+
27
+ .. image:: docs/source/images/reflectX-transp-white.png
28
+ :width: 60 %
29
+
30
+ Suite of reflected light exoplanet models for direct imaging with MagAO-X, ELTs, and HWO.
31
+
32
+ More at:
33
+ `https://reflectx.readthedocs.io/en/latest/index.html <https://reflectx.readthedocs.io/en/latest/index.html>`_
@@ -0,0 +1,10 @@
1
+ ReflectX Model Suite of Exoplanet Reflected Light Spectra
2
+ =========================================================
3
+
4
+ .. image:: docs/source/images/reflectX-transp-white.png
5
+ :width: 60 %
6
+
7
+ Suite of reflected light exoplanet models for direct imaging with MagAO-X, ELTs, and HWO.
8
+
9
+ More at:
10
+ `https://reflectx.readthedocs.io/en/latest/index.html <https://reflectx.readthedocs.io/en/latest/index.html>`_
@@ -0,0 +1,169 @@
1
+ import numpy as np
2
+ import astropy.constants as const
3
+ import astropy.units as u
4
+ import pandas as pd
5
+ import pickle
6
+ import scipy
7
+ import xarray as xr
8
+ import h5netcdf
9
+
10
+
11
+ def LoadModel(path, Teff, Planet, CtoO, teq = None, phase = None, clouds = None):
12
+ """
13
+ Args:
14
+ path (str): Path to location of `ReflectX` folder containing models
15
+ Teff (int): Star effective temperature, must be 3000, 3500, 4000, 5000, or 7000
16
+ Planet (str): Specify planet (see docs for details of each planet type); must be Neptune, SuperNeptune, Saturn, Jupiter, or SuperJupiter
17
+ CtoO (float): Planet C/O ratio; must be 0.5, 1.0, or 1.5
18
+ teq (int): Planet equilibrium temperature; must be 75, 100, 150, 180, 200, 250, 300, or 500
19
+ phase (int): Planet viewing phase in degrees; must be 0, 45, 90, 120, or 140
20
+ clouds (dict): Dictionary of cloud properties, must contain keys `fsed` and `kzz`; fsed must be 0.1, 0.5, 1, 3, 6, 0r 10; kzz must be 1e9 or 1e11
21
+
22
+ Returns:
23
+ dict or XArray: entire model set as a dictionary or single spectrum as an XArray
24
+ """
25
+ loaded = {}
26
+ CtoO = str(CtoO).replace('.','')
27
+ filename = path + 'ReflectX/ReflectXGasGiantGrid/Teff'+str(Teff)+'/'+Planet+'/CtoO'+CtoO+'/model.nc'
28
+ with h5netcdf.File(filename, "r+") as f:
29
+ def recurse(group, prefix=""):
30
+ for name, subgrp in group.groups.items():
31
+ full_path = f"{prefix}/{name}".strip("/")
32
+ # If the subgroup contains variables, open it as an xarray dataset
33
+ if subgrp.variables:
34
+ ds = xr.open_dataset(
35
+ filename,
36
+ engine="h5netcdf",
37
+ group=full_path,
38
+ )
39
+ loaded[full_path] = ds
40
+ # Recurse deeper
41
+ recurse(subgrp, full_path)
42
+ recurse(f)
43
+ if teq == None:
44
+ return loaded
45
+ else:
46
+ key = 'teq'+str(teq)+'/phase'+str(phase)
47
+ if clouds == None:
48
+ key += '/cloudfree'
49
+ else:
50
+ if type(clouds['kzz']) == float:
51
+ kzz = '{:.0e}'.format(clouds['kzz'])
52
+ elif type(clouds['kzz']) == str:
53
+ kzz = clouds['kzz']
54
+ key += '/fsed'+str(clouds['fsed']).replace('.','')+'/kzz'+kzz
55
+ return loaded[key]
56
+
57
+ def CreateGrid(min_wavelength, max_wavelength, constant_R):
58
+ """
59
+ Simple function to create a wavelength grid defined with a constant R.
60
+ Adapted from PICASO create_grid function
61
+ https://github.com/natashabatalha/picaso/blob/defc72955ad468496a814c1300e0f57244a75cd6/picaso/opacity_factory.py#L667C1-L694C27
62
+
63
+ Args:
64
+ min_wavelength (float): min value of wavelength range
65
+ max_wavelength (float): max value of wavelength range
66
+ constant_R (int): R value, ex: 10000
67
+
68
+ Returns:
69
+ arr: new wavelength grid at specified R value
70
+ """
71
+ spacing = (2.*constant_R+1.)/(2.*constant_R-1.)
72
+
73
+ npts = np.log(max_wavelength/min_wavelength)/np.log(spacing)
74
+
75
+ wsize = int(np.ceil(npts))+1
76
+ newwl = np.zeros(wsize)
77
+ newwl[0] = min_wavelength
78
+
79
+ for j in range(1,wsize):
80
+ newwl[j] = newwl[j-1]*spacing
81
+
82
+ return newwl
83
+
84
+ def MeanRegrid(x, y, newx=None, R=None):
85
+ """
86
+ Rebin the spectrum. Adapted from PICASO mean_regrid function
87
+ https://github.com/natashabatalha/picaso/blob/defc72955ad468496a814c1300e0f57244a75cd6/picaso/justplotit.py#L31C1-L63C19
88
+
89
+ Args:
90
+ x (arr): wavelength array to be rebinned
91
+ y (arr): flux values to map to new wavelength grid
92
+ newx (arr): new wavelength array to map flux onto, required if R = None
93
+ R (int): desired R to construct new wavelength array to map flux onto, required if newx = None
94
+
95
+ Returns:
96
+ tuple containing
97
+
98
+ - newx (arr): new wavelength array
99
+ - newy (float): new flux array mapped onto new wavelength at desired R
100
+ """
101
+ from scipy.stats import binned_statistic
102
+ if (isinstance(newx, type(None)) & (not isinstance(R, type(None)))) :
103
+ newx = CreateGrid(min(x), max(x), R)
104
+ elif (not isinstance(newx, type(None)) & (isinstance(R, type(None)))) :
105
+ d = np.diff(newx)
106
+ binedges = np.array([newx[0]-d[0]/2] + list(newx[0:-1]+d/2.0) + [newx[-1]+d[-1]/2])
107
+ newx = binedges
108
+ else:
109
+ raise Exception('Please either enter a newx or a R')
110
+ newy, edges, binnum = binned_statistic(x,y,bins=newx)
111
+ newx = (edges[0:-1]+edges[1:])/2.0
112
+
113
+ return newx, newy
114
+
115
+ def LoadFilters():
116
+ '''
117
+ Load XArray of filter transmission profiles
118
+ '''
119
+ import os
120
+ file = os.path.join(os.path.dirname(__file__),"filters.nc")
121
+ filt = xr.open_dataset(file, engine="h5netcdf")
122
+ return filt
123
+
124
+ def ScaleModelToStar(model, distance):
125
+ """
126
+ Scale star and planet flux arrays from surface to flux arriving at Earth
127
+
128
+ Args:
129
+ model (XArray): model XArray
130
+ distance (float): distance to star in parsecs
131
+
132
+ Returns:
133
+ XArray: XArray of model with star and planet flux scaled to flux arriving at Earth
134
+ """
135
+ omega = ((float(model.attrs['star.radius'])*u.Rsun / (distance*u.pc)).decompose())**2
136
+ data_vars=dict(starflux = (["wavelength"],
137
+ model['starflux'].data * omega,
138
+ {'units': 'erg/cm**2/s/cm/'}),
139
+ albedo = (["wavelength"], model['albedo'].data,{'units': ''}),
140
+ fpfs = (["wavelength"], model['fpfs'].data,{'units': 'erg/cm**2/s/cm/'}),
141
+ planetflux = (["wavelength"], model['starflux'].data * omega * model['fpfs'].data,{'units': 'erg/cm**2/s/cm/'})
142
+ )
143
+ coords=dict(
144
+ wavelength=(["wavelength"], model.wavelength.values,{'units': 'micron'})
145
+ )
146
+ scaled_model = xr.Dataset(
147
+ data_vars=data_vars,
148
+ coords=coords,
149
+ )
150
+ return scaled_model
151
+
152
+ def GetFluxInFilter(wavelength, flux, filtertransmission):
153
+ ''' Compute the average flux in a filter by multiplying the spectrum by the filter transmission curve
154
+ and dividing by the filter transmission curve
155
+
156
+ Args:
157
+ wavelength (arr): wavelength array
158
+ flux (arr): flux array
159
+ filtertransmission (arr): filter transmission curve on same wavelength array
160
+
161
+ Returns:
162
+ float: weighted average flux in filter
163
+ '''
164
+ dl = [wavelength[i] - wavelength[i-1] for i in range(1,len(wavelength))]
165
+ dl.append(dl[-1])
166
+ filter_weighted_average = np.sum(flux * filtertransmission * wavelength * dl) / np.sum(filtertransmission * wavelength * dl)
167
+ return filter_weighted_average
168
+
169
+
@@ -0,0 +1 @@
1
+ from .ReflectX import *
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.4
2
+ Name: ReflectX
3
+ Version: 1.0.0
4
+ Summary: Reflected Light planet models
5
+ Home-page: https://reflectx.readthedocs.io/en/latest/
6
+ Author: Logan Pearce
7
+ Author-email: Logan Pearce <lapearce@umich.edu>
8
+ Project-URL: Documentation, https://reflectx.readthedocs.io
9
+ Project-URL: Homepage, https://reflectx.readthedocs.io
10
+ Project-URL: Repository, https://github.com/logan-pearce/ReflectX
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/x-rst
13
+ Requires-Dist: numpy
14
+ Requires-Dist: astropy
15
+ Requires-Dist: scipy
16
+ Requires-Dist: matplotlib
17
+ Requires-Dist: corner
18
+ Requires-Dist: h5py
19
+ Requires-Dist: xarray
20
+ Requires-Dist: h5netcdf
21
+ Dynamic: author
22
+ Dynamic: home-page
23
+
24
+ ReflectX Model Suite of Exoplanet Reflected Light Spectra
25
+ =========================================================
26
+
27
+ .. image:: docs/source/images/reflectX-transp-white.png
28
+ :width: 60 %
29
+
30
+ Suite of reflected light exoplanet models for direct imaging with MagAO-X, ELTs, and HWO.
31
+
32
+ More at:
33
+ `https://reflectx.readthedocs.io/en/latest/index.html <https://reflectx.readthedocs.io/en/latest/index.html>`_
@@ -0,0 +1,12 @@
1
+ README.rst
2
+ pyproject.toml
3
+ setup.py
4
+ ReflectX/ReflectX.py
5
+ ReflectX/__init__.py
6
+ ReflectX.egg-info/PKG-INFO
7
+ ReflectX.egg-info/SOURCES.txt
8
+ ReflectX.egg-info/dependency_links.txt
9
+ ReflectX.egg-info/not-zip-safe
10
+ ReflectX.egg-info/requires.txt
11
+ ReflectX.egg-info/top_level.txt
12
+ docs/source/conf.py
@@ -0,0 +1,8 @@
1
+ numpy
2
+ astropy
3
+ scipy
4
+ matplotlib
5
+ corner
6
+ h5py
7
+ xarray
8
+ h5netcdf
@@ -0,0 +1,3 @@
1
+ ReflectX
2
+ dist
3
+ docs
@@ -0,0 +1,47 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+
3
+ # -- Project information
4
+
5
+ project = 'ReflectX'
6
+ copyright = 'Logan Pearce, 2026'
7
+ author = 'Logan Pearce'
8
+
9
+ release = '1.0'
10
+ version = '1.0.0'
11
+
12
+ # -- General configuration
13
+
14
+ extensions = [
15
+ 'sphinx.ext.duration',
16
+ 'sphinx.ext.doctest',
17
+ 'sphinx.ext.autodoc',
18
+ 'sphinx.ext.autosummary',
19
+ 'sphinx.ext.intersphinx',
20
+ ]
21
+
22
+ intersphinx_mapping = {
23
+ 'python': ('https://docs.python.org/3/', None),
24
+ 'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
25
+ }
26
+ intersphinx_disabled_domains = ['std']
27
+
28
+ templates_path = ['_templates']
29
+
30
+ # -- Options for HTML output
31
+
32
+ extensions = ["nbsphinx", 'sphinx.ext.duration',
33
+ 'sphinx.ext.doctest',
34
+ 'sphinx.ext.autodoc',
35
+ 'sphinx.ext.autosummary',
36
+ 'sphinx.ext.intersphinx','autoapi.extension',
37
+ 'sphinx.ext.napoleon','sphinx_copybutton']
38
+ html_theme = "sphinx_rtd_theme"
39
+ html_logo = 'images/reflectX-transp.png'
40
+ highlight_language = 'none'
41
+
42
+ autoapi_dirs = ['../../ReflectX']
43
+ autoapi_type = "python"
44
+
45
+
46
+ # -- Options for EPUB output
47
+ epub_show_urls = 'footnote'
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools",
4
+ "numpy",
5
+ "cython",
6
+ "wheel"
7
+ ]
8
+ build-backend = "setuptools.build_meta"
9
+
10
+ [project]
11
+ name = "ReflectX"
12
+ dynamic = ["version"]
13
+ dependencies = [
14
+ "numpy",
15
+ "astropy",
16
+ "scipy",
17
+ "matplotlib",
18
+ "corner",
19
+ "h5py",
20
+ "xarray",
21
+ "h5netcdf"
22
+ ]
23
+ authors = [{name = "Logan Pearce", email = "lapearce@umich.edu"}]
24
+ description = 'Reflected Light planet models'
25
+ readme = "README.rst"
26
+ requires-python = ">=3.9"
27
+
28
+ [project.urls]
29
+ Documentation = "https://reflectx.readthedocs.io"
30
+ Homepage = "https://reflectx.readthedocs.io"
31
+ Repository = "https://github.com/logan-pearce/ReflectX"
32
+
33
+ [tool.setuptools.packages]
34
+ find = {}
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,12 @@
1
+ from setuptools import setup
2
+
3
+ setup(name='ReflectX',
4
+ version='1.0.0',
5
+ description='Reflected Light planet models',
6
+ url='https://reflectx.readthedocs.io/en/latest/',
7
+ author='Logan Pearce',
8
+ author_email='lapearce@umich.edu',
9
+ #license='MIT',
10
+ install_requires=['numpy','scipy','astropy','matplotlib','xarray', 'h5netcdf', 'h5py'],
11
+ packages=['ReflectX'],
12
+ zip_safe=False)