Skip to content

Commit

Permalink
ACOM module - fix for .ang file writer (#382)
Browse files Browse the repository at this point in the history
* adding annotation import

* fft normalization

* upsampling limit bugs

* bilinear sampling during position correction

* sequential numerator-denominator pixel rolling to save memory

* some useful warnings for now

* add occupancy to CIF reader

* add occupancy to structure factors

* format with black

* removing optional conda comment

* adding dependencies comment

* Adding correlation metrics

* Correlation coefs finished

* Black formatting

* normalize_order = 0 bug

* plotting fixes

* switching to gray

* allowing python 12.1

* changing python requirement to <3.13

* changing install requirements

* adding initial fixes

* changing how peaks are accessed

* changing to PLA from BraggVectors

* changing to PLA from BraggVectors

* moving import to top of file

* black

* removing hardcoded link to sample collections

* adding overwrite

* typo

* typo

* removing accidental noteobok

* back to hardcoded id

* changing filename for FCU-Net file

* Adding ability to force filename for collection Items

* back to non hardcoded now gdrive function fixed

* removing print statements

* bumping allowed version of tensorflow

* black

* adding strain mapping back into WPF

* Finishing up

* Fixing minor bugs

* Black formatting

* removing test plotting

* doc strains for visualize strain

* bugs

* doc string update

* fixing reset=False bug

* explicit bin order

* some plotting preferences

* fixing upsampling limits

* explicit aberration orders fit

* fixing abtem bug, adding conversion to polar property

* adding ability to pass descan_correction_fit_function

* DCT-based poisson solver phase unwrapping

* constraints refactoring

* fixing reshaping bugs

* cleaning up calibrations

* cleaning up calculate rotation

* adding grid search functionality to optimize

* removing tuning functions from subclasses - moved to optimizer

* Update corr_kernel_size documentation

* small typo

* cupy numpy bug

* refactoring object and probe methods

* multislice plotting tweaks

* moved read-only self-attribute calls up-front. Might remove all-together, especially for positions

* cleaned up single-slice preprocess

* cleaned up multislice preprocess

* cleaned up mixedstate preprocess

* underscore typos

* underscore typos

* huh, not how super works

* cleaned up mixed-multi slice preprocess

* cleaned up overlap tomography preprocess

* removing redundant tune func from parallax

* moved single-slice forward and adjoint to methods.py

* added necessary multi-slice forward and adjoint methods

* added necessary mixed-state forward and adjoint methods

* added necessary mixed-state-multi-slce forward and adjoint methods

* removed redundant forward and adjoint methods from overlap tomo

* cleaned up single-slice reconstruct

* cleaned up multi-slice reconstruct

* cleaned up mixed-state reconstruct

* cleaned up mixed-state multi-slice reconstruct

* cleaned up overlap tomo reconstruct, different probes per tilt

* moved show_transmitted probe

* cleaned up self-consistency viz

* oops, forgot to delete duplicate code

* cleaned up position correction - is mixed state correct?

* more natural location for 3D function

* Bump tj-actions/changed-files from 39 to 41 in /.github/workflows

Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 39 to 41.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](tj-actions/changed-files@v39...v41)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* added and cleaned up total position update functionality back in

* modernized probe position correction viz

* starting viz overhaul

* remove redundant figax viz functions

* added visualize_last functionality

* visualize_all for single-slice

* visualize_all for all

* small np cp bugs

* some figsize defaults

* histogram scaling for all

* added virtual detector mask

* adding dependabot.yml

* update to check_config workflow

* black

* adding dp_mask argument

* renamed to ptycho-tomo, started magnetic refactoring

* arina reader bug fix

* reconstruct functionality for iterative magnetic

* splitting up constraints

* bumping python version to 3.10

* correctly handling collective updates constraints

* Bugfix for forced scan sampling

Correctly set scan units when `force_scan_sampling` is used

* finished with magnetic ptycho

* phase unwrapping bugfixes

* Update py4DSTEM/io/filereaders/read_arina.py

Co-authored-by: Steve Zeltmann <[email protected]>

* Update py4DSTEM/process/phase/utils.py

Co-authored-by: Steve Zeltmann <[email protected]>

* Update py4DSTEM/process/phase/utils.py

Co-authored-by: Steve Zeltmann <[email protected]>

* Update py4DSTEM/process/phase/utils.py

Co-authored-by: Steve Zeltmann <[email protected]>

* Update py4DSTEM/process/phase/utils.py

Co-authored-by: Steve Zeltmann <[email protected]>

* better support for multiple measurements probe properties

* broadcasting polar coordinates

* Update py4DSTEM/process/phase/utils.py

Co-authored-by: Steve Zeltmann <[email protected]>

* Update py4DSTEM/process/phase/utils.py

Co-authored-by: Steve Zeltmann <[email protected]>

* docstrings

* vectorized_fourier_resample docstrings

* generalized show_fourier_probe, added general show_probe, added intensity reporting

* visual tweaks

* removed leading iterative_ from file names and trailing Reconstruction from class names

* typo

* FFT plotting improvements

* Revert "FFT plotting improvements"

This reverts commit 6669195.

* Revert "typo"

This reverts commit 5990942.

* Revert "removed leading iterative_ from file names and trailing Reconstruction from class names"

This reverts commit 9114df5.

* removed leading iterative_ from file names and trailing Reconstruction from class names

* typo

* FFT plotting improvements

* switched divergence field functions to be periodic

* magnetic ptycho-tomo preprocessing

* magnetic ptycho tomo constraints

* magnetic ptycho tomo works

* improved 3D visualizations

* ragged list partitions support for complex plotting

* added detector plane resampling

* cleaned up cupyx.scipy imports

* added storage support for singleslice. other classes likely broken, will fix tomorrow

* actually enable overwriting device

* fixing single-slice projection sets bugs with storage refactor

* cleaning up multislice for device. changed propagator tilt convention to negative mrad

* added storage support to multislice

* adding mixed-state storage support

* added storage to mixed-multislice

* attrs copying cleanup

* added storage to dpc

* more dpc viz tweaks

* adding vectorized flag to CoM

* dp_mask can be None, dub

* adding batch size in single-slice preprocess

* adding to dpc, multislice, mixedstate, multislice-mixedstate

* adding some basic device cleanup to parallax, no storage yer

* magnetic ptycho preprocess storage support

* added full storage support for magnetic ptycho

* added storage to ptycho tomo

* added storage support to magnetic ptycho-tomo

* transferring parallax bug Steph found in phase_contrast

* Update CONTRIBUTORS.md

* Update CONTRIBUTORS.md

* Update CONTRIBUTORS.md

* Update CONTRIBUTORS.md

* Update CONTRIBUTORS.md

* tweaks to clear_fft_cache

* Create CODE_OF_CONDUCT.md

This is a suggested template that seems widely used and seems reasonable.

* adding FFT-based DCT-II implementations, fixing cupy10.6 bug

* small numpy bug

* cleaned up cupy 12 feature guarding using try-except

* restored scikit functionality

* scikit-image by default, poisson as flag

* various fixes discovered while making testing notebook

* position update bug fix

* syntax update for bug fix

* complex plotting grid search

* multislice grid search plotting

* read/write bug fix

* show hanning window fix

* typo fix

* mixedstate probe fourier constraint bug fix

* constrain first aperture only

* parallax verbosity to True

* ms butterworth bug

* silly George

* cleaning up warnings

* simplifying warnings, restructuring single  slice regularization flags

* one more read write bug fix

* more flags more problems: multislice, mixed state, and mixed-multislice

* dpc

* mistake in multislice

* flags to magnetic ptycho

* ptycho tomo flags

* magnetic ptycho tomo flags

* stricter flags

* perhaps i forgot an underscore

* small parallax change

* small read-write changes

* removing switch_obj_iter

* remore switch_iter from all classes

* show_fft bug

* Bump tj-actions/changed-files from 41 to 42

Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 41 to 42.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](tj-actions/changed-files@v41...v42)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump github/super-linter from 4 to 5

Bumps [github/super-linter](https://github.com/github/super-linter) from 4 to 5.
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](github/super-linter@v4...v5)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump actions/checkout from 3 to 4

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump actions/setup-python from 2 to 5

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v2...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* minor fixes

* Friedel origin finder, various FEM tools (#607)

* bug fix

* Revert "bug fix"

This reverts commit cbce25c.

* num_probes_fit_aberrations

* flip 180 option for read arina

* ptycho positions offset

* remove 180 flip

* median_filter_masked_pixels

* save polar aberrations instead

* read-write compatibility

* uncertainty viz bug

* adding force_com_measured functionality to ptycho

* clean up force_com_measured

* adding DP normalization progress bar

* moving fov_mask calc to as needed

* adding detector_fourier_mask

* Auto center finding works!

* Adding center finding without a mask

* Adding plot range to show_origin_fit, fixing bug

* Adding local mean / variance functions for FEM

* Adding symmetry analysis and plotting

* Fix divide by zero in correlation origin finding function

* bug fix for filtering

* adding initial commit for friedel correlation origin finder

* Correlation working, but mask still buggy

* Fixing the masked CC

* Simplifying the expression

* cleaning up - still need subpixel shifts

* Update origin fitting visualization

* adding device arg to upsample function

* First attempt to add Friedel origin finding to ptycho

GPU not yet working

* Adding GPU implementation warning

* parabolic subpixel fitting

* minor updates

* Going back to dev version of phase contrast

* Changing np to xp for GPU compatibility

* Fixing xp = np device options

* Revering phase contrast options back to dev

* Cleaning up code, fixing GPU support

* black formatting

* black updates

* Adding annular symmetry plotting function

* black formatting

* cleaning typos and dead code and such

* Update py4DSTEM/process/polar/polar_analysis.py

Co-authored-by: Steve Zeltmann <[email protected]>

---------

Co-authored-by: Stephanie Ribet <[email protected]>
Co-authored-by: Georgios Varnavides <[email protected]>
Co-authored-by: gvarnavi <[email protected]>
Co-authored-by: SE Zeltmann <[email protected]>
Co-authored-by: Steve Zeltmann <[email protected]>

* Release memory after Bayesian optimization (#599)

* do not retain optimization function after finished running, to release memory

* update comment

* set clear_fft_cache off in optimizer defaults

* Update parameter_optimize.py

* format with black 24.1.1

* Update parameter_optimize.py

* format with black

* Added phase_contrast warning in README (#608)

* Adding error for orix install requirements

* ACOM .ang file writer fixes

* format with black

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: alex-rakowski <[email protected]>
Co-authored-by: Georgios Varnavides <[email protected]>
Co-authored-by: bsavitzky <[email protected]>
Co-authored-by: Steven Zeltmann <[email protected]>
Co-authored-by: Steve Zeltmann <[email protected]>
Co-authored-by: Stephanie Ribet <[email protected]>
Co-authored-by: SE Zeltmann <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: gvarnavi <[email protected]>
  • Loading branch information
10 people authored Mar 21, 2024
1 parent 5bd35b7 commit bc8f333
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions py4DSTEM/process/diffraction/crystal_ACOM.py
Original file line number Diff line number Diff line change
Expand Up @@ -2192,6 +2192,7 @@ def save_ang_file(
pixel_units="px",
transpose_xy=True,
flip_x=False,
flip_y=False,
):
"""
This function outputs an ascii text file in the .ang format, containing
Expand All @@ -2211,8 +2212,10 @@ def save_ang_file(
nothing
"""

from orix.io.plugins.ang import file_writer
try:
from orix.io.plugins.ang import file_writer
except ImportError:
raise Exception("orix failed to import; try pip installing separately")

xmap = self.orientation_map_to_orix_CrystalMap(
orientation_map,
Expand All @@ -2222,6 +2225,7 @@ def save_ang_file(
return_color_key=False,
transpose_xy=transpose_xy,
flip_x=flip_x,
flip_y=flip_y,
)

file_writer(file_name, xmap)
Expand All @@ -2235,6 +2239,7 @@ def orientation_map_to_orix_CrystalMap(
pixel_units="px",
transpose_xy=True,
flip_x=False,
flip_y=False,
return_color_key=False,
):
try:
Expand All @@ -2260,12 +2265,20 @@ def orientation_map_to_orix_CrystalMap(

import warnings

# Get orientation matrices
# Get orientation matrices and correlation signal (will be used as iq and ci)
orientation_matrices = orientation_map.matrix[:, :, ind_orientation].copy()
corr_values = orientation_map.corr[:, :, ind_orientation].copy()

# Check for transpose
if transpose_xy:
orientation_matrices = np.transpose(orientation_matrices, (1, 0, 2, 3))
corr_values = np.transpose(corr_values, (1, 0))
if flip_x:
orientation_matrices = np.flip(orientation_matrices, axis=0)
corr_values = np.flip(corr_values, axis=0)
if flip_y:
orientation_matrices = np.flip(orientation_matrices, axis=1)
corr_values = np.flip(corr_values, axis=1)

# Convert the orientation matrices into Euler angles
# suppress Gimbal lock warnings
Expand Down Expand Up @@ -2327,8 +2340,8 @@ def fxn():
y=coords["y"],
phase_list=PhaseList(phase),
prop={
"iq": orientation_map.corr[:, :, ind_orientation].ravel(),
"ci": orientation_map.corr[:, :, ind_orientation].ravel(),
"iq": corr_values.ravel(),
"ci": corr_values.ravel(),
},
scan_unit=pixel_units,
)
Expand Down

0 comments on commit bc8f333

Please sign in to comment.