Browse Source

fix log magnitude scaling options - automated and manual

main
gesape 2 months ago
parent
commit
a0a5b15ef5
  1. 27
      src/clustering.py
  2. 2
      src/config.py

27
src/clustering.py

@ -178,12 +178,13 @@ def catalog_output(catalog, cluster_labels, outfile, no_dist_evs=False):
def mag_scale_log(mag, log_tuple, m_max, m_min, method='manual'):
if method == 'manual':
s_max = 24
factor = s_max/(log_tuple[0]**m_max)
markersize = log_tuple[0]**mag*factor
#s_max = 24
#factor = s_max/(log_factor**m_max)
#markersize = log_factor**mag*factor
markersize = (log_tuple[0]**mag)*log_tuple[1]
elif method == 'auto':
log_tuple = get_mag_tuple_auto(mag_min,mag_max)
log_tuple = get_mag_tuple_auto(m_min,m_max)
markersize = (log_tuple[0]**mag)*log_tuple[1]
return markersize
@ -226,11 +227,11 @@ def map_plot(catalog, method, cc_cnf, cl_cnf, fn=False, mark_nodata=False, work_
mag_min = num.min(mags)
mag_max = num.max(mags)
if cl_cnf.mag_scale_log != (0,0):
if cl_cnf.mag_scale_log:
log_tuple = cl_cnf.mag_scale_log
scale_meth = 'manual'
else:
log_tuple = get_mag_scale(mag_min,mag_max)
log_tuple = None
scale_meth = 'auto'
for ev in catalog:
@ -339,7 +340,7 @@ def map_plot(catalog, method, cc_cnf, cl_cnf, fn=False, mark_nodata=False, work_
* pmt.magnitude_to_moment(ev.magnitude)
m6 = pmt.to6(mt)
data = (ev.lon, ev.lat, 10) + tuple(m6) + (1,0,0)
s = 'd%sp' % mag_scale_log(ev.magnitude, log_tuple,mag_max,mag_min,method=scale_meth)
s = 'd%sp' % mag_scale_log(ev.magnitude, log_tuple, mag_max,mag_min, method=scale_meth)
if not cc_cnf and not mark_nodata:
if ev.extras['origins'][0] == True:
@ -391,7 +392,7 @@ def map_plot(catalog, method, cc_cnf, cl_cnf, fn=False, mark_nodata=False, work_
cluster_color_dict[cl]=g_col
lonsnomt = [ev.lon for ev in pl_ev]
latsnomt = [ev.lat for ev in pl_ev]
sizenomt = [mag_scale_log(ev.magnitude, log_tuple,mag_max,mag_min,method=scale_meth) for ev in pl_ev]
sizenomt = [mag_scale_log(ev.magnitude, log_tuple, mag_max, mag_min, method=scale_meth) for ev in pl_ev]
m.gmt.psxy(in_columns=(lonsnomt, latsnomt, sizenomt),
G=g_col, S=symbol, W='0.5p,%s' % g_col,
*m.jxyr)
@ -2461,11 +2462,11 @@ def map_plot_freqmerge(catalog, method, cl_cnf):
mag_min = num.min(mags)
mag_max = num.max(mags)
if cl_cnf.mag_scale_log != (0,0):
if cl_cnf.mag_scale_log:
log_tuple = cl_cnf.mag_scale_log
scale_meth = 'manual'
else:
log_tuple = get_mag_scale(mag_min,mag_max)
log_tuple = None # get_mag_scale(mag_min,mag_max)
scale_meth = 'auto'
for ev in catalog:
@ -2609,16 +2610,16 @@ def map_plot_freqmerge(catalog, method, cl_cnf):
for i_ma, ma in enumerate(num.arange(lower,upper, step)):
if i_ma == 0:
leg = 'S 0.1i c %sp black 1p 0.3i M %.1f\n' % (mag_scale_log(ma, log_tuplemag_max, mag_min,method=scale_meth),ma)
leg = 'S 0.1i c %sp black 1p 0.3i M %.1f\n' % (mag_scale_log(ma, log_tuple, mag_max, mag_min,method=scale_meth),ma)
else:
leg = leg + 'S 0.1i c %sp black 1p 0.3i M %.1f\n' % (mag_scale_log(ma, log_tuplemag_max, mag_min,method=scale_meth),ma)
leg = leg + 'S 0.1i c %sp black 1p 0.3i M %.1f\n' % (mag_scale_log(ma, log_tuple, mag_max, mag_min,method=scale_meth),ma)
leg = leg + 'D 0 1p\n'
for key in sorted(cluster_color_dict.keys()):
item = cluster_color_dict[key]
leg = leg + 'S 0.1i c %sp %s - 0.3i %s\n' % (mag_scale_log(num.median(mags), log_tuplemag_max, mag_min,method=scale_meth), item, key)
leg = leg + 'S 0.1i c %sp %s - 0.3i %s\n' % (mag_scale_log(num.median(mags), log_tuple, mag_max, mag_min,method=scale_meth), item, key)
with open('leg.txt', 'w') as f:
f.write(leg)

2
src/config.py

@ -86,7 +86,7 @@ class clustering_settings(Object):
export_stacked_traces = Bool.T(default=False)
prepare_for_grond = Bool.T(default=False)
debug_stacking = Bool.T(default=False)
mag_scale_log = Tuple.T(default=(1.75, 1.8))
mag_scale_log = Tuple.T(optional=True)
t_buffer_wfplot = Float.T(default=20.)
class merge_cat_settings(Object):

Loading…
Cancel
Save