From a2d3d8b10631e0746bcec966e202f9349c84a1ab Mon Sep 17 00:00:00 2001 From: Jan Caron <j.caron@fz-juelich.de> Date: Wed, 9 Mar 2016 11:28:22 +0100 Subject: [PATCH] Refactoring: Replaced MagData with VectorData and added ScalarData class (and common superclass FieldData). magnitude is now called field (which is more appropriate) projector now uses FieldData to process both vector and scalar data (foundation was in place before) --- .idea/workspace.xml | 735 ++++++--------- pyramid/__init__.py | 6 +- pyramid/dataset.py | 8 +- pyramid/diagnostics.py | 10 +- pyramid/fieldconverter.py | 32 +- pyramid/{magdata.py => fielddata.py} | 880 +++++++++++++----- pyramid/forwardmodel.py | 12 +- pyramid/magcreator.py | 36 +- pyramid/phasemap.py | 8 +- pyramid/phasemapper.py | 88 +- pyramid/projector.py | 21 +- pyramid/reconstruction.py | 28 +- pyramid/tests/test_dataset.py | 4 +- .../{test_magdata.py => test_fielddata.py} | 58 +- .../mag_data_flipx.hdf5 | Bin .../mag_data_flipy.hdf5 | Bin .../mag_data_flipz.hdf5 | Bin .../mag_data_orig.hdf5 | Bin .../mag_data_ref_load.hdf5 | Bin .../mag_data_ref_load.txt | 0 .../mag_data_rotx.hdf5 | Bin .../mag_data_roty.hdf5 | Bin .../mag_data_rotz.hdf5 | Bin pyramid/tests/test_phasemapper.py | 30 +- pyramid/tests/test_phasemapper/elec_proj.hdf5 | Bin 0 -> 22928 bytes .../test_phasemapper/phase_map_elec.hdf5 | Bin 0 -> 27568 bytes .../tests/test_phasemapper/ref_phase_elec.npy | Bin 208 -> 0 bytes .../test_phasemapper/ref_phase_mag_disc.npy | Bin 208 -> 0 bytes .../test_phasemapper/ref_phase_mag_fft.npy | Bin 208 -> 0 bytes .../test_phasemapper/ref_phase_mag_slab.npy | Bin 208 -> 0 bytes pyramid/tests/test_projector.py | 98 +- scripts/gui/mag_slicer.py | 4 +- .../create_alternating_filaments.py | 6 +- .../create_array_sphere_disc_slab.py | 8 +- .../magcreator/create_core_shell_disc.py | 6 +- .../magcreator/create_core_shell_sphere.py | 6 +- .../magdata/magcreator/create_homog_disc.py | 4 +- .../magcreator/create_homog_filament.py | 4 +- .../magdata/magcreator/create_homog_pixel.py | 4 +- .../magdata/magcreator/create_homog_slab.py | 4 +- .../magdata/magcreator/create_homog_sphere.py | 4 +- .../magcreator/create_paper2_homog_slab.py | 8 +- .../magcreator/create_paper2_vortex_slab.py | 5 +- .../magdata/magcreator/create_pyramid_logo.py | 4 +- .../magcreator/create_random_pixels.py | 6 +- .../magdata/magcreator/create_random_slabs.py | 6 +- .../magdata/magcreator/create_singularity.py | 4 +- .../magdata/magcreator/create_vortex_disc.py | 5 +- .../magcreator/create_vortex_sphere.py | 5 +- scripts/magdata/magdata_from_dat.py | 6 +- scripts/magdata/magdata_from_txtfortran.py | 4 +- scripts/magdata/magdata_from_vtk.py | 8 +- .../phasemap/phasemap_projection_arbitrary.py | 2 +- .../phasemap/phasemap_projection_simple.py | 2 +- scripts/phasemap/phasemap_tilt_series.py | 8 +- .../reconstruction_3d_from_magdata.py | 2 +- 56 files changed, 1204 insertions(+), 975 deletions(-) rename pyramid/{magdata.py => fielddata.py} (50%) rename pyramid/tests/{test_magdata.py => test_fielddata.py} (62%) rename pyramid/tests/{test_magdata => test_fielddata}/mag_data_flipx.hdf5 (100%) rename pyramid/tests/{test_magdata => test_fielddata}/mag_data_flipy.hdf5 (100%) rename pyramid/tests/{test_magdata => test_fielddata}/mag_data_flipz.hdf5 (100%) rename pyramid/tests/{test_magdata => test_fielddata}/mag_data_orig.hdf5 (100%) rename pyramid/tests/{test_magdata => test_fielddata}/mag_data_ref_load.hdf5 (100%) rename pyramid/tests/{test_magdata => test_fielddata}/mag_data_ref_load.txt (100%) rename pyramid/tests/{test_magdata => test_fielddata}/mag_data_rotx.hdf5 (100%) rename pyramid/tests/{test_magdata => test_fielddata}/mag_data_roty.hdf5 (100%) rename pyramid/tests/{test_magdata => test_fielddata}/mag_data_rotz.hdf5 (100%) create mode 100644 pyramid/tests/test_phasemapper/elec_proj.hdf5 create mode 100644 pyramid/tests/test_phasemapper/phase_map_elec.hdf5 delete mode 100644 pyramid/tests/test_phasemapper/ref_phase_elec.npy delete mode 100644 pyramid/tests/test_phasemapper/ref_phase_mag_disc.npy delete mode 100644 pyramid/tests/test_phasemapper/ref_phase_mag_fft.npy delete mode 100644 pyramid/tests/test_phasemapper/ref_phase_mag_slab.npy diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 96be35c..b51248b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,18 +5,8 @@ <option name="ANALYSIS_IN_BACKGROUND" value="true" /> </component> <component name="ChangeListManager"> - <list default="true" id="990252ab-aff5-4ac2-a857-b193d2c46b18" name="Default" comment="Added fieldconverter module! fieldconverter: methods to convert M to A to B magdata: a bit more parameters for quiver_plot3d(), added contour_plot3d() phasemapper: pm() extended for different projections (not just simple) kernel: u and v switched (now named after the unit magnetization direction, which makes much more sense)"> - <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/pyramid/fieldconverter.py" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/pyramid/tests/test_kernel/ref_u_fft.npy" afterPath="$PROJECT_DIR$/pyramid/tests/test_kernel/ref_u_fft.npy" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/pyramid/tests/test_kernel/ref_v_fft.npy" afterPath="$PROJECT_DIR$/pyramid/tests/test_kernel/ref_v_fft.npy" /> + <list default="true" id="990252ab-aff5-4ac2-a857-b193d2c46b18" name="Default" comment="Refactoring: Replaced MagData with VectorData and added ScalarData class (and common superclass FieldData). magnitude is now called field (which is more appropriate) projector now uses FieldData to process both vector and scalar data (foundation was in place before)"> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/pyramid/__init__.py" afterPath="$PROJECT_DIR$/pyramid/__init__.py" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/pyramid/kernel.py" afterPath="$PROJECT_DIR$/pyramid/kernel.py" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/pyramid/magdata.py" afterPath="$PROJECT_DIR$/pyramid/magdata.py" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/pyramid/phasemap.py" afterPath="$PROJECT_DIR$/pyramid/phasemap.py" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/pyramid/phasemapper.py" afterPath="$PROJECT_DIR$/pyramid/phasemapper.py" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/scripts/gui/mag_slicer.py" afterPath="$PROJECT_DIR$/scripts/gui/mag_slicer.py" /> - <change type="MODIFICATION" beforePath="$PROJECT_DIR$/scripts/phasemap/phasemap_tilt_series.py" afterPath="$PROJECT_DIR$/scripts/phasemap/phasemap_tilt_series.py" /> </list> <ignored path="Pyramid.iws" /> <ignored path=".idea/workspace.xml" /> @@ -41,171 +31,11 @@ </component> <component name="FileEditorManager"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> - <file leaf-file-name="magcreator.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/magcreator.py"> + <file leaf-file-name="colormap.py" pinned="false" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/pyramid/colormap.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="16" column="3" selection-start-line="4" selection-start-column="0" selection-end-line="16" selection-end-column="3" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="projector.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/projector.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="608" column="51" selection-start-line="608" selection-start-column="8" selection-end-line="608" selection-end-column="51" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="phasemapper.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/phasemapper.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-8.666667"> - <caret line="332" column="51" selection-start-line="332" selection-start-column="51" selection-end-line="332" selection-end-column="51" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="test_kernel.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_kernel.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="26" column="0" selection-start-line="26" selection-start-column="0" selection-end-line="26" selection-end-column="0" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="mag_slicer.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/scripts/gui/mag_slicer.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="223" column="57" selection-start-line="223" selection-start-column="57" selection-end-line="223" selection-end-column="57" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="phasemap_creator.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/scripts/gui/phasemap_creator.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="11" column="10" selection-start-line="11" selection-start-column="10" selection-end-line="11" selection-end-column="10" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="fft.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/fft.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="296" column="15" selection-start-line="296" selection-start-column="15" selection-end-line="296" selection-end-column="28" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="kernel.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/kernel.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="95" column="34" selection-start-line="95" selection-start-column="34" selection-end-line="95" selection-end-column="34" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="phasemap_tilt_series.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/scripts/phasemap/phasemap_tilt_series.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="40" column="16" selection-start-line="40" selection-start-column="16" selection-end-line="40" selection-end-column="16" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="dataset.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/dataset.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="157" column="8" selection-start-line="157" selection-start-column="8" selection-end-line="157" selection-end-column="8" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="reconstruction.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/reconstruction.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="46" column="27" selection-start-line="46" selection-start-column="27" selection-end-line="46" selection-end-column="27" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="reconstruction_3d_from_magdata.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/scripts/reconstruction/reconstruction_3d_from_magdata.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="11" column="0" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="76" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="Untitled.py" pinned="false" current-in-tab="false"> - <entry file="file://$USER_HOME$/Downloads/Untitled.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="44" column="40" selection-start-line="44" selection-start-column="40" selection-end-line="44" selection-end-column="40" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="phasemap.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/phasemap.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="781" column="8" selection-start-line="781" selection-start-column="8" selection-end-line="781" selection-end-column="8" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="magdata.py" pinned="false" current-in-tab="true"> - <entry file="file://$PROJECT_DIR$/pyramid/magdata.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.62133646"> - <caret line="879" column="31" selection-start-line="879" selection-start-column="31" selection-end-line="879" selection-end-column="31" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="__init__.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/__init__.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="90" column="38" selection-start-line="90" selection-start-column="38" selection-end-line="90" selection-end-column="38" /> - <folding /> - </state> - </provider> - </entry> - </file> - <file leaf-file-name="config.py" pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/pyramid/config.py"> - <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="14" column="4" selection-start-line="14" selection-start-column="4" selection-end-line="14" selection-end-column="4" /> + <state vertical-scroll-proportion="0.11171366"> + <caret line="89" column="28" selection-start-line="89" selection-start-column="26" selection-end-line="89" selection-end-column="28" /> <folding /> </state> </provider> @@ -227,18 +57,12 @@ <component name="IdeDocumentHistory"> <option name="CHANGED_PATHS"> <list> - <option value="$APPLICATION_CONFIG_DIR$/consoles/ide/ide-scripting.groovy" /> - <option value="$PROJECT_DIR$/../HyperSpy/.hgignore" /> - <option value="$PROJECT_DIR$/scripts/magdata/magcreator/create_array_sphere_disc_slab.py" /> <option value="$PROJECT_DIR$/../Publications/paper 2/paper2_part3_experiment.py" /> - <option value="$PROJECT_DIR$/../Publications/nanowire_z_angle.py" /> <option value="$PROJECT_DIR$/../Publications/pico 2015/poster_pico2015_2d.py" /> <option value="$PROJECT_DIR$/pyramid/numcore/__init__.py" /> <option value="$PROJECT_DIR$/../HyperSpy/hyperspy/_signals/phase_image.py" /> <option value="$PROJECT_DIR$/../HyperSpy/hyperspy/signals.py" /> <option value="$PROJECT_DIR$/pyramid/costfunction.py" /> - <option value="$PROJECT_DIR$/pyramid/projector.py" /> - <option value="$PROJECT_DIR$/pyramid/reconstruction.py" /> <option value="$PROJECT_DIR$/pyramid/regularisator.py" /> <option value="$PROJECT_DIR$/pyramid/dataset.py" /> <option value="$PROJECT_DIR$/docs/index.rst" /> @@ -249,32 +73,41 @@ <option value="$PROJECT_DIR$/pyramid/quaternion.py" /> <option value="$PROJECT_DIR$/scripts/reconstruction/reconstruction_3d_from_magdata.py" /> <option value="$PROJECT_DIR$/pyramid/forwardmodel.py" /> - <option value="$PROJECT_DIR$/pyramid/diagnostics.py" /> <option value="$PROJECT_DIR$/pyramid/fft.py" /> <option value="$PROJECT_DIR$/pyramid/version.py" /> <option value="$PROJECT_DIR$/setup.py" /> <option value="$PROJECT_DIR$/pyramid/tests/test_dataset.py" /> <option value="$PROJECT_DIR$/pyramid/tests/test_phasemap.py" /> - <option value="$PROJECT_DIR$/pyramid/tests/test_magdata.py" /> <option value="$PROJECT_DIR$/pyramid/tests/test_magcreator.py" /> <option value="$PROJECT_DIR$/pyramid/tests/test_kernel.py" /> <option value="$PROJECT_DIR$/pyramid/tests/test_forwardmodel.py" /> <option value="$PROJECT_DIR$/pyramid/tests/test_costfunction.py" /> - <option value="$PROJECT_DIR$/pyramid/tests/test_phasemapper.py" /> <option value="$PROJECT_DIR$/pyramid/tests/test_projector.py" /> <option value="$PROJECT_DIR$/pyramid/tests/test_regularisator.py" /> <option value="$PROJECT_DIR$/pyramid/tests/test_analytic.py" /> <option value="$PROJECT_DIR$/pyramid/config.py" /> <option value="$PROJECT_DIR$/pyramid/analytic.py" /> - <option value="$PROJECT_DIR$/pyramid/magcreator.py" /> <option value="$USER_HOME$/Downloads/Untitled.py" /> <option value="$PROJECT_DIR$/pyramid/__init__.py" /> - <option value="$PROJECT_DIR$/pyramid/phasemap.py" /> <option value="$PROJECT_DIR$/scripts/gui/mag_slicer.py" /> <option value="$PROJECT_DIR$/pyramid/fieldconverter.py" /> - <option value="$PROJECT_DIR$/pyramid/phasemapper.py" /> <option value="$PROJECT_DIR$/pyramid/kernel.py" /> + <option value="$PROJECT_DIR$/pyramid/reconstruction.py" /> <option value="$PROJECT_DIR$/pyramid/magdata.py" /> + <option value="$PROJECT_DIR$/../Publications/pico 2015/logfile.log" /> + <option value="$PROJECT_DIR$/pyramid/phasemap.py" /> + <option value="$PROJECT_DIR$/pyramid/diagnostics.py" /> + <option value="$PROJECT_DIR$/pyramid/magcreator.py" /> + <option value="$PROJECT_DIR$/pyramid/circle_interpolation.py" /> + <option value="$PROJECT_DIR$/../Script-Vault/circle_interpolation.py" /> + <option value="$PROJECT_DIR$/pyramid/tests/test_magdata.py" /> + <option value="$PROJECT_DIR$/pyramid/tests/test_fielddata.py" /> + <option value="$PROJECT_DIR$/../Publications/nanowire_z_angle.py" /> + <option value="$PROJECT_DIR$/pyramid/projector.py" /> + <option value="$PROJECT_DIR$/pyramid/fielddata.py" /> + <option value="$PROJECT_DIR$/pyramid/tests/test_phasemapper.py" /> + <option value="$PROJECT_DIR$/pyramid/phasemapper.py" /> + <option value="$PROJECT_DIR$/scripts/phasemap/phasemap_tilt_series.py" /> </list> </option> </component> @@ -340,34 +173,8 @@ <foldersAlwaysOnTop value="true" /> </navigator> <panes> - <pane id="Scope"> - <subPane subId="Changed Files"> - <PATH> - <PATH_ELEMENT USER_OBJECT="Root"> - <option name="myItemId" value="" /> - <option name="myItemType" value="" /> - </PATH_ELEMENT> - <PATH_ELEMENT USER_OBJECT="Pyramid"> - <option name="myItemId" value="" /> - <option name="myItemType" value="" /> - </PATH_ELEMENT> - </PATH> - <PATH> - <PATH_ELEMENT USER_OBJECT="Root"> - <option name="myItemId" value="" /> - <option name="myItemType" value="" /> - </PATH_ELEMENT> - <PATH_ELEMENT USER_OBJECT="Pyramid"> - <option name="myItemId" value="" /> - <option name="myItemType" value="" /> - </PATH_ELEMENT> - <PATH_ELEMENT USER_OBJECT="pyramid"> - <option name="myItemId" value="" /> - <option name="myItemType" value="" /> - </PATH_ELEMENT> - </PATH> - </subPane> - </pane> + <pane id="Scope" /> + <pane id="Scratches" /> <pane id="ProjectPane"> <subPane> <PATH> @@ -386,56 +193,6 @@ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> </PATH_ELEMENT> </PATH> - <PATH> - <PATH_ELEMENT> - <option name="myItemId" value="Pyramid" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="Pyramid" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="scripts" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="reconstruction" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> - </PATH_ELEMENT> - </PATH> - <PATH> - <PATH_ELEMENT> - <option name="myItemId" value="Pyramid" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="Pyramid" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="scripts" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> - </PATH_ELEMENT> - </PATH> - <PATH> - <PATH_ELEMENT> - <option name="myItemId" value="Pyramid" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="Pyramid" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="scripts" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> - </PATH_ELEMENT> - <PATH_ELEMENT> - <option name="myItemId" value="gui" /> - <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" /> - </PATH_ELEMENT> - </PATH> <PATH> <PATH_ELEMENT> <option name="myItemId" value="Pyramid" /> @@ -452,7 +209,6 @@ </PATH> </subPane> </pane> - <pane id="Scratches" /> <pane id="ColorIdeProjectViewPane"> <subPane> <PATH> @@ -476,9 +232,9 @@ </panes> </component> <component name="PropertiesComponent"> - <property name="settings.editor.selected.configurable" value="reference.settingsdialog.IDE.editor.colors.Debugger" /> + <property name="settings.editor.selected.configurable" value="editor.preferences.tabs" /> <property name="settings.editor.splitter.proportion" value="0.2" /> - <property name="last_opened_file_path" value="$PROJECT_DIR$/docs/_build" /> + <property name="last_opened_file_path" value="$PROJECT_DIR$/files/vecdata" /> <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatWidth0" value="44" /> <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatOrder0" value="0" /> <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_flatWidth1" value="64" /> @@ -497,6 +253,7 @@ <property name="FileHistory.org.zmlx.hg4idea.provider.HgHistoryProvider_treeOrder3" value="3" /> <property name="last.edited.regexp" value="asdf aasfasf.version_info " /> <property name="restartRequiresConfirmation" value="false" /> + <property name="SearchEverywhereHistoryKey" value="colorwheel	null	null" /> </component> <component name="Push.Settings"> <excluded-roots> @@ -505,11 +262,11 @@ </component> <component name="PyConsoleOptionsProvider"> <option name="myPythonConsoleState"> - <console-settings custom-start-script="# coding: utf-8 """Startup!""" from __future__ import division import sys import os import pdb import hyperspy.api as hs import pyramid from pyramid import * import pyramid.analytic as an import pyramid.magcreator as mc import pyramid.reconstruction as rc import jutil import numpy as np import scipy as sp import matplotlib as mpl import matplotlib.pyplot as plt from pylab import * import logging.config logging.config.fileConfig(LOGGING_CONFIG, disable_existing_loggers=False) ion() # Enable Matplotlib's interactive mode sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS]) " module-name="Pyramid" is-module-sdk="true" working-directory="$PROJECT_DIR$/files/magdata"> + <console-settings custom-start-script="# coding: utf-8 """Startup!""" from __future__ import division import sys import os import pdb import hyperspy.api as hs import pyramid from pyramid import * import pyramid.analytic as an import pyramid.magcreator as mc import pyramid.reconstruction as rc import jutil import numpy as np import scipy as sp import matplotlib as mpl import matplotlib.pyplot as plt from pylab import * import logging.config logging.config.fileConfig(LOGGING_CONFIG, disable_existing_loggers=False) ion() # Enable Matplotlib's interactive mode sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS]) " module-name="Pyramid" is-module-sdk="true" working-directory="$PROJECT_DIR$/files/vecdata"> <option name="myCustomStartScript" value="# coding: utf-8 """Startup!""" from __future__ import division import sys import os import pdb import hyperspy.api as hs import pyramid from pyramid import * import pyramid.analytic as an import pyramid.magcreator as mc import pyramid.reconstruction as rc import jutil import numpy as np import scipy as sp import matplotlib as mpl import matplotlib.pyplot as plt from pylab import * import logging.config logging.config.fileConfig(LOGGING_CONFIG, disable_existing_loggers=False) ion() # Enable Matplotlib's interactive mode sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS]) " /> <option name="myUseModuleSdk" value="true" /> <option name="myModuleName" value="Pyramid" /> - <option name="myWorkingDirectory" value="$PROJECT_DIR$/files/magdata" /> + <option name="myWorkingDirectory" value="$PROJECT_DIR$/files/vecdata" /> <option name="myAddSourceRoots" value="true" /> </console-settings> </option> @@ -535,45 +292,87 @@ <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <module name="Pyramid" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/pyramid/magdata.py" /> + <option name="SCRIPT_NAME" value="C:\Users\Jan\Home\PhD Thesis\Projects\Pyramid\pyramid\fielddata.py" /> <option name="PARAMETERS" value="" /> <option name="SHOW_COMMAND_LINE" value="true" /> <method /> </configuration> - <configuration default="false" name="setup" type="PythonConfigurationType" factoryName="Python" temporary="true"> + <configuration default="false" name="circle_interpolation" type="PythonConfigurationType" factoryName="Python" singleton="true" temporary="true"> <option name="INTERPRETER_OPTIONS" value="" /> <option name="PARENT_ENVS" value="true" /> <envs> <env name="PYTHONUNBUFFERED" value="1" /> </envs> - <option name="SDK_HOME" value="C:\Anaconda2\python.exe" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> + <option name="SDK_HOME" value="" /> + <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../Script-Vault" /> <option name="IS_MODULE_SDK" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <module name="Script-Vault" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/setup.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/../Script-Vault/circle_interpolation.py" /> <option name="PARAMETERS" value="" /> <option name="SHOW_COMMAND_LINE" value="true" /> <method /> </configuration> - <configuration default="false" name="Untitled" type="PythonConfigurationType" factoryName="Python" temporary="true"> + <configuration default="false" name="test_fielddata" type="PythonConfigurationType" factoryName="Python" temporary="true"> <option name="INTERPRETER_OPTIONS" value="" /> <option name="PARENT_ENVS" value="true" /> <envs> <env name="PYTHONUNBUFFERED" value="1" /> </envs> <option name="SDK_HOME" value="C:\Anaconda2\python.exe" /> - <option name="WORKING_DIRECTORY" value="$USER_HOME$/Downloads" /> - <option name="IS_MODULE_SDK" value="false" /> + <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/pyramid/tests" /> + <option name="IS_MODULE_SDK" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> <module name="Pyramid" /> - <option name="SCRIPT_NAME" value="$USER_HOME$/Downloads/Untitled.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/pyramid/tests/test_fielddata.py" /> <option name="PARAMETERS" value="" /> <option name="SHOW_COMMAND_LINE" value="true" /> <method /> </configuration> + <configuration default="false" name="Nosetest TestCasePhaseMapperMIP.test_call" type="tests" factoryName="Nosetests" temporary="true" nameIsGenerated="true"> + <option name="INTERPRETER_OPTIONS" value="" /> + <option name="PARENT_ENVS" value="true" /> + <envs /> + <option name="SDK_HOME" value="" /> + <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/pyramid/tests" /> + <option name="IS_MODULE_SDK" value="true" /> + <option name="ADD_CONTENT_ROOTS" value="true" /> + <option name="ADD_SOURCE_ROOTS" value="true" /> + <module name="Pyramid" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/pyramid/tests/test_phasemapper.py" /> + <option name="CLASS_NAME" value="TestCasePhaseMapperMIP" /> + <option name="METHOD_NAME" value="test_call" /> + <option name="FOLDER_NAME" value="" /> + <option name="TEST_TYPE" value="TEST_METHOD" /> + <option name="PATTERN" value="" /> + <option name="USE_PATTERN" value="false" /> + <option name="PARAMS" value="" /> + <option name="USE_PARAM" value="false" /> + <method /> + </configuration> + <configuration default="false" name="Nosetests in test_phasemapper" type="tests" factoryName="Nosetests" temporary="true" nameIsGenerated="true"> + <option name="INTERPRETER_OPTIONS" value="" /> + <option name="PARENT_ENVS" value="true" /> + <envs /> + <option name="SDK_HOME" value="" /> + <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/pyramid/tests" /> + <option name="IS_MODULE_SDK" value="true" /> + <option name="ADD_CONTENT_ROOTS" value="true" /> + <option name="ADD_SOURCE_ROOTS" value="true" /> + <module name="Pyramid" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/pyramid/tests/test_phasemapper.py" /> + <option name="CLASS_NAME" value="" /> + <option name="METHOD_NAME" value="" /> + <option name="FOLDER_NAME" value="" /> + <option name="TEST_TYPE" value="TEST_SCRIPT" /> + <option name="PATTERN" value="" /> + <option name="USE_PATTERN" value="false" /> + <option name="PARAMS" value="" /> + <option name="USE_PARAM" value="false" /> + <method /> + </configuration> <configuration default="true" type="CompoundRunConfigurationType" factoryName="Compound Run Configuration"> <method /> </configuration> @@ -788,20 +587,24 @@ <option name="USE_PARAM" value="false" /> <method /> </configuration> - <list size="7"> + <list size="9"> <item index="0" class="java.lang.String" itemvalue="Python.mag_slicer" /> <item index="1" class="java.lang.String" itemvalue="Python.fieldconverter" /> <item index="2" class="java.lang.String" itemvalue="Python docs.Pyramid Sphinx" /> <item index="3" class="java.lang.String" itemvalue="Python tests.Pyramid Tests" /> <item index="4" class="java.lang.String" itemvalue="Python.magdata" /> - <item index="5" class="java.lang.String" itemvalue="Python.setup" /> - <item index="6" class="java.lang.String" itemvalue="Python.Untitled" /> + <item index="5" class="java.lang.String" itemvalue="Python.circle_interpolation" /> + <item index="6" class="java.lang.String" itemvalue="Python.test_fielddata" /> + <item index="7" class="java.lang.String" itemvalue="Python tests.Nosetest TestCasePhaseMapperMIP.test_call" /> + <item index="8" class="java.lang.String" itemvalue="Python tests.Nosetests in test_phasemapper" /> </list> <recent_temporary> - <list size="3"> - <item index="0" class="java.lang.String" itemvalue="Python.magdata" /> - <item index="1" class="java.lang.String" itemvalue="Python.Untitled" /> - <item index="2" class="java.lang.String" itemvalue="Python.setup" /> + <list size="5"> + <item index="0" class="java.lang.String" itemvalue="Python tests.Nosetests in test_phasemapper" /> + <item index="1" class="java.lang.String" itemvalue="Python tests.Nosetest TestCasePhaseMapperMIP.test_call" /> + <item index="2" class="java.lang.String" itemvalue="Python.test_fielddata" /> + <item index="3" class="java.lang.String" itemvalue="Python.circle_interpolation" /> + <item index="4" class="java.lang.String" itemvalue="Python.magdata" /> </list> </recent_temporary> </component> @@ -868,38 +671,50 @@ <option name="project" value="LOCAL" /> <updated>1456703900364</updated> </task> - <option name="localTasksCounter" value="9" /> + <task id="LOCAL-00009" summary="Added fieldconverter module! fieldconverter: methods to convert M to A to B magdata: a bit more parameters for quiver_plot3d(), added contour_plot3d() phasemapper: pm() extended for different projections (not just simple) kernel: u and v switched (now named after the unit magnetization direction, which makes much more sense)"> + <created>1457095777824</created> + <option name="number" value="00009" /> + <option name="project" value="LOCAL" /> + <updated>1457095777824</updated> + </task> + <task id="LOCAL-00010" summary="Refactoring: Replaced MagData with VectorData and added ScalarData class (and common superclass FieldData). magnitude is now called field (which is more appropriate) projector now uses FieldData to process both vector and scalar data (foundation was in place before)"> + <created>1457519303095</created> + <option name="number" value="00010" /> + <option name="project" value="LOCAL" /> + <updated>1457519303095</updated> + </task> + <option name="localTasksCounter" value="11" /> <servers /> </component> <component name="TestHistory"> - <history-entry file="Pyramid_Tests - 2016.02.28 at 23h 13m 11s.xml"> - <configuration name="Pyramid Tests" configurationId="tests" /> + <history-entry file="Nosetest_TestCasePhaseMapperElectric_test_call - 2016.03.09 at 11h 05m 56s.xml"> + <configuration name="Nosetest TestCasePhaseMapperElectric.test_call" configurationId="tests" /> </history-entry> - <history-entry file="Pyramid_Tests - 2016.02.28 at 23h 56m 53s.xml"> - <configuration name="Pyramid Tests" configurationId="tests" /> + <history-entry file="Nosetests_in_test_phasemapper - 2016.03.09 at 11h 06m 54s.xml"> + <configuration name="Nosetests in test_phasemapper" configurationId="tests" /> </history-entry> - <history-entry file="Pyramid_Tests - 2016.02.29 at 00h 18m 56s.xml"> + <history-entry file="Pyramid_Tests - 2016.03.07 at 10h 44m 21s.xml"> <configuration name="Pyramid Tests" configurationId="tests" /> </history-entry> - <history-entry file="Pyramid_Tests - 2016.02.29 at 00h 21m 13s.xml"> + <history-entry file="Pyramid_Tests - 2016.03.07 at 14h 56m 25s.xml"> <configuration name="Pyramid Tests" configurationId="tests" /> </history-entry> - <history-entry file="Pyramid_Tests - 2016.03.04 at 11h 28m 50s.xml"> + <history-entry file="Pyramid_Tests - 2016.03.08 at 21h 37m 05s.xml"> <configuration name="Pyramid Tests" configurationId="tests" /> </history-entry> - <history-entry file="Pyramid_Tests - 2016.03.04 at 12h 53m 22s.xml"> + <history-entry file="Pyramid_Tests - 2016.03.09 at 00h 21m 59s.xml"> <configuration name="Pyramid Tests" configurationId="tests" /> </history-entry> - <history-entry file="Pyramid_Tests - 2016.03.04 at 12h 55m 39s.xml"> + <history-entry file="Pyramid_Tests - 2016.03.09 at 00h 33m 38s.xml"> <configuration name="Pyramid Tests" configurationId="tests" /> </history-entry> - <history-entry file="Pyramid_Tests - 2016.03.04 at 12h 56m 18s.xml"> + <history-entry file="Pyramid_Tests - 2016.03.09 at 00h 47m 08s.xml"> <configuration name="Pyramid Tests" configurationId="tests" /> </history-entry> - <history-entry file="Pyramid_Tests - 2016.03.04 at 12h 56m 40s.xml"> + <history-entry file="Pyramid_Tests - 2016.03.09 at 09h 43m 39s.xml"> <configuration name="Pyramid Tests" configurationId="tests" /> </history-entry> - <history-entry file="Pyramid_Tests - 2016.03.04 at 12h 56m 47s.xml"> + <history-entry file="Pyramid_Tests - 2016.03.09 at 11h 07m 10s.xml"> <configuration name="Pyramid Tests" configurationId="tests" /> </history-entry> </component> @@ -916,24 +731,24 @@ <frame x="-8" y="-8" width="1936" height="1056" extended-state="6" /> <editor active="true" /> <layout> - <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.13859275" sideWeight="0.49186993" order="0" side_tool="false" content_ui="combo" /> - <window_info id="TODO" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.40565032" sideWeight="0.49746513" order="9" side_tool="false" content_ui="tabs" x="-33" y="355" width="1594" height="283" /> - <window_info id="Messages" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.3326226" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" /> + <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.13859275" sideWeight="0.49186993" order="0" side_tool="false" content_ui="combo" /> + <window_info id="TODO" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3219616" sideWeight="0.49746513" order="9" side_tool="false" content_ui="tabs" x="-33" y="355" width="1594" height="283" /> + <window_info id="Messages" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3326226" sideWeight="0.5" order="12" side_tool="false" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.42866325" sideWeight="0.50253487" order="8" side_tool="false" content_ui="tabs" /> - <window_info id="Python Console" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.36620468" sideWeight="0.49746513" order="3" side_tool="false" content_ui="tabs" /> - <window_info id="Version Control" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4415167" sideWeight="0.49746513" order="7" side_tool="false" content_ui="tabs" /> - <window_info id="Run" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.37739873" sideWeight="0.49746513" order="4" side_tool="false" content_ui="tabs" /> - <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.1108742" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> + <window_info id="Find" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.34168443" sideWeight="0.5" order="13" side_tool="false" content_ui="tabs" /> + <window_info id="Python Console" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.3379531" sideWeight="0.49746513" order="3" side_tool="false" content_ui="tabs" /> + <window_info id="Version Control" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.44136462" sideWeight="0.49746513" order="7" side_tool="false" content_ui="tabs" /> + <window_info id="Run" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32622603" sideWeight="0.49746513" order="4" side_tool="false" content_ui="tabs" /> + <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.16684435" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.43316194" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="Favorites" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.4224" sideWeight="0.5081301" order="11" side_tool="false" content_ui="tabs" /> - <window_info id="Debug" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.30398458" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> + <window_info id="Debug" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32518336" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Inspection" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.37596402" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" /> <window_info id="Thumbnails" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="WINDOWED" visible="false" show_stripe_button="false" weight="0.3708108" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" x="6" y="307" width="1908" height="381" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> - <window_info id="Find" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.34254497" sideWeight="0.5" order="13" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> </layout> </component> @@ -964,7 +779,8 @@ <MESSAGE value="New branch: new signals for holographic analysis!" /> <MESSAGE value="Commit after Reformatting with PyCharms!" /> <MESSAGE value="Added fieldconverter module! fieldconverter: methods to convert M to A to B magdata: a bit more parameters for quiver_plot3d(), added contour_plot3d() phasemapper: pm() extended for different projections (not just simple) kernel: u and v switched (now named after the unit magnetization direction, which makes much more sense)" /> - <option name="LAST_COMMIT_MESSAGE" value="Added fieldconverter module! fieldconverter: methods to convert M to A to B magdata: a bit more parameters for quiver_plot3d(), added contour_plot3d() phasemapper: pm() extended for different projections (not just simple) kernel: u and v switched (now named after the unit magnetization direction, which makes much more sense)" /> + <MESSAGE value="Refactoring: Replaced MagData with VectorData and added ScalarData class (and common superclass FieldData). magnitude is now called field (which is more appropriate) projector now uses FieldData to process both vector and scalar data (foundation was in place before)" /> + <option name="LAST_COMMIT_MESSAGE" value="Refactoring: Replaced MagData with VectorData and added ScalarData class (and common superclass FieldData). magnitude is now called field (which is more appropriate) projector now uses FieldData to process both vector and scalar data (foundation was in place before)" /> <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" /> <option name="REARRANGE_BEFORE_PROJECT_COMMIT" value="true" /> <option name="CHANGE_BROWSER_SETTINGS"> @@ -999,381 +815,396 @@ </properties> </breakpoint> </default-breakpoints> - <option name="time" value="51" /> + <option name="time" value="60" /> </breakpoint-manager> <watches-manager /> </component> <component name="editorHistoryManager"> - <entry file="file://$PROJECT_DIR$/docs/make.bat"> + <entry file="file://$PROJECT_DIR$/pyramid/logging.ini"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-1.9860919"> - <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> + <state vertical-scroll-proportion="0.59002167"> + <caret line="32" column="13" selection-start-line="32" selection-start-column="13" selection-end-line="32" selection-end-column="13" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/docs/_static/sphinxdoc.css"> + <entry file="file://$PROJECT_DIR$/scripts/reconstruction/reconstruction_2d_from_phasemap.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-0.9221141"> + <state vertical-scroll-proportion="0.0"> <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/docs/pyramid.numcore.rst"> + <entry file="file://$PROJECT_DIR$/pyramid/version.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.21279556"> - <caret line="9" column="0" selection-start-line="9" selection-start-column="0" selection-end-line="9" selection-end-column="0" /> + <state vertical-scroll-proportion="0.0945758"> + <caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/ramp.py"> + <entry file="file://$PROJECT_DIR$/setup.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.29310346"> - <caret line="47" column="26" selection-start-line="47" selection-start-column="26" selection-end-line="47" selection-end-column="26" /> + <state vertical-scroll-proportion="0.32962447"> + <caret line="103" column="0" selection-start-line="103" selection-start-column="0" selection-end-line="103" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/docs/pyramid.rst"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_dataset.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.6091954"> - <caret line="136" column="22" selection-start-line="136" selection-start-column="22" selection-end-line="136" selection-end-column="22" /> + <state vertical-scroll-proportion="0.17097701"> + <caret line="7" column="0" selection-start-line="7" selection-start-column="0" selection-end-line="7" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/docs/index.rst"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_phasemap.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.31752872"> - <caret line="13" column="10" selection-start-line="13" selection-start-column="10" selection-end-line="13" selection-end-column="10" /> + <state vertical-scroll-proportion="0.21982759"> + <caret line="9" column="37" selection-start-line="9" selection-start-column="37" selection-end-line="9" selection-end-column="37" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/docs/conf.py"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_magcreator.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.38793105"> - <caret line="33" column="20" selection-start-line="33" selection-start-column="16" selection-end-line="33" selection-end-column="20" /> + <state vertical-scroll-proportion="0.0"> + <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/docs/icon.ico"> - <provider selected="true" editor-type-id="images"> - <state /> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/pyramid/colormap.py"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_forwardmodel.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.42407808"> - <caret line="23" column="9" selection-start-line="23" selection-start-column="9" selection-end-line="23" selection-end-column="9" /> + <state vertical-scroll-proportion="0.0"> + <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/quaternion.py"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_projector.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.5021692"> - <caret line="119" column="24" selection-start-line="119" selection-start-column="24" selection-end-line="119" selection-end-column="24" /> + <state vertical-scroll-proportion="0.0"> + <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/logging.ini"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_regularisator.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.59002167"> - <caret line="32" column="13" selection-start-line="32" selection-start-column="13" selection-end-line="32" selection-end-column="13" /> + <state vertical-scroll-proportion="-1.9097035"> + <caret line="17" column="0" selection-start-line="17" selection-start-column="0" selection-end-line="17" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/docs/_build/_static/underscore-1.3.1.js"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_analytic.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.3329718"> - <caret line="94" column="55" selection-start-line="94" selection-start-column="55" selection-end-line="94" selection-end-column="55" /> + <state vertical-scroll-proportion="0.43530998"> + <caret line="19" column="16" selection-start-line="19" selection-start-column="16" selection-end-line="19" selection-end-column="16" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/scripts/reconstruction/reconstruction_2d_from_phasemap.py"> + <entry file="file://$PROJECT_DIR$/pyramid/numcore/phasemapper_core.c"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> + <state vertical-scroll-proportion="-5.7277627"> + <caret line="2" column="24" selection-start-line="2" selection-start-column="24" selection-end-line="2" selection-end-column="24" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/diagnostics.py"> + <entry file="file://$PROJECT_DIR$/pyramid/analytic.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.29784366"> - <caret line="13" column="23" selection-start-line="13" selection-start-column="23" selection-end-line="13" selection-end-column="23" /> + <state vertical-scroll-proportion="0.9541779"> + <caret line="215" column="31" selection-start-line="215" selection-start-column="31" selection-end-line="215" selection-end-column="31" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/version.py"> + <entry file="file://$PROJECT_DIR$/pyramid/config.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0945758"> - <caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" /> + <state vertical-scroll-proportion="0.0"> + <caret line="14" column="4" selection-start-line="14" selection-start-column="4" selection-end-line="14" selection-end-column="4" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/setup.py"> + <entry file="file://C:/Anaconda2/Lib/site-packages/numpy/core/_methods.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.32962447"> - <caret line="103" column="0" selection-start-line="103" selection-start-column="0" selection-end-line="103" selection-end-column="0" /> + <state vertical-scroll-proportion="-0.47831184"> + <caret line="24" column="0" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_dataset.py"> + <entry file="file://$PROJECT_DIR$/scripts/gui/phasemap_creator.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.17097701"> - <caret line="7" column="0" selection-start-line="7" selection-start-column="0" selection-end-line="7" selection-end-column="0" /> + <state vertical-scroll-proportion="0.0"> + <caret line="11" column="10" selection-start-line="11" selection-start-column="10" selection-end-line="11" selection-end-column="10" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_phasemap.py"> + <entry file="file://$PROJECT_DIR$/pyramid/forwardmodel.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.21982759"> - <caret line="9" column="37" selection-start-line="9" selection-start-column="37" selection-end-line="9" selection-end-column="37" /> + <state vertical-scroll-proportion="0.27511415"> + <caret line="72" column="8" selection-start-line="72" selection-start-column="8" selection-end-line="72" selection-end-column="8" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_magdata.py"> + <entry file="file://$PROJECT_DIR$/pyramid/fft.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> + <caret line="296" column="15" selection-start-line="296" selection-start-column="15" selection-end-line="296" selection-end-column="28" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_magcreator.py"> + <entry file="file://C:/Anaconda2/Lib/site-packages/matplotlib/backend_bases.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> + <state vertical-scroll-proportion="0.72362554"> + <caret line="2436" column="0" selection-start-line="2436" selection-start-column="0" selection-end-line="2436" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_forwardmodel.py"> + <entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/pydevd.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> + <state vertical-scroll-proportion="0.9346314"> + <caret line="2410" column="0" selection-start-line="2410" selection-start-column="0" selection-end-line="2410" selection-end-column="0" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_costfunction.py"> + <entry file="file://$PROJECT_DIR$/scripts/gui/mag_slicer.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> + <caret line="223" column="57" selection-start-line="223" selection-start-column="57" selection-end-line="223" selection-end-column="57" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_phasemapper.py"> + <entry file="file://$USER_HOME$/Downloads/Untitled.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.47304583"> - <caret line="159" column="21" selection-start-line="159" selection-start-column="21" selection-end-line="159" selection-end-column="21" /> + <state vertical-scroll-proportion="0.0"> + <caret line="44" column="40" selection-start-line="44" selection-start-column="40" selection-end-line="44" selection-end-column="40" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_projector.py"> + <entry file="file://$PROJECT_DIR$/../Jutil/jutil/cg.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> + <state vertical-scroll-proportion="0.0189099"> + <caret line="72" column="18" selection-start-line="72" selection-start-column="18" selection-end-line="72" selection-end-column="18" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_regularisator.py"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_kernel.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-1.9097035"> - <caret line="17" column="0" selection-start-line="17" selection-start-column="0" selection-end-line="17" selection-end-column="0" /> + <state vertical-scroll-proportion="0.0"> + <caret line="26" column="0" selection-start-line="26" selection-start-column="0" selection-end-line="26" selection-end-column="0" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_analytic.py"> + <entry file="file://$PROJECT_DIR$/pyramid/kernel.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.43530998"> - <caret line="19" column="16" selection-start-line="19" selection-start-column="16" selection-end-line="19" selection-end-column="16" /> + <state vertical-scroll-proportion="0.0"> + <caret line="95" column="34" selection-start-line="95" selection-start-column="34" selection-end-line="95" selection-end-column="34" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/numcore/phasemapper_core.c"> + <entry file="file://$PROJECT_DIR$/../Publications/paper 2/paper2_part3_experiment.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-5.7277627"> - <caret line="2" column="24" selection-start-line="2" selection-start-column="24" selection-end-line="2" selection-end-column="24" /> + <state vertical-scroll-proportion="0.0"> + <caret line="17" column="25" selection-start-line="17" selection-start-column="25" selection-end-line="17" selection-end-column="25" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/analytic.py"> + <entry file="file://$PROJECT_DIR$/../Publications/pico 2015/poster_pico2015_2d.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.9541779"> - <caret line="215" column="31" selection-start-line="215" selection-start-column="31" selection-end-line="215" selection-end-column="31" /> + <state vertical-scroll-proportion="0.0"> + <caret line="24" column="21" selection-start-line="24" selection-start-column="21" selection-end-line="24" selection-end-column="21" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/scripts/reconstruction/reconstruction_3d_from_magdata.py"> + <entry file="file://$PROJECT_DIR$/../Publications/pico 2015/poster_pico2015_3d.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="11" column="0" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="76" /> + <caret line="31" column="45" selection-start-line="31" selection-start-column="45" selection-end-line="31" selection-end-column="45" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/config.py"> + <entry file="file://$PROJECT_DIR$/pyramid/fieldconverter.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="14" column="4" selection-start-line="14" selection-start-column="4" selection-end-line="14" selection-end-column="4" /> + <caret line="73" column="30" selection-start-line="73" selection-start-column="30" selection-end-line="73" selection-end-column="30" /> <folding /> </state> </provider> </entry> - <entry file="file://C:/Anaconda2/Lib/site-packages/numpy/core/_methods.py"> + <entry file="file://$PROJECT_DIR$/pyramid/diagnostics.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-0.47831184"> - <caret line="24" column="0" selection-start-line="24" selection-start-column="0" selection-end-line="24" selection-end-column="0" /> + <state vertical-scroll-proportion="0.0"> + <caret line="183" column="21" selection-start-line="183" selection-start-column="21" selection-end-line="183" selection-end-column="21" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/scripts/gui/phasemap_creator.py"> + <entry file="file://$PROJECT_DIR$/pyramid/magcreator.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="11" column="10" selection-start-line="11" selection-start-column="10" selection-end-line="11" selection-end-column="10" /> + <caret line="309" column="0" selection-start-line="309" selection-start-column="0" selection-end-line="309" selection-end-column="0" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/forwardmodel.py"> + <entry file="file://$PROJECT_DIR$/../Script-Vault/circle_interpolation.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.27511415"> - <caret line="72" column="8" selection-start-line="72" selection-start-column="8" selection-end-line="72" selection-end-column="8" /> + <state vertical-scroll-proportion="0.374541"> + <caret line="18" column="23" selection-start-line="18" selection-start-column="23" selection-end-line="18" selection-end-column="23" /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/dataset.py"> + <entry file="file://$PROJECT_DIR$/pyramid/phasemap.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="157" column="8" selection-start-line="157" selection-start-column="8" selection-end-line="157" selection-end-column="8" /> + <caret line="216" column="23" selection-start-line="216" selection-start-column="23" selection-end-line="216" selection-end-column="23" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/fft.py"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_costfunction.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="296" column="15" selection-start-line="296" selection-start-column="15" selection-end-line="296" selection-end-column="28" /> + <caret line="43" column="8" selection-start-line="43" selection-start-column="8" selection-end-line="43" selection-end-column="8" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/phasemap.py"> + <entry file="file://$PROJECT_DIR$/../Publications/paper 2/paper2_part2_simulation.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="781" column="8" selection-start-line="781" selection-start-column="8" selection-end-line="781" selection-end-column="8" /> + <state vertical-scroll-proportion="0.020807834"> + <caret line="17" column="25" selection-start-line="17" selection-start-column="25" selection-end-line="17" selection-end-column="25" /> <folding /> </state> </provider> </entry> - <entry file="file://C:/Anaconda2/Lib/site-packages/matplotlib/backend_bases.py"> + <entry file="file://$PROJECT_DIR$/../Publications/nanowire_z_angle.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.72362554"> - <caret line="2436" column="0" selection-start-line="2436" selection-start-column="0" selection-end-line="2436" selection-end-column="0" /> + <state vertical-scroll-proportion="0.29974812"> + <caret line="14" column="51" selection-start-line="14" selection-start-column="51" selection-end-line="14" selection-end-column="51" /> + <folding /> </state> </provider> </entry> - <entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/pydevd.py"> + <entry file="file://$PROJECT_DIR$/pyramid/projector.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.9346314"> - <caret line="2410" column="0" selection-start-line="2410" selection-start-column="0" selection-end-line="2410" selection-end-column="0" /> + <state vertical-scroll-proportion="0.0"> + <caret line="593" column="6" selection-start-line="593" selection-start-column="6" selection-end-line="593" selection-end-column="6" /> + <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/scripts/gui/mag_slicer.py"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_fielddata.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="223" column="57" selection-start-line="223" selection-start-column="57" selection-end-line="223" selection-end-column="57" /> + <caret line="118" column="0" selection-start-line="118" selection-start-column="0" selection-end-line="118" selection-end-column="0" /> <folding /> </state> </provider> </entry> - <entry file="file://$USER_HOME$/Downloads/Untitled.py"> + <entry file="file://$PROJECT_DIR$/pyramid/tests/test_phasemapper.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="44" column="40" selection-start-line="44" selection-start-column="40" selection-end-line="44" selection-end-column="40" /> + <caret line="14" column="0" selection-start-line="14" selection-start-column="0" selection-end-line="14" selection-end-column="0" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/projector.py"> + <entry file="file://$PROJECT_DIR$/pyramid/phasemapper.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="608" column="51" selection-start-line="608" selection-start-column="8" selection-end-line="608" selection-end-column="51" /> + <caret line="577" column="99" selection-start-line="577" selection-start-column="99" selection-end-line="577" selection-end-column="99" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/../Jutil/jutil/cg.py"> + <entry file="file://$PROJECT_DIR$/scripts/phasemap/phasemap_tilt_series.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0189099"> - <caret line="72" column="18" selection-start-line="72" selection-start-column="18" selection-end-line="72" selection-end-column="18" /> + <state vertical-scroll-proportion="0.2080089"> + <caret line="11" column="51" selection-start-line="11" selection-start-column="51" selection-end-line="11" selection-end-column="51" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/fieldconverter.py"> + <entry file="file://$PROJECT_DIR$/scripts/magdata/magdata_from_vtk.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.378198"> - <caret line="20" column="36" selection-start-line="20" selection-start-column="36" selection-end-line="20" selection-end-column="36" /> + <state vertical-scroll-proportion="0.2080089"> + <caret line="11" column="5" selection-start-line="11" selection-start-column="5" selection-end-line="11" selection-end-column="5" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/magcreator.py"> + <entry file="file://$PROJECT_DIR$/scripts/magdata/magdata_from_dat.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="16" column="3" selection-start-line="4" selection-start-column="0" selection-end-line="16" selection-end-column="3" /> + <state vertical-scroll-proportion="0.7163515"> + <caret line="59" column="5" selection-start-line="59" selection-start-column="5" selection-end-line="59" selection-end-column="5" /> + <folding /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/pyramid/dataset.py"> + <provider selected="true" editor-type-id="text-editor"> + <state vertical-scroll-proportion="0.0189099"> + <caret line="163" column="29" selection-start-line="163" selection-start-column="29" selection-end-line="163" selection-end-column="29" /> <folding /> </state> </provider> </entry> <entry file="file://$PROJECT_DIR$/pyramid/reconstruction.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="46" column="27" selection-start-line="46" selection-start-column="27" selection-end-line="46" selection-end-column="27" /> + <state vertical-scroll-proportion="0.0189099"> + <caret line="51" column="46" selection-start-line="51" selection-start-column="46" selection-end-line="51" selection-end-column="46" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/__init__.py"> + <entry file="file://$PROJECT_DIR$/pyramid/costfunction.py"> <provider selected="true" editor-type-id="text-editor"> <state vertical-scroll-proportion="0.0"> - <caret line="90" column="38" selection-start-line="90" selection-start-column="38" selection-end-line="90" selection-end-column="38" /> + <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/tests/test_kernel.py"> + <entry file="file://$PROJECT_DIR$/scripts/reconstruction/reconstruction_3d_from_magdata.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="26" column="0" selection-start-line="26" selection-start-column="0" selection-end-line="26" selection-end-column="0" /> + <state vertical-scroll-proportion="0.3546638"> + <caret line="30" column="0" selection-start-line="30" selection-start-column="0" selection-end-line="30" selection-end-column="0" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/phasemapper.py"> + <entry file="file://$PROJECT_DIR$/../Publications/tilt_series.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="-8.666667"> - <caret line="332" column="51" selection-start-line="332" selection-start-column="51" selection-end-line="332" selection-end-column="51" /> + <state vertical-scroll-proportion="0.6496746"> + <caret line="38" column="36" selection-start-line="38" selection-start-column="36" selection-end-line="38" selection-end-column="36" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/kernel.py"> + <entry file="file://$PROJECT_DIR$/pyramid/fielddata.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="95" column="34" selection-start-line="95" selection-start-column="34" selection-end-line="95" selection-end-column="34" /> + <state vertical-scroll-proportion="0.55748373"> + <caret line="330" column="58" selection-start-line="330" selection-start-column="58" selection-end-line="330" selection-end-column="58" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/scripts/phasemap/phasemap_tilt_series.py"> + <entry file="file://$PROJECT_DIR$/pyramid/__init__.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.0"> - <caret line="40" column="16" selection-start-line="40" selection-start-column="16" selection-end-line="40" selection-end-column="16" /> + <state vertical-scroll-proportion="0.52060735"> + <caret line="90" column="38" selection-start-line="90" selection-start-column="38" selection-end-line="90" selection-end-column="38" /> <folding /> </state> </provider> </entry> - <entry file="file://$PROJECT_DIR$/pyramid/magdata.py"> + <entry file="file://$PROJECT_DIR$/pyramid/colormap.py"> <provider selected="true" editor-type-id="text-editor"> - <state vertical-scroll-proportion="0.62133646"> - <caret line="879" column="31" selection-start-line="879" selection-start-column="31" selection-end-line="879" selection-end-column="31" /> + <state vertical-scroll-proportion="0.11171366"> + <caret line="89" column="28" selection-start-line="89" selection-start-column="26" selection-end-line="89" selection-end-column="28" /> <folding /> </state> </provider> diff --git a/pyramid/__init__.py b/pyramid/__init__.py index d45cdbb..2c8ec1d 100644 --- a/pyramid/__init__.py +++ b/pyramid/__init__.py @@ -70,8 +70,8 @@ from . import forwardmodel from .forwardmodel import * from . import kernel from .kernel import * -from . import magdata -from .magdata import * +from . import fielddata +from .fielddata import * from . import phasemap from .phasemap import * from . import phasemapper @@ -99,7 +99,7 @@ __all__.extend(dataset.__all__) __all__.extend(diagnostics.__all__) __all__.extend(forwardmodel.__all__) __all__.extend(kernel.__all__) -__all__.extend(magdata.__all__) +__all__.extend(fielddata.__all__) __all__.extend(phasemap.__all__) __all__.extend(phasemapper.__all__) __all__.extend(projector.__all__) diff --git a/pyramid/dataset.py b/pyramid/dataset.py index c32c73e..34501da 100644 --- a/pyramid/dataset.py +++ b/pyramid/dataset.py @@ -157,11 +157,11 @@ class DataSet(object): def create_phase_maps(self, mag_data): """Create a list of phasemaps with the projectors in the dataset for a given - :class:`~.MagData` object. + :class:`~.VectorData` object. Parameters ---------- - mag_data : :class:`~.MagData` + mag_data : :class:`~.VectorData` Magnetic distribution to which the projectors of the dataset should be applied. Returns @@ -280,7 +280,7 @@ class DataSet(object): Parameters ---------- - mag_data : :class:`~.MagData`, optional + mag_data : :class:`~.VectorData`, optional Magnetic distribution to which the projectors of the dataset should be applied. If not given, the phase_maps in the dataset are used. title : string, optional @@ -317,7 +317,7 @@ class DataSet(object): Parameters ---------- - mag_data : :class:`~.MagData`, optional + mag_data : :class:`~.VectorData`, optional Magnetic distribution to which the projectors of the dataset should be applied. If not given, the phase_maps in the dataset are used. title : string, optional diff --git a/pyramid/diagnostics.py b/pyramid/diagnostics.py index 74274d0..eb0bb7a 100644 --- a/pyramid/diagnostics.py +++ b/pyramid/diagnostics.py @@ -12,7 +12,7 @@ import numpy as np import jutil from pyramid import fft -from pyramid.magdata import MagData +from pyramid.fielddata import VectorData from pyramid.phasemap import PhaseMap __all__ = ['Diagnostics'] @@ -157,14 +157,14 @@ class Diagnostics(object): Returns ------- - mag_data_avg_kern: :class:`~pyramid.magdata.MagData` + mag_data_avg_kern: :class:`~pyramid.fielddata.VectorData` Averaging kernel matrix row represented as a 3D magnetization distribution """ self._log.debug('Calling get_avg_kern_row') if pos is not None: self.pos = pos - mag_data_avg_kern = MagData(self.cost.data_set.a, fft.zeros((3,) + self.dim)) + mag_data_avg_kern = VectorData(self.cost.data_set.a, fft.zeros((3,) + self.dim)) mag_data_avg_kern.set_vector(self.avrg_kern_row, mask=self.mask) return mag_data_avg_kern @@ -181,7 +181,7 @@ class Diagnostics(object): px_avrg: float The number of pixels over which is approximately averaged. The inverse is the FWHM. (x, y, z): tuple of floats - The magnitude of the averaging kernel summed along two axes (the remaining are x, y, z, + The field of the averaging kernel summed along two axes (the remaining are x, y, z, respectively). Notes @@ -191,7 +191,7 @@ class Diagnostics(object): """ self._log.debug('Calling calculate_averaging') mag_data_avg_kern = self.get_avg_kern_row(pos) - mag_x, mag_y, mag_z = mag_data_avg_kern.magnitude + mag_x, mag_y, mag_z = mag_data_avg_kern.field x = mag_x.sum(axis=(0, 1)) y = mag_y.sum(axis=(0, 2)) z = mag_z.sum(axis=(1, 2)) diff --git a/pyramid/fieldconverter.py b/pyramid/fieldconverter.py index 0b5e29f..a40413e 100644 --- a/pyramid/fieldconverter.py +++ b/pyramid/fieldconverter.py @@ -12,7 +12,7 @@ import logging import numpy as np from pyramid import fft -from pyramid.magdata import MagData +from pyramid.fielddata import VectorData __all__ = ['convert_M_to_A', 'convert_A_to_B', 'convert_M_to_B'] _log = logging.getLogger(__name__) @@ -23,20 +23,20 @@ def convert_M_to_A(mag_data, b_0=1.0): Parameters ---------- - mag_data: :class:`~pyramid.magdata.MagData` object + mag_data: :class:`~pyramid.magdata.VectorData` object The magnetic vector field from which the A-field is calculated. b_0: float, optional The saturation magnetization which is used in the calculation. Returns ------- - b_data: :class:`~pyramid.magdata.MagData` object + b_data: :class:`~pyramid.magdata.VectorData` object The calculated B-field. """ _log.debug('Calling convert_M_to_A') # Preparations of variables: - assert isinstance(mag_data, MagData), 'Only MagData objects can be mapped!' + assert isinstance(mag_data, VectorData), 'Only VectorData objects can be mapped!' dim = mag_data.dim dim_kern = tuple(2 * np.array(dim) - 1) # Dimensions of the kernel if fft.BACKEND == 'pyfftw': @@ -71,9 +71,9 @@ def convert_M_to_A(mag_data, b_0=1.0): x_mag = fft.zeros(dim_pad, dtype=fft.FLOAT) y_mag = fft.zeros(dim_pad, dtype=fft.FLOAT) z_mag = fft.zeros(dim_pad, dtype=fft.FLOAT) - x_mag[slice_M] = mag_data.magnitude[0, ...] - y_mag[slice_M] = mag_data.magnitude[1, ...] - z_mag[slice_M] = mag_data.magnitude[2, ...] + x_mag[slice_M] = mag_data.field[0, ...] + y_mag[slice_M] = mag_data.field[1, ...] + z_mag[slice_M] = mag_data.field[2, ...] # Calculate Fourier trafo of magnetization components: x_mag_fft = fft.rfftn(x_mag) y_mag_fft = fft.rfftn(y_mag) @@ -86,7 +86,7 @@ def convert_M_to_A(mag_data, b_0=1.0): a_y = fft.irfftn(a_y_fft)[slice_B] a_z = fft.irfftn(a_z_fft)[slice_B] # Return A-field: - return MagData(mag_data.a, np.asarray((a_x, a_y, a_z))) + return VectorData(mag_data.a, np.asarray((a_x, a_y, a_z))) def convert_A_to_B(a_data): @@ -94,19 +94,19 @@ def convert_A_to_B(a_data): Parameters ---------- - a_data: :class:`~pyramid.magdata.MagData` object + a_data: :class:`~pyramid.magdata.VectorData` object The vector potential field from which the A-field is calculated. Returns ------- - b_data: :class:`~pyramid.magdata.MagData` object + b_data: :class:`~pyramid.magdata.VectorData` object The calculated B-field. """ _log.debug('Calling convert_A_to_B') - assert isinstance(a_data, MagData), 'Only MagData objects can be mapped!' + assert isinstance(a_data, VectorData), 'Only VectorData objects can be mapped!' # Calculate gradients: - x_mag, y_mag, z_mag = a_data.magnitude + x_mag, y_mag, z_mag = a_data.field x_grad_z, x_grad_y, x_grad_x = np.gradient(x_mag) y_grad_z, y_grad_y, y_grad_x = np.gradient(y_mag) z_grad_z, z_grad_y, z_grad_x = np.gradient(z_mag) @@ -115,7 +115,7 @@ def convert_A_to_B(a_data): b_y = (x_grad_z - z_grad_x) b_z = (y_grad_x - x_grad_y) # Return B-field: - return MagData(a_data.a, np.asarray((b_x, b_y, b_z))) + return VectorData(a_data.a, np.asarray((b_x, b_y, b_z))) def convert_M_to_B(mag_data, b_0=1.0): @@ -123,17 +123,17 @@ def convert_M_to_B(mag_data, b_0=1.0): Parameters ---------- - mag_data: :class:`~pyramid.magdata.MagData` object + mag_data: :class:`~pyramid.magdata.VectorData` object The magnetic vector field from which the B-field is calculated. b_0: float, optional The saturation magnetization which is used in the calculation. Returns ------- - b_data: :class:`~pyramid.magdata.MagData` object + b_data: :class:`~pyramid.magdata.VectorData` object The calculated B-field. """ _log.debug('Calling convert_M_to_B') - assert isinstance(mag_data, MagData), 'Only MagData objects can be mapped!' + assert isinstance(mag_data, VectorData), 'Only VectorData objects can be mapped!' return convert_A_to_B(convert_M_to_A(mag_data, b_0=b_0)) diff --git a/pyramid/magdata.py b/pyramid/fielddata.py similarity index 50% rename from pyramid/magdata.py rename to pyramid/fielddata.py index e740e2b..4301d1f 100644 --- a/pyramid/magdata.py +++ b/pyramid/fielddata.py @@ -2,16 +2,17 @@ # Copyright 2014 by Forschungszentrum Juelich GmbH # Author: J. Caron # -"""This module provides the :class:`~.MagData` class for storing of magnetization data.""" +"""This module provides classes for storing vector and scalar 3D-field.""" from __future__ import division import logging import os +from abc import ABCMeta, abstractmethod from numbers import Number -import matplotlib.pyplot as plt import numpy as np +from matplotlib import pyplot as plt from matplotlib.ticker import MaxNLocator from scipy.ndimage.interpolation import zoom @@ -25,31 +26,31 @@ except ImportError: hs = None _log.error('Could not load hyperspy package!') -__all__ = ['MagData'] +__all__ = ['VectorData', 'ScalarData'] -class MagData(object): - """Class for storing magnetization data. +class FieldData(object): + """Class for storing field data. - Represents 3-dimensional magnetic distributions with 3 components which are stored as a - 2-dimensional numpy array in `magnitude`, but which can also be accessed as a vector via - `mag_vec`. :class:`~.MagData` objects support negation, arithmetic operators + Abstract base class for the representatio of magnetic or electric fields (see subclasses). + Fields can be accessed as 3D numpy arrays via the `field` property or as a vector via + `field_vec`. :class:`~.FieldData` objects support negation, arithmetic operators (``+``, ``-``, ``*``) and their augmented counterparts (``+=``, ``-=``, ``*=``), with numbers - and other :class:`~.MagData` objects, if their dimensions and grid spacings match. It is - possible to load data from HDF5 or LLG (.txt) files or to save the data in these formats. - Plotting methods are also provided. + and other :class:`~.FieldData` objects of the same subclass, if their dimensions and grid + spacings match. It is possible to load data from HDF5 or LLG (.txt) files or to save the data + in these formats. Specialised plotting methods are also provided. Attributes ---------- a: float The grid spacing in nm. - magnitude: :class:`~numpy.ndarray` (N=4) - The `x`-, `y`- and `z`-component of the magnetization vector for every 3D-gridpoint - as a 4-dimensional numpy array (first dimension has to be 3, because of the 3 components). + field: :class:`~numpy.ndarray` (N=4) + The field distribution for every 3D-gridpoint. """ - _log = logging.getLogger(__name__ + '.MagData') + __metaclass__ = ABCMeta + _log = logging.getLogger(__name__ + '.FieldData') @property def a(self): @@ -62,73 +63,80 @@ class MagData(object): assert a >= 0, 'Grid spacing has to be a positive number!' self._a = float(a) + @property + def shape(self): + """The shape of the `field` (3D for scalar, 4D vor vector field).""" + return self.field.shape + @property def dim(self): - """Dimensions (z, y, x) of the grid.""" - return self._dim + """Dimensions (z, y, x) of the grid, only 3D coordinates, without components if present.""" + return self.shape[-3:] @property - def magnitude(self): - """The `x`-, `y`- and `z`-component of the magnetization vector for every 3D-gridpoint.""" - return self._magnitude - - @magnitude.setter - def magnitude(self, magnitude): - assert isinstance(magnitude, np.ndarray), 'Magnitude has to be a numpy array!' - assert len(magnitude.shape) == 4, 'Magnitude has to be 4-dimensional!' - assert magnitude.shape[0] == 3, 'First dimension of the magnitude has to be 3!' - self._magnitude = np.asarray(magnitude, dtype=fft.FLOAT) - self._dim = magnitude.shape[1:] + def field(self): + """The field strength for every 3D-gridpoint (scalar: 3D, vector: 4D).""" + return self._field + + @field.setter + def field(self, field): + assert isinstance(field, np.ndarray), 'Field has to be a numpy array!' + assert 3 <= len(field.shape) <= 4, 'Field has to be 3- or 4-dimensional (scalar / vector)!' + if len(field.shape) == 4: + assert field.shape[0] == 3, 'A vector field has to have exactly 3 components!' + self._field = np.asarray(field, dtype=fft.FLOAT) @property - def mag_amp(self): - """The length (amplitude) of the magnetization vectors as a 3D-array.""" - return np.sqrt(np.sum(self.magnitude ** 2, axis=0)) + def field_amp(self): + """The field amplitude (returns the field itself for scalar and the vector amplitude + calculated via a square sum for a vector field.""" + if len(self.shape) == 4: + return np.sqrt(np.sum(self.field ** 2, axis=0)) + else: + return self.field @property - def mag_vec(self): - """Vector containing the magnetic distribution.""" - return np.reshape(self.magnitude, -1) + def field_vec(self): + """Vector containing the vector field distribution.""" + return np.reshape(self.field, -1) - @mag_vec.setter - def mag_vec(self, mag_vec): + @field_vec.setter + def field_vec(self, mag_vec): mag_vec = np.asarray(mag_vec, dtype=fft.FLOAT) - assert np.size(mag_vec) == 3 * np.prod(self.dim), \ - 'Vector has to match magnitude dimensions! {} {}'.format(mag_vec.shape, - 3 * np.prod(self.dim)) - self.magnitude = mag_vec.reshape((3,) + self.dim) + assert np.size(mag_vec) == np.prod(self.shape), \ + 'Vector has to match field shape! {} {}'.format(mag_vec.shape, np.prod(self.shape)) + self.field = mag_vec.reshape((3,) + self.dim) - def __init__(self, a, magnitude): + def __init__(self, a, field): self._log.debug('Calling __init__') self.a = a - self.magnitude = magnitude + self.field = field self._log.debug('Created ' + str(self)) def __repr__(self): self._log.debug('Calling __repr__') - return '%s(a=%r, magnitude=%r)' % (self.__class__, self.a, self.magnitude) + return '%s(a=%r, field=%r)' % (self.__class__, self.a, self.field) def __str__(self): self._log.debug('Calling __str__') - return 'MagData(a=%s, dim=%s)' % (self.a, self.dim) + return '%s(a=%s, dim=%s)' % (self.__class__, self.a, self.dim) def __neg__(self): # -self self._log.debug('Calling __neg__') - return MagData(self.a, -self.magnitude) + return VectorData(self.a, -self.field) def __add__(self, other): # self + other self._log.debug('Calling __add__') - assert isinstance(other, (MagData, Number)), \ - 'Only MagData objects and scalar numbers (as offsets) can be added/subtracted!' - if isinstance(other, MagData): - self._log.debug('Adding two MagData objects') + assert isinstance(other, (FieldData, Number)), \ + 'Only FieldData objects and scalar numbers (as offsets) can be added/subtracted!' + if isinstance(other, FieldData): + self._log.debug('Adding two VectorData objects') assert other.a == self.a, 'Added phase has to have the same grid spacing!' - assert other.magnitude.shape == (3,) + self.dim, \ - 'Added magnitude has to have the same dimensions!' - return MagData(self.a, self.magnitude + other.magnitude) + assert other.shape == self.shape, 'Added field has to have the same dimensions!' + return self.__init__(self.a, self.field + other.field) else: # other is a Number self._log.debug('Adding an offset') - return MagData(self.a, self.magnitude + other) + return self.__init__(self.a, self.field + other) def __sub__(self, other): # self - other self._log.debug('Calling __sub__') @@ -136,8 +144,8 @@ class MagData(object): def __mul__(self, other): # self * other self._log.debug('Calling __mul__') - assert isinstance(other, Number), 'MagData objects can only be multiplied by numbers!' - return MagData(self.a, other * self.magnitude) + assert isinstance(other, Number), 'FieldData objects can only be multiplied by numbers!' + return VectorData(self.a, other * self.field) def __radd__(self, other): # other + self self._log.debug('Calling __radd__') @@ -164,24 +172,211 @@ class MagData(object): return self.__mul__(other) def copy(self): - """Returns a copy of the :class:`~.MagData` object + """Returns a copy of the :class:`~.FieldData` object Returns ------- - mag_data: :class:`~.MagData` - A copy of the :class:`~.MagData`. + field_data: :class:`~.FieldData` + A copy of the :class:`~.FieldData`. """ self._log.debug('Calling copy') - return MagData(self.a, self.magnitude.copy()) + return self.__init__(self.a, self.field.copy()) + + def get_mask(self, threshold=0): + """Mask all pixels where the amplitude of the field lies above `threshold`. + + Parameters + ---------- + threshold : float, optional + A pixel only gets masked, if it lies above this threshold . The default is 0. + + Returns + ------- + mask : :class:`~numpy.ndarray` (N=3, boolean) + Mask of the pixels where the amplitude of the field lies above `threshold`. + + """ + self._log.debug('Calling get_mask') + return np.where(self.field_amp > threshold, True, False) + + def contour_plot3d(self, title='Field Distribution', contours=10, opacity=0.25): + """Plot the field as a 3D-contour plot. + + Parameters + ---------- + title: string, optional + The title for the plot. + contours: int, optional + Number of contours which should be plotted. + opacity: float, optional + Defines the opacity of the contours. Default is 0.25. + + Returns + ------- + plot : :class:`mayavi.modules.vectors.Vectors` + The plot object. + + + """ + self._log.debug('Calling quiver_plot3D') + from mayavi import mlab + # Plot them as vectors: + mlab.figure(size=(750, 700)) + plot = mlab.contour3d(self.field_amp, contours=contours, opacity=opacity) + mlab.outline(plot) + mlab.axes(plot) + mlab.title(title, height=0.95, size=0.35) + mlab.orientation_axes() + # mlab.show() + return plot + + @abstractmethod + def scale_down(self, n): + """Scale down the field distribution by averaging over two pixels along each axis. + + Parameters + ---------- + n : int, optional + Number of times the field distribution is scaled down. The default is 1. + + Returns + ------- + None + + Notes + ----- + Acts in place and changes dimensions and grid spacing accordingly. + Only possible, if each axis length is a power of 2! + + """ + pass + + @abstractmethod + def scale_up(self, n, order): + """Scale up the field distribution using spline interpolation of the requested order. + + Parameters + ---------- + n : int, optional + Power of 2 with which the grid is scaled. Default is 1, which means every axis is + increased by a factor of ``2**1 = 2``. + order : int, optional + The order of the spline interpolation, which has to be in the range between 0 and 5 + and defaults to 0. + + Returns + ------- + None + + Notes + ----- + Acts in place and changes dimensions and grid spacing accordingly. + """ + pass + + @abstractmethod + def get_vector(self, mask): + """Returns the field as a vector, specified by a mask. + + Parameters + ---------- + mask : :class:`~numpy.ndarray` (N=3, boolean) + Masks the pixels from which the entries should be taken. + + Returns + ------- + vector : :class:`~numpy.ndarray` (N=1) + The vector containing the field of the specified pixels. + + """ + pass + + @abstractmethod + def set_vector(self, vector, mask): + """Set the field of the masked pixels to the values specified by `vector`. + + Parameters + ---------- + mask : :class:`~numpy.ndarray` (N=3, boolean), optional + Masks the pixels from which the field should be taken. + vector : :class:`~numpy.ndarray` (N=1) + The vector containing the field of the specified pixels. + + Returns + ------- + None + + """ + pass + + @abstractmethod + def to_signal(self): + """Convert :class:`~.FieldData` data into a HyperSpy signal. + + Returns + ------- + signal: :class:`~hyperspy.signals.Signal` + Representation of the :class:`~.FieldData` object as a HyperSpy Signal. + + Notes + ----- + This method recquires the hyperspy package! + + """ + pass + + @abstractmethod + def save_to_hdf5(self, filename): + """Save field data in a file with HyperSpys HDF5-format. + + Parameters + ---------- + filename : string, optional + The name of the HDF5-file in which to store the field data. + + Returns + ------- + None + + """ + pass + + +class VectorData(FieldData): + """Class for storing vector ield data. + + Represents 3-dimensional vector field distributions with 3 components which are stored as a + 3-dimensional numpy array in `field`, but which can also be accessed as a vector via + `field_vec`. :class:`~.VectorData` objects support negation, arithmetic operators + (``+``, ``-``, ``*``) and their augmented counterparts (``+=``, ``-=``, ``*=``), with numbers + and other :class:`~.VectorData` objects, if their dimensions and grid spacings match. It is + possible to load data from HDF5 or LLG (.txt) files or to save the data in these formats. + Plotting methods are also provided. + + Attributes + ---------- + a: float + The grid spacing in nm. + field: :class:`~numpy.ndarray` (N=4) + The `x`-, `y`- and `z`-component of the vector field for every 3D-gridpoint + as a 4-dimensional numpy array (first dimension has to be 3, because of the 3 components). + + """ + _log = logging.getLogger(__name__ + '.VectorData') + + def __init__(self, a, field): + self._log.debug('Calling __init__') + super(VectorData, self).__init__(a, field) + self._log.debug('Created ' + str(self)) def scale_down(self, n=1): - """Scale down the magnetic distribution by averaging over two pixels along each axis. + """Scale down the field distribution by averaging over two pixels along each axis. Parameters ---------- n : int, optional - Number of times the magnetic distribution is scaled down. The default is 1. + Number of times the field distribution is scaled down. The default is 1. Returns ------- @@ -200,14 +395,14 @@ class MagData(object): # Pad if necessary: pz, py, px = self.dim[0] % 2, self.dim[1] % 2, self.dim[2] % 2 if pz != 0 or py != 0 or px != 0: - self.magnitude = np.pad(self.magnitude, ((0, 0), (0, pz), (0, py), (0, px)), - mode='constant') - # Create coarser grid for the magnetization: + self.field = np.pad(self.field, ((0, 0), (0, pz), (0, py), (0, px)), + mode='constant') + # Create coarser grid for the vector field: shape_4d = (3, self.dim[0] / 2, 2, self.dim[1] / 2, 2, self.dim[2] / 2, 2) - self.magnitude = self.magnitude.reshape(shape_4d).mean(axis=(6, 4, 2)) + self.field = self.field.reshape(shape_4d).mean(axis=(6, 4, 2)) def scale_up(self, n=1, order=0): - """Scale up the magnetic distribution using spline interpolation of the requested order. + """Scale up the field distribution using spline interpolation of the requested order. Parameters ---------- @@ -231,12 +426,12 @@ class MagData(object): assert 5 > order >= 0 and isinstance(order, (int, long)), \ 'order must be a positive integer between 0 and 5!' self.a /= 2 ** n - self.magnitude = np.array((zoom(self.magnitude[0], zoom=2 ** n, order=order), - zoom(self.magnitude[1], zoom=2 ** n, order=order), - zoom(self.magnitude[2], zoom=2 ** n, order=order))) + self.field = np.array((zoom(self.field[0], zoom=2 ** n, order=order), + zoom(self.field[1], zoom=2 ** n, order=order), + zoom(self.field[2], zoom=2 ** n, order=order))) def pad(self, pad_values): - """Pad the current magnetic distribution with zeros for each individual axis. + """Pad the current field distribution with zeros for each individual axis. Parameters ---------- @@ -259,12 +454,12 @@ class MagData(object): for i, values in enumerate(pad_values): assert np.shape(values) in [(), (2,)], 'Only one or two values per axis can be given!' pv[2 * i:2 * (i + 1)] = values - self.magnitude = np.pad(self.magnitude, - ((0, 0), (pv[0], pv[1]), (pv[2], pv[3]), (pv[4], pv[5])), - mode='constant') + 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): - """Crop the current magnetic distribution with zeros for each individual axis. + """Crop the current field distribution with zeros for each individual axis. Parameters ---------- @@ -289,27 +484,10 @@ class MagData(object): cv[2 * i:2 * (i + 1)] = values cv *= np.resize([1, -1], len(cv)) cv = np.where(cv == 0, None, cv) - self.magnitude = self.magnitude[:, cv[0]:cv[1], cv[2]:cv[3], cv[4]:cv[5]] - - def get_mask(self, threshold=0): - """Mask all pixels where the amplitude of the magnetization lies above `threshold`. - - Parameters - ---------- - threshold : float, optional - A pixel only gets masked, if it lies above this threshold . The default is 0. - - Returns - ------- - mask : :class:`~numpy.ndarray` (N=3, boolean) - Mask of the pixels where the amplitude of the magnetization lies above `threshold`. - - """ - self._log.debug('Calling get_mask') - return np.where(self.mag_amp > threshold, True, False) + self.field = self.field[:, cv[0]:cv[1], cv[2]:cv[3], cv[4]:cv[5]] def get_vector(self, mask): - """Returns the magnetic components arranged in a vector, specified by a mask. + """Returns the vector field components arranged in a vector, specified by a mask. Parameters ---------- @@ -319,27 +497,27 @@ class MagData(object): Returns ------- vector : :class:`~numpy.ndarray` (N=1) - The vector containing magnetization components of the specified pixels. + The vector containing vector field components of the specified pixels. Order is: first all `x`-, then all `y`-, then all `z`-components. """ self._log.debug('Calling get_vector') if mask is not None: - return np.reshape([self.magnitude[0][mask], - self.magnitude[1][mask], - self.magnitude[2][mask]], -1) + return np.reshape([self.field[0][mask], + self.field[1][mask], + self.field[2][mask]], -1) else: - return self.mag_vec + return self.field_vec def set_vector(self, vector, mask=None): - """Set the magnetic components of the masked pixels to the values specified by `vector`. + """Set the field components of the masked pixels to the values specified by `vector`. Parameters ---------- mask : :class:`~numpy.ndarray` (N=3, boolean), optional Masks the pixels from which the components should be taken. vector : :class:`~numpy.ndarray` (N=1) - The vector containing magnetization components of the specified pixels. + The vector containing vector field components of the specified pixels. Order is: first all `x`-, then all `y-, then all `z`-components. Returns @@ -352,129 +530,129 @@ class MagData(object): assert np.size(vector) % 3 == 0, 'Vector has to contain all 3 components for every pixel!' count = np.size(vector) // 3 if mask is not None: - self.magnitude[0][mask] = vector[:count] # x-component - self.magnitude[1][mask] = vector[count:2 * count] # y-component - self.magnitude[2][mask] = vector[2 * count:] # z-component + self.field[0][mask] = vector[:count] # x-component + self.field[1][mask] = vector[count:2 * count] # y-component + self.field[2][mask] = vector[2 * count:] # z-component else: - self.mag_vec = vector - - def get_magslice(self, ax_slice=0, proj_axis='z', mode='complex'): - """Extract a slice from the :class:`~.MagData` object. - - Parameters - ---------- - proj_axis : {'z', 'y', 'x'}, optional - The axis, from which the slice is taken. The default is 'z'. - ax_slice : int, optional - The slice-index of the axis specified in `proj_axis`. Defaults to zero (first slice). - mode : {'complex', 'amplitude'}, optional - Determines if the 2D magnetization is returned as complex values or if the amplitude - of the two components is calculated. - - Returns - ------- - mag_slice : :class:`~numpy.ndarray` (N=2) - The extracted magnetization slice. - - """ - self._log.debug('Calling get_mag_slice') - # Find slice: - assert proj_axis == 'z' or proj_axis == 'y' or proj_axis == 'x', \ - 'Axis has to be x, y or z (as string).' - if proj_axis == 'z': # Slice of the xy-plane with z = ax_slice - self._log.debug('proj_axis == z') - u_mag = np.copy(self.magnitude[0][ax_slice, ...]) # x-component - v_mag = np.copy(self.magnitude[1][ax_slice, ...]) # y-component - elif proj_axis == 'y': # Slice of the xz-plane with y = ax_slice - self._log.debug('proj_axis == y') - u_mag = np.copy(self.magnitude[0][:, ax_slice, :]) # x-component - v_mag = np.copy(self.magnitude[2][:, ax_slice, :]) # z-component - elif proj_axis == 'x': # Slice of the yz-plane with x = ax_slice - self._log.debug('proj_axis == x') - u_mag = np.swapaxes(np.copy(self.magnitude[2][..., ax_slice]), 0, 1) # z-component - v_mag = np.swapaxes(np.copy(self.magnitude[1][..., ax_slice]), 0, 1) # y-component - else: - raise ValueError('{} is not a valid argument (use x, y or z)'.format(proj_axis)) - # Create data field: - if mode == 'complex': - return u_mag + 1j * v_mag - elif mode == 'amplitude': - return np.hypot(u_mag, v_mag) - else: - raise ValueError('Given mode not understood!') + self.field_vec = vector def flip(self, axis='x'): - """Flip/mirror the magnetization around the specified axis. + """Flip/mirror the vector field around the specified axis. Parameters ---------- axis: {'x', 'y', 'z'}, optional - The axis around which the magnetization is flipped. + The axis around which the vector field is flipped. Returns ------- - mag_data_flip: :class:`~.MagData` - A flipped copy of the :class:`~.MagData` object. + mag_data_flip: :class:`~.VectorData` + A flipped copy of the :class:`~.VectorData` object. """ self._log.debug('Calling flip') if axis == 'x': - mag_x, mag_y, mag_z = self.magnitude[:, :, :, ::-1] - magnitude_flip = np.array((-mag_x, mag_y, mag_z)) + mag_x, mag_y, mag_z = self.field[:, :, :, ::-1] + field_flip = np.array((-mag_x, mag_y, mag_z)) elif axis == 'y': - mag_x, mag_y, mag_z = self.magnitude[:, :, ::-1, :] - magnitude_flip = np.array((mag_x, -mag_y, mag_z)) + mag_x, mag_y, mag_z = self.field[:, :, ::-1, :] + field_flip = np.array((mag_x, -mag_y, mag_z)) elif axis == 'z': - mag_x, mag_y, mag_z = self.magnitude[:, ::-1, :, :] - magnitude_flip = np.array((mag_x, mag_y, -mag_z)) + mag_x, mag_y, mag_z = self.field[:, ::-1, :, :] + field_flip = np.array((mag_x, mag_y, -mag_z)) else: raise ValueError("Wrong input! 'x', 'y', 'z' allowed!") - return MagData(self.a, magnitude_flip) + return VectorData(self.a, field_flip) def rot90(self, axis='x'): - """Rotate the magnetization 90° around the specified axis (right hand rotation). + """Rotate the vector field 90° around the specified axis (right hand rotation). Parameters ---------- axis: {'x', 'y', 'z'}, optional - The axis around which the magnetization is rotated. + The axis around which the vector field is rotated. Returns ------- - mag_data_rot: :class:`~.MagData` - A rotated copy of the :class:`~.MagData` object. + mag_data_rot: :class:`~.VectorData` + A rotated copy of the :class:`~.VectorData` object. """ self._log.debug('Calling rot90') if axis == 'x': - magnitude_rot = np.zeros((3, self.dim[1], self.dim[0], self.dim[2])) + field_rot = np.zeros((3, self.dim[1], self.dim[0], self.dim[2])) for i in range(self.dim[2]): - mag_x, mag_y, mag_z = self.magnitude[:, :, :, i] + mag_x, mag_y, mag_z = self.field[:, :, :, i] mag_xrot, mag_yrot, mag_zrot = np.rot90(mag_x), np.rot90(mag_y), np.rot90(mag_z) - magnitude_rot[:, :, :, i] = np.array((mag_xrot, mag_zrot, -mag_yrot)) + field_rot[:, :, :, i] = np.array((mag_xrot, mag_zrot, -mag_yrot)) elif axis == 'y': - magnitude_rot = np.zeros((3, self.dim[2], self.dim[1], self.dim[0])) + field_rot = np.zeros((3, self.dim[2], self.dim[1], self.dim[0])) for i in range(self.dim[1]): - mag_x, mag_y, mag_z = self.magnitude[:, :, i, :] + mag_x, mag_y, mag_z = self.field[:, :, i, :] mag_xrot, mag_yrot, mag_zrot = np.rot90(mag_x), np.rot90(mag_y), np.rot90(mag_z) - magnitude_rot[:, :, i, :] = np.array((mag_zrot, mag_yrot, -mag_xrot)) + field_rot[:, :, i, :] = np.array((mag_zrot, mag_yrot, -mag_xrot)) elif axis == 'z': - magnitude_rot = np.zeros((3, self.dim[0], self.dim[2], self.dim[1])) + field_rot = np.zeros((3, self.dim[0], self.dim[2], self.dim[1])) for i in range(self.dim[0]): - mag_x, mag_y, mag_z = self.magnitude[:, i, :, :] + mag_x, mag_y, mag_z = self.field[:, i, :, :] mag_xrot, mag_yrot, mag_zrot = np.rot90(mag_x), np.rot90(mag_y), np.rot90(mag_z) - magnitude_rot[:, i, :, :] = np.array((mag_yrot, -mag_xrot, mag_zrot)) + field_rot[:, i, :, :] = np.array((mag_yrot, -mag_xrot, mag_zrot)) else: raise ValueError("Wrong input! 'x', 'y', 'z' allowed!") - return MagData(self.a, magnitude_rot) + return VectorData(self.a, field_rot) + + def get_slice(self, ax_slice=0, proj_axis='z', mode='complex'): + """Extract a slice from the :class:`~.VectorData` object. + + Parameters + ---------- + proj_axis : {'z', 'y', 'x'}, optional + The axis, from which the slice is taken. The default is 'z'. + ax_slice : int, optional + The slice-index of the axis specified in `proj_axis`. Defaults to zero (first slice). + mode : {'complex', 'amplitude'}, optional + Determines if the 2D vector field is returned as complex values or if the amplitude + of the two components is calculated. + + Returns + ------- + mag_slice : :class:`~numpy.ndarray` (N=2) + The extracted vector field slice. + + """ + self._log.debug('Calling get_slice') + # Find slice: + assert proj_axis == 'z' or proj_axis == 'y' or proj_axis == 'x', \ + 'Axis has to be x, y or z (as string).' + if proj_axis == 'z': # Slice of the xy-plane with z = ax_slice + self._log.debug('proj_axis == z') + u_mag = np.copy(self.field[0][ax_slice, ...]) # x-component + v_mag = np.copy(self.field[1][ax_slice, ...]) # y-component + elif proj_axis == 'y': # Slice of the xz-plane with y = ax_slice + self._log.debug('proj_axis == y') + u_mag = np.copy(self.field[0][:, ax_slice, :]) # x-component + v_mag = np.copy(self.field[2][:, ax_slice, :]) # z-component + elif proj_axis == 'x': # Slice of the yz-plane with x = ax_slice + self._log.debug('proj_axis == x') + u_mag = np.swapaxes(np.copy(self.field[2][..., ax_slice]), 0, 1) # z-component + v_mag = np.swapaxes(np.copy(self.field[1][..., ax_slice]), 0, 1) # y-component + else: + raise ValueError('{} is not a valid argument (use x, y or z)'.format(proj_axis)) + # Create data field: + if mode == 'complex': + return u_mag + 1j * v_mag + elif mode == 'amplitude': + return np.hypot(u_mag, v_mag) + else: + raise ValueError('Given mode not understood!') def to_signal(self): - """Convert :class:`~.MagData` data into a HyperSpy signal. + """Convert :class:`~.VectorData` data into a HyperSpy signal. Returns ------- signal: :class:`~hyperspy.signals.Signal` - Representation of the :class:`~.MagData` object as a HyperSpy Signal. + Representation of the :class:`~.VectorData` object as a HyperSpy Signal. Notes ----- @@ -487,7 +665,7 @@ class MagData(object): self._log.error('This method recquires the hyperspy package!') return # Create signal: - signal = hs.signals.Signal(np.rollaxis(self.magnitude, 0, 4)) + signal = hs.signals.Signal(np.rollaxis(self.field, 0, 4)) # Set axes: signal.axes_manager[0].name = 'x-axis' signal.axes_manager[0].units = 'nm' @@ -501,23 +679,23 @@ class MagData(object): signal.axes_manager[3].name = 'components (x,y,z)' signal.axes_manager[3].units = '' # Set metadata: - signal.metadata.Signal.title = 'MagData' + signal.metadata.Signal.title = 'VectorData' # Return signal: return signal @classmethod def from_signal(cls, signal): - """Convert a :class:`~hyperspy.signals.Signal` object to a :class:`~.MagData` object. + """Convert a :class:`~hyperspy.signals.Signal` object to a :class:`~.FieldData` object. Parameters ---------- signal: :class:`~hyperspy.signals.Signal` - The :class:`~hyperspy.signals.Signal` object which should be converted to MagData. + The :class:`~hyperspy.signals.Signal` object which should be converted to FieldData. Returns ------- - mag_data: :class:`~.MagData` - A :class:`~.MagData` object containing the loaded data. + mag_data: :class:`~.FieldData` + A :class:`~.VectorData` object containing the loaded data. Notes ----- @@ -525,20 +703,20 @@ class MagData(object): """ cls._log.debug('Calling from_signal') - # Extract magnitude: - magnitude = np.rollaxis(signal.data, 3, 0) + # Extract field: + field = np.rollaxis(signal.data, 3, 0) # Extract properties: a = signal.axes_manager[0].scale - return cls(a, magnitude) + return cls(a, field) - def save_to_hdf5(self, filename='magdata.hdf5'): - """Save magnetization data in a file with HyperSpys HDF5-format. + def save_to_hdf5(self, filename='vecdata.hdf5'): + """Save vector field data in a file with HyperSpys HDF5-format. Parameters ---------- filename : string, optional - The name of the HDF5-file in which to store the magnetization data. - The default is 'magdata.hdf5'. + The name of the HDF5-file in which to store the vector field. + The default is 'vecdata.hdf5'. Returns ------- @@ -549,7 +727,7 @@ class MagData(object): # Construct path if filename isn't already absolute: if not os.path.isabs(filename): from pyramid.config import DIR_FILES - directory = os.path.join(DIR_FILES, 'magdata') + directory = os.path.join(DIR_FILES, 'vecdata') if not os.path.exists(directory): os.makedirs(directory) filename = os.path.join(directory, filename) @@ -558,7 +736,7 @@ class MagData(object): @classmethod def load_from_hdf5(cls, filename): - """Construct :class:`~.MagData` object from HyperSpys HDF5-file. + """Construct :class:`~.VectorData` object from HyperSpys HDF5-file. Parameters ---------- @@ -567,8 +745,8 @@ class MagData(object): Returns ------- - mag_data: :class:`~.MagData` - A :class:`~.MagData` object containing the loaded data. + mag_data: :class:`~.VectorData` + A :class:`~.VectorData` object containing the loaded data. """ cls._log.debug('Calling load_from_hdf5') @@ -578,19 +756,19 @@ class MagData(object): # Use relative path if filename isn't already absolute: if not os.path.isabs(filename): from pyramid.config import DIR_FILES - directory = os.path.join(DIR_FILES, 'magdata') + directory = os.path.join(DIR_FILES, 'vecdata') filename = os.path.join(directory, filename) # Load data from file: - return MagData.from_signal(hs.load(filename)) + return VectorData.from_signal(hs.load(filename)) - def save_to_llg(self, filename='magdata.txt'): - """Save magnetization data in a file with LLG-format. + def save_to_llg(self, filename='vecdata.txt'): + """Save vector field data in a file with LLG-format. Parameters ---------- filename : string, optional - The name of the LLG-file in which to store the magnetization data. - The default is '..\output\magdata_output.txt'. + The name of the LLG-file in which to store the vector field data. + The default is 'vecdata.txt'. Returns ------- @@ -599,14 +777,14 @@ class MagData(object): """ self._log.debug('Calling save_to_llg') SCALE = 1.0E-9 / 1.0E-2 # from nm to cm - # Create 3D meshgrid and reshape it and the magnetization into a list where x varies first: + # Create 3D meshgrid and reshape it and the field into a list where x varies first: zz, yy, xx = self.a * SCALE * (np.indices(self.dim) + 0.5).reshape(3, -1) - x_vec, y_vec, z_vec = self.magnitude.reshape(3, -1) + x_vec, y_vec, z_vec = self.field.reshape(3, -1) data = np.array([xx, yy, zz, x_vec, y_vec, z_vec]).T # Construct path if filename isn't already absolute: if not os.path.isabs(filename): from pyramid.config import DIR_FILES - directory = os.path.join(DIR_FILES, 'magdata') + directory = os.path.join(DIR_FILES, 'vecdata') if not os.path.exists(directory): os.makedirs(directory) filename = os.path.join(directory, filename) @@ -619,7 +797,7 @@ class MagData(object): @classmethod def load_from_llg(cls, filename): - """Construct :class:`~.MagData` object from LLG-file. + """Construct :class:`~.VectorData` object from LLG-file. Parameters ---------- @@ -628,8 +806,8 @@ class MagData(object): Returns ------- - mag_data: :class:`~.MagData` - A :class:`~.MagData` object containing the loaded data. + mag_data: :class:`~.VectorData` + A :class:`~.VectorData` object containing the loaded data. """ cls._log.debug('Calling load_from_llg') @@ -637,19 +815,19 @@ class MagData(object): # Use relative path if filename isn't already absolute: if not os.path.isabs(filename): from pyramid.config import DIR_FILES - directory = os.path.join(DIR_FILES, 'magdata') + directory = os.path.join(DIR_FILES, 'vecdata') filename = os.path.join(directory, filename) # Load data from file: data = np.genfromtxt(filename, skip_header=2) dim = tuple(np.genfromtxt(filename, dtype=int, skip_header=1, skip_footer=len(data[:, 0]))) a = (data[1, 0] - data[0, 0]) / SCALE - magnitude = data[:, 3:6].T.reshape((3,) + dim) - return cls(a, magnitude) + field = data[:, 3:6].T.reshape((3,) + dim) + return cls(a, field) - def quiver_plot(self, title='Magnetization Distribution', axis=None, proj_axis='z', + def quiver_plot(self, title='Vector Field', axis=None, proj_axis='z', coloring='angle', ar_dens=1, ax_slice=None, log=False, scaled=True, scale=1., show_mask=True): - """Plot a slice of the magnetization as a quiver plot. + """Plot a slice of the vector field as a quiver plot. Parameters ---------- @@ -692,8 +870,8 @@ class MagData(object): if ax_slice is None: self._log.debug('ax_slice is None') ax_slice = self.dim[0] // 2 - u_mag = np.copy(self.magnitude[0][ax_slice, ...]) # x-component - v_mag = np.copy(self.magnitude[1][ax_slice, ...]) # y-component + u_mag = np.copy(self.field[0][ax_slice, ...]) # x-component + v_mag = np.copy(self.field[1][ax_slice, ...]) # y-component u_label = 'x [px]' v_label = 'y [px]' submask = self.get_mask()[ax_slice, ...] @@ -702,8 +880,8 @@ class MagData(object): if ax_slice is None: self._log.debug('ax_slice is None') ax_slice = self.dim[1] // 2 - u_mag = np.copy(self.magnitude[0][:, ax_slice, :]) # x-component - v_mag = np.copy(self.magnitude[2][:, ax_slice, :]) # z-component + u_mag = np.copy(self.field[0][:, ax_slice, :]) # x-component + v_mag = np.copy(self.field[2][:, ax_slice, :]) # z-component u_label = 'x [px]' v_label = 'z [px]' submask = self.get_mask()[:, ax_slice, :] @@ -712,8 +890,8 @@ class MagData(object): if ax_slice is None: self._log.debug('ax_slice is None') ax_slice = self.dim[2] // 2 - u_mag = np.swapaxes(np.copy(self.magnitude[2][..., ax_slice]), 0, 1) # z-component - v_mag = np.swapaxes(np.copy(self.magnitude[1][..., ax_slice]), 0, 1) # y-component + u_mag = np.swapaxes(np.copy(self.field[2][..., ax_slice]), 0, 1) # z-component + v_mag = np.swapaxes(np.copy(self.field[1][..., ax_slice]), 0, 1) # y-component u_label = 'z [px]' v_label = 'y [px]' submask = self.get_mask()[..., ax_slice] @@ -759,7 +937,7 @@ class MagData(object): v_mag = np.round(v_mag, decimals=cutoff) / min_value v_mag = np.log10(np.abs(v_mag) + 1) * np.sign(v_mag) amplitudes = np.hypot(u_mag, v_mag) # Recalculate (used if scaled)! - # Scale the magnitude of the arrows to the highest one (if specified): + # Scale the amplitude of the arrows to the highest one (if specified): if scaled: u_mag /= amplitudes.max() + 1E-30 v_mag /= amplitudes.max() + 1E-30 @@ -784,16 +962,16 @@ class MagData(object): # Return plotting axis: return axis - def quiver_plot3d(self, title='Magnetization Distribution', limit=None, cmap='jet', + def quiver_plot3d(self, title='Vector Field', limit=None, cmap='jet', mode='2darrow', coloring='angle', ar_dens=1, opacity=1.0): - """Plot the magnetization as 3D-vectors in a quiverplot. + """Plot the vector field as 3D-vectors in a quiverplot. Parameters ---------- title : string, optional The title for the plot. limit : float, optional - Plotlimit for the magnetization arrow length used to scale the colormap. + Plotlimit for the vector field arrow length used to scale the colormap. cmap : string, optional String describing the colormap which is used (default is 'jet'). ar_dens: int (optional) @@ -818,16 +996,16 @@ class MagData(object): a = self.a dim = self.dim if limit is None: - limit = np.max(self.mag_amp) + limit = np.max(self.field_amp) ad = ar_dens # Create points and vector components as lists: zzz, yyy, xxx = (np.indices(dim) - a / 2).reshape((3,) + dim) zzz = zzz[::ad, ::ad, ::ad].flatten() yyy = yyy[::ad, ::ad, ::ad].flatten() xxx = xxx[::ad, ::ad, ::ad].flatten() - x_mag = self.magnitude[0][::ad, ::ad, ::ad].flatten() - y_mag = self.magnitude[1][::ad, ::ad, ::ad].flatten() - z_mag = self.magnitude[2][::ad, ::ad, ::ad].flatten() + x_mag = self.field[0][::ad, ::ad, ::ad].flatten() + y_mag = self.field[1][::ad, ::ad, ::ad].flatten() + z_mag = self.field[2][::ad, ::ad, ::ad].flatten() # Plot them as vectors: mlab.figure(size=(750, 700)) plot = mlab.quiver3d(xxx, yyy, zzz, x_mag, y_mag, z_mag, @@ -854,39 +1032,243 @@ class MagData(object): mlab.axes(plot) mlab.title(title, height=0.95, size=0.35) mlab.orientation_axes() - # mlab.show() return plot - def contour_plot3d(self, title='Magnetization Distribution', contours=10, opacity=0.25): - """Plot the magnetization as 3D-vectors in a quiverplot. + +class ScalarData(FieldData): + """Class for storing scalar field data. + + Represents 3-dimensional scalar field distributions which is stored as a 3-dimensional + numpy array in `field`, but which can also be accessed as a vector via `field_vec`. + :class:`~.ScalarData` objects support negation, arithmetic operators (``+``, ``-``, ``*``) + and their augmented counterparts (``+=``, ``-=``, ``*=``), with numbers and other + :class:`~.ScalarData` objects, if their dimensions and grid spacings match. It is possible + to load data from HDF5 or LLG (.txt) files or to save the data in these formats. + Plotting methods are also provided. + + Attributes + ---------- + a: float + The grid spacing in nm. + field: :class:`~numpy.ndarray` (N=4) + The scalar field. + + """ + _log = logging.getLogger(__name__ + '.ScalarData') + + def __init__(self, a, field): + self._log.debug('Calling __init__') + super(ScalarData, self).__init__(a, field) + self._log.debug('Created ' + str(self)) + + def scale_down(self, n=1): + """Scale down the field distribution by averaging over two pixels along each axis. Parameters ---------- - title: string, optional - The title for the plot. - contours: int, optional - Number of contours which should be plotted. - opacity: float, optional - Defines the opacity of the contours. Default is 0.25. + n : int, optional + Number of times the field distribution is scaled down. The default is 1. Returns ------- - plot : :class:`mayavi.modules.vectors.Vectors` - The plot object. + None + Notes + ----- + Acts in place and changes dimensions and grid spacing accordingly. + Only possible, if each axis length is a power of 2! """ - self._log.debug('Calling quiver_plot3D') - from mayavi import mlab - # Create points and vector components as lists: - x_mag, y_mag, z_mag = self.magnitude - amplitudes = np.sqrt(x_mag ** 2 + y_mag ** 2 + z_mag ** 2) - # Plot them as vectors: - mlab.figure(size=(750, 700)) - plot = mlab.contour3d(amplitudes, contours=contours, opacity=opacity) - mlab.outline(plot) - mlab.axes(plot) - mlab.title(title, height=0.95, size=0.35) - mlab.orientation_axes() - # mlab.show() - return plot + self._log.debug('Calling scale_down') + assert n > 0 and isinstance(n, (int, long)), 'n must be a positive integer!' + self.a *= 2 ** n + for t in range(n): + # Pad if necessary: + pz, py, px = self.dim[0] % 2, self.dim[1] % 2, self.dim[2] % 2 + if pz != 0 or py != 0 or px != 0: + self.field = np.pad(self.field, ((0, pz), (0, py), (0, px)), mode='constant') + # Create coarser grid for the field: + shape_4d = (self.dim[0] / 2, 2, self.dim[1] / 2, 2, self.dim[2] / 2, 2) + self.field = self.field.reshape(shape_4d).mean(axis=(5, 3, 1)) + + def scale_up(self, n=1, order=0): + """Scale up the field distribution using spline interpolation of the requested order. + + Parameters + ---------- + n : int, optional + Power of 2 with which the grid is scaled. Default is 1, which means every axis is + increased by a factor of ``2**1 = 2``. + order : int, optional + The order of the spline interpolation, which has to be in the range between 0 and 5 + and defaults to 0. + + Returns + ------- + None + + Notes + ----- + Acts in place and changes dimensions and grid spacing accordingly. + """ + self._log.debug('Calling scale_up') + assert n > 0 and isinstance(n, (int, long)), 'n must be a positive integer!' + assert 5 > order >= 0 and isinstance(order, (int, long)), \ + 'order must be a positive integer between 0 and 5!' + self.a /= 2 ** n + self.field = zoom(self.field, zoom=2 ** n, order=order) + + def get_vector(self, mask): + """Returns the field as a vector, specified by a mask. + + Parameters + ---------- + mask : :class:`~numpy.ndarray` (N=3, boolean) + Masks the pixels from which the components should be taken. + + Returns + ------- + vector : :class:`~numpy.ndarray` (N=1) + The vector containing the field of the specified pixels. + + """ + self._log.debug('Calling get_vector') + if mask is not None: + return np.reshape(self.field[mask], -1) + else: + return self.field_vec + + def set_vector(self, vector, mask=None): + """Set the field components of the masked pixels to the values specified by `vector`. + + Parameters + ---------- + mask : :class:`~numpy.ndarray` (N=3, boolean), optional + Masks the pixels from which the components should be taken. + vector : :class:`~numpy.ndarray` (N=1) + The vector containing the field of the specified pixels. + + Returns + ------- + None + + """ + self._log.debug('Calling set_vector') + vector = np.asarray(vector, dtype=fft.FLOAT) + if mask is not None: + self.field[mask] = vector + else: + self.field_vec = vector + + def to_signal(self): + """Convert :class:`~.ScalarData` data into a HyperSpy signal. + + Returns + ------- + signal: :class:`~hyperspy.signals.Signal` + Representation of the :class:`~.ScalarData` object as a HyperSpy Signal. + + Notes + ----- + This method recquires the hyperspy package! + + """ + self._log.debug('Calling to_signal') + # Try importing HyperSpy: + if hs is None: + self._log.error('This method recquires the hyperspy package!') + return + # Create signal: + signal = hs.signals.Signal(self.field) + # Set axes: + signal.axes_manager[0].name = 'x-axis' + signal.axes_manager[0].units = 'nm' + signal.axes_manager[0].scale = self.a + signal.axes_manager[1].name = 'y-axis' + signal.axes_manager[1].units = 'nm' + signal.axes_manager[1].scale = self.a + signal.axes_manager[2].name = 'z-axis' + signal.axes_manager[2].units = 'nm' + signal.axes_manager[2].scale = self.a + # Set metadata: + signal.metadata.Signal.title = 'ScalarData' + # Return signal: + return signal + + @classmethod + def from_signal(cls, signal): + """Convert a :class:`~hyperspy.signals.Signal` object to a :class:`~.ScalarData` object. + + Parameters + ---------- + signal: :class:`~hyperspy.signals.Signal` + The :class:`~hyperspy.signals.Signal` object which should be converted to ScalarData. + + Returns + ------- + mag_data: :class:`~.ScalarData` + A :class:`~.ScalarData` object containing the loaded data. + + Notes + ----- + This method recquires the hyperspy package! + + """ + cls._log.debug('Calling from_signal') + # Extract field: + field = signal.data + # Extract properties: + a = signal.axes_manager[0].scale + return cls(a, field) + + def save_to_hdf5(self, filename='scaldata.hdf5'): + """Save field data in a file with HyperSpys HDF5-format. + + Parameters + ---------- + filename : string, optional + The name of the HDF5-file in which to store the field data. + The default is 'scaldata.hdf5'. + + Returns + ------- + None + + """ + self._log.debug('Calling save_to_hdf5') + # Construct path if filename isn't already absolute: + if not os.path.isabs(filename): + from pyramid.config import DIR_FILES + directory = os.path.join(DIR_FILES, 'scaldata') + if not os.path.exists(directory): + os.makedirs(directory) + filename = os.path.join(directory, filename) + # Save data to file: + self.to_signal().save(filename) + + @classmethod + def load_from_hdf5(cls, filename): + """Construct :class:`~.ScalarData` object from HyperSpys HDF5-file. + + Parameters + ---------- + filename : string + The name of the HDF5-file from which to load the data. Standard format is '\*.hdf5'. + + Returns + ------- + mag_data: :class:`~.ScalarData` + A :class:`~.ScalarData` object containing the loaded data. + + """ + cls._log.debug('Calling load_from_hdf5') + if hs is None: + cls._log.error('This method recquires the hyperspy package!') + return + # Use relative path if filename isn't already absolute: + if not os.path.isabs(filename): + from pyramid.config import DIR_FILES + directory = os.path.join(DIR_FILES, 'scaldata') + filename = os.path.join(directory, filename) + # Load data from file: + return ScalarData.from_signal(hs.load(filename)) diff --git a/pyramid/forwardmodel.py b/pyramid/forwardmodel.py index f3e97fe..eca8aca 100644 --- a/pyramid/forwardmodel.py +++ b/pyramid/forwardmodel.py @@ -14,7 +14,7 @@ import sys import numpy as np from pyramid.dataset import DataSet -from pyramid.magdata import MagData +from pyramid.fielddata import VectorData from pyramid.ramp import Ramp __all__ = ['ForwardModel', 'DistributedForwardModel'] @@ -59,7 +59,7 @@ class ForwardModel(object): self.n += self.ramp.n self.shape = (self.m, self.n) self.hook_points = data_set.hook_points - self.mag_data = MagData(self.data_set.a, np.zeros((3,) + self.data_set.dim)) + self.mag_data = VectorData(self.data_set.a, np.zeros((3,) + self.data_set.dim)) self._log.debug('Creating ' + str(self)) def __repr__(self): @@ -74,7 +74,7 @@ class ForwardModel(object): # Extract ramp parameters if necessary (x will be shortened!): x = self.ramp.extract_ramp_params(x) # Reset mag_data and fill with vector: - self.mag_data.magnitude[...] = 0 + self.mag_data.field[...] = 0 self.mag_data.set_vector(x, self.data_set.mask) # Simulate all phase maps and create result vector: result = np.zeros(self.m) @@ -110,13 +110,13 @@ class ForwardModel(object): # Extract ramp parameters if necessary (vector will be shortened!): vector = self.ramp.extract_ramp_params(vector) # Reset mag_data and fill with vector: - self.mag_data.magnitude[...] = 0 + self.mag_data.field[...] = 0 self.mag_data.set_vector(vector, self.data_set.mask) # Simulate all phase maps and create result vector: result = np.zeros(self.m) hp = self.hook_points for i, projector in enumerate(self.data_set.projectors): - mag_vec = self.mag_data.mag_vec + mag_vec = self.mag_data.field_vec mapper = self.phase_mappers[projector.dim_uv] res = mapper.jac_dot(projector.jac_dot(mag_vec)) res += self.ramp.jac_dot(i) # add ramp! @@ -148,7 +148,7 @@ class ForwardModel(object): sub_vec = vector[hp[i]:hp[i + 1]] mapper = self.phase_mappers[projector.dim_uv] proj_T_result += projector.jac_T_dot(mapper.jac_T_dot(sub_vec)) - self.mag_data.mag_vec = proj_T_result + self.mag_data.field_vec = proj_T_result result = self.mag_data.get_vector(self.data_set.mask) ramp_params = self.ramp.jac_T_dot(vector) # calculate ramp_params separately! return np.concatenate((result, ramp_params)) diff --git a/pyramid/magcreator.py b/pyramid/magcreator.py index a228a13..20d31d4 100644 --- a/pyramid/magcreator.py +++ b/pyramid/magcreator.py @@ -34,7 +34,7 @@ class Shapes(object): The :class:`~.Shapes` class is a collection of some methods that return a 3-dimensional matrix that represents the magnetized volume and consists of values between 0 and 1. This matrix is used in the functions of the :mod:`~.magcreator` module to create - :class:`~pyramid.magdata.MagData` objects which store the magnetic informations. + :class:`~pyramid.magdata.VectorData` objects which store the magnetic informations. """ @@ -274,7 +274,7 @@ class Shapes(object): return mag_shape -def create_mag_dist_homog(mag_shape, phi, theta=pi / 2, magnitude=1): +def create_mag_dist_homog(mag_shape, phi, theta=pi / 2, amplitude=1): """Create a 3-dimensional magnetic distribution of a homogeneously magnetized object. Parameters @@ -286,12 +286,12 @@ def create_mag_dist_homog(mag_shape, phi, theta=pi / 2, magnitude=1): theta : float, optional The polar angle, describing the direction of the magnetized object. The default is pi/2, which means, the z-component is zero. - magnitude : float, optional - The relative magnitude for the magnetic shape. The default is 1. + amplitude : float, optional + The relative amplitude for the magnetic shape. The default is 1. Returns ------- - magnitude : tuple (N=3) of :class:`~numpy.ndarray` (N=3) + amplitude : tuple (N=3) of :class:`~numpy.ndarray` (N=3) The magnetic distribution as a tuple of the 3 components in `x`-, `y`- and `z`-direction on the 3-dimensional grid. @@ -299,13 +299,13 @@ def create_mag_dist_homog(mag_shape, phi, theta=pi / 2, magnitude=1): _log.debug('Calling create_mag_dist_homog') dim = np.shape(mag_shape) assert len(dim) == 3, 'Magnetic shapes must describe 3-dimensional distributions!' - z_mag = np.ones(dim) * np.cos(theta) * mag_shape * magnitude - y_mag = np.ones(dim) * np.sin(theta) * np.sin(phi) * mag_shape * magnitude - x_mag = np.ones(dim) * np.sin(theta) * np.cos(phi) * mag_shape * magnitude + z_mag = np.ones(dim) * np.cos(theta) * mag_shape * amplitude + y_mag = np.ones(dim) * np.sin(theta) * np.sin(phi) * mag_shape * amplitude + x_mag = np.ones(dim) * np.sin(theta) * np.cos(phi) * mag_shape * amplitude return np.array([x_mag, y_mag, z_mag]) -def create_mag_dist_vortex(mag_shape, center=None, axis='z', magnitude=1): +def create_mag_dist_vortex(mag_shape, center=None, axis='z', amplitude=1): """Create a 3-dimensional magnetic distribution of a homogeneous magnetized object. Parameters @@ -316,15 +316,15 @@ def create_mag_dist_vortex(mag_shape, center=None, axis='z', magnitude=1): The vortex center, given in 2D `(v, u)` or 3D `(z, y, x)`, where the perpendicular axis is is discarded. Is set to the center of the field of view if not specified. The vortex center has to be between two pixels. - magnitude : float, optional - The relative magnitude for the magnetic shape. The default is 1. Negative signs reverse + amplitude : float, optional + The relative amplitude for the magnetic shape. The default is 1. Negative signs reverse the vortex direction (left-handed instead of right-handed). axis : {'z', 'y', 'x'}, optional The orientation of the vortex axis. The default is 'z'. Returns ------- - magnitude : tuple (N=3) of :class:`~numpy.ndarray` (N=3) + amplitude : tuple (N=3) of :class:`~numpy.ndarray` (N=3) The magnetic distribution as a tuple of the 3 components in `x`-, `y`- and `z`-direction on the 3-dimensional grid. @@ -352,8 +352,8 @@ def create_mag_dist_vortex(mag_shape, center=None, axis='z', magnitude=1): phi = np.expand_dims(np.arctan2(vv, uu) - pi / 2, axis=0) phi = np.tile(phi, (dim[0], 1, 1)) z_mag = np.zeros(dim) - y_mag = -np.ones(dim) * np.sin(phi) * mag_shape * magnitude - x_mag = -np.ones(dim) * np.cos(phi) * mag_shape * magnitude + y_mag = -np.ones(dim) * np.sin(phi) * mag_shape * amplitude + x_mag = -np.ones(dim) * np.cos(phi) * mag_shape * amplitude elif axis == 'y': if len(center) == 3: # if a 3D-center is given, just take the x and z components center = (center[0], center[2]) @@ -362,9 +362,9 @@ def create_mag_dist_vortex(mag_shape, center=None, axis='z', magnitude=1): uu, vv = np.meshgrid(u, v) phi = np.expand_dims(np.arctan2(vv, uu) - pi / 2, axis=1) phi = np.tile(phi, (1, dim[1], 1)) - z_mag = np.ones(dim) * np.sin(phi) * mag_shape * magnitude + z_mag = np.ones(dim) * np.sin(phi) * mag_shape * amplitude y_mag = np.zeros(dim) - x_mag = np.ones(dim) * np.cos(phi) * mag_shape * magnitude + x_mag = np.ones(dim) * np.cos(phi) * mag_shape * amplitude elif axis == 'x': if len(center) == 3: # if a 3D-center is given, just take the z and y components center = (center[0], center[1]) @@ -373,8 +373,8 @@ def create_mag_dist_vortex(mag_shape, center=None, axis='z', magnitude=1): uu, vv = np.meshgrid(u, v) phi = np.expand_dims(np.arctan2(vv, uu) - pi / 2, axis=2) phi = np.tile(phi, (1, 1, dim[2])) - z_mag = -np.ones(dim) * np.sin(phi) * mag_shape * magnitude - y_mag = -np.ones(dim) * np.cos(phi) * mag_shape * magnitude + z_mag = -np.ones(dim) * np.sin(phi) * mag_shape * amplitude + y_mag = -np.ones(dim) * np.cos(phi) * mag_shape * amplitude x_mag = np.zeros(dim) else: raise ValueError('{} is not a valid argument (use x, y or z)'.format(axis)) diff --git a/pyramid/phasemap.py b/pyramid/phasemap.py index 2e95cfa..b1bc70a 100644 --- a/pyramid/phasemap.py +++ b/pyramid/phasemap.py @@ -214,7 +214,7 @@ class PhaseMap(object): self._log.debug('Adding two PhaseMap objects') assert other.a == self.a, 'Added phase has to have the same grid spacing!' assert other.phase.shape == self.dim_uv, \ - 'Added magnitude has to have the same dimensions!' + 'Added field has to have the same dimensions!' mask_comb = np.logical_or(self.mask, other.mask) # masks combine conf_comb = (self.confidence + other.confidence) / 2 # confidence averaged! return PhaseMap(self.a, self.phase + other.phase, mask_comb, conf_comb, self.unit) @@ -504,8 +504,8 @@ class PhaseMap(object): Returns ------- - mag_data: :class:`~.MagData` - A :class:`~.MagData` object containing the loaded data. + mag_data: :class:`~.VectorData` + A :class:`~.VectorData` object containing the loaded data. """ cls._log.debug('Calling load_from_hdf5') @@ -735,7 +735,7 @@ class PhaseMap(object): holo = np.cos(gain * self.phase) holo += 1 # Shift to positive values holo /= 2 # Rescale to [0, 1] - # Calculate the phase gradients, expressed by magnitude and angle: + # Calculate the phase gradients, expressed by amplitude and angle: phase_grad_x, phase_grad_y = np.gradient(self.phase, self.a, self.a) angles = (1 - np.arctan2(phase_grad_y, phase_grad_x) / np.pi) / 2 phase_grad_amp = np.hypot(phase_grad_y, phase_grad_x) diff --git a/pyramid/phasemapper.py b/pyramid/phasemapper.py index 2b05ed7..b07345a 100644 --- a/pyramid/phasemapper.py +++ b/pyramid/phasemapper.py @@ -16,11 +16,11 @@ from numpy import pi from pyramid import fft from pyramid.kernel import Kernel -from pyramid.magdata import MagData +from pyramid.fielddata import VectorData, ScalarData from pyramid.phasemap import PhaseMap from pyramid.projector import RotTiltProjector, XTiltProjector, YTiltProjector, SimpleProjector -__all__ = ['PhaseMapperRDFC', 'PhaseMapperRDRC', 'PhaseMapperFDFC', 'pm'] +__all__ = ['PhaseMapperRDFC', 'PhaseMapperRDRC', 'PhaseMapperFDFC', 'PhaseMapperMIP', 'pm'] _log = logging.getLogger(__name__) PHI_0 = 2067.83 # magnetic flux in T*nm² @@ -34,10 +34,10 @@ class PhaseMapper(object): """Abstract base class for the phase calculation from a 2-dimensional distribution. The :class:`~.PhaseMapper-` class represents a strategy for the phasemapping of a - 2-dimensional magnetic distribution with two components onto a scalar phase map. - :class:`~.Kernel` is an abstract base class and provides a unified interface which should be - subclassed with custom :func:`__init__` and :func:`__call__` functions. Concrete subclasses - can be called as a function and take a :class:`~.MagData` object as input and return a + 2-dimensional magnetic/electric distribution onto a scalar phase map. :class:`~.PhaseMapper` + is an abstract base class and provides a unified interface which should be subclassed with + custom :func:`__init__` and :func:`__call__` functions. Concrete subclasses + can be called as a function and take a :class:`~.FieldData` object as input and return a :class:`~.PhaseMap` object. """ @@ -46,7 +46,7 @@ class PhaseMapper(object): _log = logging.getLogger(__name__ + '.PhaseMapper') @abc.abstractmethod - def __call__(self, mag_data): + def __call__(self, field_data): raise NotImplementedError() @abc.abstractmethod @@ -56,9 +56,7 @@ class PhaseMapper(object): Parameters ---------- vector : :class:`~numpy.ndarray` (N=1) - Vectorized form of the magnetization in `u`- and `v`-direction of every pixel - (row-wise). The first ``N**2`` elements have to correspond to the `u`-, the next - ``N**2`` elements to the `v`-component of the magnetization. + Vectorized form of the field. Returns ------- @@ -75,14 +73,13 @@ class PhaseMapper(object): Parameters ---------- vector : :class:`~numpy.ndarray` (N=1) - Vector with ``N**2`` entries which represents a matrix with dimensions like a scalar - phasemap. + Vector which represents a matrix with dimensions like a scalar phasemap. Returns ------- result : :class:`~numpy.ndarray` (N=1) Product of the transposed Jacobi matrix (which is not explicitely calculated) with - the vector, which has ``2*N**2`` entries like a 2D magnetic projection. + the vector. """ raise NotImplementedError() @@ -93,7 +90,7 @@ class PhaseMapperRDFC(PhaseMapper): space convolution. The :class:`~.PMConvolve` class represents a phase mapping strategy involving discretization in - real space. It utilizes the convolution in Fourier space, directly takes :class:`~.MagData` + real space. It utilizes the convolution in Fourier space, directly takes :class:`~.VectorData` objects and returns :class:`~.PhaseMap` objects. Attributes @@ -128,13 +125,13 @@ class PhaseMapperRDFC(PhaseMapper): return 'PhaseMapperRDFC(kernel=%s)' % self.kernel def __call__(self, mag_data): - assert isinstance(mag_data, MagData), 'Only MagData objects can be mapped!' + assert isinstance(mag_data, VectorData), 'Only VectorData objects can be mapped!' assert mag_data.a == self.kernel.a, 'Grid spacing has to match!' assert mag_data.dim[0] == 1, 'Magnetic distribution must be 2-dimensional!' assert mag_data.dim[1:3] == self.kernel.dim_uv, 'Dimensions do not match!' # Process input parameters: - self.u_mag[self.kernel.slice_mag] = mag_data.magnitude[0, 0, ...] # u-component - self.v_mag[self.kernel.slice_mag] = mag_data.magnitude[1, 0, ...] # v-component + self.u_mag[self.kernel.slice_mag] = mag_data.field[0, 0, ...] # u-component + self.v_mag[self.kernel.slice_mag] = mag_data.field[1, 0, ...] # v-component return PhaseMap(mag_data.a, self._convolve()) def _convolve(self): @@ -201,7 +198,7 @@ class PhaseMapperRDRC(PhaseMapper): """Class representing a phase mapping strategy using real space discretization. The :class:`~.PMReal` class represents a phase mapping strategy involving discretization in - real space. It directly takes :class:`~.MagData` objects and returns :class:`~.PhaseMap` + real space. It directly takes :class:`~.VectorData` objects and returns :class:`~.PhaseMap` objects. Attributes @@ -246,12 +243,12 @@ class PhaseMapperRDRC(PhaseMapper): def __call__(self, mag_data): self._log.debug('Calling __call__') dim_uv = self.kernel.dim_uv - assert isinstance(mag_data, MagData), 'Only MagData objects can be mapped!' + assert isinstance(mag_data, VectorData), 'Only VectorData objects can be mapped!' assert mag_data.a == self.kernel.a, 'Grid spacing has to match!' assert mag_data.dim[0] == 1, 'Magnetic distribution must be 2-dimensional!' assert mag_data.dim[1:3] == dim_uv, 'Dimensions do not match!' # Process input parameters: - u_mag, v_mag = mag_data.magnitude[0:2, 0, ...] + u_mag, v_mag = mag_data.field[0:2, 0, ...] # Get kernel (lookup-tables for the phase of one pixel): u_phi = self.kernel.u v_phi = self.kernel.v @@ -355,7 +352,7 @@ class PhaseMapperFDFC(PhaseMapper): The :class:`~.PMFourier` class represents a phase mapping strategy involving discretization in Fourier space. It utilizes the Fourier transforms, which are inherently calculated in the - :class:`~.Kernel` class and directly takes :class:`~.MagData` objects and returns + :class:`~.Kernel` class and directly takes :class:`~.VectorData` objects and returns :class:`~.PhaseMap` objects. Attributes @@ -401,12 +398,12 @@ class PhaseMapperFDFC(PhaseMapper): def __call__(self, mag_data): self._log.debug('Calling __call__') - assert isinstance(mag_data, MagData), 'Only MagData objects can be mapped!' + assert isinstance(mag_data, VectorData), 'Only VectorData objects can be mapped!' assert mag_data.a == self.a, 'Grid spacing has to match!' assert mag_data.dim[0] == 1, 'Magnetic distribution must be 2-dimensional!' assert mag_data.dim[1:3] == self.dim_uv, 'Dimensions do not match!' v_dim, u_dim = self.dim_uv - u_mag, v_mag = mag_data.magnitude[0:2, 0, ...] + u_mag, v_mag = mag_data.field[0:2, 0, ...] # Create zero padded matrices: u_pad = int(u_dim / 2 * self.padding) v_pad = int(v_dim / 2 * self.padding) @@ -446,9 +443,9 @@ class PhaseMapperFDFC(PhaseMapper): self._log.debug('Calling jac_dot') assert len(vector) == self.n, \ 'vector size not compatible! vector: {}, size: {}'.format(len(vector), self.n) - mag_proj = MagData(self.a, np.zeros((3, 1) + self.dim_uv, dtype=np.float32)) + mag_proj = VectorData(self.a, np.zeros((3, 1) + self.dim_uv, dtype=np.float32)) magnitude_proj = np.reshape(vector, (2,) + self.dim_uv) - mag_proj.magnitude[:2, 0, ...] = magnitude_proj + mag_proj.field[:2, 0, ...] = magnitude_proj return self(mag_proj).phase_vec def jac_T_dot(self, vector): @@ -476,7 +473,7 @@ class PhaseMapperMIP(PhaseMapper): The :class:`~.PhaseMapperMIP` class represents a phase mapping strategy for the electrostatic contribution to the electron phase shift which results e.g. from the mean inner potential in certain samples and which is sensitive to properties of the electron microscope. It directly - takes :class:`~.MagData` objects and returns :class:`~.PhaseMap` objects. + takes :class:`~.ScalarData` objects and returns :class:`~.PhaseMap` objects. Attributes ---------- @@ -508,7 +505,7 @@ class PhaseMapperMIP(PhaseMapper): self.v_acc = v_acc self.threshold = threshold self.m = np.prod(self.dim_uv) - self.n = np.prod(self.dim_uv) + self.n = self.m # Coefficient calculation: lam = H_BAR / np.sqrt(2 * M_E * Q_E * v_acc * (1 + Q_E * v_acc / (2 * M_E * C ** 2))) C_e = 2 * pi * Q_E / lam * (Q_E * v_acc + M_E * C ** 2) / ( @@ -526,21 +523,14 @@ class PhaseMapperMIP(PhaseMapper): return 'PhaseMapperMIP(a=%s, dim_uv=%s, v_0=%s, v_acc=%s, threshold=%s)' % \ (self.a, self.dim_uv, self.v_0, self.v_acc, self.threshold) - def __call__(self, mag_data): + def __call__(self, elec_data): self._log.debug('Calling __call__') - raise NotImplementedError() # TODO: Implement right! - # assert isinstance(mag_data, MagData), 'Only MagData objects can be mapped!' - # assert mag_data.a == self.a, 'Grid spacing has to match!' - # assert mag_data.dim[0] == 1, 'Magnetic distribution must be 2-dimensional!' - # assert mag_data.dim[1:3] == self.dim_uv, 'Dimensions do not match!' - # return self.coeff * mag_data.get_mask(self.threshold)[0, ...].reshape(self.dim_uv) - # # Calculate mask: - # mask = mag_data.get_mask(self.threshold) - # # Project and calculate phase: - # # TODO: check if projector manages scalar multiplication (problem with MagData) and fix! - # projection = self.projector(mask.reshape(-1)).reshape(self.projector.dim_uv) - # phase = self.coeff * projection - # return PhaseMap(mag_data.a, phase) + assert isinstance(elec_data, ScalarData), 'Only ScalarData objects can be mapped!' + assert elec_data.a == self.a, 'Grid spacing has to match!' + assert elec_data.dim[0] == 1, 'Magnetic distribution must be 2-dimensional!' + assert elec_data.dim[1:3] == self.dim_uv, 'Dimensions do not match!' + phase = self.coeff * np.squeeze(elec_data.get_mask(self.threshold)) + return PhaseMap(elec_data.a, phase) def jac_dot(self, vector): """Calculate the product of the Jacobi matrix with a given `vector`. @@ -548,9 +538,7 @@ class PhaseMapperMIP(PhaseMapper): Parameters ---------- vector : :class:`~numpy.ndarray` (N=1) - Vectorized form of the magnetization in `u`- and `v`-direction of every pixel - (row-wise). The first ``N**2`` elements have to correspond to the `u`-, the next - ``N**2`` elements to the `v`-component of the magnetization. + Vectorized form of the electrostatic field of every pixel (row-wise). Returns ------- @@ -558,7 +546,7 @@ class PhaseMapperMIP(PhaseMapper): Product of the Jacobi matrix (which is not explicitely calculated) with the vector. """ - raise NotImplementedError() + raise NotImplementedError() # TODO: Implement right! def jac_T_dot(self, vector): """Calculate the product of the transposed Jacobi matrix with a given `vector`. @@ -573,19 +561,19 @@ class PhaseMapperMIP(PhaseMapper): ------- result : :class:`~numpy.ndarray` (N=1) Product of the transposed Jacobi matrix (which is not explicitely calculated) with - the vector, which has ``2*N**2`` entries like a 2D magnetic projection. + the vector, which has ``N**2`` entries like an electrostatic projection. """ - raise NotImplementedError() + raise NotImplementedError() # TODO: Implement right! def pm(mag_data, mode='z', b_0=1, **kwargs): - """Convenience function for fast phase mapping. + """Convenience function for fast magnetic phase mapping. Parameters ---------- - mag_data : :class:`~.MagData` - A :class:`~.MagData` object, from which the projected phase map should be calculated. + mag_data : :class:`~.VectorData` + A :class:`~.VectorData` object, from which the projected phase map should be calculated. mode: {'z', 'y', 'x', 'x-tilt', 'y-tilt', 'rot-tilt'}, optional Projection mode which determines the :class:`~.pyramid.projector.Projector` subclass, which is used for the projection. Default is a simple projection along the `z`-direction. diff --git a/pyramid/projector.py b/pyramid/projector.py index 5f0e238..7c6e065 100644 --- a/pyramid/projector.py +++ b/pyramid/projector.py @@ -16,7 +16,7 @@ from numpy import pi from scipy.sparse import coo_matrix, csr_matrix import pyramid.fft as fft -from pyramid.magdata import MagData +from pyramid.fielddata import FieldData, VectorData, ScalarData from pyramid.quaternion import Quaternion __all__ = ['RotTiltProjector', 'XTiltProjector', 'YTiltProjector', 'SimpleProjector'] @@ -80,11 +80,20 @@ class Projector(object): self._log.debug('Calling __str__') return 'Projector(dim=%s, dim_uv=%s, coeff=%s)' % (self.dim, self.dim_uv, self.coeff) - def __call__(self, mag_data): - mag_proj = MagData(mag_data.a, fft.zeros((3, 1) + self.dim_uv, dtype=fft.FLOAT)) - magnitude_proj = self.jac_dot(mag_data.mag_vec).reshape((2,) + self.dim_uv) - mag_proj.magnitude[0:2, 0, ...] = magnitude_proj - return mag_proj + def __call__(self, field_data): + if isinstance(field_data, VectorData): + field_empty = fft.zeros((3, 1) + self.dim_uv, dtype=fft.FLOAT) + field_data_proj = VectorData(field_data.a, field_empty) + field_proj = self.jac_dot(field_data.field_vec).reshape((2,) + self.dim_uv) + field_data_proj.field[0:2, 0, ...] = field_proj + elif isinstance(field_data, ScalarData): + field_empty = fft.zeros((1,) + self.dim_uv, dtype=fft.FLOAT) + field_data_proj = ScalarData(field_data.a, field_empty) + field_proj = self.jac_dot(field_data.field_vec).reshape(self.dim_uv) + field_data_proj.field[0, ...] = field_proj + else: + raise TypeError('Input is neither of type VectorData or ScalarData') + return field_data_proj def _vector_field_projection(self, vector): result = fft.zeros(2 * self.size_2d, dtype=fft.FLOAT) diff --git a/pyramid/reconstruction.py b/pyramid/reconstruction.py index d847a70..592cb40 100644 --- a/pyramid/reconstruction.py +++ b/pyramid/reconstruction.py @@ -4,7 +4,7 @@ # """Reconstruct magnetic distributions from given phasemaps. -This module reconstructs 3-dimensional magnetic distributions (as :class:`~pyramid.magdata.MagData` +This module reconstructs 3-dimensional magnetic distributions (as :class:`~pyramid.magdata.VectorData` objects) from a given set of phase maps (represented by :class:`~pyramid.phasemap.PhaseMap` objects) by using several model based reconstruction algorithms which use the forward model provided by :mod:`~pyramid.projector` and :mod:`~pyramid.phasemapper` and a priori knowledge of @@ -16,7 +16,7 @@ import logging import numpy as np -from pyramid.magdata import MagData +from pyramid.fielddata import VectorData __all__ = ['optimize_linear', 'optimize_nonlin', 'optimize_splitbregman'] _log = logging.getLogger(__name__) @@ -37,8 +37,8 @@ def optimize_linear(costfunction, max_iter=None): Returns ------- - mag_data : :class:`~pyramid.magdata.MagData` - The reconstructed magnetic distribution as a :class:`~.MagData` object. + mag_data : :class:`~pyramid.fielddata.VectorData` + The reconstructed magnetic distribution as a :class:`~.VectorData` object. """ import jutil.cg as jcg @@ -48,9 +48,9 @@ def optimize_linear(costfunction, max_iter=None): _log.info('Cost after optimization: {}'.format(costfunction(x_opt))) # Cut ramp parameters if necessary (this also saves the final parameters in the ramp class!): x_opt = costfunction.fwd_model.ramp.extract_ramp_params(x_opt) - # Create and return fitting MagData object: + # Create and return fitting VectorData object: data_set = costfunction.fwd_model.data_set - mag_opt = MagData(data_set.a, np.zeros((3,) + data_set.dim)) + mag_opt = VectorData(data_set.a, np.zeros((3,) + data_set.dim)) mag_opt.set_vector(x_opt, data_set.mask) return mag_opt @@ -65,13 +65,13 @@ def optimize_nonlin(costfunction, first_guess=None): costfunction : :class:`~.Costfunction` A :class:`~.Costfunction` object which implements a specified forward model and regularisator which is minimized in the optimization process. - first_guess : :class:`~pyramid.magdata.MagData` + first_guess : :class:`~pyramid.fielddata.VectorData` magnetization to start the non-linear iteration with. Returns ------- - mag_data : :class:`~pyramid.magdata.MagData` - The reconstructed magnetic distribution as a :class:`~.MagData` object. + mag_data : :class:`~pyramid.fielddata.VectorData` + The reconstructed magnetic distribution as a :class:`~.VectorData` object. """ import jutil.minimizer as jmin @@ -79,7 +79,7 @@ def optimize_nonlin(costfunction, first_guess=None): _log.debug('Calling optimize_nonlin') data_set = costfunction.fwd_model.data_set if first_guess is None: - first_guess = MagData(data_set.a, np.zeros((3,) + data_set.dim)) + first_guess = VectorData(data_set.a, np.zeros((3,) + data_set.dim)) x_0 = first_guess.get_vector(data_set.mask) assert len(x_0) == costfunction.n, (len(x_0), costfunction.m, costfunction.n) @@ -102,7 +102,7 @@ def optimize_nonlin(costfunction, first_guess=None): tol={"max_iteration": 10000}) x_opt = result.x _log.info('Cost after optimization: {}'.format(costfunction(x_opt))) - mag_opt = MagData(data_set.a, np.zeros((3,) + data_set.dim)) + mag_opt = VectorData(data_set.a, np.zeros((3,) + data_set.dim)) mag_opt.set_vector(x_opt, data_set.mask) return mag_opt @@ -129,8 +129,8 @@ def optimize_splitbregman(costfunction, weight, lam, mu): Returns ------- - mag_data : :class:`~pyramid.magdata.MagData` - The reconstructed magnetic distribution as a :class:`~.MagData` object. + mag_data : :class:`~pyramid.fielddata.VectorData` + The reconstructed magnetic distribution as a :class:`~.VectorData` object. """ import jutil.splitbregman as jsb @@ -157,6 +157,6 @@ def optimize_splitbregman(costfunction, weight, lam, mu): A, D, y, weight=weight, mu=mu, lambd=lam, max_iter=1000) - mag_opt = MagData(data_set.a, np.zeros((3,) + data_set.dim)) + mag_opt = VectorData(data_set.a, np.zeros((3,) + data_set.dim)) mag_opt.set_vector(x_opt, data_set.mask) return mag_opt diff --git a/pyramid/tests/test_dataset.py b/pyramid/tests/test_dataset.py index 3a3505a..8cb02ab 100644 --- a/pyramid/tests/test_dataset.py +++ b/pyramid/tests/test_dataset.py @@ -10,7 +10,7 @@ import numpy as np from numpy.testing import assert_allclose from pyramid.dataset import DataSet -from pyramid.magdata import MagData +from pyramid.fielddata import VectorData from pyramid.phasemap import PhaseMap from pyramid.projector import SimpleProjector @@ -42,7 +42,7 @@ class TestCaseDataSet(unittest.TestCase): def test_create_phase_maps(self): self.data.projectors = [self.projector] - mag_data = MagData(self.a, np.ones((3,) + self.dim)) + mag_data = VectorData(self.a, np.ones((3,) + self.dim)) self.data.phase_maps = self.data.create_phase_maps(mag_data) phase_vec_ref = np.load(os.path.join(self.path, 'phase_vec_ref.npy')) assert_allclose(self.data.phase_vec, phase_vec_ref, atol=1E-6, diff --git a/pyramid/tests/test_magdata.py b/pyramid/tests/test_fielddata.py similarity index 62% rename from pyramid/tests/test_magdata.py rename to pyramid/tests/test_fielddata.py index 23691e8..f2766ad 100644 --- a/pyramid/tests/test_magdata.py +++ b/pyramid/tests/test_fielddata.py @@ -7,15 +7,15 @@ import unittest import numpy as np from numpy.testing import assert_allclose -from pyramid.magdata import MagData +from pyramid.fielddata import VectorData -class TestCaseMagData(unittest.TestCase): +class TestCaseVectorData(unittest.TestCase): def setUp(self): - self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_magdata') + self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_fielddata') magnitude = np.zeros((3, 4, 4, 4)) magnitude[:, 1:-1, 1:-1, 1:-1] = 1 - self.mag_data = MagData(10.0, magnitude) + self.mag_data = VectorData(10.0, magnitude) def tearDown(self): self.path = None @@ -30,7 +30,7 @@ class TestCaseMagData(unittest.TestCase): def test_scale_down(self): self.mag_data.scale_down() reference = 1 / 8. * np.ones((3, 2, 2, 2)) - assert_allclose(self.mag_data.magnitude, reference, + assert_allclose(self.mag_data.field, reference, err_msg='Unexpected behavior in scale_down()!') assert_allclose(self.mag_data.a, 20, err_msg='Unexpected behavior in scale_down()!') @@ -39,20 +39,20 @@ class TestCaseMagData(unittest.TestCase): self.mag_data.scale_up() reference = np.zeros((3, 8, 8, 8)) reference[:, 2:6, 2:6, 2:6] = 1 - assert_allclose(self.mag_data.magnitude, reference, + assert_allclose(self.mag_data.field, reference, err_msg='Unexpected behavior in scale_down()!') assert_allclose(self.mag_data.a, 5, err_msg='Unexpected behavior in scale_down()!') def test_pad(self): - reference = self.mag_data.magnitude.copy() + reference = self.mag_data.field.copy() self.mag_data.pad((1, 1, 1)) reference = np.pad(reference, ((0, 0), (1, 1), (1, 1), (1, 1)), mode='constant') - assert_allclose(self.mag_data.magnitude, reference, + assert_allclose(self.mag_data.field, reference, err_msg='Unexpected behavior in scale_down()!') self.mag_data.pad(((1, 1), (1, 1), (1, 1))) reference = np.pad(reference, ((0, 0), (1, 1), (1, 1), (1, 1)), mode='constant') - assert_allclose(self.mag_data.magnitude, reference, + assert_allclose(self.mag_data.field, reference, err_msg='Unexpected behavior in scale_down()!') def test_get_mask(self): @@ -75,48 +75,48 @@ class TestCaseMagData(unittest.TestCase): self.mag_data.set_vector(vector, mask) reference = np.zeros((3, 4, 4, 4)) reference[:, 1:-1, 1:-1, 1:-1] = 2 - assert_allclose(self.mag_data.magnitude, reference, + assert_allclose(self.mag_data.field, reference, err_msg='Unexpected behavior in set_vector()!') def test_flip(self): - mag_data = MagData.load_from_hdf5(os.path.join(self.path, 'mag_data_orig.hdf5')) - mag_data_flipx = MagData.load_from_hdf5(os.path.join(self.path, 'mag_data_flipx.hdf5')) - mag_data_flipy = MagData.load_from_hdf5(os.path.join(self.path, 'mag_data_flipy.hdf5')) - mag_data_flipz = MagData.load_from_hdf5(os.path.join(self.path, 'mag_data_flipz.hdf5')) - assert_allclose(mag_data.flip('x').magnitude, mag_data_flipx.magnitude, + mag_data = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_data_orig.hdf5')) + mag_data_flipx = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_data_flipx.hdf5')) + mag_data_flipy = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_data_flipy.hdf5')) + mag_data_flipz = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_data_flipz.hdf5')) + assert_allclose(mag_data.flip('x').field, mag_data_flipx.field, err_msg='Unexpected behavior in flip()! (x)') - assert_allclose(mag_data.flip('y').magnitude, mag_data_flipy.magnitude, + assert_allclose(mag_data.flip('y').field, mag_data_flipy.field, err_msg='Unexpected behavior in flip()! (y)') - assert_allclose(mag_data.flip('z').magnitude, mag_data_flipz.magnitude, + assert_allclose(mag_data.flip('z').field, mag_data_flipz.field, err_msg='Unexpected behavior in flip()! (z)') def test_rot(self): - mag_data = MagData.load_from_hdf5(os.path.join(self.path, 'mag_data_orig.hdf5')) - mag_data_rotx = MagData.load_from_hdf5(os.path.join(self.path, 'mag_data_rotx.hdf5')) - mag_data_roty = MagData.load_from_hdf5(os.path.join(self.path, 'mag_data_roty.hdf5')) - mag_data_rotz = MagData.load_from_hdf5(os.path.join(self.path, 'mag_data_rotz.hdf5')) - assert_allclose(mag_data.rot90('x').magnitude, mag_data_rotx.magnitude, + mag_data = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_data_orig.hdf5')) + mag_data_rotx = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_data_rotx.hdf5')) + mag_data_roty = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_data_roty.hdf5')) + mag_data_rotz = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_data_rotz.hdf5')) + assert_allclose(mag_data.rot90('x').field, mag_data_rotx.field, err_msg='Unexpected behavior in rot()! (x)') - assert_allclose(mag_data.rot90('y').magnitude, mag_data_roty.magnitude, + assert_allclose(mag_data.rot90('y').field, mag_data_roty.field, err_msg='Unexpected behavior in rot()! (y)') - assert_allclose(mag_data.rot90('z').magnitude, mag_data_rotz.magnitude, + assert_allclose(mag_data.rot90('z').field, mag_data_rotz.field, err_msg='Unexpected behavior in rot()! (z)') def test_load_from_llg(self): - mag_data = MagData.load_from_llg(os.path.join(self.path, 'mag_data_ref_load.txt')) - assert_allclose(mag_data.magnitude, self.mag_data.magnitude, + mag_data = VectorData.load_from_llg(os.path.join(self.path, 'mag_data_ref_load.txt')) + assert_allclose(mag_data.field, self.mag_data.field, err_msg='Unexpected behavior in load_from_llg()!') assert_allclose(mag_data.a, self.mag_data.a, err_msg='Unexpected behavior in load_from_llg()!') def test_load_from_hdf5(self): - mag_data = MagData.load_from_hdf5(os.path.join(self.path, 'mag_data_ref_load.hdf5')) - assert_allclose(mag_data.magnitude, self.mag_data.magnitude, + mag_data = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_data_ref_load.hdf5')) + assert_allclose(mag_data.field, self.mag_data.field, err_msg='Unexpected behavior in load_from_netcdf4()!') assert_allclose(mag_data.a, self.mag_data.a, err_msg='Unexpected behavior in load_from_netcdf4()!') if __name__ == '__main__': - suite = unittest.TestLoader().loadTestsFromTestCase(TestCaseMagData) + suite = unittest.TestLoader().loadTestsFromTestCase(TestCaseVectorData) unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/pyramid/tests/test_magdata/mag_data_flipx.hdf5 b/pyramid/tests/test_fielddata/mag_data_flipx.hdf5 similarity index 100% rename from pyramid/tests/test_magdata/mag_data_flipx.hdf5 rename to pyramid/tests/test_fielddata/mag_data_flipx.hdf5 diff --git a/pyramid/tests/test_magdata/mag_data_flipy.hdf5 b/pyramid/tests/test_fielddata/mag_data_flipy.hdf5 similarity index 100% rename from pyramid/tests/test_magdata/mag_data_flipy.hdf5 rename to pyramid/tests/test_fielddata/mag_data_flipy.hdf5 diff --git a/pyramid/tests/test_magdata/mag_data_flipz.hdf5 b/pyramid/tests/test_fielddata/mag_data_flipz.hdf5 similarity index 100% rename from pyramid/tests/test_magdata/mag_data_flipz.hdf5 rename to pyramid/tests/test_fielddata/mag_data_flipz.hdf5 diff --git a/pyramid/tests/test_magdata/mag_data_orig.hdf5 b/pyramid/tests/test_fielddata/mag_data_orig.hdf5 similarity index 100% rename from pyramid/tests/test_magdata/mag_data_orig.hdf5 rename to pyramid/tests/test_fielddata/mag_data_orig.hdf5 diff --git a/pyramid/tests/test_magdata/mag_data_ref_load.hdf5 b/pyramid/tests/test_fielddata/mag_data_ref_load.hdf5 similarity index 100% rename from pyramid/tests/test_magdata/mag_data_ref_load.hdf5 rename to pyramid/tests/test_fielddata/mag_data_ref_load.hdf5 diff --git a/pyramid/tests/test_magdata/mag_data_ref_load.txt b/pyramid/tests/test_fielddata/mag_data_ref_load.txt similarity index 100% rename from pyramid/tests/test_magdata/mag_data_ref_load.txt rename to pyramid/tests/test_fielddata/mag_data_ref_load.txt diff --git a/pyramid/tests/test_magdata/mag_data_rotx.hdf5 b/pyramid/tests/test_fielddata/mag_data_rotx.hdf5 similarity index 100% rename from pyramid/tests/test_magdata/mag_data_rotx.hdf5 rename to pyramid/tests/test_fielddata/mag_data_rotx.hdf5 diff --git a/pyramid/tests/test_magdata/mag_data_roty.hdf5 b/pyramid/tests/test_fielddata/mag_data_roty.hdf5 similarity index 100% rename from pyramid/tests/test_magdata/mag_data_roty.hdf5 rename to pyramid/tests/test_fielddata/mag_data_roty.hdf5 diff --git a/pyramid/tests/test_magdata/mag_data_rotz.hdf5 b/pyramid/tests/test_fielddata/mag_data_rotz.hdf5 similarity index 100% rename from pyramid/tests/test_magdata/mag_data_rotz.hdf5 rename to pyramid/tests/test_fielddata/mag_data_rotz.hdf5 diff --git a/pyramid/tests/test_phasemapper.py b/pyramid/tests/test_phasemapper.py index 1b9f5fe..d743f2c 100644 --- a/pyramid/tests/test_phasemapper.py +++ b/pyramid/tests/test_phasemapper.py @@ -8,16 +8,16 @@ import numpy as np from numpy.testing import assert_allclose from pyramid.kernel import Kernel -from pyramid.magdata import MagData +from pyramid.fielddata import VectorData, ScalarData from pyramid.phasemap import PhaseMap -from pyramid.phasemapper import PhaseMapperMIP, pm from pyramid.phasemapper import PhaseMapperRDFC, PhaseMapperRDRC, PhaseMapperFDFC +from pyramid.phasemapper import PhaseMapperMIP, pm class TestCasePhaseMapperRDFC(unittest.TestCase): def setUp(self): self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_phasemapper') - self.mag_proj = MagData.load_from_hdf5(os.path.join(self.path, 'mag_proj.hdf5')) + self.mag_proj = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_proj.hdf5')) self.mapper = PhaseMapperRDFC(Kernel(self.mag_proj.a, self.mag_proj.dim[1:])) def tearDown(self): @@ -34,7 +34,7 @@ class TestCasePhaseMapperRDFC(unittest.TestCase): def test_PhaseMapperRDFC_jac_dot(self): phase = self.mapper(self.mag_proj).phase - mag_proj_vec = self.mag_proj.magnitude[:2, ...].flatten() + mag_proj_vec = self.mag_proj.field[:2, ...].flatten() phase_jac = self.mapper.jac_dot(mag_proj_vec).reshape(self.mapper.kernel.dim_uv) assert_allclose(phase, phase_jac, atol=1E-7, err_msg='Inconsistency between __call__() and jac_dot()!') @@ -55,7 +55,7 @@ class TestCasePhaseMapperRDFC(unittest.TestCase): class TestCasePhaseMapperRDRC(unittest.TestCase): def setUp(self): self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_phasemapper') - self.mag_proj = MagData.load_from_hdf5(os.path.join(self.path, 'mag_proj.hdf5')) + self.mag_proj = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_proj.hdf5')) self.mapper = PhaseMapperRDRC(Kernel(self.mag_proj.a, self.mag_proj.dim[1:])) def tearDown(self): @@ -72,7 +72,7 @@ class TestCasePhaseMapperRDRC(unittest.TestCase): def test_PhaseMapperRDRC_jac_dot(self): phase = self.mapper(self.mag_proj).phase - mag_proj_vec = self.mag_proj.magnitude[:2, ...].flatten() + mag_proj_vec = self.mag_proj.field[:2, ...].flatten() phase_jac = self.mapper.jac_dot(mag_proj_vec).reshape(self.mapper.kernel.dim_uv) assert_allclose(phase, phase_jac, atol=1E-7, err_msg='Inconsistency between __call__() and jac_dot()!') @@ -93,7 +93,7 @@ class TestCasePhaseMapperRDRC(unittest.TestCase): class TestCasePhaseMapperFDFC(unittest.TestCase): def setUp(self): self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_phasemapper') - self.mag_proj = MagData.load_from_hdf5(os.path.join(self.path, 'mag_proj.hdf5')) + self.mag_proj = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_proj.hdf5')) self.mapper = PhaseMapperFDFC(self.mag_proj.a, self.mag_proj.dim[1:], padding=0) def tearDown(self): @@ -110,7 +110,7 @@ class TestCasePhaseMapperFDFC(unittest.TestCase): def test_PhaseMapperFDFC_jac_dot(self): phase = self.mapper(self.mag_proj).phase - mag_proj_vec = self.mag_proj.magnitude[:2, ...].flatten() + mag_proj_vec = self.mag_proj.field[:2, ...].flatten() phase_jac = self.mapper.jac_dot(mag_proj_vec).reshape(self.mapper.dim_uv) assert_allclose(phase, phase_jac, atol=1E-7, err_msg='Inconsistency between __call__() and jac_dot()!') @@ -124,10 +124,10 @@ class TestCasePhaseMapperFDFC(unittest.TestCase): self.assertRaises(NotImplementedError, self.mapper.jac_T_dot, None) -class TestCasePhaseMapperElectric(unittest.TestCase): +class TestCasePhaseMapperMIP(unittest.TestCase): def setUp(self): self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_phasemapper') - self.mag_proj = MagData.load_from_hdf5(os.path.join(self.path, 'mag_proj.hdf5')) + self.mag_proj = ScalarData.load_from_hdf5(os.path.join(self.path, 'elec_proj.hdf5')) self.mapper = PhaseMapperMIP(self.mag_proj.a, self.mag_proj.dim[1:]) def tearDown(self): @@ -136,7 +136,11 @@ class TestCasePhaseMapperElectric(unittest.TestCase): self.mapper = None def test_call(self): - self.assertRaises(NotImplementedError, self.mapper, None) + phase_ref = PhaseMap.load_from_hdf5(os.path.join(self.path, 'phase_map_elec.hdf5')) + phase_map = self.mapper(self.mag_proj) + assert_allclose(phase_map.phase, phase_ref.phase, atol=1E-7, + err_msg='Unexpected behavior in __call__()!') + assert_allclose(phase_map.a, phase_ref.a, err_msg='Unexpected behavior in __call__()!') def test_jac_dot(self): self.assertRaises(NotImplementedError, self.mapper.jac_dot, None) @@ -148,7 +152,7 @@ class TestCasePhaseMapperElectric(unittest.TestCase): class TestCasePM(unittest.TestCase): def setUp(self): self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_phasemapper') - self.mag_proj = MagData.load_from_hdf5(os.path.join(self.path, 'mag_proj.hdf5')) + self.mag_proj = VectorData.load_from_hdf5(os.path.join(self.path, 'mag_proj.hdf5')) def tearDown(self): self.path = None @@ -170,7 +174,7 @@ if __name__ == '__main__': unittest.TextTestRunner(verbosity=2).run(suite) suite = unittest.TestLoader().loadTestsFromTestCase(TestCasePhaseMapperFDFC) unittest.TextTestRunner(verbosity=2).run(suite) - suite = unittest.TestLoader().loadTestsFromTestCase(TestCasePhaseMapperElectric) + suite = unittest.TestLoader().loadTestsFromTestCase(TestCasePhaseMapperMIP) unittest.TextTestRunner(verbosity=2).run(suite) suite = unittest.TestLoader().loadTestsFromTestCase(TestCasePM) unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/pyramid/tests/test_phasemapper/elec_proj.hdf5 b/pyramid/tests/test_phasemapper/elec_proj.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..0a8c792bcc15d81ca923d4577cf2cad6d8600839 GIT binary patch literal 22928 zcmeHPO>9#~5MC!h3^5Q8Dh9Q}m8yzXqH+;!Q&kmCn*^&x5D}=t1?NFtf+goUvYpD| z(j3!UjvRCBF~=S`^uUoLw_Z8)kYg?t-PxHhkGJ8;aehcc=0)+m-JPA?{X8??H@k0t zFAtBNJaO@ap(~p;N6dh`#m8&8mhW>8(kP#ln~cyUp?~!7O~xEGRF;?g0g+$m<%}1S zfA`MFh_RfI4=TlG^%&n}k)iZZAy6I}8lwSE$f%)D&qdDw#z=cEY*c5%sMT~?(904S zx};}BUwysKnX<JN(%76iXR>CxS_>=F^~P+_axGl24U;9&Klgz(7yY5sq$o4x<;<AK zJLk)*{2Dfz)p}&PjOiqo%nEWD8fnDUroPZ$Y>yaUo(5yDL9w$=_PBnL`IFK)Pe0#( z1k&trLi7g+R4VgP6wHQGm5R%P{+GbeB^|$YdzdsBdbcLOBarLsahKu`4SSj&m=wpl zDE3WAzv(aV`#tv+L$wItQ;@sy<L#S{g&d*1z>e>)ykPzH_}l{AxO|=F>K8@Fk2KV3 z;Y!f1TGuY_%Aj5}>)7pVgD>#6g&%33zt7`;BK+u|&wt$GuiUCfp;c|3KpBH}kl!!- zAUWI!J?W)SNgDFT9|g6bF&wl4E;#M+Be{Z#$WW>XC<2OrBA^H;0*Zhlpa>`eihv@Z z2)siCI>ix}KjY2}zQaCgQ~w_X5Jy~<E<F}n{)KPS;#BKWo|kp0Zb#(D5!WRUg!q&n z2kTb;Vd2l1K91=La2dmvoayBZ;E8x0Xj*=+T`8opGlfeM<13i+S#$n30raTEBYS$e z*?v=SHyIJg@yd*u3a4v9E8K_^W`(b}=g8PcEQ@MTcku6W&q`#O3SYhY+iKZmm%r5y z@^_@OSib~4yF~#nKTk5sur|g4{6Lf3no<N50YyL&Py`eKML-cy1QdaTgaAL6_Q|d@ zV+yhn0nY(1ukvWtuQA0wxV5i24Zi$0oF4p^X@Q9;e#bZ9n~-$-d(Owchth{qA%%=d z{>sKa5zg?R%klIycb&`8?o&zsImG#h|16Cs`Bo+U;vVO3^|Srp(d4sZ7ytP<fBsU& zJou~U->ueEK1DzgPy`eKML-cas0i@7li3u9#dvhx2}m4Higl+689wH{dD+(tR4`w~ zd>8rKrFh@MpU3Cyx(UVfGj<0ty-(7#`+h^4K2x|ZD-tDht>0XG?d^Bxetc5OnUd5$ z>gv;;dn&tN7e)pwrGFj^j}+sg{mPRvcoH4=qtD5yPfs^P`%25!`a$*44<5&SRCRCS zbm|A~vqnD%hny*Hj3-BURG+x<4A{Q%+DE~1VN5ZN-)wQkn?BO^v#-i?(xL#P{$mq# zn(+n#Y5rqE^a!l5v)%R|{_}loxBKTm=-rFBAN%J&$ftGdKjQUNL{#t%CTW`gSd;jP z`i~@DntD3|Y5wD>=n-n|mH+VLezD!|pZ}mOIB`Gr&wtQ#Xz%<7?GA}&DVPuX@z75D z=GKN;LuBg43H>}Y2>AZvvW)!YP!fU)Ua*wx@#;(z)Qq_iMq$I=z`qoe)lySw`|&1z z;3{p=%TD^cUS@vP-&CmI>jGbY>G_ndr=mZcGG?@1o2o`L8+s~ggW|3!udnr*g48U_ z#2j`oC+X!o%z)Y8^Pf2lzBNe?+~R!baZ&65e7;>svj?7F-zV_Fd*P*@cxX!kK&R(u z^#cc96?QZL-w(i!Ry;$8J&Aels7<Qu@BbbgWszuSQqqfFKX%;kdnN$$S0AtVJe%X@ zQyagVkEX3B52rBvybbsf))dcU%(G^6=;ru{&AWT&9uZf7@580-M||$iX^u}esxwtP zqp36>2Xi(;*y((nH{+djmP6dn50dhNcG#@U22n5*HY{H^a_Q`bSnhxuf78vo>|rPZ z!*<8dkzCt=ccsN8mgM*8nE<K&*aJ?J2?WyoaZ&UL%&^Pd^2hKa{=6!-cRpuJ?5Jgr zjd5M+w5~u*SXZF4SYmmnoV|;@x^pA8yc>CRmP;(J&)NCIY7~)|+pc}b@=mz^HNr>r z##H6uf^CbgZu&=O%lPXtt!m4yD|M1XJ`A|=(K49nQ7<-M8M`V&Isq=s2eYz&Yf-AG z|JjV4=EMl3`JYvJ9s}oI`5*uJZ@czG{e=DSnN6?^j37zV;wt|BN41|MZkkFWkY+z? z-u~I$wjcCjN=_=HQ`)W+jdAo#p?2@`Y}g9GLv{Fv*UsO)f?60fA{+RrG{WY5O%C(4 e{OI>iAIsE^@Qo>b8v<!|G<ZMB4Sn3LdGLRg6jAa3 literal 0 HcmV?d00001 diff --git a/pyramid/tests/test_phasemapper/phase_map_elec.hdf5 b/pyramid/tests/test_phasemapper/phase_map_elec.hdf5 new file mode 100644 index 0000000000000000000000000000000000000000..140749420e420631d6bf2883a3df619ed9f42b94 GIT binary patch literal 27568 zcmeHQ&u<$=6duQI<2G*Vpo;zw2p<sSQWQ!nf<V-zO&g@rT1|?2!rsQ~*u_~#wo@g& z;A0R-aO{zz4;+HTfg{Hr^9LYt;gDkyLh7x|+xI?iGREDcF{EkUMBbTs^Y-n`=Qrb- zH*YpyPhGis^vIbbhC(W34wy`s#O0}k)i0TXJj#obNJzXQac77V33Jd;*(srCM1D5O zgf*eh+?t#;mJ{+3OR-r!#Hkbr8t*FvrY0}tslj)o)zGI$qGteOa%sVDROkJm)eK3{ z%N!WC8IOv-x_X^9Q?{>=#-_~)lQQLM%`cSejd`yXKH;=|F!dz*a2;54Q6I_`MVX0~ zHhGbE!j)IJ?>Cy&dSJPXiIYp+3UV15c}RFS)rJ0|{)qOSqQ=-TA^j|_KR!9b{F|jS zO|LIM0{!~q9nl{kP$(=0fj94$3Wbma{m+46oALCGn^#DKp?8nvcLZ`>J>I7HeZ$^w z94N}b+Lr!JNN*f3@cUhPkD+P<_&&&8yL|I{$U+054PeLjH??fX>*<AM4CC^3nse`r zhy2Jxt(MPvOI16x%W!3IUoaoC+t~&O@Gl8J@-F|d!(X^j4}7bts2}bF{jl((JYVse z{%76-PoPZq`PF%E&bPcH!jCA8gv3WBMmrl`DWn{8_>ldjUjZ02Rs<9QML-cy1QY>9 zKoL*`6ahs*5l{qn0f9I>;>z1xDPHaGLIw4ayNUqph^tbIB5EW1O~?*9cI}8y#1I7g zlxqhY^z&a9c?mPjHa!6@VaCFyC5D&)J6*pxX?F&Rb2R&g*z~gIWXhcUN&q@2_Q#<l zKW4;a!$hL{JhD$FOvx|Tyq4d!3#LSFawwU9on=uK@G-B5g^$GC`}_CLjma_B4zD!c zQGKv~iTFf}+%<-+%heCBE`uf%0YyL&Py`eKML-cy1okunydF6u-bTh`WrJC!xn@lk z$dAu)GvWWVexCE-%Ut06`1>4VpE~y%=lfl!q##$}1msmDzjBZ1S>YS|U^8D{@(Uj_ z9qaivZGzhXc^%0=nq&H)uS;Ld7JohP+mDU=*>Au3E^RLSocM`omDRZ)Owv3kjQnY{ zr7PA?;Gr2E^wU+IBA^H;0*Zhlpa|>+0=(Z~dhBngi|#i7iTxR4zX9h6Fh9<SKPynd zd^Hck4rBP)yYu+8nFx*233Dj)`)|&AHJT!iW-p3`I%m$0nDb8^KWDDao4K^LTa&Gr z&e_m81oE|}veVW;p0P1~xGmgLw2S;&i_&-!9o1tvlv6L4o4!5Du(f*7{ip}GV=<_P zCotmbF|?r`)Q+?n@3tpx+taK*2-}mfb!D4))^edupb-TtB1-p$etygyStqpx7#%-) zu~SNfK)>-LFM0${^s_;aAMW}->bJW$e%Q723o(AsnD*a|AGE6%jWQU|UAsq|zeDF^ z))4&ea89rL1p#;b7?Xy7FLpEFP{6?$Axu~20<UJwH9znhHi7YF95=+o{m%PjKH?k4 zMK9y@cl8tISN)9v{3R`R^_S+C6!M}!oHOQXy;iCQb6q{1Lcw#!Y#&dWtlXcw%L(*@ zisV;HOvh}nJ-L~$Bl$<ym<~N&m;MKNZogpey?=$j4)DQwz9*NtZ7Tvm+&oyvfxWK_ zJ86MC4xk_1k>3Z%Mt>UAJlOTydwh|fgy)>fael(72kN6SBY^p<i&yj>g2U!5yZ&Ab z%6268WmL8E-yvRm(|VjSPnoNiu20jjI&<qbkFK@=-v{uH-j{Hk?F)_ST-DBK3eAeQ z;K#q$V57Z)Ts5P5zPeeSx8yeq^Il+&-!?2?-1`zX$|W6+<YvP5H^X_CJ;W|BJa7Bi z5(6}%IAKo+6ISkcyf(u;ZDEa@m#s`QBjm_!8toGV-0?Uo?OvC84q%wA2jyzX4`ywj zqcHC^Lr-h;*9j(X`HJ}jI{b_1|NAMohRlcf{O|t1$72xvV{9`6Rg{7oGgYsOfFhs> zC<2OrBA^H;0(%_+wrdR86*q_6)U#WJbzc7Vv-$R0DeM}qo!9kGXjNOGpGBO10(~Fw zlc0Bh!Cv~X$jElEaN?|82JQ4b<QUrnwrFP=!1>6cJ^V-kYooA5z2_shy3@qMa3#CN zznzD4--`x*#DB%ChaA{(o5qTOBA^H;0*Zhlpa>`edlZ3azi>F*hr3%10@{Uq-u<^o z-jQ&>u;I_v8>PbCWx*$I9dOX{VI4s4`i<oA``=}suw`Fo97>FnM@*1MbKywdv9Nw3 zuO4ob+VbtlqjwBP>mBwBCx2{9j+H~c;HVeBn;0uiy1O?d?6QI8;^4yi$jJUuTW*Q- zC(-@OUTpUh#ofPz9i(IX{KkNF-=O?SU@vg}$D;nje$`vG7f@Z%fB041=ouSZ5vBY2 zWxD62wf{tzX{r~2e*I_NIcGoU{?ku?-S-Bl{`P)nN{JBYr@tL}?*uppt-p|4@>(9H w>Ay>ywWiK6e%JcP_$?1*RL&DJ>$m0<)O@cIScm6A!*4Fu<ev{&{z2FGAJ>I!_W%F@ literal 0 HcmV?d00001 diff --git a/pyramid/tests/test_phasemapper/ref_phase_elec.npy b/pyramid/tests/test_phasemapper/ref_phase_elec.npy deleted file mode 100644 index 506b4882208d1e413818aea5126d865a9782603a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmbR27wQ`j$;jZwP_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= tXCxM+0{I#yItnJ5ItsN4aKObtB#8KEnzHb~VS5;jt_>y*qtWGY@d2H=CRYFe diff --git a/pyramid/tests/test_phasemapper/ref_phase_mag_disc.npy b/pyramid/tests/test_phasemapper/ref_phase_mag_disc.npy deleted file mode 100644 index 32a53e451d64445777a84bdfc3f42a92190a497f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmbR27wQ`j$;jZwP_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I#yItnJ5ItsN4aKOa?1vh2dUS8o|y8rQpWZ!&)&HLw`Hm#ksZNvT>5OI5$ ix=H2{l0PPHf~$K1QEv|whpU5`HxFWtJ=9!#bn^gdZb&%* diff --git a/pyramid/tests/test_phasemapper/ref_phase_mag_fft.npy b/pyramid/tests/test_phasemapper/ref_phase_mag_fft.npy deleted file mode 100644 index ce42b12c1c4fb8bf294d5a850e9a69a42dcda827..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmbR27wQ`j$;jZwP_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I#yItnJ5ItsN4aKQC)QMcZ%7t3re{LQ__%D#Mm*S5B9zH3|dD@IA#m44i? z{{uwa{-UdRY{|u?HiC+eemQO3vA+YVZUTh1mxYMiGl0Pqo9j^X)FI~BPlT#_4mA&C JnyYxN4FK?~Q=|X@ diff --git a/pyramid/tests/test_phasemapper/ref_phase_mag_slab.npy b/pyramid/tests/test_phasemapper/ref_phase_mag_slab.npy deleted file mode 100644 index 1c761d58d307a7190094092a94712d9d67abd4fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmbR27wQ`j$;jZwP_3SlTAW;@Zl$1ZlV+i=qoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I#yItnJ5ItsN4aKOa?1)MKAW-Pq5WdE<Zy!wx1H}Bt(82G+??}q*C5OI5$ ix)8}tn=Ynrf~$k7w}*<u)p0=0gPLOxQwJ4?s{;T_)<^pQ diff --git a/pyramid/tests/test_projector.py b/pyramid/tests/test_projector.py index 7463afd..f3498d6 100644 --- a/pyramid/tests/test_projector.py +++ b/pyramid/tests/test_projector.py @@ -8,14 +8,14 @@ import numpy as np from numpy import pi from numpy.testing import assert_allclose -from pyramid.magdata import MagData +from pyramid.fielddata import VectorData from pyramid.projector import XTiltProjector, YTiltProjector, SimpleProjector class TestCaseSimpleProjector(unittest.TestCase): def setUp(self): self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_projector') - self.mag_data = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_data.hdf5')) + self.mag_data = VectorData.load_from_hdf5(os.path.join(self.path, 'ref_mag_data.hdf5')) self.proj_z = SimpleProjector(self.mag_data.dim, axis='z') self.proj_y = SimpleProjector(self.mag_data.dim, axis='y') self.proj_x = SimpleProjector(self.mag_data.dim, axis='x') @@ -31,29 +31,29 @@ class TestCaseSimpleProjector(unittest.TestCase): mag_proj_z = self.proj_z(self.mag_data) mag_proj_y = self.proj_y(self.mag_data) mag_proj_x = self.proj_x(self.mag_data) - mag_proj_z_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_z.hdf5')) - mag_proj_y_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_y.hdf5')) - mag_proj_x_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_x.hdf5')) - assert_allclose(mag_proj_z.magnitude, mag_proj_z_ref.magnitude, + mag_proj_z_ref = VectorData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_z.hdf5')) + mag_proj_y_ref = VectorData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_y.hdf5')) + mag_proj_x_ref = VectorData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_x.hdf5')) + assert_allclose(mag_proj_z.field, mag_proj_z_ref.field, err_msg='Unexpected behaviour in SimpleProjector (z-axis)') - assert_allclose(mag_proj_y.magnitude, mag_proj_y_ref.magnitude, + assert_allclose(mag_proj_y.field, mag_proj_y_ref.field, err_msg='Unexpected behaviour in SimpleProjector (y-axis)') - assert_allclose(mag_proj_x.magnitude, mag_proj_x_ref.magnitude, + assert_allclose(mag_proj_x.field, mag_proj_x_ref.field, err_msg='Unexpected behaviour in SimpleProjector (x-axis)') def test_SimpleProjector_jac_dot(self): - mag_vec = self.mag_data.mag_vec + mag_vec = self.mag_data.field_vec mag_proj_z = self.proj_z.jac_dot(mag_vec).reshape((2,) + self.proj_z.dim_uv) mag_proj_y = self.proj_y.jac_dot(mag_vec).reshape((2,) + self.proj_y.dim_uv) mag_proj_x = self.proj_x.jac_dot(mag_vec).reshape((2,) + self.proj_x.dim_uv) - mag_proj_z_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_z.hdf5')) - mag_proj_y_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_y.hdf5')) - mag_proj_x_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_x.hdf5')) - assert_allclose(mag_proj_z, mag_proj_z_ref.magnitude[:2, 0, ...], + mag_proj_z_ref = VectorData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_z.hdf5')) + mag_proj_y_ref = VectorData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_y.hdf5')) + mag_proj_x_ref = VectorData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_x.hdf5')) + assert_allclose(mag_proj_z, mag_proj_z_ref.field[:2, 0, ...], err_msg='Inconsistency between __call__() and jac_dot()! (z-axis)') - assert_allclose(mag_proj_y, mag_proj_y_ref.magnitude[:2, 0, ...], + assert_allclose(mag_proj_y, mag_proj_y_ref.field[:2, 0, ...], err_msg='Inconsistency between __call__() and jac_dot()! (y-axis)') - assert_allclose(mag_proj_x, mag_proj_x_ref.magnitude[:2, 0, ...], + assert_allclose(mag_proj_x, mag_proj_x_ref.field[:2, 0, ...], err_msg='Inconsistency between __call__() and jac_dot()! (x-axis)') nz = self.proj_z.n ny = self.proj_y.n @@ -92,7 +92,7 @@ class TestCaseSimpleProjector(unittest.TestCase): class TestCaseXTiltProjector(unittest.TestCase): def setUp(self): self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_projector') - self.mag_data = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_data.hdf5')) + self.mag_data = VectorData.load_from_hdf5(os.path.join(self.path, 'ref_mag_data.hdf5')) self.proj_00 = XTiltProjector(self.mag_data.dim, tilt=0) self.proj_45 = XTiltProjector(self.mag_data.dim, tilt=pi / 4) self.proj_90 = XTiltProjector(self.mag_data.dim, tilt=pi / 2) @@ -108,29 +108,35 @@ class TestCaseXTiltProjector(unittest.TestCase): mag_proj_00 = self.proj_00(self.mag_data) mag_proj_45 = self.proj_45(self.mag_data) mag_proj_90 = self.proj_90(self.mag_data) - mag_proj_00_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_x00.hdf5')) - mag_proj_45_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_x45.hdf5')) - mag_proj_90_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_x90.hdf5')) - assert_allclose(mag_proj_00.magnitude, mag_proj_00_ref.magnitude, + mag_proj_00_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_x00.hdf5')) + mag_proj_45_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_x45.hdf5')) + mag_proj_90_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_x90.hdf5')) + assert_allclose(mag_proj_00.field, mag_proj_00_ref.field, err_msg='Unexpected behaviour in XTiltProjector (0°)') - assert_allclose(mag_proj_45.magnitude, mag_proj_45_ref.magnitude, + assert_allclose(mag_proj_45.field, mag_proj_45_ref.field, err_msg='Unexpected behaviour in XTiltProjector (45°)') - assert_allclose(mag_proj_90.magnitude, mag_proj_90_ref.magnitude, + assert_allclose(mag_proj_90.field, mag_proj_90_ref.field, err_msg='Unexpected behaviour in XTiltProjector (90°)') def test_XTiltProjector_jac_dot(self): - mag_vec = self.mag_data.mag_vec + mag_vec = self.mag_data.field_vec mag_proj_00 = self.proj_00.jac_dot(mag_vec).reshape((2,) + self.proj_00.dim_uv) mag_proj_45 = self.proj_45.jac_dot(mag_vec).reshape((2,) + self.proj_45.dim_uv) mag_proj_90 = self.proj_90.jac_dot(mag_vec).reshape((2,) + self.proj_90.dim_uv) - mag_proj_00_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_x00.hdf5')) - mag_proj_45_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_x45.hdf5')) - mag_proj_90_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_x90.hdf5')) - assert_allclose(mag_proj_00, mag_proj_00_ref.magnitude[:2, 0, ...], + mag_proj_00_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_x00.hdf5')) + mag_proj_45_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_x45.hdf5')) + mag_proj_90_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_x90.hdf5')) + assert_allclose(mag_proj_00, mag_proj_00_ref.field[:2, 0, ...], err_msg='Inconsistency between __call__() and jac_dot()! (0°)') - assert_allclose(mag_proj_45, mag_proj_45_ref.magnitude[:2, 0, ...], + assert_allclose(mag_proj_45, mag_proj_45_ref.field[:2, 0, ...], err_msg='Inconsistency between __call__() and jac_dot()! (45°)') - assert_allclose(mag_proj_90, mag_proj_90_ref.magnitude[:2, 0, ...], + assert_allclose(mag_proj_90, mag_proj_90_ref.field[:2, 0, ...], err_msg='Inconsistency between __call__() and jac_dot()! (90°)') n00 = self.proj_00.n n45 = self.proj_45.n @@ -169,7 +175,7 @@ class TestCaseXTiltProjector(unittest.TestCase): class TestCaseYTiltProjector(unittest.TestCase): def setUp(self): self.path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_projector') - self.mag_data = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_data.hdf5')) + self.mag_data = VectorData.load_from_hdf5(os.path.join(self.path, 'ref_mag_data.hdf5')) self.proj_00 = YTiltProjector(self.mag_data.dim, tilt=0) self.proj_45 = YTiltProjector(self.mag_data.dim, tilt=pi / 4) self.proj_90 = YTiltProjector(self.mag_data.dim, tilt=pi / 2) @@ -185,29 +191,35 @@ class TestCaseYTiltProjector(unittest.TestCase): mag_proj_00 = self.proj_00(self.mag_data) mag_proj_45 = self.proj_45(self.mag_data) mag_proj_90 = self.proj_90(self.mag_data) - mag_proj_00_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_y00.hdf5')) - mag_proj_45_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_y45.hdf5')) - mag_proj_90_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_y90.hdf5')) - assert_allclose(mag_proj_00.magnitude, mag_proj_00_ref.magnitude, + mag_proj_00_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_y00.hdf5')) + mag_proj_45_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_y45.hdf5')) + mag_proj_90_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_y90.hdf5')) + assert_allclose(mag_proj_00.field, mag_proj_00_ref.field, err_msg='Unexpected behaviour in XTiltProjector (0°)') - assert_allclose(mag_proj_45.magnitude, mag_proj_45_ref.magnitude, + assert_allclose(mag_proj_45.field, mag_proj_45_ref.field, err_msg='Unexpected behaviour in XTiltProjector (45°)') - assert_allclose(mag_proj_90.magnitude, mag_proj_90_ref.magnitude, + assert_allclose(mag_proj_90.field, mag_proj_90_ref.field, err_msg='Unexpected behaviour in XTiltProjector (90°)') def test_XTiltProjector_jac_dot(self): - mag_vec = self.mag_data.mag_vec + mag_vec = self.mag_data.field_vec mag_proj_00 = self.proj_00.jac_dot(mag_vec).reshape((2,) + self.proj_00.dim_uv) mag_proj_45 = self.proj_45.jac_dot(mag_vec).reshape((2,) + self.proj_45.dim_uv) mag_proj_90 = self.proj_90.jac_dot(mag_vec).reshape((2,) + self.proj_90.dim_uv) - mag_proj_00_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_y00.hdf5')) - mag_proj_45_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_y45.hdf5')) - mag_proj_90_ref = MagData.load_from_hdf5(os.path.join(self.path, 'ref_mag_proj_y90.hdf5')) - assert_allclose(mag_proj_00, mag_proj_00_ref.magnitude[:2, 0, ...], + mag_proj_00_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_y00.hdf5')) + mag_proj_45_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_y45.hdf5')) + mag_proj_90_ref = VectorData.load_from_hdf5( + os.path.join(self.path, 'ref_mag_proj_y90.hdf5')) + assert_allclose(mag_proj_00, mag_proj_00_ref.field[:2, 0, ...], err_msg='Inconsistency between __call__() and jac_dot()! (0°)') - assert_allclose(mag_proj_45, mag_proj_45_ref.magnitude[:2, 0, ...], + assert_allclose(mag_proj_45, mag_proj_45_ref.field[:2, 0, ...], err_msg='Inconsistency between __call__() and jac_dot()! (45°)') - assert_allclose(mag_proj_90, mag_proj_90_ref.magnitude[:2, 0, ...], + assert_allclose(mag_proj_90, mag_proj_90_ref.field[:2, 0, ...], err_msg='Inconsistency between __call__() and jac_dot()! (90°)') n00 = self.proj_00.n n45 = self.proj_45.n diff --git a/scripts/gui/mag_slicer.py b/scripts/gui/mag_slicer.py index 9181910..52a1503 100644 --- a/scripts/gui/mag_slicer.py +++ b/scripts/gui/mag_slicer.py @@ -13,7 +13,7 @@ import sys import pyramid from pyramid.kernel import Kernel -from pyramid.magdata import MagData +from pyramid.fielddata import VectorData from pyramid.phasemapper import PhaseMapperRDFC from pyramid.projector import SimpleProjector @@ -231,7 +231,7 @@ class UI_MagSlicerMain(QtGui.QWidget): directory = os.path.join(pyramid.DIR_FILES, 'magdata') mag_file = QtGui.QFileDialog.getOpenFileName(self, 'Open Data File', directory, 'HDF5 files (*.hdf5)') - self.mag_data = MagData.load_from_hdf5(mag_file) + self.mag_data = VectorData.load_from_hdf5(mag_file) self.mag_data_loaded = True self.mplWidgetMag.axes.set_visible(True) self.mplWidgetHolo.axes.set_visible(True) diff --git a/scripts/magdata/magcreator/create_alternating_filaments.py b/scripts/magdata/magcreator/create_alternating_filaments.py index a59afa2..60a9068 100644 --- a/scripts/magdata/magcreator/create_alternating_filaments.py +++ b/scripts/magdata/magcreator/create_alternating_filaments.py @@ -19,12 +19,12 @@ magnitude = 1 spacing = 5 filename = 'magdata_mc_alternating_filaments_spacing={}.nc'.format(spacing) -# Create and save MagData object: -mag_data = py.MagData(a, np.zeros((3,)+dim)) +# Create and save VectorData object: +mag_data = py.VectorData(a, np.zeros((3,) + dim)) count = int((dim[1]-1) / spacing) + 1 for i in range(count): pos = i * spacing mag_shape = py.magcreator.Shapes.filament(dim, (0, pos)) - mag_data += py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi)) + mag_data += py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi)) phi *= -1 # Switch the angle mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_array_sphere_disc_slab.py b/scripts/magdata/magcreator/create_array_sphere_disc_slab.py index e324947..18d71e4 100644 --- a/scripts/magdata/magcreator/create_array_sphere_disc_slab.py +++ b/scripts/magdata/magcreator/create_array_sphere_disc_slab.py @@ -29,8 +29,8 @@ center = (32, 96, 64) # in px (z, y, x), index starts with 0! radius = 24 # in px mag_shape_sphere = py.magcreator.Shapes.sphere(dim, center, radius) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape_slab, np.pi/4)) -mag_data += py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape_disc, np.pi/2)) -mag_data += py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape_sphere, np.pi)) +# Create and save VectorData object: +mag_data = py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape_slab, np.pi / 4)) +mag_data += py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape_disc, np.pi / 2)) +mag_data += py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape_sphere, np.pi)) mag_data.save_to_hdf5(filename) diff --git a/scripts/magdata/magcreator/create_core_shell_disc.py b/scripts/magdata/magcreator/create_core_shell_disc.py index 87310b8..b28c4bf 100644 --- a/scripts/magdata/magcreator/create_core_shell_disc.py +++ b/scripts/magdata/magcreator/create_core_shell_disc.py @@ -24,7 +24,7 @@ mag_shape_core = py.magcreator.Shapes.disc(dim, center, radius_core, height) mag_shape_outer = py.magcreator.Shapes.disc(dim, center, radius_shell, height) mag_shape_shell = np.logical_xor(mag_shape_outer, mag_shape_core) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_vortex(mag_shape_shell, magnitude=0.75)) -mag_data += py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape_core, phi=0, theta=0)) +# Create and save VectorData object: +mag_data = py.VectorData(a, py.magcreator.create_mag_dist_vortex(mag_shape_shell, amplitude=0.75)) +mag_data += py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape_core, phi=0, theta=0)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_core_shell_sphere.py b/scripts/magdata/magcreator/create_core_shell_sphere.py index 06e2206..64b3dea 100644 --- a/scripts/magdata/magcreator/create_core_shell_sphere.py +++ b/scripts/magdata/magcreator/create_core_shell_sphere.py @@ -24,7 +24,7 @@ mag_shape_disc = py.magcreator.Shapes.disc(dim, center, radius_core, height=dim[ mag_shape_core = np.logical_and(mag_shape_sphere, mag_shape_disc) mag_shape_shell = np.logical_and(mag_shape_sphere, np.logical_not(mag_shape_core)) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_vortex(mag_shape_shell, magnitude=0.75)) -mag_data += py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape_core, phi=0, theta=0)) +# Create and save VectorData object: +mag_data = py.VectorData(a, py.magcreator.create_mag_dist_vortex(mag_shape_shell, amplitude=0.75)) +mag_data += py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape_core, phi=0, theta=0)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_homog_disc.py b/scripts/magdata/magcreator/create_homog_disc.py index 2ca2f84..d3f2c28 100644 --- a/scripts/magdata/magcreator/create_homog_disc.py +++ b/scripts/magdata/magcreator/create_homog_disc.py @@ -24,6 +24,6 @@ radius = dim[2]//4 height = dim[0]//2 mag_shape = py.magcreator.Shapes.disc(dim, center, radius, height) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) +# Create and save VectorData object: +mag_data = py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_homog_filament.py b/scripts/magdata/magcreator/create_homog_filament.py index fe036c6..3ac6eb7 100644 --- a/scripts/magdata/magcreator/create_homog_filament.py +++ b/scripts/magdata/magcreator/create_homog_filament.py @@ -22,6 +22,6 @@ filename = 'magdata_mc_homog_filament.nc' pos = (0, dim[1]//2) mag_shape = py.magcreator.Shapes.filament(dim, pos) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) +# Create and save VectorData object: +mag_data = py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_homog_pixel.py b/scripts/magdata/magcreator/create_homog_pixel.py index d2358a3..8dd222f 100644 --- a/scripts/magdata/magcreator/create_homog_pixel.py +++ b/scripts/magdata/magcreator/create_homog_pixel.py @@ -22,6 +22,6 @@ filename = 'magdata_mc_pixel.nc' pixel = (0, dim[1]//4, dim[2]//4) mag_shape = py.magcreator.Shapes.pixel(dim, pixel) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) +# Create and save VectorData object: +mag_data = py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_homog_slab.py b/scripts/magdata/magcreator/create_homog_slab.py index 5d1394c..80008b8 100644 --- a/scripts/magdata/magcreator/create_homog_slab.py +++ b/scripts/magdata/magcreator/create_homog_slab.py @@ -23,6 +23,6 @@ center = (dim[0]//2-0.5, dim[1]//2-0.5, dim[2]//2-0.5) width = (dim[0]//8, dim[1]//2, dim[2]//4) mag_shape = py.magcreator.Shapes.slab(dim, center, width) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) +# Create and save VectorData object: +mag_data = py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_homog_sphere.py b/scripts/magdata/magcreator/create_homog_sphere.py index 244e203..0fd1c75 100644 --- a/scripts/magdata/magcreator/create_homog_sphere.py +++ b/scripts/magdata/magcreator/create_homog_sphere.py @@ -23,6 +23,6 @@ center = (dim[0]//2-0.5, dim[1]//2-0.5, dim[2]//2-0.5) radius = dim[2]//4 # in px mag_shape = py.magcreator.Shapes.sphere(dim, center, radius) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) +# Create and save VectorData object: +mag_data = py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_paper2_homog_slab.py b/scripts/magdata/magcreator/create_paper2_homog_slab.py index 33a0e73..35deeca 100644 --- a/scripts/magdata/magcreator/create_paper2_homog_slab.py +++ b/scripts/magdata/magcreator/create_paper2_homog_slab.py @@ -26,10 +26,10 @@ width = (0, 80, 80) # in px mag_shape_1 = py.magcreator.Shapes.slab(dim, center_1, width) mag_shape_2 = py.magcreator.Shapes.slab(dim, center_2, width) -# Create and save MagData object: -mag = py.magcreator.create_mag_dist_homog(mag_shape_1, phi=7/12.*np.pi, magnitude=magnitude) -mag += py.magcreator.create_mag_dist_homog(mag_shape_2, phi=1/3.*np.pi, magnitude=magnitude) -mag_data = py.MagData(a, mag) +# Create and save VectorData object: +mag = py.magcreator.create_mag_dist_homog(mag_shape_1, phi=7 / 12. * np.pi, amplitude=magnitude) +mag += py.magcreator.create_mag_dist_homog(mag_shape_2, phi=1 / 3. * np.pi, amplitude=magnitude) +mag_data = py.VectorData(a, mag) projector = py.RotTiltProjector(mag_data.dim, rotation, tilt) mag_data = projector(mag_data) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_paper2_vortex_slab.py b/scripts/magdata/magcreator/create_paper2_vortex_slab.py index a3ff614..f7574e5 100644 --- a/scripts/magdata/magcreator/create_paper2_vortex_slab.py +++ b/scripts/magdata/magcreator/create_paper2_vortex_slab.py @@ -21,6 +21,7 @@ center = (0, dim[1]//2-0.5, dim[2]//2-0.5) width = (0, 128, 128) # in px mag_shape = py.magcreator.Shapes.slab(dim, center, width) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_vortex(mag_shape, center, axis, magnitude)) +# Create and save VectorData object: +mag_data = py.VectorData(a, + py.magcreator.create_mag_dist_vortex(mag_shape, center, axis, magnitude)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_pyramid_logo.py b/scripts/magdata/magcreator/create_pyramid_logo.py index b399924..55b6c7c 100644 --- a/scripts/magdata/magcreator/create_pyramid_logo.py +++ b/scripts/magdata/magcreator/create_pyramid_logo.py @@ -28,6 +28,6 @@ left = (yy <= 0.75/0.5 * dim[1]/dim[2] * xx) right = np.fliplr(left) mag_shape[0, ...] = np.logical_and(np.logical_and(left, right), bottom) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) +# Create and save VectorData object: +mag_data = py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi, theta, magnitude)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_random_pixels.py b/scripts/magdata/magcreator/create_random_pixels.py index ce81436..7173694 100644 --- a/scripts/magdata/magcreator/create_random_pixels.py +++ b/scripts/magdata/magcreator/create_random_pixels.py @@ -28,11 +28,11 @@ left = (yy <= 0.75/0.5 * dim[1]/dim[2] * xx) right = np.fliplr(left) mag_shape[0, ...] = np.logical_and(np.logical_and(left, right), bottom) -# Create and save MagData object: -mag_data = py.MagData(a, np.zeros((3,)+dim)) +# Create and save VectorData object: +mag_data = py.VectorData(a, np.zeros((3,) + dim)) for i in range(count): pixel = (rnd.randrange(dim[0]), rnd.randrange(dim[1]), rnd.randrange(dim[2])) mag_shape = py.magcreator.Shapes.pixel(dim, pixel) phi = 2 * np.pi * rnd.random() - mag_data += py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi)) + mag_data += py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_random_slabs.py b/scripts/magdata/magcreator/create_random_slabs.py index 3bc7a91..b68e374 100644 --- a/scripts/magdata/magcreator/create_random_slabs.py +++ b/scripts/magdata/magcreator/create_random_slabs.py @@ -29,8 +29,8 @@ left = (yy <= 0.75/0.5 * dim[1]/dim[2] * xx) right = np.fliplr(left) mag_shape[0, ...] = np.logical_and(np.logical_and(left, right), bottom) -# Create and save MagData object: -mag_data = py.MagData(a, np.zeros((3,)+dim)) +# Create and save VectorData object: +mag_data = py.VectorData(a, np.zeros((3,) + dim)) for i in range(count): width = (1, rnd.randint(1, w_max), rnd.randint(1, w_max)) center = (rnd.randrange(int(width[0]/2), dim[0]-int(width[0]/2)), @@ -38,5 +38,5 @@ for i in range(count): rnd.randrange(int(width[2]/2), dim[2]-int(width[2]/2))) mag_shape = py.magcreator.Shapes.slab(dim, center, width) phi = 2 * np.pi * rnd.random() - mag_data += py.MagData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi)) + mag_data += py.VectorData(a, py.magcreator.create_mag_dist_homog(mag_shape, phi)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_singularity.py b/scripts/magdata/magcreator/create_singularity.py index d050b0e..cc69368 100644 --- a/scripts/magdata/magcreator/create_singularity.py +++ b/scripts/magdata/magcreator/create_singularity.py @@ -20,7 +20,7 @@ zz, yy, xx = np.indices(dim) magnitude = np.array((xx-center[2], yy-center[1], zz-center[0])) magnitude /= np.sqrt((magnitude**2).sum(axis=0)) -# Create and save MagData object: -mag_data = py.MagData(a, magnitude) +# Create and save VectorData object: +mag_data = py.VectorData(a, magnitude) mag_data.quiver_plot3d(coloring='full angle') mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_vortex_disc.py b/scripts/magdata/magcreator/create_vortex_disc.py index 4feb7ca..72291dc 100644 --- a/scripts/magdata/magcreator/create_vortex_disc.py +++ b/scripts/magdata/magcreator/create_vortex_disc.py @@ -22,6 +22,7 @@ radius = dim[2]//4 height = dim[0]//2 mag_shape = py.magcreator.Shapes.disc(dim, center, radius, height, axis) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_vortex(mag_shape, center, axis, magnitude)) +# Create and save VectorData object: +mag_data = py.VectorData(a, + py.magcreator.create_mag_dist_vortex(mag_shape, center, axis, magnitude)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magcreator/create_vortex_sphere.py b/scripts/magdata/magcreator/create_vortex_sphere.py index 0999d30..2c2ccee 100644 --- a/scripts/magdata/magcreator/create_vortex_sphere.py +++ b/scripts/magdata/magcreator/create_vortex_sphere.py @@ -21,6 +21,7 @@ center = (dim[0]//2-0.5, dim[1]//2-0.5, dim[2]//2-0.5) radius = dim[2]//4 # in px mag_shape = py.magcreator.Shapes.sphere(dim, center, radius) -# Create and save MagData object: -mag_data = py.MagData(a, py.magcreator.create_mag_dist_vortex(mag_shape, center, axis, magnitude)) +# Create and save VectorData object: +mag_data = py.VectorData(a, + py.magcreator.create_mag_dist_vortex(mag_shape, center, axis, magnitude)) mag_data.save_to_netcdf4(filename) diff --git a/scripts/magdata/magdata_from_dat.py b/scripts/magdata/magdata_from_dat.py index c0fdf10..e698299 100644 --- a/scripts/magdata/magdata_from_dat.py +++ b/scripts/magdata/magdata_from_dat.py @@ -29,7 +29,7 @@ xmag = xmag.reshape(dim).swapaxes(1, 2) ymag = ymag.reshape(dim).swapaxes(1, 2) zmag = zmag.reshape(dim).swapaxes(1, 2) magnitude = np.array((xmag, ymag, zmag)) -mag_data = py.MagData(a, magnitude) +mag_data = py.VectorData(a, magnitude) #mag_data.save_to_netcdf4('magdata_dat_{}'.format(filename.replace('.dat', '.nc'))) mag_data.quiver_plot3d(ar_dens=4, coloring='amplitude') mag_data.quiver_plot3d(ar_dens=4, coloring='angle') @@ -57,8 +57,8 @@ py.pm(mag_data).display_combined(interpolation='bilinear') # xmag = np.reshape(xmag, dim).swapaxes(1, 2) # ymag = np.reshape(ymag, dim).swapaxes(1, 2) # zmag = np.reshape(zmag, dim).swapaxes(1, 2) -# magnitude = np.array((xmag, ymag, zmag)) -# mag_data = py.MagData(a, magnitude) +# field = np.array((xmag, ymag, zmag)) +# mag_data = py.VectorData(a, field) # return mag_data ## mag_data.save_to_netcdf4('magdata_dat_{}'.format(filename.replace('.dat', '.nc'))) # diff --git a/scripts/magdata/magdata_from_txtfortran.py b/scripts/magdata/magdata_from_txtfortran.py index 912a0f1..6a461cd 100644 --- a/scripts/magdata/magdata_from_txtfortran.py +++ b/scripts/magdata/magdata_from_txtfortran.py @@ -26,6 +26,6 @@ y_mag = np.reshape(data[:, 4], dim, order='F') z_mag = np.reshape(data[:, 5], dim, order='F') magnitude = np.array((x_mag, y_mag, z_mag)) -# Create and save MagData object: -mag_data = py.MagData(a, magnitude) +# Create and save VectorData object: +mag_data = py.VectorData(a, magnitude) mag_data.save_to_netcdf4('magdata_txtfortran_{}'.format(filename.replace('.txt', '.nc'))) diff --git a/scripts/magdata/magdata_from_vtk.py b/scripts/magdata/magdata_from_vtk.py index 76b3dba..d377aa6 100644 --- a/scripts/magdata/magdata_from_vtk.py +++ b/scripts/magdata/magdata_from_vtk.py @@ -113,13 +113,13 @@ def excluding_mesh(x, y, nx=30, ny=30): #plt.show() -# Create empty magnitude: +# Create empty field: magnitude = np.zeros((3, len(z), len(y), len(x)), dtype=py.fft.FLOAT) print 'Mag Dimensions:', magnitude.shape[1:] #import pdb; pdb.set_trace() -# Fill magnitude slice per slice: +# Fill field slice per slice: for i, zi in tqdm(enumerate(z), total=len(z)): # Take all points that lie in one z-voxel of the new regular grid into account (use weights!): z_slice = data[np.abs(data[:, 2]-zi) <= a/2., :] @@ -150,7 +150,7 @@ for i, zi in tqdm(enumerate(z), total=len(z)): a *= 10 print 'CREATE AND SAVE MAGDATA OBJECT!' -mag_data = py.MagData(a, magnitude) +mag_data = py.VectorData(a, magnitude) mag_data.save_to_netcdf4('magdata_vtk_{}'.format(filename.replace('.vtk', '.nc'))) -py.pm(mag_data).display_combined() \ No newline at end of file +py.pm(mag_data).display_combined() diff --git a/scripts/phasemap/phasemap_projection_arbitrary.py b/scripts/phasemap/phasemap_projection_arbitrary.py index e0f7b7b..baa3fbd 100644 --- a/scripts/phasemap/phasemap_projection_arbitrary.py +++ b/scripts/phasemap/phasemap_projection_arbitrary.py @@ -17,7 +17,7 @@ rotation = np.pi/4. tilt = 0. ################################################################################################### -mag_data = py.MagData.load_from_netcdf4(filename) +mag_data = py.VectorData.load_from_netcdf4(filename) projector = py.RotTiltProjector(mag_data.dim, rotation, tilt, dim_uv) mag_proj = projector(mag_data) phasemapper = py.PhaseMapperRDFC(py.Kernel(mag_data.a, projector.dim_uv, b_0)) diff --git a/scripts/phasemap/phasemap_projection_simple.py b/scripts/phasemap/phasemap_projection_simple.py index 02c8ee2..1141d66 100644 --- a/scripts/phasemap/phasemap_projection_simple.py +++ b/scripts/phasemap/phasemap_projection_simple.py @@ -14,7 +14,7 @@ b_0 = 1. dim_uv = None ################################################################################################### -mag_data = py.MagData.load_from_netcdf4(filename) +mag_data = py.VectorData.load_from_netcdf4(filename) phase_map = py.pm(mag_data, dim_uv=dim_uv, b_0=b_0) phase_map.save_to_netcdf4('phasemap_{}'.format(filename.replace('magdata_', ''))) phase_map.display_combined() diff --git a/scripts/phasemap/phasemap_tilt_series.py b/scripts/phasemap/phasemap_tilt_series.py index 06c0d64..992bcef 100644 --- a/scripts/phasemap/phasemap_tilt_series.py +++ b/scripts/phasemap/phasemap_tilt_series.py @@ -18,7 +18,7 @@ dim_uv = None angles = np.linspace() ################################################################################################### -mag_data = py.MagData.load_from_netcdf4(filename) +mag_data = py.VectorData.load_from_netcdf4(filename) phase_map = py.pm(mag_data, mode=axis, dim_uv=dim_uv, b_0=b_0) phase_map.save_to_netcdf4('phasemap_{}_axis={}'.format(filename.replace('magdata_', ''), axis)) phase_map.display_combined() @@ -29,11 +29,11 @@ dim_uv = (500, 200) angles = np.arange(-60, 61, 5)#[0, 20, 40, 60] #mag_data_xy = mag_data.copy() -#mag_data_xy.magnitude[2] = 0 +# mag_data_xy.field[2] = 0 # #mag_data_z = mag_data.copy() -#mag_data_z.magnitude[0] = 0 -#mag_data_z.magnitude[1] = 0 +# mag_data_z.field[0] = 0 +# mag_data_z.field[1] = 0 # Iterate over all angles: for angle in angles: diff --git a/scripts/reconstruction/reconstruction_3d_from_magdata.py b/scripts/reconstruction/reconstruction_3d_from_magdata.py index 3d0cb3b..25981c6 100644 --- a/scripts/reconstruction/reconstruction_3d_from_magdata.py +++ b/scripts/reconstruction/reconstruction_3d_from_magdata.py @@ -34,7 +34,7 @@ if __name__ == '__main__': mp.freeze_support() # Load magnetization distribution: - mag_data = pr.MagData.load_from_hdf5(mag_name + '.hdf5') + mag_data = pr.VectorData.load_from_hdf5(mag_name + '.hdf5') dim = mag_data.dim # Construct data set and regularisator: -- GitLab