Example #1
0
    def test__star_params_validity_check(self):
        with self.assertRaises(Exception) as context:
            BinarySystem(primary=69,
                         secondary=self._secondary,
                         argument_of_periastron=self._initial_params["argument_of_periastron"],
                         gamma=self._initial_params["gamma"],
                         period=self._initial_params["period"],
                         eccentricity=self._initial_params["eccentricity"],
                         inclination=self._initial_params["inclination"],
                         primary_minimum_time=self._initial_params["primary_minimum_time"],
                         phase_shift=self._initial_params["phase_shift"])

        self.assertTrue('Component `primary` is not instance of class' in str(context.exception))

        star_mandatory_kwargs = ['mass', 'surface_potential', 'synchronicity',
                                 'albedo', 'metallicity', 'gravity_darkening']

        for kw in star_mandatory_kwargs[:1]:
            p = copy(self._primary)
            setattr(p, f"{kw}", None)

            with self.assertRaises(Exception) as context:
                BinarySystem(primary=p,
                             secondary=self._secondary,
                             argument_of_periastron=self._initial_params["argument_of_periastron"],
                             gamma=self._initial_params["gamma"],
                             period=self._initial_params["period"],
                             eccentricity=self._initial_params["eccentricity"],
                             inclination=self._initial_params["inclination"],
                             primary_minimum_time=self._initial_params["primary_minimum_time"],
                             phase_shift=self._initial_params["phase_shift"])

            self.assertTrue(f'Mising argument(s): `{kw}`' in str(context.exception))
Example #2
0
    def _get_community():
        data = {
            "system": {
                "inclination": 90.0,
                "period": 10.1,
                "argument_of_periastron": 90.0,
                "gamma": 0.0,
                "eccentricity": 0.3,
                "primary_minimum_time": 0.0,
                "phase_shift": 0.0,
                "mass_ratio": 0.75,
                "semi_major_axis": 29.854
            },
            "primary": {
                "surface_potential": 7.1,
                "synchronicity": 1.0,
                "t_eff": 6500.0,
                "gravity_darkening": 1.0,
                "discretization_factor": 5,
                "albedo": 1.0,
                "metallicity": 0.0
            },
            "secondary": {
                "surface_potential": 7.1,
                "synchronicity": 1.0,
                "t_eff": 6500.0,
                "gravity_darkening": 1.0,
                "discretization_factor": 5,
                "albedo": 1.0,
                "metallicity": 0.0
            }
        }

        return BinarySystem.from_json(data, _kind_of='community')
Example #3
0
 def test_invalid_kwarg_checker(self):
     with self.assertRaises(Exception) as context:
         BinarySystem(primary=self._primary,
                      secondary=self._secondary,
                      argument_of_periastron=self._initial_params["argument_of_periastron"],
                      gamma=self._initial_params["gamma"],
                      period=self._initial_params["period"],
                      eccentricity=self._initial_params["eccentricity"],
                      inclination=self._initial_params["inclination"],
                      primary_minimum_time=self._initial_params["primary_minimum_time"],
                      phase_shift=self._initial_params["phase_shift"],
                      adhoc_param="xxx")
     self.assertTrue('Invalid keyword argument(s): adhoc_param' in str(context.exception))
Example #4
0
    def test_check_missing_kwargs(self):
        initial_kwargs = dict(primary=self._primary,
                              secondary=self._secondary,
                              argument_of_periastron=self._initial_params["argument_of_periastron"],
                              period=self._initial_params["period"],
                              eccentricity=self._initial_params["eccentricity"],
                              inclination=self._initial_params["inclination"],
                              primary_minimum_time=self._initial_params["primary_minimum_time"])

        for kw in self.MANDATORY_KWARGS:
            kwargs = copy(initial_kwargs)
            del (kwargs[kw])
            with self.assertRaises(Exception) as context:
                BinarySystem(**kwargs)
            self.assertTrue(f'Missing argument(s): `{kw}`' in str(context.exception))
Example #5
0
def prepare_binary_system(params, spots_primary=None, spots_secondary=None):
    primary = Star(mass=params["primary_mass"], surface_potential=params["primary_surface_potential"],
                   synchronicity=params["primary_synchronicity"],
                   t_eff=params["primary_t_eff"], gravity_darkening=params["primary_gravity_darkening"],
                   albedo=params['primary_albedo'],
                   metallicity=0.0, spots=spots_primary)

    secondary = Star(mass=params["secondary_mass"], surface_potential=params["secondary_surface_potential"],
                     synchronicity=params["secondary_synchronicity"],
                     t_eff=params["secondary_t_eff"], gravity_darkening=params["secondary_gravity_darkening"],
                     albedo=params['secondary_albedo'],
                     metallicity=0.0, spots=spots_secondary)

    return BinarySystem(primary=primary,
                        secondary=secondary,
                        argument_of_periastron=params["argument_of_periastron"],
                        gamma=params["gamma"],
                        period=params["period"],
                        eccentricity=params["eccentricity"],
                        inclination=params["inclination"],
                        primary_minimum_time=params["primary_minimum_time"],
                        phase_shift=params["phase_shift"])
Example #6
0
secondary = Star(mass=0.327 * u.solMass,
                 surface_potential=contact_pot,
                 synchronicity=1.0,
                 t_eff=4000 * u.K,
                 gravity_darkening=1.0,
                 albedo=0.6,
                 metallicity=0,
                 # spots=spots_metadata['secondary'],
                 )

bs = BinarySystem(primary=primary,
                  secondary=secondary,
                  argument_of_periastron=320 * u.deg,
                  gamma=-41.7 * u.km / u.s,
                  period=0.7949859 * u.d,
                  eccentricity=0.25,
                  # eccentricity=0,
                  inclination=85 * u.deg,
                  primary_minimum_time=2440862.60793 * u.d,
                  phase_shift=0.0,
                  )

print('Elapsed time during system build: {:.6f}'.format(time() - star_time))


o = Observer(passband=['Generic.Bessell.V',
                       # 'Generic.Bessell.B',
                       # 'Generic.Bessell.U',
                       # 'Generic.Bessell.R',
                       # 'Generic.Bessell.I',
                       ],
 def test_compute_filling_factor(self):
     potential, l_points = 100.0, [2.4078, 2.8758, 2.5772]
     expected = -325.2652
     obtained = round(
         BinarySystem.compute_filling_factor(potential, l_points), 4)
     self.assertEqual(expected, obtained)
Example #8
0
    surface_potential=3.5,
    synchronicity=1.0,
    t_eff=4800 * u.K,
    gravity_darkening=1.0,
    # discretization_factor=20,
    albedo=0.6,
    metallicity=0,
)

# setattr(primary, "_mass", None)
bs = BinarySystem(
    primary=primary,
    secondary=secondary,
    argument_of_periastron=58 * u.deg,
    gamma=-30.7 * u.km / u.s,
    period=2.5 * u.d,
    eccentricity=0.0,
    inclination=85 * u.deg,
    primary_minimum_time=2440000.0 * u.d,
    phase_shift=0.0,
)

# pick only one
filters = [
    # 'Generic.Bessell.U',
    # 'Generic.Bessell.B',
    # 'Generic.Bessell.V',
    'Generic.Bessell.R',
    # 'Generic.Bessell.I',
    ]
lc_kwargs = {"from_phase": -0.6,