In [6]:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
%config InlineBackend.rc = {'figure.figsize': (14., 8.)}
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import numpy as np
import pandas as pd
In [7]:
class Result(object):
def __init__(self, eta, B, res_as_np_array=None):
if res_as_np_array:
self.data = res_as_np_array
self.eta = eta
self.B = B
def plot(self, mask = 0):
import matplotlib.pyplot as plt
if not mask == None:
self.data_masked = np.ma.masked_less_equal(self.data, mask)
else:
self.data_masked = self.data
plt.matshow(self.data_masked, extent=(0, 31, -2.5, 0), interpolation='none', aspect='auto', vmin=0)
plt.xlabel("$\Omega / \Omega_\odot$")
plt.ylabel("$\partial \log \Omega / \partial \log r$")
plt.title(r"FGM with $\eta = %g$ and $B_{\theta} = %g$ -- in CGS " % (self.eta, self.B))
plt.colorbar()
plt.grid()
#plt.gca().invert_yaxis()
plt.show()
def load_data(self, path, first_line=0):
import numpy as np
# skip the first_line
for _ in range(first_line):
f.readline()
# read the data
with open(path, 'r') as f:
self.data = np.array([ [ float(e)/2.7e-6 for e in line.split() ] for line in f.readlines() ])
assert(len(self.data.shape) == 2)
In [24]:
FGM_file = open("FGM")
FGM = np.array([ [ float(e) for e in line.split() ] for line in FGM_file.readlines() ])
kr_file = open("kr")
kr = np.array([ [ float(e) for e in line.split() ] for line in kr_file.readlines() ])
kthe_file = open("kthe")
kthe = np.array([ [ float(e) for e in line.split() ] for line in kthe_file.readlines() ])
# recreate a matrix with its elements = Omega
om_mat = np.fromfunction(lambda _, om : 3*(om+1), FGM.shape)
In [25]:
plt.matshow(om_mat); plt.colorbar()
Out[25]:
In [26]:
plt.matshow(np.ma.masked_less_equal(FGM/om_mat, 0)/2.7e-6, extent=(0, 31, -2.5, 0), interpolation='none', aspect='auto', vmin=0)
plt.xlabel("$\Omega / \Omega_\odot$")
plt.ylabel("$\partial \log \Omega / \partial \log r$")
plt.title(r"$\sigma$ [$\Omega_\odot$] in the Early sun")
plt.colorbar()
plt.grid()
In [10]:
plt.matshow(np.log10(np.ma.masked_less_equal(FGM, 0)/(kr*kr)), extent=(0, 31, -2.5, 0), interpolation='none', aspect='auto',
)#norm=LogNorm())
plt.xlabel("$\Omega / \Omega_\odot$")
plt.ylabel("$\partial \log \Omega / \partial \log r$")
plt.title(r"$\log(\sigma/k_r^2)$ [$cm^2/s$] in the Early sun",size=14)
plt.colorbar()
plt.grid()
In [37]:
plt.matshow(kr, extent=(0, 31, -2.5, 0), interpolation='none', aspect='auto', vmin=0)
plt.xlabel("$\Omega / \Omega_\odot$")
plt.ylabel("$\partial \log \Omega / \partial \log r$")
plt.title(r"FGM in the Early sun")
plt.colorbar()
plt.grid()
In [55]:
In [55]:
In [55]: