Local time using UTC, coordinates (PyEphem doesn't work)

I have a list of coordinates and UTC time, but unfortunately pyephem's localtime function doesn't work - local computer time is displayed. I want to filter out stations that are at night (not between 8:00 and 16:00). 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)

      

+3


source to share


1 answer


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



0


source







All Articles