Question: python 3 Write lambda functions to replace dir2cart() and cart2dir(). Call them dir_cart and cart_dir You measured a bedding plane with an azimuth of 40

python 3

  • Write lambda functions to replace dir2cart() and cart2dir(). Call them dir_cart and cart_dir
  • You measured a bedding plane with an azimuth of 40 and a plunge of 62. Use your function dir_cart() to convert the coordinates to cartesian coordinates.
  • Use your function cart_dir() to convert the cartesian coordinates back to polar coordinates
  • test your functions by calling the dir2cart() and cart2dir() funtions in the lecture.
  • modify cart2dir() to round to the nearest decimal
def dir2cart(Dir): """ converts polar directions to cartesian coordinates Inputs: Dir[Azimuth,Plunge]: directions in degreess Output: [X,Y,Z]: cartesian coordinates """ Az,Pl=np.radians(Dir[0]),np.radians(Dir[1]) return [np.cos(Az)*np.cos(Pl),np.sin(Az)*np.cos(Pl),np.sin(Pl)] def cart2dir(X): """ converts cartesian coordinates to polar azimuth and plunge Inputs: X: list of X,Y,Z coordinates Ouputs: [Az,Pl]: list of polar coordinates in degrees """ R=np.sqrt(X[0]**2+X[1]**2+X[2]**2) # calculate resultant vector length Az=np.degrees(np.arctan2(X[1],X[0]))%360. # calculate declination taking care of correct quadrants (arctan2) and making modulo 360. Pl=np.degrees(np.arcsin(X[2]/R)) # calculate inclination (converting to degrees) # return [Az,Pl]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!