Skip to content

get_next_moon can return times during daytime #11

@baileyji

Description

@baileyji

What happened?

ScopeSim/scopesim/utils.py

Lines 1218 to 1240 in 595a86b

def get_next_moon(moontype="full"):
"""
Get time of the next closest moon phase of given moon type (full, half or new).
"""
times = Time.now() + np.linspace(0, 30, 1000)*u.day
phases = get_moon_phase(times)
flis = get_moon_fli(phases)
next_full = times[np.argmax(flis)]
next_new = times[np.argmin(flis)]
prev_full = next_full - 29.53*u.day
prev_new = next_new - 29.53*u.day
if min(next_new, next_full) - Time.now() > Time.now() - max(prev_new, prev_full):
next_half = min(next_new, next_full) - 7.38*u.day
else:
next_half = min(next_new, next_full) + 7.38*u.day
if moontype == "full":
return next_full.isot.split('T')[0]+"T00:00:00"
elif moontype == "new":
return next_new.isot.split('T')[0]+"T00:00:00"
elif moontype == "half":
return next_half.isot.split('T')[0]+"T00:00:00"
else:
raise ValueError(f"Invalid moon type: {moontype}, should be 'full', 'new' or 'half'.")

Likely should be location aware

Code to reproduce

Exception traceback

ScopeSim bug_report()

IRDB installation

I'm creating my own instrument package

Use case

Other

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions