def eci2RaDec(eci): """ Convert Earth-centered intertial vector to right ascension and declination. Arguments: eci: [3 element ndarray] Earth-centered inertial coordinats Return: (ra, dec): [tuple of floats] right ascension and declinaton """ # Normalize the ECI coordinates eci = vectNorm(eci) # Calculate declination dec = np.arcsin(eci[2]) # Calculate right ascension ra = np.arctan2(eci[1], eci[0]) % (2 * np.pi) return ra, dec
def calcSpatialResidual(jd, state_vect, radiant_eci, stat, meas): """ Calculate horizontal and vertical residuals from the radiant line, for the given observed point. Arguments: jd: [float] Julian date state_vect: [3 element ndarray] ECI position of the state vector radiant_eci: [3 element ndarray] radiant direction vector in ECI stat: [3 element ndarray] position of the station in ECI meas: [3 element ndarray] line of sight from the station, in ECI Return: (hres, vres): [tuple of floats] residuals in horitontal and vertical direction from the radiant line """ meas = vectNorm(meas) # Calculate closest points of approach (observed line of sight to radiant line) from the state vector obs_cpa, rad_cpa, d = findClosestPoints(stat, meas, state_vect, radiant_eci) # Vector pointing from the point on the trajectory to the point on the line of sight p = obs_cpa - rad_cpa # Calculate geographical coordinates of the state vector lat, lon, elev = cartesian2Geo(jd, *state_vect) # Calculate ENU (East, North, Up) vector at the position of the state vector, and direction of the radiant nn = np.array(ecef2ENU(lat, lon, *radiant_eci)) # Convert the vector to polar coordinates theta = np.arctan2(nn[1], nn[0]) phi = np.arccos(nn[2] / vectMag(nn)) # Local reference frame unit vectors hx = np.array([-np.cos(theta), np.sin(theta), 0.0]) vz = np.array([ -np.cos(phi) * np.sin(theta), -np.cos(phi) * np.cos(theta), np.sin(phi) ]) hy = np.array([ np.sin(phi) * np.sin(theta), np.sin(phi) * np.cos(theta), np.cos(phi) ]) # Calculate local reference frame unit vectors in ECEF coordinates ehorzx = enu2ECEF(lat, lon, *hx) ehorzy = enu2ECEF(lat, lon, *hy) evert = enu2ECEF(lat, lon, *vz) ehx = np.dot(p, ehorzx) ehy = np.dot(p, ehorzy) # Calculate vertical residuals vres = np.sign(ehx) * np.hypot(ehx, ehy) # Calculate horizontal residuals hres = np.dot(p, evert) return hres, vres
stat = np.array(geo2Cartesian(lat, lon, h + 10, jd)) meas = np.array([0.0, 0.0, 1.0]) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') print(calcSpatialResidual(jd, state_vect, radiant_eci, stat, meas)) # Plot the origin #ax.scatter(0, 0, 0) # Plot the first point ax.scatter(*state_vect) # Plot the line from the origin rad_x, rad_y, rad_z = -vectNorm(state_vect) rst_x, rst_y, rst_z = state_vect meteor_len = 1000000 ax.quiver(rst_x, rst_y, rst_z, rad_x, rad_y, rad_z, length=meteor_len, normalize=True, color='b', arrow_length_ratio=0.1) # Plot the radiant direction line rad_x, rad_y, rad_z = -radiant_eci
def calcOrbit(radiant_eci, v_init, v_avg, eci_ref, jd_ref, stations_fixed=False, reference_init=True, \ rotation_correction=False): """ Calculate the meteor's orbit from the given meteor trajectory. The orbit of the meteoroid is defined relative to the centre of the Sun (heliocentric). Arguments: radiant_eci: [3 element ndarray] Radiant vector in ECI coordinates (meters). v_init: [float] Initial velocity (m/s). v_avg: [float] Average velocity of a meteor (m/s). eci_ref: [float] reference ECI coordinates in the epoch of date (meters, in the epoch of date) of the meteor trajectory. They can be calculated with the geo2Cartesian function. Ceplecha (1987) assumes this to the the average point on the trajectory, while Jennsikens et al. (2011) assume this to be the first point on the trajectory as that point is not influenced by deceleration. NOTE: If the stations are not fixed, the reference ECI coordinates should be the ones of the initial point on the trajectory, NOT of the average point! jd_ref: [float] reference Julian date of the meteor trajectory. Ceplecha (1987) takes this as the average time of the trajectory, while Jenniskens et al. (2011) take this as the the first point on the trajectory. Keyword arguments: stations_fixed: [bool] If True, the correction for Earth's rotation will be performed on the radiant, but not the velocity. This should be True ONLY in two occasions: - if the ECEF coordinate system was used for trajectory estimation - if the ECI coordinate system was used for trajectory estimation, BUT the stations were not moved in time, but were kept fixed at one point, regardless of the trajectory estimation method. It is necessary to perform this correction for the intersecting planes method, but not for the lines of sight method ONLY when the stations are not fixed. Of course, if one is using the lines of sight method with fixed stations, one should perform this correction! reference_init: [bool] If True (default), the initial point on the trajectory is given as the reference one, i.e. the reference ECI coordinates are the ECI coordinates of the initial point on the trajectory, where the meteor has the velocity v_init. If False, then the reference point is the average point on the trajectory, and the average velocity will be used to do the corrections. rotation_correction: [bool] If True, the correction of the initial velocity for Earth's rotation will be performed. False by default. This should ONLY be True if the coordiante system for trajectory estimation was ECEF, i.e. did not rotate with the Earth. In all other cases it should be False, even if fixed station coordinates were used in the ECI coordinate system! Return: orb: [Orbit object] Object containing the calculated orbit. """ ### Correct the velocity vector for the Earth's rotation if the stations are fixed ### ########################################################################################################## eci_x, eci_y, eci_z = eci_ref # Calculate the geocentric latitude (latitude which considers the Earth as an elipsoid) of the reference # trajectory point lat_geocentric = np.arctan2(eci_z, np.sqrt(eci_x**2 + eci_y**2)) # Calculate the dynamical JD jd_dyn = jd2DynamicalTimeJD(jd_ref) # Calculate the geographical coordinates of the reference trajectory ECI position lat_ref, lon_ref, ht_ref = cartesian2Geo(jd_ref, *eci_ref) # Initialize a new orbit structure and assign calculated parameters orb = Orbit() # Calculate the velocity of the Earth rotation at the position of the reference trajectory point (m/s) v_e = 2 * np.pi * vectMag(eci_ref) * np.cos(lat_geocentric) / 86164.09053 # Calculate the equatorial coordinates of east from the reference position on the trajectory azimuth_east = np.pi / 2 altitude_east = 0 ra_east, dec_east = altAz2RADec(azimuth_east, altitude_east, jd_ref, lat_ref, lon_ref) # Compute velocity components of the state vector if reference_init: # If the initial velocity was the reference velocity, use it for the correction v_ref_vect = v_init * radiant_eci else: # Calculate reference velocity vector using the average point on the trajectory and the average # velocity v_ref_vect = v_avg * radiant_eci # Apply the Earth rotation correction if the station coordinates are fixed (a MUST for the # intersecting planes method!) if stations_fixed: ### Set fixed stations radiant info ### # If the stations are fixed, then the input state vector is already fixed to the ground orb.ra_norot, orb.dec_norot = eci2RaDec(radiant_eci) # Apparent azimuth and altitude (no rotation) orb.azimuth_apparent_norot, orb.elevation_apparent_norot = raDec2AltAz(orb.ra_norot, orb.dec_norot, \ jd_ref, lat_ref, lon_ref) # Estimated average velocity (no rotation) orb.v_avg_norot = v_avg # Estimated initial velocity (no rotation) orb.v_init_norot = v_init ### ### v_ref_corr = np.zeros(3) # Calculate the corrected reference velocity vector/radiant v_ref_corr[0] = v_ref_vect[0] - v_e * np.cos(ra_east) v_ref_corr[1] = v_ref_vect[1] - v_e * np.sin(ra_east) v_ref_corr[2] = v_ref_vect[2] else: # MOVING STATIONS # Velocity vector will remain unchanged if the stations were moving if reference_init: v_ref_corr = v_init * radiant_eci else: v_ref_corr = v_avg * radiant_eci ### ### # If the rotation correction does not have to be applied, meaning that the rotation is already # included, compute a version of the radiant and the velocity without Earth's rotation # (REPORTING PURPOSES ONLY, THESE VALUES ARE NOT USED IN THE CALCULATION) v_ref_nocorr = np.zeros(3) # Calculate the derotated reference velocity vector/radiant v_ref_nocorr[0] = v_ref_vect[0] + v_e * np.cos(ra_east) v_ref_nocorr[1] = v_ref_vect[1] + v_e * np.sin(ra_east) v_ref_nocorr[2] = v_ref_vect[2] # Compute the radiant without Earth's rotation included orb.ra_norot, orb.dec_norot = eci2RaDec(vectNorm(v_ref_nocorr)) orb.azimuth_apparent_norot, orb.elevation_apparent_norot = raDec2AltAz(orb.ra_norot, orb.dec_norot, \ jd_ref, lat_ref, lon_ref) orb.v_init_norot = vectMag(v_ref_nocorr) orb.v_avg_norot = orb.v_init_norot - v_init + v_avg ### ### ########################################################################################################## ### Correct velocity for Earth's gravity ### ########################################################################################################## # If the reference velocity is the initial velocity if reference_init: # Use the corrected velocity for Earth's rotation (when ECEF coordinates are used) if rotation_correction: v_init_corr = vectMag(v_ref_corr) else: # IMPORTANT NOTE: The correction in this case is only done on the radiant (even if the stations # were fixed, but NOT on the initial velocity!). Thus, correction from Ceplecha 1987, # equation (35) is not needed. If the initial velocity is determined from time vs. length and in # ECI coordinates, whose coordinates rotate with the Earth, the moving stations play no role in # biasing the velocity. v_init_corr = v_init else: if rotation_correction: # Calculate the corrected initial velocity if the reference velocity is the average velocity v_init_corr = vectMag(v_ref_corr) + v_init - v_avg else: v_init_corr = v_init # Calculate apparent RA and Dec from radiant state vector orb.ra, orb.dec = eci2RaDec(radiant_eci) orb.v_init = v_init orb.v_avg = v_avg # Calculate the apparent azimuth and altitude (geodetic latitude, because ra/dec are calculated from ECI, # which is calculated from WGS84 coordinates) orb.azimuth_apparent, orb.elevation_apparent = raDec2AltAz( orb.ra, orb.dec, jd_ref, lat_ref, lon_ref) orb.jd_ref = jd_ref orb.lon_ref = lon_ref orb.lat_ref = lat_ref orb.ht_ref = ht_ref orb.lat_geocentric = lat_geocentric # Assume that the velocity in infinity is the same as the initial velocity (after rotation correction, if # it was needed) orb.v_inf = v_init_corr # Make sure the velocity of the meteor is larger than the escape velocity if v_init_corr**2 > (2 * 6.67408 * 5.9722) * 1e13 / vectMag(eci_ref): # Calculate the geocentric velocity (sqrt of squared inital velocity minus the square of the Earth escape # velocity at the height of the trajectory), units are m/s. # Square of the escape velocity is: 2GM/r, where G is the 2014 CODATA-recommended value of # 6.67408e-11 m^3/(kg s^2), and the mass of the Earth is M = 5.9722e24 kg v_g = np.sqrt(v_init_corr**2 - (2 * 6.67408 * 5.9722) * 1e13 / vectMag(eci_ref)) # Calculate the radiant corrected for Earth's rotation (ONLY if the stations were fixed, otherwise it # is the same as the apparent radiant) ra_corr, dec_corr = eci2RaDec(vectNorm(v_ref_corr)) # Calculate the Local Sidreal Time of the reference trajectory position lst_ref = np.radians(jd2LST(jd_ref, np.degrees(lon_ref))[0]) # Calculate the apparent zenith angle zc = np.arccos(np.sin(dec_corr)*np.sin(lat_geocentric) \ + np.cos(dec_corr)*np.cos(lat_geocentric)*np.cos(lst_ref - ra_corr)) # Calculate the zenith attraction correction delta_zc = 2 * np.arctan2( (v_init_corr - v_g) * np.tan(zc / 2), v_init_corr + v_g) # Zenith distance of the geocentric radiant zg = zc + np.abs(delta_zc) ########################################################################################################## ### Calculate the geocentric radiant ### ########################################################################################################## # Get the azimuth from the corrected RA and Dec azimuth_corr, _ = raDec2AltAz(ra_corr, dec_corr, jd_ref, lat_geocentric, lon_ref) # Calculate the geocentric radiant ra_g, dec_g = altAz2RADec(azimuth_corr, np.pi / 2 - zg, jd_ref, lat_geocentric, lon_ref) ### Precess ECI coordinates to J2000 ### # Convert rectangular to spherical coordiantes re, delta_e, alpha_e = cartesianToSpherical(*eci_ref) # Precess coordinates to J2000 alpha_ej, delta_ej = equatorialCoordPrecession(jd_ref, J2000_JD.days, alpha_e, delta_e) # Convert coordinates back to rectangular eci_ref = sphericalToCartesian(re, delta_ej, alpha_ej) eci_ref = np.array(eci_ref) ###### # Precess the geocentric radiant to J2000 ra_g, dec_g = equatorialCoordPrecession(jd_ref, J2000_JD.days, ra_g, dec_g) # Calculate the ecliptic latitude and longitude of the geocentric radiant (J2000 epoch) L_g, B_g = raDec2Ecliptic(J2000_JD.days, ra_g, dec_g) # Load the JPL ephemerids data jpl_ephem_data = SPK.open(config.jpl_ephem_file) # Get the position of the Earth (km) and its velocity (km/s) at the given Julian date (J2000 epoch) # The position is given in the ecliptic coordinates, origin of the coordinate system is in the centre # of the Sun earth_pos, earth_vel = calcEarthRectangularCoordJPL( jd_dyn, jpl_ephem_data, sun_centre_origin=True) # print('Earth position:') # print(earth_pos) # print('Earth velocity:') # print(earth_vel) # Convert the Earth's position to rectangular equatorial coordinates (FK5) earth_pos_eq = rotateVector(earth_pos, np.array([1, 0, 0]), J2000_OBLIQUITY) # print('Earth position (FK5):') # print(earth_pos_eq) # print('Meteor ECI:') # print(eci_ref) # Add the position of the meteor's trajectory to the position of the Earth to calculate the # equatorial coordinates of the meteor (in kilometers) meteor_pos = earth_pos_eq + eci_ref / 1000 # print('Meteor position (FK5):') # print(meteor_pos) # Convert the position of the trajectory from FK5 to heliocentric ecliptic coordinates meteor_pos = rotateVector(meteor_pos, np.array([1, 0, 0]), -J2000_OBLIQUITY) # print('Meteor position:') # print(meteor_pos) ########################################################################################################## # Calculate components of the heliocentric velocity of the meteor (km/s) v_h = np.array(earth_vel) + np.array( eclipticToRectangularVelocityVect(L_g, B_g, v_g / 1000)) # Calculate the heliocentric velocity in km/s v_h_mag = vectMag(v_h) # Calculate the corrected heliocentric ecliptic coordinates of the meteoroid using the method of # Sato and Watanabe (2014). L_h, B_h, met_v_h = correctedEclipticCoord(L_g, B_g, v_g / 1000, earth_vel) # Calculate the solar longitude la_sun = jd2SolLonJPL(jd_dyn) # Calculations below done using Dave Clark's Master thesis equations # Specific orbital energy epsilon = (vectMag(v_h)**2) / 2 - SUN_MU / vectMag(meteor_pos) # Semi-major axis in AU a = -SUN_MU / (2 * epsilon * AU) # Calculate mean motion in rad/day n = np.sqrt(G * SUN_MASS / ((np.abs(a) * AU * 1000.0)**3)) * 86400.0 # Calculate the orbital period in years T = 2 * np.pi * np.sqrt( ((a * AU)**3) / SUN_MU) / (86400 * SIDEREAL_YEAR) # Calculate the orbit angular momentum h_vect = np.cross(meteor_pos, v_h) # Calculate inclination incl = np.arccos(h_vect[2] / vectMag(h_vect)) # Calculate eccentricity e_vect = np.cross(v_h, h_vect) / SUN_MU - vectNorm(meteor_pos) eccentricity = vectMag(e_vect) # Calculate perihelion distance (source: Jenniskens et al., 2011, CAMS overview paper) if eccentricity == 1: q = (vectMag(meteor_pos) + np.dot(e_vect, meteor_pos)) / (1 + vectMag(e_vect)) else: q = a * (1.0 - eccentricity) # Calculate the aphelion distance Q = a * (1.0 + eccentricity) # Normal vector to the XY reference frame k_vect = np.array([0, 0, 1]) # Vector from the Sun pointing to the ascending node n_vect = np.cross(k_vect, h_vect) # Calculate node if vectMag(n_vect) == 0: node = 0 else: node = np.arctan2(n_vect[1], n_vect[0]) node = node % (2 * np.pi) # Calculate argument of perihelion if vectMag(n_vect) != 0: peri = np.arccos( np.dot(n_vect, e_vect) / (vectMag(n_vect) * vectMag(e_vect))) if e_vect[2] < 0: peri = 2 * np.pi - peri else: peri = np.arccos(e_vect[0] / vectMag(e_vect)) peri = peri % (2 * np.pi) # Calculate the longitude of perihelion pi = (node + peri) % (2 * np.pi) ### Calculate true anomaly true_anomaly = np.arccos( np.dot(e_vect, meteor_pos) / (vectMag(e_vect) * vectMag(meteor_pos))) if np.dot(meteor_pos, v_h) < 0: true_anomaly = 2 * np.pi - true_anomaly true_anomaly = true_anomaly % (2 * np.pi) ### # Calculate eccentric anomaly eccentric_anomaly = np.arctan2(np.sqrt(1 - eccentricity**2)*np.sin(true_anomaly), eccentricity \ + np.cos(true_anomaly)) # Calculate mean anomaly mean_anomaly = eccentric_anomaly - eccentricity * np.sin( eccentric_anomaly) mean_anomaly = mean_anomaly % (2 * np.pi) # Calculate the time in days since the last perihelion passage of the meteoroid dt_perihelion = (mean_anomaly * a**(3.0 / 2)) / 0.01720209895 if not np.isnan(dt_perihelion): # Calculate the date and time of the last perihelion passage last_perihelion = jd2Date(jd_dyn - dt_perihelion, dt_obj=True) else: last_perihelion = None # Calculate Tisserand's parameter with respect to Jupiter Tj = 2 * np.sqrt( (1 - eccentricity**2) * a / 5.204267) * np.cos(incl) + 5.204267 / a # Assign calculated parameters orb.lst_ref = lst_ref orb.jd_dyn = jd_dyn orb.v_g = v_g orb.ra_g = ra_g orb.dec_g = dec_g orb.meteor_pos = meteor_pos orb.L_g = L_g orb.B_g = B_g orb.v_h_x, orb.v_h_y, orb.v_h_z = met_v_h orb.L_h = L_h orb.B_h = B_h orb.zc = zc orb.zg = zg orb.v_h = v_h_mag * 1000 orb.la_sun = la_sun orb.a = a orb.e = eccentricity orb.i = incl orb.peri = peri orb.node = node orb.pi = pi orb.q = q orb.Q = Q orb.true_anomaly = true_anomaly orb.eccentric_anomaly = eccentric_anomaly orb.mean_anomaly = mean_anomaly orb.last_perihelion = last_perihelion orb.n = n orb.T = T orb.Tj = Tj return orb
def checkFOVOverlap(self, rp, tp): """ Check if two stations have overlapping fields of view between heights of 50 to 115 km. Arguments: rp: [Platepar] Reference platepar. tp: [Platepar] Test platepar. Return: [bool] True if FOVs overlap, False otherwise. """ # Compute the FOV diagonals of both stations reference_fov = np.radians(np.sqrt(rp.fov_v**2 + rp.fov_h**2)) test_fov = np.radians(np.sqrt(tp.fov_v**2 + tp.fov_h**2)) lat1, lon1, elev1 = np.radians(rp.lat), np.radians(rp.lon), rp.elev lat2, lon2, elev2 = np.radians(tp.lat), np.radians(tp.lon), tp.elev # Compute alt/az of the FOV centre azim1, alt1 = raDec2AltAz(np.radians(rp.RA_d), np.radians(rp.dec_d), rp.JD, lat1, lon1) azim2, alt2 = raDec2AltAz(np.radians(tp.RA_d), np.radians(tp.dec_d), tp.JD, lat2, lon2) # Use now as a reference time for FOV overlap check ref_jd = datetime2JD(datetime.datetime.utcnow()) # Compute ECI coordinates of both stations reference_stat_eci = np.array( geo2Cartesian(lat1, lon1, rp.elev, ref_jd)) test_stat_eci = np.array(geo2Cartesian(lat2, lon2, tp.elev, ref_jd)) # Compute ECI vectors of the FOV centre ra1, dec1 = altAz2RADec(azim1, alt1, ref_jd, lat1, lon1) reference_fov_eci = vectNorm(np.array(raDec2ECI(ra1, dec1))) ra2, dec2 = altAz2RADec(azim2, alt2, ref_jd, lat2, lon2) test_fov_eci = vectNorm(np.array(raDec2ECI(ra2, dec2))) # Compute ECI coordinates at different heights along the FOV line and check for FOV overlap # The checked heights are 50, 70, 95, and 115 km (ordered by overlap probability for faster # execution) for height_above_ground in [95000, 70000, 115000, 50000]: # Compute points in the middle of FOVs of both stations at given heights reference_fov_point = reference_stat_eci + reference_fov_eci*(height_above_ground \ - elev1)/np.sin(alt1) test_fov_point = test_stat_eci + test_fov_eci * ( height_above_ground - elev2) / np.sin(alt2) # Check if the middles of the FOV are in the other camera's FOV if (angleBetweenVectors(reference_fov_eci, test_fov_point - reference_stat_eci) <= reference_fov/2) \ or (angleBetweenVectors(test_fov_eci, reference_fov_point - test_stat_eci) <= test_fov/2): return True # Compute vectors pointing from one station's point on the FOV line to the other reference_to_test = vectNorm(test_fov_point - reference_fov_point) test_to_reference = -reference_to_test # Compute vectors from the ground to those points reference_fov_gnd = reference_fov_point - reference_stat_eci test_fov_gnd = test_fov_point - test_stat_eci # Compute vectors moved towards the other station by half the FOV diameter reference_moved = reference_stat_eci + vectorFromPointDirectionAndAngle(reference_fov_gnd, \ reference_to_test, reference_fov/2) test_moved = test_stat_eci + vectorFromPointDirectionAndAngle(test_fov_gnd, test_to_reference, \ test_fov/2) # Compute the vector pointing from one station to the moved point of the other station reference_to_test_moved = vectNorm(test_moved - reference_stat_eci) test_to_reference_moved = vectNorm(reference_moved - test_stat_eci) # Check if the FOVs overlap if (angleBetweenVectors(reference_fov_eci, reference_to_test_moved) <= reference_fov/2) \ or (angleBetweenVectors(test_fov_eci, test_to_reference_moved) <= test_fov/2): return True return False
def sampleTrajectory(dir_path, file_name, beg_ht, end_ht, sample_step): """ Given the trajectory, beginning, end and step in km, this function will interpolate the fireball height vs. distance and return the coordinates of sampled positions and compute the azimuth and elevation for every point. Arguments: Return: """ # Load the trajectory file traj = loadPickle(dir_path, file_name) # Set begin and end heights, if not given if beg_ht < 0: beg_ht = traj.rbeg_ele / 1000 if end_ht < 0: end_ht = traj.rend_ele / 1000 # Convert heights to meters beg_ht *= 1000 end_ht *= 1000 sample_step *= 1000 # Generate heights for sampling height_array = np.flipud( np.arange(end_ht, beg_ht + sample_step, sample_step)) ### Fit time vs. height time_data = [] height_data = [] for obs in traj.observations: time_data += obs.time_data.tolist() height_data += obs.model_ht.tolist() # Plot the station data plt.scatter(obs.time_data, obs.model_ht / 1000, label=obs.station_id, marker='x', zorder=3) height_data = np.array(height_data) time_data = np.array(time_data) # Sort the arrays by decreasing time arr_sort_indices = np.argsort(time_data)[::-1] height_data = height_data[arr_sort_indices] time_data = time_data[arr_sort_indices] # Plot the non-smoothed time vs. height #plt.scatter(time_data, height_data/1000, label='Data') # Apply Savitzky-Golay to smooth out the height change height_data = scipy.signal.savgol_filter(height_data, 21, 5) plt.scatter(time_data, height_data / 1000, label='Savitzky-Golay filtered', marker='+', zorder=3) # Sort the arrays by increasing heights (needed for interpolation) arr_sort_indices = np.argsort(height_data) height_data = height_data[arr_sort_indices] time_data = time_data[arr_sort_indices] # Interpolate height vs. time ht_vs_time_interp = scipy.interpolate.PchipInterpolator( height_data, time_data) # Plot the interpolation ht_arr = np.linspace(np.min(height_data), np.max(height_data), 1000) time_arr = ht_vs_time_interp(ht_arr) plt.plot(time_arr, ht_arr / 1000, label='Interpolation', zorder=3) plt.legend() plt.xlabel('Time (s)') plt.ylabel('Height (km)') plt.grid() plt.show() ### # Take the ground above the state vector as the reference distance from the surface of the Earth ref_radius = vectMag(traj.state_vect_mini) - np.max(height_data) # Compute distance from the centre of the Earth to each height radius_array = ref_radius + height_array print('Beginning coordinates (observed):') print(' Lat: {:.6f}'.format(np.degrees(traj.rbeg_lat))) print(' Lon: {:.6f}'.format(np.degrees(traj.rbeg_lon))) print(' Elev: {:.1f}'.format(traj.rbeg_ele)) print() print("Ground-fixed azimuth and altitude:") print( ' Time(s), Sample ht (m), Lat (deg), Lon (deg), Height (m), Azim (deg), Elev (deg)' ) # Go through every distance from the Earth centre and compute the geo coordinates at the given distance, # as well as the point-to-point azimuth and elevation prev_eci = None for ht, radius in zip(height_array, radius_array): # If the height is lower than the eng height, use a fixed velocity of 3 km/s if ht < traj.rend_ele: t_est = ht_vs_time_interp( traj.rend_ele) + abs(ht - traj.rend_ele) / 3000 time_marker = "*" else: # Estimate the fireball time at the given height using interpolated values t_est = ht_vs_time_interp(ht) time_marker = " " # Compute the intersection between the trajectory line and the sphere of radius at the given height intersections = lineAndSphereIntersections(np.array([0, 0, 0]), radius, traj.state_vect_mini, traj.radiant_eci_mini) # Choose the intersection that is closer to the state vector inter_min_dist_indx = np.argmin( [vectMag(inter - traj.state_vect_mini) for inter in intersections]) height_eci = intersections[inter_min_dist_indx] # Compute the Julian date at the given height jd = traj.jdt_ref + t_est / 86400.0 # Compute geographical coordinates lat, lon, ele_geo = cartesian2Geo(jd, *height_eci) # Compute azimuth and elevation if prev_eci is not None: # Compute the vector pointing from the previous point to the current point direction_vect = vectNorm(prev_eci - height_eci) ### Compute the ground-fixed alt/az eci_x, eci_y, eci_z = height_eci # Calculate the geocentric latitude (latitude which considers the Earth as an elipsoid) of the reference # trajectory point lat_geocentric = np.arctan2(eci_z, np.sqrt(eci_x**2 + eci_y**2)) # Calculate the velocity of the Earth rotation at the position of the reference trajectory point (m/s) v_e = 2 * np.pi * vectMag(height_eci) * np.cos( lat_geocentric) / 86164.09053 # Calculate the equatorial coordinates of east from the reference position on the trajectory azimuth_east = np.pi / 2 altitude_east = 0 ra_east, dec_east = altAz2RADec(azimuth_east, altitude_east, jd, lat, lon) # The reference velocity vector has the average velocity and the given direction # Note that ideally this would be the instantaneous velocity v_ref_vect = traj.orbit.v_avg_norot * direction_vect v_ref_nocorr = np.zeros(3) # Calculate the derotated reference velocity vector/radiant v_ref_nocorr[0] = v_ref_vect[0] + v_e * np.cos(ra_east) v_ref_nocorr[1] = v_ref_vect[1] + v_e * np.sin(ra_east) v_ref_nocorr[2] = v_ref_vect[2] # Compute the radiant without Earth's rotation included ra_norot, dec_norot = eci2RaDec(vectNorm(v_ref_nocorr)) azim_norot, elev_norot = raDec2AltAz(ra_norot, dec_norot, jd, lat, lon) ### else: azim_norot = -np.inf elev_norot = -np.inf prev_eci = np.copy(height_eci) print( "{:s}{:7.3f}, {:13.1f}, {:10.6f}, {:11.6f}, {:10.1f}, {:10.6f}, {:10.6f}" .format(time_marker, t_est, ht, np.degrees(lat), np.degrees(lon), ele_geo, np.degrees(azim_norot), np.degrees(elev_norot))) print( 'The star * denotes heights extrapolated after the end of the fireball, with the fixed velocity of 3 km/s.' ) print('End coordinates (observed):') print(' Lat: {:.6f}'.format(np.degrees(traj.rend_lat))) print(' Lon: {:.6f}'.format(np.degrees(traj.rend_lon))) print(' Elev: {:.1f}'.format(traj.rend_ele))