astropy / astroplan

Observation planning package for astronomers – maintainer @bmorris3
https://astroplan.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
198 stars 109 forks source link

Months observable gives unexpected result #514

Closed knservis closed 1 year ago

knservis commented 2 years ago

Hi,

I was trying the following:

from astroplan.constraints import AtNightConstraint
from astroplan import Observer, FixedTarget, months_observable
mwa = Observer.at_site('Murchison Widefield Array')
bs = FixedTarget.from_name('Barnard star')
months_observable(constraints=[AtNightConstraint.twilight_civil()], observer=mwa, targets=[bs])

gives me [{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}]

I was expecting to get about 6 months for that star of dec ~+4d

Is this a bug or just me?

bmorris3 commented 2 years ago

Hi,

If you edit your code to the following:

from astroplan.constraints import AtNightConstraint, AirmassConstraint
from astroplan import Observer, FixedTarget, months_observable

mwa = Observer.at_site('Murchison Widefield Array')
bs = FixedTarget.from_name('Barnard star')
constraints = [AtNightConstraint.twilight_astronomical(), AirmassConstraint(max=1.5)]
months_observable(constraints=constraints, observer=mwa, targets=[bs])

You'll get a result more like what you're expecting: [{3, 4, 5, 6, 7, 8, 9, 10}].

The main problem here is that you haven't defined any type of altitude or airmass constraint, and none is included by default. So it's counting any time that is night time as an observable time, even when the target is not above the horizon.

Does anyone subscribed have opinions about whether or not we should catch this corner case? Clearly targets below the horizon are not observable, but right now we don't catch the case when the user supplies no altitude-constraint and force it to pass times only when the alt > 0.

knservis commented 2 years ago

Hi @bmorris3

Thank you for that workaround, which I did use but I thought that the above was a bug and that is why I reported it. I am not sure what the intended intention of constraints is but it seems counter-intuitive. What is the intended meaning of AtNightContraint? At night anywhere in the world? I took it to mean nighttime between the specified twilight for the observer..

bmorris3 commented 2 years ago

What is the intended meaning of AtNightContraint?

This is specific to the observatory that you specify as the observer in the months_observable call.

I took it to mean nighttime between the specified twilight for the observer..

Correct.