Skip to content

Commit 56a9641

Browse files
authored
Merge pull request #8 from jorgemarpa/locator-cloud-rearange
Removing `tess-cloud` dependency to make `tess-locator` simpler
2 parents add23e2 + daba0ce commit 56a9641

File tree

7 files changed

+127
-118
lines changed

7 files changed

+127
-118
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[flake8]
22
max-line-length = 127
3-
max-complexity = 13
3+
max-complexity = 15
44
count = True
55
show-source = True
66
extend-ignore = E203, W503

pyproject.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "tess-locator"
3-
version = "0.6.dev"
3+
version = "0.6.0"
44
description = "Fast offline queries of TESS FFI positions and filenames."
55
license = "MIT"
66
authors = ["Geert Barentsen <[email protected]>",
@@ -16,14 +16,14 @@ classifiers = [
1616
]
1717

1818
[tool.poetry.dependencies]
19-
python = "^3.7"
20-
astropy = ">= 4.0"
21-
pandas = ">= 1.0"
22-
numpy = ">= 1.19"
23-
tqdm = ">= 4.51"
24-
attrs = ">= 20.3.0"
25-
tess-point = ">= 0.6.1"
26-
tess-cloud = ">=0.3.1"
19+
python = "^3.8"
20+
astropy = "^5.2.0"
21+
pandas = "^1.4.4"
22+
numpy = "^1.23.0"
23+
tqdm = "^4.51.1"
24+
attrs = "^23.1.0"
25+
tess-point = "^0.8"
26+
# tess-cloud = "^0.5"
2727

2828
[tool.poetry.dev-dependencies]
2929
pytest = "^6.0"

src/tess_locator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pathlib import Path
33
import tess_stars2px # provided by the `tess-point` package
44

5-
__version__ = "0.6.dev"
5+
__version__ = "0.6.0"
66

77
# Where does this package store its embedded data?
88
PACKAGEDIR: Path = Path(__file__).parent.absolute()

src/tess_locator/locate.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,27 @@ def locate(
4444
dec = np.atleast_1d(target.dec.to("deg").value)
4545
result = []
4646
for idx in range(len(ra)):
47-
(
48-
_,
49-
_,
50-
_,
51-
out_sector,
52-
out_camera,
53-
out_ccd,
54-
out_col,
55-
out_row,
56-
scinfo,
57-
) = tess_stars2px_function_entry(
58-
0, ra[idx], dec[idx], trySector=sectors_to_search[idx], aberrate=aberrate
59-
)
47+
# tess_stars2px_function_entry will exit with SystemExit: 1 if trySector < 0
48+
try:
49+
(
50+
_,
51+
_,
52+
_,
53+
out_sector,
54+
out_camera,
55+
out_ccd,
56+
out_col,
57+
out_row,
58+
scinfo,
59+
) = tess_stars2px_function_entry(
60+
0,
61+
ra[idx],
62+
dec[idx],
63+
trySector=sectors_to_search[idx],
64+
aberrate=aberrate,
65+
)
66+
except SystemExit:
67+
continue
6068

6169
for idx_out in range(len(out_sector)):
6270
if out_sector[idx_out] < 0:

src/tess_locator/tesscoord.py

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Defines the TessCoord and TessCoordList classes."""
22
from collections import UserList
3-
from typing import Union, Optional
3+
4+
# from typing import Union, Optional
45

56
import attr
67
import numpy as np
@@ -79,41 +80,41 @@ def to_skycoord(self) -> SkyCoord:
7980
crd.obstime = self.time
8081
return crd
8182

82-
def is_observed(self) -> bool:
83-
"""Returns true if this coordinate has been observed."""
84-
return len(self.list_images()) > 0
85-
86-
def list_images(
87-
self,
88-
time: Union[str, Time] = None,
89-
author: str = "spoc",
90-
provider: Optional[str] = None,
91-
):
92-
"""Returns a `TessImageList` detailing the FFI images which include the coordinate.
93-
94-
Parameters
95-
----------
96-
author : str
97-
"spoc" or "tica"
98-
99-
Notes
100-
-----
101-
This feature will use the `tess-cloud` package to query a catalog of
102-
TESS images.
103-
"""
104-
# local import to avoid circular dependency
105-
from tess_cloud import list_images
106-
107-
if time is None:
108-
time = self.time
109-
return list_images(
110-
sector=self.sector,
111-
camera=self.camera,
112-
ccd=self.ccd,
113-
time=time,
114-
author=author,
115-
provider=provider,
116-
)
83+
# def is_observed(self) -> bool:
84+
# """Returns true if this coordinate has been observed."""
85+
# return len(self.list_images()) > 0
86+
87+
# def list_images(
88+
# self,
89+
# time: Union[str, Time] = None,
90+
# author: str = "spoc",
91+
# provider: Optional[str] = None,
92+
# ):
93+
# """Returns a `TessImageList` detailing the FFI images which include the coordinate.
94+
#
95+
# Parameters
96+
# ----------
97+
# author : str
98+
# "spoc" or "tica"
99+
#
100+
# Notes
101+
# -----
102+
# This feature will use the `tess-cloud` package to query a catalog of
103+
# TESS images.
104+
# """
105+
# # local import to avoid circular dependency
106+
# from tess_cloud import list_images
107+
#
108+
# if time is None:
109+
# time = self.time
110+
# return list_images(
111+
# sector=self.sector,
112+
# camera=self.camera,
113+
# ccd=self.ccd,
114+
# time=time,
115+
# author=author,
116+
# provider=provider,
117+
# )
117118

118119

119120
class TessCoordList(UserList):
@@ -134,29 +135,29 @@ def __eq__(self, obj):
134135
obj.to_pandas()
135136
)
136137

137-
def list_images(
138-
self,
139-
time: Union[str, Time] = None,
140-
author: str = "spoc",
141-
provider: Optional[str] = None,
142-
):
143-
"""Returns a `TessImageList` detailing the FFI images which include the coordinates.
144-
145-
Parameters
146-
----------
147-
author : str
148-
"spoc" or "tica"
149-
"""
150-
# local import to avoid circular dependency
151-
from tess_cloud import TessImageList
152-
153-
if len(self) == 0:
154-
return TessImageList([])
155-
156-
result = self[0].list_images(time=time, author=author, provider=provider).copy()
157-
for img in self[1:]:
158-
result += img.list_images(time=time, author=author, provider=provider)
159-
return result
138+
# def list_images(
139+
# self,
140+
# time: Union[str, Time] = None,
141+
# author: str = "spoc",
142+
# provider: Optional[str] = None,
143+
# ):
144+
# """Returns a `TessImageList` detailing the FFI images which include the coordinates.
145+
#
146+
# Parameters
147+
# ----------
148+
# author : str
149+
# "spoc" or "tica"
150+
# """
151+
# # local import to avoid circular dependency
152+
# from tess_cloud import TessImageList
153+
#
154+
# if len(self) == 0:
155+
# return TessImageList([])
156+
#
157+
# result = self[0].list_images(time=time, author=author, provider=provider).copy()
158+
# for img in self[1:]:
159+
# result += img.list_images(time=time, author=author, provider=provider)
160+
# return result
160161

161162
def to_pandas(self) -> DataFrame:
162163
data = {

tests/test_locate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_pi_men():
1818
"""Tests `locate()` against `astroquery.mast.Tesscut.get_sectors()`"""
1919
# Query using Tesscut
2020
crd = SkyCoord(ra=84.291188, dec=-80.46911982, unit="deg")
21-
mast_result = Tesscut.get_sectors(crd)
21+
mast_result = Tesscut.get_sectors(coordinates=crd)
2222
# Query using our tool
2323
our_result = locate(crd)
2424
# Do the sector, camera, and ccd numbers all match?
@@ -31,7 +31,7 @@ def test_pi_men():
3131
assert our_result_df.iloc[0 : len(mast_result_df)].equals(mast_result_df)
3232
# Can we search by passing a string instead of the coordinates?
3333
our_result2 = locate("Pi Men")
34-
assert our_result.to_pandas().round(2).equals(our_result2.to_pandas().round(2))
34+
assert our_result.to_pandas().round(1).equals(our_result2.to_pandas().round(1))
3535

3636

3737
def test_scalar_vs_nonscalar_coordinate():

tests/test_tesscoord.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,36 @@ def test_list_from_pandas():
5050

5151

5252
# @pytest.mark.skip # because TessImage has moved to tess-cloud for now
53-
def test_list_images_twice():
54-
"""Regression test: requesting an image list twice should not change the outcome."""
55-
tcl = TessCoordList(
56-
[
57-
TessCoord(
58-
sector=5,
59-
camera=1,
60-
ccd=4,
61-
column=1553.9,
62-
row=1103.0,
63-
time="2018-11-21 17:35:00",
64-
),
65-
TessCoord(
66-
sector=5,
67-
camera=1,
68-
ccd=4,
69-
column=1553.9,
70-
row=1103.0,
71-
time="2018-11-22 17:35:00",
72-
),
73-
]
74-
)
75-
len1 = len(tcl.list_images())
76-
len2 = len(tcl.list_images())
77-
assert len1 == len2
78-
79-
80-
def test_list_images():
81-
crd = TessCoord(sector=11, camera=2, ccd=2, column=1699, row=1860)
82-
imglist = crd.list_images()
83-
assert len(imglist) == 1248
84-
df = imglist.to_pandas()
85-
assert len(df) == len(imglist)
53+
# def test_list_images_twice():
54+
# """Regression test: requesting an image list twice should not change the outcome."""
55+
# tcl = TessCoordList(
56+
# [
57+
# TessCoord(
58+
# sector=5,
59+
# camera=1,
60+
# ccd=4,
61+
# column=1553.9,
62+
# row=1103.0,
63+
# time="2018-11-21 17:35:00",
64+
# ),
65+
# TessCoord(
66+
# sector=5,
67+
# camera=1,
68+
# ccd=4,
69+
# column=1553.9,
70+
# row=1103.0,
71+
# time="2018-11-22 17:35:00",
72+
# ),
73+
# ]
74+
# )
75+
# len1 = len(tcl.list_images())
76+
# len2 = len(tcl.list_images())
77+
# assert len1 == len2
78+
#
79+
#
80+
# def test_list_images():
81+
# crd = TessCoord(sector=11, camera=2, ccd=2, column=1699, row=1860)
82+
# imglist = crd.list_images()
83+
# assert len(imglist) == 1248
84+
# df = imglist.to_pandas()
85+
# assert len(df) == len(imglist)

0 commit comments

Comments
 (0)