@@ -68,7 +68,7 @@ def detect_plates_vzcheck(step, vz_thres_ratio=0):
6868 return limits , dvphi , vphi_surf
6969
7070
71- def detect_plates (step , vrms_surface , fids , time ):
71+ def detect_plates (step , vrms_surface ):
7272 """Detect plates using derivative of horizontal velocity."""
7373 vphi = step .fields ['v2' ].values [0 , :, :, 0 ]
7474 ph_coord = step .geom .p_centers
@@ -89,7 +89,7 @@ def detect_plates(step, vrms_surface, fids, time):
8989 argless_dv = argrelextrema (
9090 pom2 , np .less , order = trench_span , mode = 'wrap' )[0 ]
9191 trench = ph_coord [argless_dv ]
92- velocity_trench = vph2 [argless_dv , indsurf ]
92+ v_trenches = vph2 [argless_dv , indsurf ]
9393
9494 # finding ridges
9595 pom2 = np .copy (dvph2 )
@@ -108,30 +108,9 @@ def detect_plates(step, vrms_surface, fids, time):
108108 if mdistance < 0.016 :
109109 argdel .append (i )
110110 if argdel :
111- print ('deleting from ridge' , trench , ridge [argdel ])
112111 ridge = np .delete (ridge , np .array (argdel ))
113112
114- if 'age' in step .fields :
115- agefld = step .fields ['age' ].values [0 , :, :, 0 ]
116- age_surface = np .ma .masked_where (agefld [:, indsurf ] < 0.00001 ,
117- agefld [:, indsurf ])
118- age_surface_dim = age_surface * vrms_surface * \
119- conf .scaling .ttransit / conf .scaling .yearins / 1.e6
120- agetrench = age_surface_dim [argless_dv ] # age at the trench
121- else :
122- agetrench = np .zeros (len (argless_dv ))
123-
124- # writing the output into a file, all time steps are in one file
125- for itrench in np .arange (len (trench )):
126- fids [0 ].write ("%7.0f %11.7f %10.6f %9.2f %9.2f \n " % (
127- step .isnap ,
128- step .time ,
129- trench [itrench ],
130- velocity_trench [itrench ],
131- agetrench [itrench ]
132- ))
133-
134- return trench , ridge , agetrench
113+ return trench , ridge , argless_dv , v_trenches
135114
136115
137116def plot_plate_limits (axis , ridges , trenches ):
@@ -361,8 +340,29 @@ def main_plates(sdat):
361340
362341 time = step .time * vrms_surface * \
363342 conf .scaling .ttransit / conf .scaling .yearins / 1.e6
364- trenches , ridges , agetrenches = \
365- detect_plates (step , vrms_surface , fids , time )
343+ trenches , ridges , itrenches , v_trenches = \
344+ detect_plates (step , vrms_surface )
345+
346+ if 'age' in step .fields :
347+ agefld = step .fields ['age' ].values [0 , :, :, 0 ]
348+ age_surface = np .ma .masked_where (agefld [:, isurf ] < 1.e-5 ,
349+ agefld [:, isurf ])
350+ age_surface_dim = age_surface * vrms_surface * \
351+ conf .scaling .ttransit / conf .scaling .yearins / 1.e6
352+ agetrenches = age_surface_dim [itrenches ] # age at the trench
353+ else :
354+ agetrenches = np .zeros (len (itrenches ))
355+
356+ # writing the output into a file, all time steps are in one file
357+ for itrench in range (len (trenches )):
358+ fids [0 ].write ("%7.0f %11.7f %10.6f %9.2f %9.2f \n " % (
359+ step .isnap ,
360+ step .time ,
361+ trenches [itrench ],
362+ v_trenches [itrench ],
363+ agetrenches [itrench ]
364+ ))
365+
366366 _write_trench_diagnostics (step , time , trenches , agetrenches , fids )
367367
368368 plot_at_surface (step , conf .plates .plot , trenches , ridges )
0 commit comments