Skip to content

Commit c0bd9bd

Browse files
committed
Removing cython as a dependency
It was only needed for niriss_cython.pyx which (since we currently don't support NIRISS) could just be a python file instead of a cython file. This will hopefully resolve our GitHub automated testing
1 parent 3ee2cf6 commit c0bd9bd

File tree

9 files changed

+39
-50
lines changed

9 files changed

+39
-50
lines changed

environment.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: eureka
1+
name: eureka2
22
channels:
33
- conda-forge
44
- defaults
@@ -10,7 +10,6 @@ dependencies:
1010
- ccdproc
1111
- celerite # Needed for GP
1212
- corner
13-
- cython
1413
- dynesty[version='>1.0'] # Lower limit needed for specific arguments
1514
- emcee[version='>3.0.0'] # Lower limit needed for specific arguments
1615
- flake8 # Needed for testing
@@ -40,7 +39,7 @@ dependencies:
4039
- crds
4140
- exotic-ld
4241
- image_registration@git+https://github.com/keflavich/image_registration@master # Need GitHub version to avoid np.float issue
43-
- jwst==1.10.2
42+
- jwst==1.11.4
4443
- myst-parser # Needed for documentation
4544
- setuptools_scm # Needed for version number
4645
- sphinx-rtd-theme # Needed for documentation

environment_pymc3.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: eureka_starry
1+
name: eureka_starry2
22
channels:
33
- conda-forge
44
- defaults
@@ -11,7 +11,6 @@ dependencies:
1111
- ccdproc
1212
- celerite # Needed for GP
1313
- corner
14-
- cython
1514
- dynesty[version='>1.0'] # Lower limit needed for specific arguments
1615
- emcee[version='>3.0.0'] # Lower limit needed for specific arguments
1716
- flake8 # Needed for testing
@@ -43,7 +42,7 @@ dependencies:
4342
- exoplanet
4443
- exotic-ld
4544
- image_registration@git+https://github.com/keflavich/image_registration@master # Need GitHub version to avoid np.float issue
46-
- jwst==1.10.2
45+
- jwst==1.11.4
4746
- myst-parser # Needed for documentation
4847
- opencv-python<4.8 # Upper limit needed for numpy<1.22
4948
- opencv-python-headless<4.8 # Upper limit needed for numpy<1.22

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools>=42", "wheel", "cython", "setuptools_scm[toml]>=6.2"]
2+
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=6.2"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.setuptools_scm]

setup.cfg

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ package_dir =
2323
packages = find:
2424
zip_safe = True
2525
python_requires= >=3.8
26-
setup_requires =
27-
cython
2826
install_requires =
2927
astraeus@git+https://github.com/kevin218/Astraeus@main
3028
astropy

setup.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/usr/bin/env python
22
from setuptools import setup
3-
from Cython.Build import cythonize
43

54
if __name__ == "__main__":
65

7-
setup(
8-
ext_modules=cythonize(
9-
["src/eureka/S3_data_reduction/niriss_cython.pyx"]),
10-
)
6+
setup()

src/eureka/S3_data_reduction/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from . import miri
66
from . import nircam
77
from . import niriss_profiles
8+
from . import niriss_python
89
from . import niriss
910
from . import nirspec
1011
from . import optspex

src/eureka/S3_data_reduction/niriss.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121

2222
from .background import fitbg3
2323
from .niriss_profiles import *
24-
25-
# some cute cython code
26-
import pyximport
27-
pyximport.install()
28-
from . import niriss_cython
24+
from . import niriss_python
2925

3026

3127
__all__ = ['read', 'simplify_niriss_img', 'image_filtering',
@@ -606,7 +602,7 @@ def construct_guesses(A, B, sig, length=10):
606602
combos = construct_guesses([0.1,30], [0.1,30], [1,40])
607603

608604
# generates length x length x length number of images and fits to the data
609-
img1, sigout1 = niriss_cython.build_image_models(data.median,
605+
img1, sigout1 = niriss_python.build_image_models(data.median,
610606
combos[:,0], combos[:,1],
611607
combos[:,2],
612608
pos1, pos2)
@@ -619,15 +615,15 @@ def construct_guesses(A, B, sig, length=10):
619615

620616
# generates length x length x length number of images centered around the previous
621617
# guess to optimize the image fit
622-
img2, sigout2 = niriss_cython.build_image_models(data.median,
618+
img2, sigout2 = niriss_python.build_image_models(data.median,
623619
combos[:,0], combos[:,1],
624620
combos[:,2],
625621
pos1, pos2)
626622

627623
# creates a 2D image for the first and second orders with the best-fit gaussian
628624
# profiles
629625
final_guess = combos[np.argmin(sigout2)]
630-
ord1, ord2, _ = niriss_cython.build_image_models(data.median,
626+
ord1, ord2, _ = niriss_python.build_image_models(data.median,
631627
[final_guess[0]],
632628
[final_guess[1]],
633629
[final_guess[2]],
@@ -661,7 +657,7 @@ def residuals(params, data, y1_pos, y2_pos):
661657
""" Calcualtes residuals for best-fit profile. """
662658
A, B, sig1 = params
663659
# Produce the model:
664-
model,_ = niriss_cython.build_image_models(data, [A], [B], [sig1], y1_pos, y2_pos)
660+
model,_ = niriss_python.build_image_models(data, [A], [B], [sig1], y1_pos, y2_pos)
665661
# Calculate residuals:
666662
res = (model[0] - data)
667663
return res.flatten()
@@ -676,7 +672,7 @@ def residuals(params, data, y1_pos, y2_pos):
676672
)
677673

678674
# creates the final mask
679-
out_img1,out_img2,_= niriss_cython.build_image_models(data.median,
675+
out_img1,out_img2,_= niriss_python.build_image_models(data.median,
680676
results.x[0:1],
681677
results.x[1:2],
682678
results.x[2:3],

src/eureka/S3_data_reduction/niriss_cython.pyx

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import numpy as np
2+
3+
def build_image_models(data, A, B, sig, mu1, mu2, return_together=True):
4+
5+
y = np.transpose(np.full((len(A), data.shape[-1], data.shape[0]),
6+
np.arange(0,data.shape[0],1)), axes=(0,2,1))
7+
8+
sig = np.full(y.T.shape, sig).T
9+
10+
A = np.full(y.T.shape, A).T
11+
exp = np.exp(-(y-mu1)**2/(2.0*sig**2))
12+
gauss = 1.0/(2.0*np.pi*np.sqrt(sig))*exp
13+
f1x = mu1*gauss*A
14+
15+
B = np.full(y.T.shape, B).T
16+
exp = np.exp(-(y-mu2)**2/(2.0*sig**2))
17+
gauss = 1.0/(2.0*np.pi*np.sqrt(sig))*exp
18+
f2x = mu2*gauss*B
19+
20+
model = f1x+f2x
21+
sigma = np.nansum(np.sqrt((model-data)**2.0), axis=(1,2))
22+
23+
if return_together:
24+
return model, sigma
25+
else:
26+
return f1x, f2x, sigma

0 commit comments

Comments
 (0)