def build_model_spec_dict(lbl_file, cube_file, spacecraft_state, instrument_orientation, scalar=1.0, verbose=False): image_time = info.get_field_value(lbl_file, "IMAGE_TIME") interframe_delay = float(info.get_field_value(lbl_file, "INTERFRAME_DELAY")) + 0.001 start_time = spice.str2et(info.get_field_value(lbl_file, "START_TIME")) + 0.06188 stop_time = spice.str2et(info.get_field_value(lbl_file, "STOP_TIME")) + 0.06188 mid_time = (start_time + stop_time) / 2.0 min_lat = float( scripting.getkey(cube_file, "MinimumLatitude", grpname="Mapping")) max_lat = float( scripting.getkey(cube_file, "MaximumLatitude", grpname="Mapping")) min_lon = float( scripting.getkey(cube_file, "MinimumLongitude", grpname="Mapping")) max_lon = float( scripting.getkey(cube_file, "MaximumLongitude", grpname="Mapping")) rot = rotation_matrix_to_euler_angles(instrument_orientation) rot = radians_xyz_to_degrees_xyz(rot) if verbose: print_r("Image Time: ", image_time) print_r("Interframe Delay: ", interframe_delay) print_r("Start Time: ", start_time) print_r("Stop Time: ", stop_time) print_r("Middle Time: ", mid_time) print_r("Minimum Latitude: ", min_lat) print_r("Maximum Latitude: ", max_lat) print_r("Minimum Longitude: ", min_lon) print_r("Maximum Longitude: ", max_lon) print_r("Scalar: ", scalar) print_r("Spacecraft Location: ", spacecraft_state * scalar) print_r("JunoCam Orientation: ", rot) model_spec_dict = { "image_time": image_time, "interframe_delay": interframe_delay, "start_time": start_time, "stop_time": stop_time, "middle_time": mid_time, "latitude_minimum": min_lat, "latitude_maximum": max_lat, "longitude_minimum": min_lon, "longitude_maximum": max_lon, "scalar": scalar, "spacecraft_location": (spacecraft_state * scalar).tolist(), "instrument_orientation": rot.tolist() } return model_spec_dict
def is_supported_file(file_name): try: if file_name[-3:].upper() in ("CUB",): value = info.get_field_value(file_name, "SpacecraftName", grpname="Instrument") return value == "Galileo Orbiter" elif file_name[-3:].upper() in ("LBL", ): value = info.get_field_value(file_name, "SPACECRAFT_NAME") return value == "GALILEO ORBITER" else: return False except: return False
def is_supported_file(file_name): if file_name is None: return False if file_name[-3:].upper() in ("CUB",): value = info.get_field_value(file_name, "SpacecraftName", grpname="Instrument") return value is not None and value.decode('UTF-8') == "JUNO" elif file_name[-3:].upper() in ("LBL", ): value = info.get_field_value(file_name, "SPACECRAFT_NAME") return value is not None and value.decode('UTF-8') == "JUNO" else: return False
def is_supported_file(file_name): if file_name[-3:].upper() in ("CUB", "IMQ"): value = info.get_field_value(file_name, "SpacecraftName", grpname="Instrument") return (value in (__VOYAGER_1__, __VOYAGER_2__)) elif file_name[-3:].upper() == "IMG": value = info.get_field_value(file_name, "SpacecraftName") if value is None: value = info.get_field_value(file_name, "SPACECRAFT_NAME") return (value in (__VOYAGER_1__, __VOYAGER_2__)) else: return False
def get_image_locations(data_homes, scalar=1.0): vecs = [] for data_home in data_homes: lbl_files = glob.glob('%s/*.lbl' % data_home) for lbl_file in lbl_files: image_time = spice.str2et( info.get_field_value(lbl_file, "IMAGE_TIME")) stop_name = info.get_field_value(lbl_file, "PRODUCT_ID") spacecraft_vec, lt = spice.spkpos('JUNO_SPACECRAFT', image_time, 'IAU_JUPITER', 'NONE', 'JUPITER') stop_spec = { "name": stop_name, "vec": ((spacecraft_vec[0] * scalar), (spacecraft_vec[1] * scalar), (spacecraft_vec[2] * scalar)) } vecs.append(stop_spec) return vecs
def __init__(self, cube_file, label_file): self.__cube_file = cube_file self.__label_file = label_file self.__texture = Texture(cube_file) self.image_time = info.get_field_value(self.__label_file, "IMAGE_TIME") self.interframe_delay = float(info.get_field_value(self.__label_file, "INTERFRAME_DELAY")) + 0.001 self.start_time = spice.str2et(info.get_field_value(self.__label_file, "START_TIME")) + 0.06188 self.stop_time = spice.str2et(info.get_field_value(self.__label_file, "STOP_TIME")) + 0.06188 self.mid_time = (self.start_time + self.stop_time) / 2.0 self.num_lines = int(info.get_field_value(self.__label_file, "LINES")) self.min_lat = float(scripting.getkey(self.__cube_file, "MinimumLatitude", grpname="Mapping")) self.max_lat = float(scripting.getkey(self.__cube_file, "MaximumLatitude", grpname="Mapping")) self.min_lon = float(scripting.getkey(self.__cube_file, "MinimumLongitude", grpname="Mapping")) self.max_lon = float(scripting.getkey(self.__cube_file, "MaximumLongitude", grpname="Mapping")) self.__model_output = "%s_rendered.tif"%(self.__cube_file[:-4]) self.__program_id = None
def is_supported_file(file_name): try: if file_name[-3:].upper() in ("LBL", "BEL"): p = load_pvl(file_name) if "INSTRUMENT_HOST_NAME" in p: instument_host_name = p["INSTRUMENT_HOST_NAME"] return instument_host_name == "CASSINI ORBITER" else: return False elif file_name[-3:].upper() == "CUB": value = info.get_field_value(file_name, "SpacecraftName", grpname="Instrument") return value == "Cassini-Huygens" else: return False except: return False
def create_obj(lbl_file, cube_file, output_file_path, scalar=1.0, lat_slices=128, lon_slices=256, verbose=False): image_time = info.get_field_value(lbl_file, "IMAGE_TIME") interframe_delay = float(info.get_field_value(lbl_file, "INTERFRAME_DELAY")) + 0.001 start_time = spice.str2et(info.get_field_value(lbl_file, "START_TIME")) + 0.06188 stop_time = spice.str2et(info.get_field_value(lbl_file, "STOP_TIME")) + 0.06188 mid_time = (start_time + stop_time) / 2.0 min_lat = float( scripting.getkey(cube_file, "MinimumLatitude", grpname="Mapping")) max_lat = float( scripting.getkey(cube_file, "MaximumLatitude", grpname="Mapping")) min_lon = float( scripting.getkey(cube_file, "MinimumLongitude", grpname="Mapping")) max_lon = float( scripting.getkey(cube_file, "MaximumLongitude", grpname="Mapping")) spacecraft_orientation, jupiter_state, spacecraft_state, jupiter_rotation, instrument_cube_orientation, instrument_orientation = calculate_orientations( mid_time, interframe_delay, frame_number=0) model_spec_dict = build_model_spec_dict(lbl_file, cube_file, spacecraft_state, instrument_orientation, scalar=scalar, verbose=verbose) if verbose: print_r("Generating Sphere...") vertex_list, uv_list, norm_list, face_list = generate_sphere( min_lat, max_lat, min_lon, max_lon, lat_slices=lat_slices, lon_slices=lon_slices) f = open(output_file_path, "w") f.write("o Sphere\n") for v in vertex_list: f.write("v %f %f %f\n" % (v[0] * scalar, v[1] * scalar, v[2] * scalar)) for uv in uv_list: f.write("vt %f %f\n" % (uv[0], uv[1])) for n in norm_list: f.write("vn %f %f %f\n" % (n[0], n[1], n[2])) for fc in face_list: f.write("f") for il in fc: f.write(" %d/%d/%d" % (il[0] + 1, il[1] + 1, il[2] + 1)) f.write("\n") f.close() if verbose: print_r("Done") return model_spec_dict