Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- _pi=$(echo "scale=12;4*a(1)"|bc -l)
- _d1=0
- _at=0
- _tr=$_at+$_d1
- _t1=0
- _angle=0
- _pw90=1
- _pw=0
- clear;echo
- function pwToAngle {
- echo "scale=2;90*$1/$_pw90"|bc -l
- }
- function AngleTopw {
- echo "scale=2;$_pw90*$1/90"|bc -l
- }
- echo " Ernst Angle Calculator"
- echo "------------------------"
- echo " 1. Angle"
- echo " 2. T1"
- echo " 3. Recycle Delay (d1)"
- echo " 4. Acq. Time (at)"
- echo " 5. d1 + at"
- echo
- read -p "Solve for?: " response
- case "$response" in
- 1) read -p "Enter at (s): " _at
- read -p "Enter d1 (s): " _d1
- read -p "Enter T1 (s): " _t1
- read -p "Enter pw90 (us): " _pw90
- _ans=$(echo "e(-($_at+$_d1)/$_t1)"|bc -l)
- _ans=$(echo "a(sqrt(1-$_ans^2)/$_ans)"|bc -l)
- _ans=$(echo "$_ans*180/$_pi"|bc -l)
- _pw=$(AngleTopw $_ans)
- echo;echo "Angle = $_ans degrees ($_pw microseconds)";echo
- ;;
- 2) read -p "Enter angle in degrees (or 's' for pw): " _angle
- if [ "$_angle" == "s" ]; then
- read -p "Enter pw (us): " _angle
- read -p "Enter pw90 (us): " _pw90
- _angle=$(pwToAngle $_angle)
- fi
- read -p "Enter d1 (s): " _d1
- read -p "Enter at (s): " _at
- _angleR=$(echo "$_angle*$_pi/180"|bc -l)
- _ans=$(echo "-($_at+$_d1)/l(c($_angleR))"|bc -l)
- echo;echo "T1 = $_ans seconds";echo
- ;;
- 3) read -p "Enter angle in degrees (or 's' for pw): " _angle
- if [ "$_angle" == "s" ]; then
- read -p "Enter pw (us): " _angle
- read -p "Enter pw90 (us): " _pw90
- _angle=$(pwToAngle $_angle)
- fi
- read -p "Enter at (s): " _at
- read -p "Enter t1 (s): " _t1
- _angleR=$(echo "$_angle*$_pi/180"|bc -l)
- _ans=$(echo "(-l(c($_angleR))*$_t1)-$_at"|bc -l)
- echo;echo "d1 = $_ans seconds";echo
- ;;
- 4) read -p "Enter angle in degrees (or 's' for pw): " _angle
- if [ "$_angle" == "s" ]; then
- read -p "Enter pw (us): " _angle
- read -p "Enter pw90 (us): " _pw90
- _angle=$(pwToAngle $_angle)
- fi
- read -p "Enter d1 (s): " _d1
- read -p "Enter t1 (s): " _t1
- _angleR=$(echo "$_angle*$_pi/180"|bc -l)
- _ans=$(echo "(-l(c($_angleR))*$_t1)-$_d1"|bc -l)
- echo;echo "at = $_ans seconds";echo
- ;;
- 5) read -p "Enter angle in degrees (or 's' for pw): " _angle
- if [ "$_angle" == "s" ]; then
- read -p "Enter pw (us): " _angle
- read -p "Enter pw90 (us): " _pw90
- _angle=$(pwToAngle $_angle)
- fi
- read -p "Enter t1 (s): " _t1
- _angleR=$(echo "$_angle*$_pi/180"|bc -l)
- _ans=$(echo "(-l(c($_angleR))*$_t1)"|bc -l)
- echo;echo "at+d1 = $_ans seconds";echo
- ;;
- esac
Advertisement
Comments
-
- Simple Nuclear Magnetic Resonance Ernst angle calculator for bash. In addition to solving for angle, it can solve for any of the variables in the equation, which can be useful for verifying experimental conditions.
Add Comment
Please, Sign In to add comment
Advertisement