def test_save_gyre(self): header1, data1 = gyre.load_gyre('data/mesa.gyre') gyre.save_gyre(tmpfile, header1, data1) header2, data2 = gyre.load_gyre(tmpfile) self.assertEqual(header1, header2) for row1, row2 in zip(data1, data2): self.assertEqual(row1, row2)
def test_save_gyre(self): m1 = gyre.load_gyre('data/mesa.gyre') m1.to_file(tmpfile) m2 = gyre.load_gyre(tmpfile) np.testing.assert_equal(m1.header, m2.header) np.testing.assert_equal(m1.data, m2.data) np.testing.assert_allclose(m1.r, m2.x * m2.R) np.testing.assert_allclose(m1.cs2, m2.Gamma_1 * m2.P / m2.rho) np.testing.assert_allclose(m1.AA[1:], m2.N2[1:] * m2.r[1:] / m2.g[1:])
def test_load_spb_mesa_versions(self): filenames = [ 'data/spb.mesa.78677cc', 'data/spb.mesa.813eed2', 'data/spb.mesa.adc6989' ] for filename in filenames: header1, data1 = gyre.load_gyre(filename) gyre.save_gyre(tmpfile, header1, data1) header2, data2 = gyre.load_gyre(tmpfile) self.assertEqual(header1, header2) for row1, row2 in zip(data1, data2): self.assertEqual(row1, row2)
def test_load_gyre(self): header, data = gyre.load_gyre('data/mesa.gyre') self.assertEqual(header['n'], 601) self.assertAlmostEqual(header['M'], 1.9882053999999999E+33) self.assertAlmostEqual(header['R'], 6.2045507132959908E+10) self.assertAlmostEqual(header['L'], 3.3408563666602257E+33) self.assertEqual(header['version'], 101)
def test_load_spb_mesa_versions(self): filenames = [ 'data/spb.mesa.78677cc', 'data/spb.mesa.813eed2', 'data/spb.mesa.adc6989' ] for filename in filenames: m1 = gyre.load_gyre('data/mesa.gyre') m1.to_file(tmpfile) m2 = gyre.load_gyre(tmpfile) np.testing.assert_equal(m1.header, m2.header) np.testing.assert_equal(m1.data, m2.data) np.testing.assert_allclose(m1.r, m2.x * m2.R) np.testing.assert_allclose(m1.cs2, m2.Gamma_1 * m2.P / m2.rho) np.testing.assert_allclose(m1.AA[1:], m2.N2[1:] * m2.r[1:] / m2.g[1:])
def test_load_gyre(self): m = gyre.load_gyre('data/mesa.gyre') self.assertEqual(len(m.data), 601) self.assertAlmostEqual(m.M, 1.9882053999999999E+33) self.assertAlmostEqual(m.R, 6.2045507132959908E+10) self.assertAlmostEqual(m.L, 3.3408563666602257E+33) self.assertEqual(m.version, 101) np.testing.assert_allclose(m.Omega, 0) np.testing.assert_allclose(m.Gamma_1 / (m.Gamma_3 - 1), m.Gamma_2 / (m.Gamma_2 - 1), rtol=1e-14, atol=1e-14) s = '%r' % m r = gyre.load_gyre(remote_url + 'data/mesa.gyre') np.testing.assert_equal(m.header, r.header) np.testing.assert_equal(m.data, r.data)
def convert(args): """Convert function for `tomso` command-line script.""" from_format = (guess_format(args.input_file) if args.from_format == 'guess' else args.from_format) to_format = (guess_format(args.output_file) if args.to_format == 'guess' else args.to_format) if from_format == to_format: raise ValueError("input format and output format are both %s\n" "did you mean to copy the file?" % from_format) kwargs = {} if args.G is not None: kwargs['G'] = args.G if from_format == 'fgong': from tomso.fgong import load_fgong m = load_fgong(args.input_file, **kwargs) elif from_format == 'amdl': from tomso.adipls import load_amdl m = load_amdl(args.input_file, **kwargs) elif from_format == 'gyre': from tomso.gyre import load_gyre m = load_gyre(args.input_file, **kwargs) else: raise ValueError("%s is not a valid input format" % from_format) if to_format == 'fgong': m.to_fgong(ivers=args.ivers).to_file(args.output_file) elif to_format == 'amdl': m.to_amdl().to_file(args.output_file) elif to_format == 'gyre': m.to_gyre().to_file(args.output_file) else: raise ValueError("%s is not a valid output format" % to_format)
def test_gyre_to_gyre(self): g = load_gyre('data/mesa.gyre') self.compare_models(g, g.to_fgong().to_gyre(), thermo=True)
'ELat': '[degrees] ecliptic latitude', 'tred': '', 'region': '', 'max_T': '', 'Pdet_fixedBeta': 'detection probability', 'SNR_fixedBeta': 'signal-to-noise ratio', 'Pdet_varyBeta': 'detection probability', 'SNR_varyBeta': 'signal-to-noise ratio', 'P_mix': 'average detection probability', 'Rank_Pmix': 'rank of average detection probability' } history_header, history_data = mesa.load_history(folder + '/LOGS/history.data.gz') profile_header, profile_data = mesa.load_profile(folder + '/final.profile.gz') gyre_header, gyre_profile = gyre.load_gyre(folder + '/final.profile.GYRE.rot') nml = AADG3.load_namelist(basename + '.in') L = 10.**history_data['log_L'][-1] R = 10.**history_data[-1]['log_R'] M = history_data[-1]['star_mass'] Teff = 10.**history_data[-1]['log_Teff'] numax = numax_sun * (M / R**2 / (Teff / Teff_sun)**0.5) Dnu = Dnu_sun * np.sqrt(M / R**3) Tred = Tred_sun * L**-0.093 beta = 1.0 - np.exp((Teff - Tred) / dT) Amax = Amax_sun * beta * L / M * (Teff / Teff_sun)**-2 Henv = Amax**2 / Dnu wenv = 0.66 * numax**0.88
'--output', type=str, default=None, help="Filename for output GYRE model " "(default=append .rot to source model filename)") parser.add_argument( '--no-core-noise', action='store_true', help="don't randomly sample uncertainty in core rotation rate") parser.add_argument( '--no-env-noise', action='store_true', help="don't randomly sample uncertainty in envelope rotation rate") args = parser.parse_args() gyre_header, profile = gyre.load_gyre(args.model) mesa_header, history = mesa.load_history(args.history) # P = P_mamabrand(10.**history['log_Teff'][-1], history['star_age'][-1]/1e6, # noisy=not args.no_env_noise)*86400.0 P = P_angus(10.**history['log_Teff'][-1], 10.0, history['star_age'][-1] / 1e6, noisy=not args.no_env_noise) * 86400.0 Omega_env = 2. * np.pi / P profile['Omega'] = Omega_env if history['center_h1'][ -1] < 1e-4: # and np.log10(history['gravity'][-1]) < 3.8: # decrease rotation rate by a factor (R/R_TAMS)^2 R = 10.**history['log_R'][-1]