def test_load_modelS_amde(self): amde1 = adipls.load_amde('data/modelS_nfmode1.amde') amde2 = adipls.load_amde('data/modelS_nfmode2.amde', nfmode=2) amde3 = adipls.load_amde('data/modelS_nfmode3.amde', nfmode=3) np.testing.assert_equal(amde1.eigs[:, :, 1:3], amde2.eigs) np.testing.assert_equal(amde1.x, amde2.x) np.testing.assert_equal(amde1.x, amde3.x) np.testing.assert_equal(amde1.css, amde2.css) np.testing.assert_equal(amde1.css, amde3.css) np.testing.assert_equal(amde1.eigs[0], amde1.eig_ln(amde1.l[0], amde1.n[0])) np.testing.assert_equal(amde1.eigs[0], amde1.eig_nl(amde1.n[0], amde1.l[0])) s = '%s' % amde1 s = '%r' % amde2
def test_load_modelS_amde(self): css1, eigs1 = adipls.load_amde('data/modelS_nfmode1.amde') css2, eigs2, x2 = adipls.load_amde('data/modelS_nfmode2.amde', nfmode=2) css3, eigs3, x3 = adipls.load_amde('data/modelS_nfmode3.amde', nfmode=3) for cs1, cs2, cs3 in zip(css1, css2, css3): self.assertTrue(np.all(cs1 == cs2)) self.assertTrue(np.all(cs1 == cs3)) self.assertAlmostEqual(cs1['M'], 1.989e33) self.assertAlmostEqual(cs1['R'], 69599062580.0) for eig1, eig2, eig3 in zip(eigs1, eigs2, eigs3): self.assertTrue(np.all(eig1[:, 1:3] == eig2)) self.assertTrue(np.all(eig1[:, 5:] == eig3)) self.assertTrue(np.all(eig1[:, 0] == x2)) self.assertTrue(np.all(eig1[:, 0] == x3))
def myplot(): th = np.linspace(0.0, np.pi, 201) ph = np.linspace(0.5*np.pi, 2.0*np.pi, 301) Th, Ph = np.meshgrid(th, ph) x = np.outer(np.cos(ph), np.sin(th)) y = np.outer(np.sin(ph), np.sin(th)) z = np.outer(np.ones(np.size(ph)), np.cos(th)) s = sph_harm(emm, ell, Ph, Th).real mlab.mesh(x, y, z, scalars=s, colormap='seismic') S = fgong.load_fgong('data/modelS.fgong', return_object=True) css, eigs = adipls.load_amde('data/modelS.amde') I = np.where(css['ell']==ell)[0] if args.freq: i = I[np.argmin((css['nu_Ri'][I]-args.freq)**2)] elif args.enn: i = I[css['enn'][I]==args.enn][0] else: i = I[css['enn'][I]==14][0] print(' n = %i' % css['enn'][i]) print('freq = %.6f mHz' % css['nu_Ri'][i]) r = eigs[i][:,0] y1 = eigs[i][:,1] rho = np.interp(r, S.x[::-1], S.rho[::-1]) # r = np.linspace(0.,1.,51) # s = np.outer(np.sin(1.5*np.pi*r), np.ones(len(th))) s = np.outer(r*rho**0.5*y1, np.ones(len(th))) s = s*sph_harm(emm, ell, np.outer(np.ones(len(r)), np.ones(len(th))), np.outer(np.ones(len(r)), th)).real # s = 0.5+0.5*s/np.max(np.abs(s)) smax = np.max(np.abs(s))/2. # divide by two gives richer colour smin = -smax # guarantees symmetry in colourmap # first inner semicircle x = np.outer(r, np.sin(th)) y = 0.*x z = np.outer(r, np.cos(th)) mlab.mesh(x, y, z, scalars=-s, colormap='seismic', vmin=smin, vmax=smax) # second inner semicircle y = np.outer(r, np.sin(th)) x = 0.*y z = np.outer(r, np.cos(th)) mlab.mesh(x, y, z, scalars=-s, colormap='seismic', vmin=smin, vmax=smax) mlab.view(azimuth=args.view[0], elevation=args.view[1], distance=4.2)
psi = InterpolatedUnivariateSpline(result.x, result.y[0])(x) K_psi = P_hat(x) * np.gradient(psi / P_hat(x), x) #K_psi = P * np.gradient(psi / P, r) pd.DataFrame({ 'x': x, 'psi': psi, 'K_psi': K_psi }).to_csv('psi_lambda.dat', sep='\t', index=False) #exit() ## amde file holds the eigenfunctions # ref: ibid., Section 8.4 # important note: TOMSO uses nfmode=1 ! amde = adipls.load_amde(amde_fname, nfmode=1, return_object=True) ## read equation of state derivatives from file, either FGONG or external if os.path.exists(gamder_fname): gamder = pd.read_table(gamder_fname, sep='\\s+', names=['x', 'dgam_P', 'dgam_rho', 'dgam_Y'])[::-1] else: gong = fgong.load_fgong(fgong_fname, return_object=True) if gong.var.shape <= 25: print("Error: FGONG does not contain EOS derivatives") gamder = pd.DataFrame({ 'x': gong.var[:, 0] / R, 'dgam_rho': gong.var[:, 25], # (dGamma_1/drho)_P,Y 'dgam_P': gong.var[:, 26], # (dGamma_1/dP)_rho,Y
--enn) or the cyclic frequency (-f, --freq)""") amax = 0.55 # np.sqrt((2.*ell+1.)/(4.*np.pi)*factorial(l-m)/factorial(l+m)) ? Ntheta = 201 def get_colour(theta, phi): a = sph_harm(args.emm, args.ell, np.outer(phi, np.ones(len(theta))), np.outer(np.ones(len(phi)), theta)).real a = 0.5+0.5*a/amax return pl.cm.seismic(a) S = fgong.load_fgong('data/modelS.fgong', return_object=True) css, eigs = adipls.load_amde('data/modelS.amde') I = np.where(css['ell']==args.ell)[0] if args.freq: i = I[np.argmin((css['nu_Ri'][I]-args.freq)**2)] elif args.enn: i = I[css['enn'][I]==args.enn][0] else: i = I[css['enn'][I]==14][0] r = eigs[i][:,0] y1 = eigs[i][:,1] rho = np.interp(r, S.x[::-1], S.rho[::-1]) theta = np.linspace(0.0, 2.*np.pi, Ntheta) a = np.outer(r*rho**0.5*y1, np.ones(len(theta))) # use pi/2-theta instead of theta so that 0 degrees is at the top a = a*sph_harm(args.emm, args.ell,
def test_cross_check_css(self): agsm = adipls.load_agsm('data/modelS.agsm') amde = adipls.load_amde('data/modelS_nfmode1.amde') rkr = adipls.load_rkr('data/modelS.rkr') np.testing.assert_equal(agsm.css, amde.css) np.testing.assert_equal(agsm.css, rkr.css)
def test_cross_check_css(self): css_agsm = adipls.load_agsm('data/modelS.agsm') css_amde = adipls.load_amde('data/modelS_nfmode1.amde')[0] css_rkr = adipls.load_rkr('data/modelS.rkr')[0] self.assertTrue(np.all(css_agsm == css_amde)) self.assertTrue(np.all(css_agsm == css_rkr))