# code to calculate H_r and H_theta
import numpy as np
deg2rad=np.pi/180.  # converts degrees to radians
#  write code here to calculate H_r and H_theta and convert to B_r, B_theta


# This is how you print out nice formatted numbers
# floating point variables have the syntax:  
# '%X.Yf'%(FP_variable) where X is the number of digits and Y is the 
# number of didgets after the decimal.  
# uncomment this line to print
#print 'H_r= ','%7.1f'%(H_r), 'H_theta= ', '%7.1f'%(H_theta)
#  to format integers:  use the syntax:
# '%i'%(INT_variable)
#print 'B_r = ','%i'%(B_r*1e6), 'uT' # B_r in microtesla
#print 'B_theta =','%i'%(B_theta*1e6),'uT' # B_theta in microtesla

"""
Explanation: IPython Notebook for turning in solutions to the problems in the Essentials of Paleomagnetism Textbook by L. Tauxe
Problems in Chapter 1
Problem 1:
Given that:
$$
\nabla V_m = - \bigl(
{ {\partial}\over {\partial r} }
{ {m \cos \theta} \over {4 \pi r^2}} + 
{ {1\over r} }
{ {\partial}\over {\partial \theta} }
 { { m\cos \theta}\over { 4 \pi r^2} }
 \bigr)
$$
it follows that:
Complete this text using LaTeX formatting.  see the above example.  Notice how stand alone equations  look like this: 
$$
\hbox{Type your equation here}
$$
and inline math looks like this:  $\alpha,\beta,\gamma$
End of explanation
"""


# write a function here with the form
def myfunc(B_in):  # edit this line for your own input variables!
    # do some math here to define OUTPUT_VARIABLES
    B_out=B_in*1.
    return B_out
B=42 # define your input variables here
print myfunc(B)

"""
Explanation: Problem 2a:
Some text to describe what you are doing.  (Edit this!)
End of explanation
"""


# take your program from 2a and modify it to respond to some input flag
# e.g.:
def myfunc(B_in,units):
    if units=='cgs':
        # do cgs conversion.....  
        pass
    elif units=='SI':
        # do SI conversion
        pass

"""
Explanation: Problem 2b:
End of explanation
"""


# Write code here to calculate the moment, m and print it in ZAm^2


"""
Explanation: Problem 3a:
a) This problem boils down to finding the value for ${\bf m}$ in Equation 1.8 in Chapter 1 that would give rise to a radial field of 10$\mu$T at a depth  of 2890 km (radius of the Earth minus radius of the dipole source).  
Write text here about how you solve the problem....
End of explanation
"""


# Write some code here that calculates H_r, H_theta, the total field
# in H and converted to microtesla.   Use nicely formated print statements 
# display your results.  

"""
Explanation: Problem 3b
b) To compare 10 $\mu$T with the field produced by an axial dipole of 80 ZAm$^2$, we need the second part of Equation 1.8 in the text:
Type your answer here with nice LaTeX formatting.
End of explanation
"""


