def __init__(self, normal, degree=None, axis=None, time=None, rad = None, height = None): MarsSpicer.__init__(self, time) self.r = rad self._h = height if degree and axis: rot_axis = zeros(3) rot_axis[axis] = 1 self.normal = vrotv(normal,deg2rad(degree), rot_axis) self.gamma = degree else: self.normal = normal
dem = ImgData(os.path.join(folder, 'big_spider_dem.cub')) slopes = ImgData(os.path.join(folder,'big_spider_slopes.tif')) aspects = ImgData(os.path.join(folder,'big_spider_aspects.tif')) spider1 = ImgData(os.path.join(folder,'ESP_022607_0985_cropped_big_spider.cub')) # spider2 = ImgData(os.path.join(folder,'ESP_022699_0985_cropped_big_spider.cub')) # read in required data dem.read_all() slopes.read_all() aspects.read_all() spider1.read_all() correct_azimuth(dem, aspects) # create MarsSpicer object mspice = MarsSpicer() mspice.goto_ls_0() mspice.advance_time_by(24*3600*356) utc = mspice.utc # seconds per step timestep = 600 # how many steps for the time series nsteps = 500 mspice.goto('inca') # getting l_s times times, _ = mspice.time_series('F_aspect',timestep, nsteps, provide_times='l_s') insol = np.zeros_like(dem.data)
diff_angle = vsep(mspicer.trnormal, mspicer.sun_direction) if (mspicer.illum_angles.dsolar > 90) or (np.degrees(diff_angle) > 90): to_append = 0 else: to_append = mspicer.solar_constant * dt.seconds * math.cos(diff_angle) energies.append(to_append) mspicer.time += dt return np.array((ets, energies)) def save_data_to_file(data, fname, start, dt): with open(fname,'w') as f: f.write('# Start: {1}, dt: {0} s, Intensities in J/(dt*m**2)\n'.format(dt.seconds,start.isoformat())) np.savetxt(f, data.T) # location setup mspicer = MarsSpicer() mspicer.set_spoint_by(lat=85,lon=0) # timing setup mspicer.goto_ls_0() mspicer.time -= dt.timedelta(days=10,hours=12) # dt, the time step my_dt = dt.timedelta(hours=1) # saving for restart later start_time = mspicer.time out_flat = create_arrays(mspicer, 50, my_dt) save_data_to_file(out_flat[1], 'insolation_flat.txt', start_time, my_dt)
def __init__(self, time = None, dt = None): MarsSpicer.__init__(self, time)
def main(): # default time is now: mspice = MarsSpicer() # set up location mspice.set_spoint_by(lat=85, lon = 0) # set up starting time of analysis, l_s = 0 mspice.utc = '2011-09-13T14:24:33.733548' # mspice.time += dt.timedelta(30) # ls1 = mspice.l_s # utc1 = mspice.utc # mspice.time += dt.timedelta(1) # ls2 = mspice.l_s # mspice.utc = utc1 # stopping l_s value end_ls = 360 # l_s resolution # ls_res = 0.02 ls_res = 5.0 # time resolution time_res = 3600 # save this time for multiple runs for resetting mspice each time start_time = mspice.time # container for all energy arrays energies = [] # labels for the plotting labels = [] # tilt the surface normal by 30 degree to the north (north = default) # this creates an instance variable called 'tnormal' mspice.tilt = 30 # first time, save the bigtimes array bigtimes, energies_t30 = outer_loop(mspice, end_ls, ls_res, 'tilted_normal',time_res=time_res) energies.append(energies_t30) labels.append('t30') # rotate the tilted vector around the local surface normal to create an aspect # angle # this creates an instance variable called 'trnormal' mspice.aspect = 90 mspice.time = start_time energies.append(outer_loop(mspice, end_ls, ls_res, 'tilted_rotated_normal',time_res=time_res)[1]) labels.append('t30_a90') mspice.time = start_time energies.append(outer_loop(mspice, end_ls, ls_res, 'snormal',time_res=time_res)[1]) labels.append('flat') mspice.aspect = 180 mspice.time = start_time energies.append(outer_loop(mspice, end_ls, ls_res, 'tilted_rotated_normal',time_res=time_res)[1]) labels.append('t30,a180') fig = figure() ax = fig.add_subplot(111) grid() for energy,label in zip(energies,labels): ax.plot(bigtimes,energy, '-*', label=label) ax.set_xlabel('L_s [deg]') ax.set_ylabel('Insolation per 10 L_s [MJ]') ax.set_title('Insolation of t_ilted and a_spected (rotated) surfaces at 85 N') ax.legend(loc='best') show() return (energies, labels)
from __future__ import division import numpy as np from matplotlib.pyplot import figure, show, cm, grid, subplots from matplotlib.ticker import MultipleLocator from use_mspicer import outer_loop from kmaspice import MarsSpicer # default time is now: mspice = MarsSpicer() # set up location mspice.set_spoint_by(lat=85, lon = 0) # set up starting time of analysis, l_s = 0 mspice.utc = '2011-09-13T14:24:33.733548' # stopping l_s value end_ls = 360 # l_s resolution ls_res = 10 # save this time for multiple runs for resetting mspice each time start_time = mspice.time # container for all energy arrays energies = [] # labels for the plotting labels = []
""" from __future__ import print_function from kmaspice import MarsSpicer from numpy import array import pdstools labels = pdstools.PDSLabel('/Users/maye/data/hirise/inca/ESP_022607_0985_RED.LBL') # taking these from the grayscale label of ESP_022607_0985 max_lat = labels.maxlat min_lat = labels.minlat east_lon = labels.eastmost west_lon = labels.westmost start_time = labels.time event = MarsSpicer(time=start_time) inc_angles = [] for lat,lon in [(max_lat,east_lon), (max_lat,west_lon), (min_lat,east_lon), (min_lat,west_lon)]: event.set_spoint_by(lat=lat,lon=lon) inc_angles.append(event.illum_angles.dsolar) print("Lat = {0}, Lon = {1}, \nIncidence angle:{2}\n".format( lat,lon,event.illum_angles.dsolar)) angles = array(inc_angles) delta = angles.max()-angles.min()
# delta between north and top of image delta_angle = np.degrees(np.arctan2(v1[1],v1[0]))-90.0 # dsample = newPoint.sample - dem.center.sample # dline = newPoint.line - dem.center.line # plt.quiver(dem.center.sample,dem.center.line,dsample,dline,angles='xy', scale_units='xy', scale=1) # correct aspects for delta angle # it needs to be added, because aspects go clock-wise aspects.data += delta_angle # bend around data > 360 mask = aspects.data > 360.0 aspects.data[mask] = aspects.data[mask] - 360.0 # # create MarsSpicer object mspice = MarsSpicer() utc1 = '2011-05-24T00:58:08.402' utc2 = '2011-05-31T05:01:50.854' mspice.utc = utc2 mspice.obs = 'MRO' mspice.instrument = 'MRO_HIRISE' mspice.set_spoint_by('sincpt') phase = np.zeros_like(dem.data) emissions = [] incidences = [] rev_srfvec = spice.vminus(mspice.srfvec) for sample in xrange(phase.shape[0]): if sample % 10 == 0: print('Sample {0}'.format(sample))