Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes made to obspyIO.py and focalmechplotter.py for string equiva… #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions hashpy/io/obspyIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def inputOBSPY(hp, event):
hp.sez = _o.origin_uncertainty.confidence_ellipsoid.semi_intermediate_axis_length
if _m:
hp.qmag = _m.mag

# The index 'k' is deliberately non-Pythonic to deal with the fortran
# subroutines which need to be called and the structure of the original HASH code.
# May be able to update with a rewrite... YMMV
Expand All @@ -63,21 +63,22 @@ def inputOBSPY(hp, event):
if arrv.phase not in 'Pp':
continue

if (pick.polarity is 'positive'):
hp.p_pol[k] = 1
elif (pick.polarity is 'negative'):
hp.p_pol[k] = -1
else:
continue

if (pick.onset is 'impulsive'):
if (pick.onset == 'impulsive'):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cosmetics, but those brackets ain't necessary..

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was in Fortran mode when I did that 👎

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@megies is correct. use == to compare strings, never is.
is is a much stricter and here unwanted comparison.

hp.p_qual[k] = 0
elif (pick.onset is 'emergent'):
elif (pick.onset == 'emergent'):
hp.p_qual[k] = 1
elif (pick.onset is 'questionable'):
elif (pick.onset == 'questionable'):
hp.p_qual[k] = 1
else:
hp.p_qual[k] = 0

if (pick.polarity == 'positive'):
hp.p_pol[k] = 1
elif (pick.polarity == 'negative'):
hp.p_pol[k] = -1
else:
continue


# polarity check in original code... doesn't work here
#hp.p_pol[k] = hp.p_pol[k] * hp.spol
Expand Down
8 changes: 5 additions & 3 deletions hashpy/plotting/focalmechplotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def plot_on_stereonet(self, axis=None, fm=None):
'markeredgewidth' : 2,
}
for ind, a in enumerate(self._orig.arrivals):
plotit = True
p = a.pick_id.getReferredObject()
# Calculate strike azi from direct (dip-pointing) azi
azi = a.azimuth - 90.
Expand All @@ -122,16 +123,17 @@ def plot_on_stereonet(self, axis=None, fm=None):
elif 90. <= a.takeoff_angle <= 180.:
toa = 270. - a.takeoff_angle # project upward angles
else:
plotit = False
raise ValueError("Takeoff angle ({0}) must be in [0, 180]".format(a.azimuth))

if p.polarity is 'positive':
if p.polarity == 'positive' and plotit == True:
#plot_specs.update({'markeredgecolor' : 'black', 'markerfacecolor' : 'red' })
h += ax.rake(azi, toa, 90, 'o', markeredgecolor='black', markerfacecolor='red', **plot_specs)
if p.polarity is 'negative':
if p.polarity == 'negative' and plotit == True:
#plot_specs.update({'markeredgecolor' : 'blue', 'markerfacecolor' : 'white' })
h += ax.rake(azi, toa, 90, 'o', markeredgecolor='blue', markerfacecolor='white', **plot_specs)
index.append(ind)
if True:
if plotit:
h_text = ax.rake(azi, toa+5, 90, marker='$ {0}$'.format(p.waveform_id.station_code), color='black',markersize=20)

for comm in self.focm.comments:
Expand Down