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) mspicer.get_tilted_normal(30)
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() print("Max difference: ",delta) print("Relative error to mean [%]: ",delta*100/angles.mean())
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)
# 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)) for line in xrange(phase.shape[1]): slope = float(slopes.data[sample, line]) aspect = float(aspects.data[sample, line]) # newPoint = Point(sample, line) # newPoint.pixel_to_lonlat(dem.geotransform, dem.projection) # mspice.set_spoint_by(lat = newPoint.lat, lon = newPoint.lon)