Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
74b0298
Initial framework for data mocking.
DinoBektesevic Mar 21, 2024
3d6ee6e
Add generic mutable and static header factories.
DinoBektesevic Mar 22, 2024
6e91c9d
Make decorator take static and bound methods.
DinoBektesevic Mar 22, 2024
ad18529
Add a simple masking data factory, break apart into modules.
DinoBektesevic Mar 22, 2024
c60249d
Add better data mocking, realistic and simplicit data factories, add …
DinoBektesevic Mar 23, 2024
4c21279
Add catalog factories, refactor fits and fits_data a bit.
DinoBektesevic Mar 24, 2024
ad107c1
Refactor, fix bugs with noise, tidy up.
DinoBektesevic Mar 24, 2024
cf85165
Add Standardizer for data produced by SimpleFits.
DinoBektesevic Mar 25, 2024
9d5e60e
Roadmark.
DinoBektesevic Mar 26, 2024
b4b6847
Add vectorized image creation.
DinoBektesevic Mar 26, 2024
a018bdf
Add a config class.
DinoBektesevic Apr 9, 2024
0a27587
Refactor data factories to use the config class.
DinoBektesevic Apr 9, 2024
9ca7f81
Cleanup, add docs.
DinoBektesevic Apr 10, 2024
baf5ada
Remove test_mocking script.
DinoBektesevic Apr 11, 2024
a2fd87b
Fixup the mocking code.
DinoBektesevic Apr 23, 2024
3e41cdd
Fixup, merge into subsequent pr with a better message.
DinoBektesevic Aug 5, 2024
23ed338
Adding tests, fixup.
DinoBektesevic Aug 5, 2024
b0d4505
More fixups to squash later, moving to baldur for testing.
DinoBektesevic Aug 5, 2024
53d5f16
Another fixup.
DinoBektesevic Aug 6, 2024
a7cf50e
more fixup
DinoBektesevic Aug 6, 2024
0b88c8a
Flakify
DinoBektesevic Aug 6, 2024
de1e859
fixup again, moving home to test decamimdiff gen
DinoBektesevic Aug 6, 2024
fe26398
Fixup.
DinoBektesevic Aug 15, 2024
1b81849
fixup
DinoBektesevic Aug 19, 2024
53bbb29
blacken
DinoBektesevic Aug 19, 2024
c3e7d5b
Syntax error on the tuple vs unpack operator again
DinoBektesevic Aug 21, 2024
bdb6297
Fix catalog.kind setter
DinoBektesevic Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ dependencies = [
"PyYAML>=6.0"
]

[project.scripts]
archiveheaders = "kbmod.mocking.dump_headers:main"

[project.urls]
Documentation = "https://epyc.astro.washington.edu/~kbmod/"
Repository = "https://github.com/dirac-institute/kbmod"
Expand Down
6 changes: 6 additions & 0 deletions src/kbmod/mocking/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from . import utils
from .catalogs import *
from .headers import *
from .data import *
from .fits import *
from .callbacks import *
84 changes: 84 additions & 0 deletions src/kbmod/mocking/callbacks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import random

from astropy.time import Time
import astropy.units as u


__all__ = ["IncrementObstime", "ObstimeIterator"]


class IncrementObstime:
"""Endlessly incrementing FITS-standard timestamp.

Parameters
----------
start : `astropy.time.Time`
Starting timestamp, or a value from which AstroPy can instantiate one.
dt : `float` or `astropy.units.Quantity`
Size of time-step to take. Assumed to be in days by default.

Examples
--------
>>> from kbmod.mocking import IncrementObstime
>>> obst = IncrementObstime("2021-01-01T00:00:00.0000", 1)
>>> obst()
'2021-01-01T00:00:00.000'
>>> obst()
'2021-01-02T00:00:00.000'
>>> import astropy.units as u
>>> obst = IncrementObstime("2021-01-01T00:00:00.0000", 1*u.hour)
>>> obst(); obst()
'2021-01-01T00:00:00.000'
'2021-01-01T01:00:00.000'
"""

default_unit = "day"

def __init__(self, start, dt):
self.start = Time(start)
if not isinstance(dt, u.Quantity):
dt = dt * getattr(u, self.default_unit)
self.dt = dt

def __call__(self, header=None):
curr = self.start
self.start += self.dt
return curr.fits


class ObstimeIterator:
"""Iterate through given timestamps.

Parameters
----------
obstimes : `astropy.time.Time`
Starting timestamp, or a value from which AstroPy can instantiate one.

Raises
------
StopIteration
When all the obstimes are exhausted.

Examples
--------
>>> from astropy.time import Time
>>> times = Time(range(60310, 60313, 1), format="mjd")
>>> from kbmod.mocking import ObstimeIterator
>>> obst = ObstimeIterator(times)
>>> obst(); obst(); obst(); obst()
'2024-01-01T00:00:00.000'
'2024-01-02T00:00:00.000'
'2024-01-03T00:00:00.000'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/local/tmp/kbmod/src/kbmod/mocking/callbacks.py", line 49, in __call__

StopIteration
"""

def __init__(self, obstimes, **kwargs):
self.obstimes = Time(obstimes, **kwargs)
self.generator = (t for t in obstimes)

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