def find(self, start: int, stop: int, aei_paths: tuple): """Analyze resonances for pointed half-interval of numbers of asteroids. It gets resonances aggregated to asteroids. Computes resonant phase by orbital elements from prepared aei files of three bodies (asteroid and two planets). After this it finds circulations in vector of resonant phases and solves, based in circulations, libration does exists or no. :param aei_paths: :param start: start point of half-interval. :param stop: stop point of half-interval. It will be excluded. :return: """ orbital_element_sets = None pathbuilder = FilepathBuilder(aei_paths, self._is_recursive, self._clear_s3) filepaths = [pathbuilder.build('%s.aei' % x) for x in self._planets] try: orbital_element_sets = build_bigbody_elements(filepaths) except AEIValueError: logging.error('Incorrect data in %s' % ' or in '.join(filepaths)) exit(-1) aei_getter = AEIDataGetter(pathbuilder, self._clear) classifier = LibrationClassifier(self._is_current, BodyNumberEnum(len(self._planets) + 1)) phase_builder = PhaseBuilder(self._phase_storage) p_bar = None if self._is_verbose: p_bar = ProgressBar((stop + 1 - start), 'Find librations') asteroid_name = None for resonance, aei_data in get_aggregated_resonances(start, stop, False, self._planets, aei_getter): if self._is_verbose and asteroid_name != resonance.small_body.name: p_bar.update() asteroid_name = resonance.small_body.name broken_asteroid_mediator = _BrokenAsteroidMediator(asteroid_name) if broken_asteroid_mediator.check(): continue logging.debug('Analyze asteroid %s, resonance %s' % (asteroid_name, resonance)) resonance_id = resonance.id classifier.set_resonance(resonance) orbital_elem_set_facade = ResonanceOrbitalElementSetFacade(orbital_element_sets, resonance) try: serialized_phases = phase_builder.build(aei_data, resonance_id, orbital_elem_set_facade) except AEIValueError: broken_asteroid_mediator.save() continue classifier.classify(orbital_elem_set_facade, serialized_phases) session.flush() session.commit()
def load_resonances(from_filepath: str, start_asteroid: int, stop_asteroid: int, planets: Tuple[str], axis_swing: float = 0.01)\ -> Dict[int, List[ThreeBodyResonance]]: """ Makes all possible resonances for asteroids, that pointed by half-interval. Orbital elements for every asteroid will got from catalog, which has pointed filepath. :param axis_swing: :param planets: :param from_filepath: file path of catalog. :param start_asteroid: start point of half-interval. :param stop_asteroid: stop point of half-interval. It will be excluded. :return: dictionary, where keys are number of asteroids and values are lists of resonances. """ p_bar = ProgressBar((stop_asteroid - start_asteroid), 'Build resonances') res = {} for i in range(start_asteroid, stop_asteroid): res[i] = build_possible_resonances(from_filepath, i, planets, axis_swing) p_bar.update() p_bar.fin() return res