Skip to content

Commit b2d2697

Browse files
fixup
1 parent abd0f6e commit b2d2697

File tree

13 files changed

+1785
-829
lines changed

13 files changed

+1785
-829
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ dependencies = [
4646
"PyYAML>=6.0"
4747
]
4848

49+
[project.scripts]
50+
archiveheaders = "kbmod.mocking.dump_headers:main"
51+
4952
[project.urls]
5053
Documentation = "https://epyc.astro.washington.edu/~kbmod/"
5154
Repository = "https://github.com/dirac-institute/kbmod"

src/kbmod/mocking/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from . import utils
22
from .catalogs import *
33
from .headers import *
4-
from .fits_data import *
4+
from .data import *
55
from .fits import *
66
from .callbacks import *

src/kbmod/mocking/callbacks.py

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,82 @@
33
from astropy.time import Time
44
import astropy.units as u
55

6+
67
__all__ = [
78
"IncrementObstime",
8-
"ObstimeIterator",
9+
"ObstimeIterator"
910
]
1011

1112

1213
class IncrementObstime:
14+
"""Endlessly incrementing FITS-standard timestamp.
15+
16+
Parameters
17+
----------
18+
start : `astropy.time.Time`
19+
Starting timestamp, or a value from which AstroPy can instantiate one.
20+
dt : `float` or `astropy.units.Quantity`
21+
Size of time-step to take. Assumed to be in days by default.
22+
23+
Examples
24+
--------
25+
>>> from kbmod.mocking import IncrementObstime
26+
>>> obst = IncrementObstime("2021-01-01T00:00:00.0000", 1)
27+
>>> obst()
28+
'2021-01-01T00:00:00.000'
29+
>>> obst()
30+
'2021-01-02T00:00:00.000'
31+
>>> import astropy.units as u
32+
>>> obst = IncrementObstime("2021-01-01T00:00:00.0000", 1*u.hour)
33+
>>> obst(); obst()
34+
'2021-01-01T00:00:00.000'
35+
'2021-01-01T01:00:00.000'
36+
"""
1337
default_unit = "day"
1438
def __init__(self, start, dt):
1539
self.start = Time(start)
1640
if not isinstance(dt, u.Quantity):
1741
dt = dt * getattr(u, self.default_unit)
1842
self.dt = dt
1943

20-
def __call__(self, header_val):
44+
def __call__(self, header=None):
2145
curr = self.start
2246
self.start += self.dt
2347
return curr.fits
2448

2549

2650
class ObstimeIterator:
27-
def __init__(self, obstimes, **kwargs):
28-
self.obstimes = Time(obstimes, **kwargs)
29-
self.generator = (t for t in obstimes)
51+
"""Iterate through given timestamps.
3052
31-
def __call__(self, header_val):
32-
return Time(next(self.generator)).fits
53+
Parameters
54+
----------
55+
obstimes : `astropy.time.Time`
56+
Starting timestamp, or a value from which AstroPy can instantiate one.
3357
58+
Raises
59+
------
60+
StopIteration
61+
When all the obstimes are exhausted.
3462
35-
class DitherValue:
36-
def __init__(self, value, dither_range):
37-
self.value = value
38-
self.dither_range = dither_range
63+
Examples
64+
--------
65+
>>> from astropy.time import Time
66+
>>> times = Time(range(60310, 60313, 1), format="mjd")
67+
>>> from kbmod.mocking import ObstimeIterator
68+
>>> obst = ObstimeIterator(times)
69+
>>> obst(); obst(); obst(); obst()
70+
'2024-01-01T00:00:00.000'
71+
'2024-01-02T00:00:00.000'
72+
'2024-01-03T00:00:00.000'
73+
Traceback (most recent call last):
74+
File "<stdin>", line 1, in <module>
75+
File "/local/tmp/kbmod/src/kbmod/mocking/callbacks.py", line 49, in __call__
3976
40-
def __call__(self, header_val):
41-
return self.value + random.uniform(self.dither_range)
77+
StopIteration
78+
"""
79+
def __init__(self, obstimes, **kwargs):
80+
self.obstimes = Time(obstimes, **kwargs)
81+
self.generator = (t for t in obstimes)
4282

83+
def __call__(self, header=None):
84+
return Time(next(self.generator)).fits

0 commit comments

Comments
 (0)