Skip to content
Snippets Groups Projects
Commit 6a8b7c1f authored by Jan Caron's avatar Jan Caron
Browse files

More TODOs, confidence scale_down now stricter (uses minimum)!

parent c27fdeb0
No related branches found
No related tags found
No related merge requests found
......@@ -16,13 +16,13 @@ dependencies:
# Basic:
- python=3.5 # TODO: upgrade to 3.6!
- numpy=1.11
- scipy=0.19 # TODO: upgrade to 1.0 (if channels exist...)!
- scipy=1.0 # TODO: upgrade to 1.0 (if channels exist...)!
- tqdm=4.14
- scikit-image=0.13
# Fast computation:
- pyFFTW=0.10
# File IO:
- hyperspy=1.3
- hyperspy=1.3 # TODO: Update as soon as 1.4 is out!
- hyperspy-gui-ipywidgets=1.0
# - hyperspy-gui-traitsui=1.0 # TODO: Optional! Delete when mayavi is gone!
- h5py=2.7
......
......@@ -554,7 +554,7 @@ class VectorData(FieldData):
self.field = np.pad(self.field, ((0, 0), (pv[0], pv[1]), (pv[2], pv[3]), (pv[4], pv[5])),
mode='constant')
def crop(self, crop_values):
def crop(self, crop_values): # TODO: bad copy&paste from pad?
"""Crop the current field distribution with zeros for each individual axis.
Parameters
......@@ -796,6 +796,14 @@ class VectorData(FieldData):
# TODO: we have 2D and 3D plots, what about 1D line of vector arrows? Would be nice!
# TODO: Make all a bit more flexible with squeeze (so dimensions are not as strict).
# TODO: Implement clip value for amplitude!
# TODO: ar_dens should work differently! do not show every n-th arrow! instead average:
# mag_overlay_vort = mag_data_vort.copy()
# mag_overlay_vort.scale_down(2)
# mag_overlay_vort.plot_quiver(axis=newax, coloring='uniform', bgcolor='white', show_mask=False,
# scalebar=False, hideaxes=True)
# # plt.savefig(directory + '/ch5-0-magnetic_distributions_v.png', bbox_inches='tight')
# plt.savefig(directory + '/ch5-0-magnetic_distributions_v.pdf', bbox_inches='tight')
def plot_quiver(self, ar_dens=1, log=False, scaled=True, scale=1., b_0=None, qkey_unit='T',
coloring='angle', cmap=None, # Used here and plot_streamlines!
......
......@@ -33,7 +33,11 @@ __all__ = ['ForwardModel', 'ForwardModelCharge', 'DistributedForwardModel']
# TODO: Hook points belong to the forward models (or better the CombinedForwardModel)
# TODO: Maybe have one ForwardModel per image? (maybe not a good idea...?)
# TODO: Build factory convenience functions for constructing CombinedForwardModels!
# TODO: OR implement arithmetic + (combine) and * (concatenate one after the other)?!
# TODO: DistributedForwardModel and CombinedForwardModel could be the same thing?!
# TODO: Build vector class which should now what it contains (stack of PhaseMaps, VectorData,
# TODO: ScalarData, Ramp parameters, or a combination) and according hook points!
# TODO: Vector should be easily convertible to container classes (e.g. stack of PhaseMaps)!
class ForwardModel(object):
"""Class for mapping 3D magnetic distributions to 2D phase maps.
......
......@@ -295,7 +295,7 @@ class PhaseMap(object):
mask = self.mask.reshape(dim_uv[0] // 2, 2, dim_uv[1] // 2, 2)
self.mask = mask[:, 0, :, 0] & mask[:, 1, :, 0] & mask[:, 0, :, 1] & mask[:, 1, :, 1]
self.confidence = self.confidence.reshape(dim_uv[0] // 2, 2,
dim_uv[1] // 2, 2).mean(axis=(3, 1))
dim_uv[1] // 2, 2).min(axis=(3, 1))
def scale_up(self, n=1, order=0):
"""Scale up the phase map using spline interpolation of the requested order.
......
......@@ -28,6 +28,8 @@ FIGSIZE_DEFAULT = (6.7, 5) # TODO: Apparently does not fit as well as before...
FONTSIZE_DEFAULT = 20
STROKE_DEFAULT = None
# TODO: Cool: Plotting with four parameters for what to put in all four corners (with defaults)!
# TODO: Replace by matplotlib styles!
def pretty_plots(figsize=None, fontsize=None, stroke=None):
"""Set IPython formats (for interactive and PDF output) and set pretty matplotlib font."""
......@@ -360,3 +362,31 @@ def format_axis(axis, format_axis=True, title='', fontsize=None, stroke=None, sc
plt.tight_layout()
# Return plotting axis:
return axis
# TODO: Implement stuff from Florian:
def figsize(scale, height=None, textwidth=448.1309):
"""
Calculates ideal matplotlib Figure size, according to the desirde scale.
:param scale: Fraction of Latex graphic input (scale*\textwidth)
:param height: figure height = figure width * height
:param textwidth:
:return:
"""
fig_width_pt = textwidth # Get this from LaTeX using \the\textwidth
inches_per_pt = 1.0 / 72.27 # Convert pt to inch
golden_mean = (np.sqrt(5.0) - 1.0) / 2.0 # Aesthetic ratio (you could change this)
fig_width = fig_width_pt * inches_per_pt * scale # width in inches
if height is None:
fig_height = fig_width * golden_mean # height in inches
else:
fig_height = fig_width * height
fig_size = [fig_width, fig_height]
return fig_size
# TODO: Florians way of shifting axes labels (should already be in somewhere):
# for i in [1, 3]:
# axs[i].yaxis.set_label_position('right')
# axs[i].tick_params(axis='both', labelleft='off', labelright='on', labelsize=5)
# axs[i].yaxis.tick_right()
# axs[i].get_yaxis().set_label_coords(1.22, 0.5)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment