This commit is contained in:
Maria Marchwicka 2020-11-05 17:59:36 +01:00
parent a71888558e
commit 96b4860d2e
3 changed files with 89 additions and 41 deletions

View File

@ -108,11 +108,11 @@ class CableSummand():
return SignatureFunction(values=results)
@classmethod
def get_untwisted_part(cls, *knot_as_k_values, theta=0):
def get_satellite_part(cls, *knot_as_k_values, theta=0):
patt_k = knot_as_k_values[-1]
ksi = 1/(2 * abs(patt_k) + 1)
untwisted_part = SignatureFunction()
satellite_part = SignatureFunction()
# For each knot summand consider k values in reversed order,
# ommit k value for pattern.
for layer_num, k in enumerate(knot_as_k_values[:-1][::-1]):
@ -123,8 +123,8 @@ class CableSummand():
for _ in range(layer_num):
right_shift = right_shift.double_cover()
left__shift = left__shift.double_cover()
untwisted_part += right_shift + left__shift
return untwisted_part
satellite_part += right_shift + left__shift
return satellite_part
@staticmethod
def get_untwisted_signature_function(j):
@ -140,7 +140,7 @@ class CableSummand():
def get_summand_signature_as_theta_function(self):
knot_as_k_values = self.knot_as_k_values
def get_summand_signture_function(theta, plot=False):
def get_summand_signture_function(theta):
patt_k = knot_as_k_values[-1]
@ -148,14 +148,10 @@ class CableSummand():
theta %= (2 * abs(patt_k) + 1)
theta = min(theta, 2 * abs(patt_k) + 1 - theta)
twisted_part = self.get_blanchfield_for_pattern(patt_k, theta)
untwisted_part = self.get_untwisted_part(*knot_as_k_values,
pattern_part = self.get_blanchfield_for_pattern(patt_k, theta)
satellite_part = self.get_satellite_part(*knot_as_k_values,
theta=theta)
if plot:
twisted_part.plot()
untwisted_part.plot()
return twisted_part, untwisted_part
return pattern_part, satellite_part
get_summand_signture_function.__doc__ = \
get_summand_signture_function_docsting
@ -173,16 +169,15 @@ class CableSummand():
def plot_summand_for_theta(self, theta, save_path=None):
tp, up = self.signature_as_function_of_theta(theta)
pp, sp = self.signature_as_function_of_theta(theta)
title = self.knot_description + ", theta = " + str(theta)
if save_path is not None:
file_name = self.get_file_name_for_summand_plot(theta)
save_path = os.path.join(save_path, file_name)
tp.plot_sum_with_other(up, title=title, save_path=save_path)
pp.plot_sum_with_other(sp, title=title, save_path=save_path)
def plot_summand(self):
sf_theta = self.signature_as_function_of_theta
range_limit = min(self.knot_as_k_values[-1] + 1, 3)
for theta in range(range_limit):
self.plot_summand_for_theta(theta)
@ -229,6 +224,28 @@ class CableSum():
for i, knot in enumerate(self.knot_summands):
knot.plot_summand_for_theta(thetas[i], save_path=save_path)
pp, sp = self.signature_as_function_of_theta(*thetas)
title = self.knot_description + ", thetas = " + str(thetas)
if save_path is not None:
file_name = re.sub(r', ', '_', str(thetas))
file_name = re.sub(r'[\[\]]', '', str(file_name))
file_path = os.path.join(save_path, file_name)
pp.plot_sum_with_other(sp, title=title, save_path=file_path)
if save_path is not None:
file_path = os.path.join(save_path, "all_" + file_name)
sf_list = [knot.signature_as_function_of_theta(thetas[i])
for i, knot in enumerate(self.knot_summands)]
# pp, sp = knot.signature_as_function_of_theta(thetas[i])
# (pp + sp) = sp.plot
#
# pp.plot_sum_with_other(sp, title=title, save_path=file_path)
return dir_name
def plot_all_summands(self):
@ -319,23 +336,23 @@ class CableSum():
verbose = kwargs['verbose']
thetas = self.parse_thetas(*thetas)
untwisted_part = SignatureFunction()
twisted_part = SignatureFunction()
satellite_part = SignatureFunction()
pattern_part = SignatureFunction()
# for each cable knot (summand) in cable sum apply theta
for i, knot in enumerate(self.knot_summands):
ssf = knot.signature_as_function_of_theta
tp, up = ssf(thetas[i])
twisted_part += tp
untwisted_part += up
sf = twisted_part + untwisted_part
sfth = knot.signature_as_function_of_theta
pp, sp = sfth(thetas[i])
pattern_part += pp
satellite_part += sp
sf = pattern_part + satellite_part
if verbose:
print()
print(str(thetas))
print(sf)
assert sf.total_sign_jump() == 0
return sf
return pattern_part, satellite_part
signature_as_function_of_theta.__doc__ =\
signature_as_function_of_theta_docstring
@ -363,7 +380,8 @@ class CableSum():
# has a large signature.
for shift in range(1, self.q_order):
shifted_thetas = [shift * th for th in thetas]
sf = self.signature_as_function_of_theta(*shifted_thetas)
pp, sp = self.signature_as_function_of_theta(*shifted_thetas)
sf = pp + sp
limit = 5 + np.count_nonzero(shifted_thetas)
extremum = abs(sf.extremum(limit=limit))
if shift > 1:
@ -400,7 +418,6 @@ class CableSum():
print("\nOK")
return True
class CableTemplate():
def __init__(self, knot_formula, q_vector=None, k_vector=None,
@ -602,7 +619,7 @@ signature_as_function_of_theta_docstring = \
# T(2, q_n) is a pattern knot for a single cable from a cable sum
# theta: twist/character for the cable (value form v vector)
# Return:
# SignatureFunction created for twisted signature function
# SignatureFunction created for pattern signature function
# for a given cable and theta/character
# Based on:
# Proposition 9.8. in Twisted Blanchfield Pairing

View File

@ -64,7 +64,7 @@ def main(arg=None):
template = CableTemplate(knot_formula, q_vector=[3, 5, 7, 11])
cab = template.cable
# cab.plot_all_summands()
cab.plot_sum_for_theta_vector([2,1,1,1], save_to_dir=True)
cab.plot_sum_for_theta_vector([0,4,0,4], save_to_dir=True)
# knot_formula = config.knot_formula
# q_vector = (3, 5, 7, 13)
# q_vector = (3, 5, 7, 11)

View File

@ -121,6 +121,42 @@ class SignatureFunction():
# Total signature jump is the sum of all jumps.
return sum([j[1] for j in sorted(self.jumps_counter.items())])
def plot_four(self, sf1, sf2, sf3, save_path=None, title=''):
fig, axes_matrix = plt.subplots(2, 2, sharey=True,
figsize=(10,5))
sf0 = self
sf.plot(subplot=True,
ax=axes_matrix[0][1])
sf1.plot(subplot=True,
ax=axes_matrix[1][0],
color='red',
linestyle='dotted')
sf2.plot(subplot=True,
ax=axes_matrix[0][0],
color='black')
sf3.plot(subplot=True,
ax=axes_matrix[1][1],
alpha=0.3)
fig.suptitle(title)
plt.tight_layout()
if save_path is None:
save_path = os.path.join(os.getcwd(),"tmp.png")
save_path = Path(save_path)
save_path = save_path.with_suffix('.png')
plt.savefig(save_path)
plt.close()
image = Image.open(save_path)
image.show()
pass
def plot_sum_with_other(self, other,
@ -132,34 +168,28 @@ class SignatureFunction():
fig, axes_matrix = plt.subplots(2, 2, sharey=True,
figsize=(10,5))
tp.plot(title='subplot_tp',
subplot=True,
tp.plot(subplot=True,
ax=axes_matrix[0][1])
up.plot(title='subplot_up',
subplot=True,
up.plot(subplot=True,
ax=axes_matrix[1][0],
color='red',
linestyle='dotted')
sf.plot(title='subplot_up',
subplot=True,
sf.plot(subplot=True,
ax=axes_matrix[0][0],
color='black')
tp.plot(title='subplot_tp',
subplot=True,
tp.plot(subplot=True,
ax=axes_matrix[1][1],
alpha=0.3)
up.plot(title='subplot_up',
subplot=True,
up.plot(subplot=True,
ax=axes_matrix[1][1],
color='red', alpha=0.3,
linestyle='dotted')
sf.plot(title='subplot_up',
subplot=True,
sf.plot(subplot=True,
ax=axes_matrix[1][1],
color='black',
alpha=0.7,)
@ -188,7 +218,8 @@ class SignatureFunction():
title="",
alpha=1,
color='blue',
linestyle='solid'):
linestyle='solid',
ylabel=''):
if ax is None:
fig, ax = plt.subplots(1, 1)
@ -198,7 +229,7 @@ class SignatureFunction():
xmax = keys[1:]
xmin = keys[:-1]
ax.set(ylabel='signature function')
ax.set(ylabel=ylabel)
ax.set(title=title)
ax.hlines(y, xmin, xmax, color=color, linestyle=linestyle, alpha=alpha)