3

I have a list of coordinates and UTC time but frustratingly pyephem's localtime function doesn't work--it displays the computer's local time. I want to filter out stations that are in night time (not in between the hours of 8 am and 4 pm). Is there an easy way to do this?

    for sit,lat,lon in zip(nsites,lats,longs):
        user=[]
        user = ephem.Observer()
        user.lat = lat
        user.lon = lon
        user.date=bstart

        if ephem.localtime(user.date).time()>=datetime.time(8) and ephem.localtime(user.date).time()<=datetime.time(16):
            user.date=cend
            if ephem.localtime(user.date).time()>=datetime.time(8) and ephem.localtime(user.date).time()<=datetime.time(16):
                mask.append(True)
            else:
                mask.append(False)
        else:
            mask.append(False)
pythanaconda
  • 173
  • 2
  • 9
  • 1
    `pyephem`'s `localtime` is meant to be [your computer's time](http://rhodesmill.org/pyephem/tutorial.html#computing-with-dates). For stations in nighttime could you check, given `bstart`, `user.next_setting(sun) > user.next_rising(sun)`? See [docs](http://rhodesmill.org/pyephem/quick.html#transit-rising-setting) for details. – rickhg12hs May 25 '15 at 14:27

1 Answers1

0

adding to rickhg12hs answer, consider setting user.horizon to "–6" (civil twilight), "-12" (nautical twilight), or "-18" (astronomical twilight) depending on how dark you need it to be for your use case.

rtphokie
  • 609
  • 1
  • 6
  • 14