コード例 #1
0
def when_is_sunrise_and_sunset(ground_position_lat, ground_position_lon, date, date_format = "%d/%m/%Y"):
    '''when_is_sunrise_and_sunset calculates the sunrise and sunset time at any location on earth for the date given.

    ground_position_lat = -19.2590 # The latitude of the ground position (int)
    ground_position_lon = 146.8169 # The longitude of the ground position (int)
    date = '21/06/2016' # date of the day to find passes on in UTC (string)
    date_format = "%d/%m/%Y" # the format of thh date string (string)

    Returns: [sunrise-time, sunset-time)] as datetime objects in the local time zone

    Contact:
    [email protected]
    '''
    # check the lat and lons to be sensible.
    futs.check_for_sensible_lat_long([ground_position_lat, ground_position_lon])
    # set up my observer.
    user = ephem.Observer()
    user.lat = ground_position_lat
    user.lon = ground_position_lon
    user.date = datetime.strptime(date, date_format)
    # set up the celestial body we're interested in
    body=ephem.Sun()
    body.compute()
    # do the calcs
    local_sun_rise_set = [ephem.localtime(user.previous_rising(body)),ephem.localtime(user.next_setting(body))] # rise then set
    return local_sun_rise_set
コード例 #2
0
def time_above_the_horizon(ground_position_lat, ground_position_lon, date, date_format = "%d/%m/%Y", time_window = 24, satellite_sensor = 'aqua', elevation = 0):
    '''time_above_the_horizon calculates the observation times of satellite passes for the day and time window of a given position on the earth.
    It is based on pyorbital functions.

    ground_position_lat = -19.2590 # The latitude of the ground position (int)
    ground_position_lon = 146.8169 # The longitude of the ground position (int)
    date = '21/06/2016' # date of the day to find passes on. (This is techincally in local time for your location an is converted to UTC internally here.) (string)
    date_format = "%d/%m/%Y" # the format of thh date string (string)
    satellite_sensor = 'aqua' # the name of the satellite sensor you are tracking (string). for VIIRS use 'SUOMI NPP'
    time_window = 24 # Number of hours to find passes (int)
    elevation = 0 # the elevation of horizon to compute risetime and falltime. (int)

    Returns: [(rise-time, fall-time, max-elevation-time), ...] as datetime objects in the UTC time zone.

    Contact:
    [email protected]
    '''
    # check the lat and lons to be sensible.
    futs.check_for_sensible_lat_long([ground_position_lat, ground_position_lon])
    #set up the satellite
    orb = Orbital(satellite_sensor)
    # convert the local time to a utc time.
    utc_date = futs.local_to_utc(futs.which_time_zone(ground_position_lat, ground_position_lon), date, date_format)
    # do calcs and remove the utc awareness from the utc_date so that pyorbital can use it.
    time_satellite_is_above_horizon = orb.get_next_passes(utc_date.replace(tzinfo=None), time_window, ground_position_lon, ground_position_lon, elevation)
    return time_satellite_is_above_horizon
コード例 #3
0
def which_time_zone(ground_position_lat, ground_position_lon):
    '''which_time_zone takes a gps coord and returns the timezone it falls in.

    Contact:
    [email protected]
    '''
    # check the lat and lons to be sensible.
    futs.check_for_sensible_lat_long([ground_position_lat, ground_position_lon])
    tz = tzwhere.tzwhere()
    return tz.tzNameAt(ground_position_lat, ground_position_lon)
コード例 #4
0
 def test_is_working_reverse(self):
     self.assertTrue(isinstance(futs.check_for_sensible_lat_long([146.8169,-19.2590], order_expected = ['lon','lat']), basestring))
コード例 #5
0
 def test_is_working_default(self):
     self.assertTrue(isinstance(futs.check_for_sensible_lat_long([-19.2590,146.8169]), basestring))