Skip to content

Instantly share code, notes, and snippets.

@hmparanjape
hmparanjape / misc_ge_scripts.sh
Last active August 28, 2015 18:33
Scripts for Manipulation and Analysis of High Energy Diffraction Images (GE2 files)
# Miscellaneous Diffraction Image Processing Commands
# This file defines aliases for several common image processing
# functions for GE2 diffraction images. This uses ImageMagick
# program, which is typically available on all Linux and Mac
# systems - http://www.imagemagick.org/script/index.php
# USAGE:
# Copy the contents of this file to the bottom of ~/.bashrc
# Run from terminal: source ~/.bashrc
# After this, following commands should be available
# 1. Convert TIFF to GE. Saves input.ge2
@hmparanjape
hmparanjape / moving_diffraction_patterns.m
Created August 10, 2015 01:14
A MATLAB script to create 2D line patterns inspired by far-field high energy x-ray diffraction.
%% Moving diffraction patterns
% A MATLAB-based program to generate high energy x-ray diffraction inspired
% line art.
%
%% USAGE
% Enter various parameters in the INPUT section. The meaning of each
% parameter is described below. Then run this script. It will produce a
% plot with the line patterns.
%
% The basic concept behind the pattern generation is this -
# Display files numbers from an ff directory
# Add this function to ~/.bashrc
function show_ff_data() {
# Find all directories with name ff and loop over them
find "$@" -not -empty -name "ff" -print | while read f; do
# Show directory name
echo "$f"
# Get size of all contents in the directory (in bytes)
tot_byte_size=$(du -b "$f")
# By default du prints the folder name too. Strip that.
analysis_name: RUBY_SWEEP_0 # defaults to analysis
## working directory defaults to current working directory
## all relative paths specified herein are assumed to be in the working_dir
## any files not in working_dir should be specified with an absolute path
#working_dir:
multiprocessing: 1 # "all", or "half", or -1 means all but one, defaults to -1
material:
analysis_name: NiTi_9 # defaults to analysis
multiprocessing: -1 # "all", or "half", or -1 means all but one, defaults to -1
material:
definitions: material_niti
active: NiTi
image_series:
file:
@hmparanjape
hmparanjape / movie_from_image_sequence.sh
Created July 9, 2015 20:08
Make MP4 movie from a PNG image sequence
#!/bin/bash
# Create an MP4 movie from the image sequence.
# Specify
# -framerate N = frames/sec
# -i FILENAMES = image file path and names. %04d says that the numbering for images is fixed width (width = 4) and zeros are used for padding
ffmpeg -framerate 11 -i image_directory/image_stem_%04d.png -c:v libx264 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" movie_name.mp4
# Ideally this should play well on OS X, Windows and Linux. Uploads to Youtube.
@hmparanjape
hmparanjape / DIC_2d_aggregate_strain_force_data.m
Created July 7, 2015 22:02
Aggregate and visualize load-strain data from spec log and NCORR DIC calculation
% Where are ncorr result files located
strain_result_mat_directory = 'X:\stebner-252-1\HEA_tension\DIC_post';
% List of ncorr result mat files in the correct order
strain_result_mat_files = { ...
'strain_2d_1', ...
'strain_2d_2' ...
};
ignore_these_many_DIC_results_at_the_start = 2;
ignore_these_many_DIC_results_at_the_end = 0;
% Aggregate the strain stuff
@hmparanjape
hmparanjape / DIC_2d_get_stress_from_spec.m
Created July 7, 2015 22:00
Obtain load/displacement data from CHESS/APS spec log file
spec_file_dir = 'X:\stebner-252-1\HEA_tension';
spec_log_file_name = 'spec.log';
DIC_image_dir = 'X:\stebner-252-1\301lss_rams2t_1\dic_post\raw_images';
cross_section_area = 1;
log_file = fopen(fullfile(spec_file_dir, spec_log_file_name), 'r');
image_file_numbers = [];
force = [];
displacement = [];
newimages = [];
@hmparanjape
hmparanjape / DIC_2d_strain_visualization.m
Created July 7, 2015 21:57
Visualize 2D strain obtained using NCORR
% 2D DIC strain analysis
%
% 1. Run handles_ncorr = ncorr
% 2. Save the data and load the MAT file
% 3. Run this
%
num_of_dic_images = numel(current_save);
%
% exx = 2D distribution of xx strain component in the ROI
exx = cell(num_of_dic_images,1);