def test_j2000_from_Mars_Solar_Date(): assert within_error(marstime.j2000_from_Mars_Solar_Date(44795.99904), 4.5,1e-2) assert within_error(marstime.j2000_from_Mars_Solar_Date(0), -46022.997,1e-3)
import matplotlib as mpl mpl.use("Agg") mpl.rc("axes", labelsize=10) mpl.rc("xtick", labelsize=10) mpl.rc("ytick", labelsize=10) mpl.rc("legend", fontsize=10) import pylab as pl import numpy as np import marstime #define mars solar days to use in the plot start_j2000_ott = 151.27365 # sometime in May 2000, start of MY25 msd = np.linspace(0, 669, 120) #calculate the j2000 offset dates j2000_offsets = marstime.j2000_from_Mars_Solar_Date( msd + marstime.Mars_Solar_Date(start_j2000_ott)) eot_axis = marstime.equation_of_time( j2000_offsets) * 60 / 15. #convert from degrees to minutes dec_axis = marstime.solar_declination( marstime.Mars_Ls(j2000_offsets)) #takes Ls, not MSD pl.figure(figsize=(4, 6)) pl.subplots_adjust(left=0.15) pl.plot(eot_axis, dec_axis, marker='.', ls='none', color='k') pl.plot(eot_axis[::10], dec_axis[::10], marker='.', ls='none', color='r') pl.ylim(-28, 28) pl.xlim(-55, 45) pl.xticks(np.arange(-50, 50, 10)) pl.yticks(np.arange(-30, 30, 5)) pl.ylabel("Declination (degrees)")
parser.add_argument("--marker_radius",type=float, default=2.0, help="set the marker radius in degrees, requires --use_marker_radius") parser.add_argument("--number_of_points","-n",type=int, default=72, help="set the number of markers to plot, evenly spaced throughout the day") parser.add_argument("--filename",type=str, default="sunrise.png", help="set the output filename and type") 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)
import matplotlib as mpl mpl.use("Agg") mpl.rc("axes",labelsize=10) mpl.rc("xtick",labelsize=10) mpl.rc("ytick",labelsize=10) mpl.rc("legend",fontsize=10) import pylab as pl import numpy as np import marstime #define mars solar days to use in the plot start_j2000_ott = 151.27365 # sometime in May 2000, start of MY25 msd = np.linspace(0,669,120) #calculate the j2000 offset dates j2000_offsets = marstime.j2000_from_Mars_Solar_Date(msd + marstime.Mars_Solar_Date(start_j2000_ott)) eot_axis = marstime.equation_of_time(j2000_offsets)*60/15. #convert from degrees to minutes dec_axis = marstime.solar_declination(marstime.Mars_Ls(j2000_offsets)) #takes Ls, not MSD pl.figure(figsize=(4,6)) pl.subplots_adjust(left=0.15) pl.plot(eot_axis, dec_axis, marker='.', ls='none',color='k') pl.plot(eot_axis[::10], dec_axis[::10], marker='.', ls='none',color='r') pl.ylim(-28,28) pl.xlim(-55,45) pl.xticks(np.arange(-50,50,10)) pl.yticks(np.arange(-30,30,5)) pl.ylabel("Declination (degrees)") pl.xlabel("Equation of Time (minutes)") pl.savefig("analemma.png")
default=72, help= "set the number of markers to plot, evenly spaced throughout the day") parser.add_argument("--filename", type=str, default="sunrise.png", help="set the output filename and type") 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)
def day2date(n): dt = datetime.datetime(2017,1,1) dtdelta = datetime.timedelta(days=n) return(dt + dtdelta) if __name__ == '__main__': jd = 200 #offset from Jan 1, 2000 - starting Julian Date lat = 0 start_j2000_ott = 151.27365 #create the calendar array with 120 points, adding days to propagate in the future msd = np.linspace(0,1,800) #calculate the j2000 offset dates j2000_offsets = marstime.j2000_from_Mars_Solar_Date(msd + marstime.Mars_Solar_Date(jd)) dec= declination_mars(j2000_offsets) eot = marstime.equation_of_time(j2000_offsets)*60/15. #convert from degrees to minutes h = marstime.hourangle(0, j2000_offsets) S= atmosphere_solarIrradiance_mars(j2000_offsets, lat, dec) S = [0 if i < 0 else i for i in S] plt.plot(np.rad2deg(h)+180, S,'ro') plt.xlabel('Hour Angle (deg)', fontsize=18) plt.ylabel('Radiation (Watts/m^2)', fontsize=18) plt.title('Mars Radiation', fontsize=20)