Skip to article frontmatterSkip to article content
# Prepare Python environment
import numpy as np
import plotly.express as px
import os
import nibabel as nib
import numpy as np
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import math
from sklearn.linear_model import LinearRegression
from dash import Dash, dcc, html
import pandas as pd
PI_UNICODE = "\U0001D70B"
GYRO_BAR_RATIO_H = 42.6e6  # [Hz/T]
len_x = 500
len_y = 500
x, y = np.meshgrid(np.linspace(-len_x, len_x/2, len_x//2), np.linspace(-len_y, len_y, len_y), indexing='ij')
x1 = np.array(x)
y1 = np.array(y)
x, y = np.meshgrid(np.linspace(-len_x/2, len_x, len_x//2), np.linspace(-len_y, len_y, len_y), indexing='ij')
x2 = np.array(x)
y2 = np.array(y)
x = np.zeros([len_x, len_y])
y = np.zeros([len_x, len_y])
x[:len_x//2] = x1
y[:len_x//2,:] = -y1
x[len_x//2:,:] = -x2
y[len_x//2:,:] = -y2


phase = np.rot90(np.arctan2(y.astype(float),x.astype(float)),k=-1)
fig = make_subplots(rows=1, cols=1, subplot_titles=[("Phase Singularities")], specs=[[{"type": "Heatmap"}]])
fig.add_trace(go.Heatmap(z=phase, colorscale='gray', colorbar=dict(title="Rad", titleside="top", tickmode="array", tickvals=[-math.pi+0.01, 0, math.pi-0.01], ticktext = [f'-{PI_UNICODE}', 0, f'{PI_UNICODE}'])))
fig.add_trace(go.Scatter(x=[370, 370], y=[90, 410], mode='markers',  marker=dict(size=10), line=dict(color='red')))

fig.add_shape(type="line", x0=370, y0=90, x1=370, y1=410, line=dict(color="red",width=3))
fig.add_shape(type="path", path="M 370,90 Q 200,250 370,410", line=dict(color="red",width=3))
fig.add_annotation(x=390, y=90, text="A", showarrow=False)
fig.add_annotation(x=390, y=410, text="B", showarrow=False, font=dict(color="white"))
fig.update_layout({"width": 500, "height": 400})
fig.update_xaxes(showticklabels=False)
fig.update_yaxes(showticklabels=False)
fig.show()
Loading...