예제 #1
0
파일: find.py 프로젝트: 4xxi/resonances
    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()
예제 #2
0
파일: find.py 프로젝트: 4xxi/resonances
 def save(self):
     get_or_create(BrokenAsteroid, name=self._asteroid_name)
     session.flush()