def detector_center(self): if not hasattr(self, '_detector_center'): center_line = float( spice.gdpool('INS{}_BORESIGHT_LINE'.format(self.ikid), 0, 1)[0]) center_sample = float( spice.gdpool('INS{}_BORESIGHT_SAMPLE'.format(self.ikid), 0, 1)[0]) self._detector_center = [center_line, center_sample] return self._detector_center
def focal2pixel_lines(self): """ Calculated using 1/pixel pitch """ pixel_size = spice.gdpool('INS{}_PIXEL_SIZE'.format(self._tc_id), 0, 1)[0] return [0, -1 / pixel_size, 0]
def solar_radiation_pressure(self, t, y): """ 计算太阳辐射光压 见英文版教材P79 3.75 :self.PARAM t: TDB时刻 :self.PARAM y: 对应时刻人造卫星的状态向量[x, y, z, vx, vy, vz] :return: 太阳辐射光压加速度 """ r_mex = y[:3] r_sun = spice.spkezr("Sun", t, self.PARAM["Ref_Frame"], 'None', self.PARAM["Ref_Body"])[0][:3] r_sun_mex = r_mex - r_sun AU_km = spice.gdpool("AU", 0, 1)[0] v = min([ self.body_shadow_function(r_mex, name, t) for name in self.PARAM["Occulting_Bodies"] ]) CR, A, m = [ self.PARAM[i] for i in ["CR", "Surface_Area", "Satellite_Mass"] ] a = v * self.P_Solar * CR * A / m * AU_km**2 * r_sun_mex / norm( r_sun_mex)**3 return a * 1e-3 # km * s^-2 pass
def test_topo_frame_setup(): # Check that the frame setup puts all the correct values in the kernel pool. latitude, longitude = 30, 25 name, idnum, frame_dict, latlon = spice_utils.topo_frame_def( latitude, longitude) frame_strs = ["{}={}".format(k, v) for (k, v) in frame_dict.items()] spice.lmpool(frame_strs) for k, v in frame_dict.items(): N, typecode = spice.dtpool(k) if typecode == 'N': res = spice.gdpool(k, 0, 100) if len(res) == 1: res = [int(res[0])] if N > 1: v = [float(it) for it in v.split(' ')] res = res.tolist() else: res = res[0] v = int(v) assert v == res else: res = spice.gcpool(k, 0, 100)[0] v = v.replace('\'', '') assert v == res
def definition(sensor): # # We check if the resolution of the camera has been provided as an input # if not we try to obtain the resolution of the camera from the IK # sensor_id = spiceypy.bodn2c(sensor) pixel_samples = spiceypy.gdpool(f'INS{sensor_id}_PIXEL_SAMPLES', 0, 1)[0] pixel_lines = spiceypy.gdpool(f'INS{sensor_id}_PIXEL_LINES', 0, 1)[0] ccd_center = spiceypy.gdpool(f'INS{sensor_id}_CCD_CENTER', 0, 2) print(f'{sensor} pixel_samples (x) = {pixel_samples}') print(f'{sensor} pixel_lines (y) = {pixel_lines}') print(f'{sensor} ccd_sensor (x,y) = {ccd_center[0]},{ccd_center[1]}') return
def odtk(self): """ Returns ------- : list Radial distortion coefficients """ return spice.gdpool('INS{}_OD_K'.format(self.ikid), 0, 3).tolist()
def odty(self): """ Returns ------- : list Optical distortion y coefficients """ return spice.gdpool('INS{}_OD_T_Y'.format(self.ikid), 0, 10).tolist()
def _odky(self): """ Returns ------- : list Optical distortion y coefficients """ return spice.gdpool('INS{}_DISTORTION_COEF_Y'.format(self._tc_id), 0, 4).tolist()
def focal_length(self): """ Returns ------- : float Camera focal length """ return float( spice.gdpool('INS{}_FOCAL_LENGTH'.format(self._tc_id), 0, 1)[0])
def focal2pixel_samples(self): """ Expects ikid to be defined. This must be the integer Naif id code of the instrument Returns ------- : list<double> focal plane to detector samples """ return list(spice.gdpool('INS{}_ITRANSS'.format(self.ikid), 0, 3))
def pixel_size(self): """ Expects ikid to be defined. This must be the integer Naif id code of the instrument Returns ------- : float pixel size """ return spice.gdpool('INS{}_PIXEL_SIZE'.format(self.ikid), 0, 1)[0] * 0.001
def detector_start_line(self): """ Returns starting detector line acquired from Spice Kernels. Returns ------- : string Path to latest metakernel file """ return int(spice.gdpool('INS{}_FPUBIN_START_LINE'.format(self.ikid), 0, 1)[0])
def pixel_size(self): """ Overriden because the MESSENGER IK uses PIXEL_PITCH and the units are already millimeters Returns ------- : float pixel size """ return spice.gdpool('INS{}_PIXEL_PITCH'.format(self.ikid), 0, 1)
def detector_start_sample(self): """ Returns starting detector sample quired from Spice Kernels. Returns ------- : int starting detector sample """ return int(spice.gdpool('INS{}_FPUBIN_START_SAMPLE'.format(self.ikid), 0, 1)[0])
def odtk(self): """ The coefficients for the distortion model Returns ------- : list Radial distortion coefficients. There is only one coefficient for LROC NAC l/r """ return spice.gdpool('INS{}_OD_K'.format(self.ikid), 0, 1).tolist()
def pixel2focal_y(self): """ Expects ikid to be defined. This must be the integer Naif id code of the instrument Returns ------- : list<double> detector to focal plane y """ return list(spice.gdpool('INS{}_TRANSY'.format(self.ikid), 0, 3))
def odtk(self): """ The coefficients for the radial distortion model Expects ikid to be defined. This must be the integer Naif id code of the instrument Returns ------- : list Radial distortion coefficients """ return spice.gdpool('INS{}_OD_K'.format(self.ikid), 0, 3).tolist()
def focal_epsilon(self): """ Expects ikid to be defined. This should be an integer containing the Naif ID code of the instrument Returns ------- : float focal epsilon """ return float(spice.gdpool('INS{}_FL_UNCERTAINTY'.format(self.ikid), 0, 1)[0])
def focal_length(self): """ """ coeffs = spice.gdpool('INS{}_FL_TEMP_COEFFS '.format(self.fikid), 0, 5) # reverse coeffs, mdis coeffs are listed a_0, a_1, a_2 ... a_n where # numpy wants them a_n, a_n-1, a_n-2 ... a_0 f_t = np.poly1d(coeffs[::-1]) # eval at the focal_plane_tempature return f_t(self.label['FOCAL_PLANE_TEMPERATURE'].value)
def naif_keywords(self): """ Adds the focal length cover keyword to the already populated naif keywords Returns ------- : dict Dictionary of keywords and values that ISIS creates and attaches to the label """ key = "INS" + str(self.ikid) + "_FOCAL_LENGTH_COVER" return {**super().naif_keywords, key: spice.gdpool(key, 0, 1)}
def focal_length(self): """ Returns camera focal length Expects ikid to be defined. This should be the NAIF ID for the base band. Returns ------- : float Camera focal length """ return float(spice.gdpool('INS{}_FOCAL_LENGTH'.format(self.ikid), 0, 1)[0])
def detector_center_sample(self): """ Expects ikid to be defined. This should be an integer containing the Naif ID code of the instrument Returns ------- : int The detector sample of the principle point """ return float(spice.gdpool('INS{}_FOV_CENTER_PIXEL'.format(self.ikid), 0, 2)[0])
def odty(self): """ Returns the y coefficient for the optical distortion model. Expects ikid to be defined. This must be the integer Naif id code of the instrument Returns ------- : list Optical distortion y coefficients """ return spice.gdpool('INS{}_OD_T_Y'.format(self.ikid), 0, 10).tolist()
def focal2pixel_lines(self): """ Expects ikid to be defined. This should be an integer containing the Naif ID code of the instrument Returns ------- : list<double> focal plane to detector lines """ pixel_size = spice.gdpool('INS{}_PIXEL_SIZE'.format(self.ikid), 0, 1)[0] * 0.001 return [0.0, 0.0, 1/pixel_size]
def _odky(self): """ Returns the y coefficients of the optical distortion model. Expects tc_id to be defined. This should be a string of the form LISM_TC1 or LISM_TC2. Returns ------- : list Optical distortion y coefficients """ return spice.gdpool('INS{}_DISTORTION_COEF_Y'.format(self.ikid), 0, 4).tolist()
def boresight_y(self): """ Returns the y focal plane coordinate of the boresight. Expects ikid to be defined. This should be the NAIF integer ID for the sensor. Returns ------- : float Boresight focal plane x coordinate """ return spice.gdpool('INS{}_BORESIGHT'.format(self.ikid), 1, 1)[0]
def detector_center_sample(self): """ Returnce the center detector sample of the image. Expects tc_id to be defined. This should be a string of the form LISM_TC1 or LISM_TC2. Returns ------- : int The detector sample of the principle point """ # Pixels are 0 based, not one based, so subtract 1 return spice.gdpool('INS{}_CENTER'.format(self._tc_id), 0, 2)[0] - 1
def detector_center_line(self): """ Returns the center detector line. Expects ikid to be defined. This should be an integer containing the Naif Id code of the instrument. Returns ------- : float Detector line of the principal point """ return float( spice.gdpool('INS{}_BORESIGHT_LINE'.format(self.ikid), 0, 1)[0])
def _odkx(self): """ Returns the x coefficients of the optical distortion model. Expects ikid to be defined. This should be the NAIF integer ID code for the sensor. Returns ------- : list Optical distortion x coefficients """ return spice.gdpool('INS{}_DISTORTION_COEF_X'.format(self.ikid),0, 4).tolist()
def focal_length(self): """ Returns the focal length of the sensor Expects ikid to be defined. This must be the integer Naif id code of the instrument Returns ------- : float focal length """ return float( spice.gdpool('INS{}_FOCAL_LENGTH'.format(self.ikid), 0, 1)[0])