Example #1
0
    sunrise = so.bisect(solelev, mid1, noon, args=(longitude, latitude, solar_angular_radius))
    sunset = so.bisect(solelev, noon, mid2, args=(longitude, latitude, solar_angular_radius))
    return sunrise, sunset

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Testsuite for marstime library")
    parser.add_argument("date",type=str, nargs="?",
            help="Earth date in ISO format YYYY/MM/DD")
    parser.add_argument("time",type=str, nargs="?",
            help="Earth time in ISO format HH:ii:ss")
    parser.add_argument("longitude",type=float,
            help="East Longitude")
    parser.add_argument("latitude",type=float,
            help="East Longitude")
    args = parser.parse_args()
    
    dt = args.date + " " + args.time
    jdate = test_simple_julian_offset.simple_julian_offset(datetime.datetime.strptime(dt, "%Y/%m/%d %H:%M:%S"))
    west_longitude = marstime.east_to_west(args.longitude)
    north_latitude = args.latitude
    #find the midnight times
    mdate = midnight(jdate, west_longitude, north_latitude)

    #calculate the angular radius of the Sun to offset the bissect calculation
    solar_angular_radius = 0.0
    
    sup, sdown = sunrise_sunset(jdate, west_longitude, north_latitude, solar_angular_radius = solar_angular_radius)
    print str(sup) + ',' + str(sdown)


Example #2
0
import marstime
import datetime
import scipy
import scipy.optimize
import argparse

def simple_julian_offset(indate):
    """Simple conversion from date to J2000 offset"""
    datetime_epoch = datetime.datetime(2000,1,1,12,0,0)
    date = indate-datetime_epoch
    jdate = date.days + date.seconds/86400.
    return jdate

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Testsuite for marstime library")
    parser.add_argument("date",type=str, nargs="?",
            help="Earth date in ISO format YYYY/MM/DD")
    parser.add_argument("time",type=str, nargs="?",
            help="Earth time in ISO format HH:ii:ss")
    parser.add_argument("longitude",type=float,
            help="East Longitude")
    args = parser.parse_args()
    
    dt = args.date + " " + args.time
    jdate = simple_julian_offset(datetime.datetime.strptime(dt, "%Y/%m/%d %H:%M:%S"))
    print marstime.east_to_west(args.longitude)

Example #3
0
def test_east_to_west():
    assert marstime.west_to_east(0.0) == marstime.east_to_west(0.0)
Example #4
0
    args = parser.parse_args()
    
    
    if args.date is None: #nodate, use now
        default_date = datetime.datetime.now()
        jdate = simple_julian_offset(default_date)
        output_date = default_date.strftime("%Y/%m/%d")
    elif args.msd: #Mars solar date
        output_date = args.date
        jdate = marstime.j2000_from_Mars_Solar_Date(args.date)
    else: #earth date
        output_date = args.date
        jdate = simple_julian_offset(datetime.datetime.strptime(args.date, "%Y/%m/%d"))
     
    #convert to west longitude
    west_longitude = marstime.east_to_west(args.longitude)
    north_latitude = args.latitude
    #find the midnight times
    mdate = midnight(jdate, west_longitude, north_latitude)

    #calculate the angular radius of the Sun to offset the bissect calculation
    solar_angular_radius = 0.0
    if not args.ignore_solar_radius:
        solar_angular_radius = sun_angular_radius(jdate)
    
    sup, sdown = sunrise_sunset(jdate, west_longitude, north_latitude, solar_angular_radius = solar_angular_radius)
    xup = marstime.Local_Mean_Solar_Time( west_longitude, sup) #sunrise
    xdown = marstime.Local_Mean_Solar_Time( west_longitude, sdown) #sunset
    
    print str_hms(xup, prefix="Sunrise at LMST of ")
    print str_hms(xdown, prefix="Sunset at LMST of ")