Skip to content

Commit

Permalink
formatted with black and flake 8
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Ravenell committed Apr 18, 2022
1 parent 98017da commit bbfe6ec
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 34 deletions.
23 changes: 16 additions & 7 deletions libcomcat/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from urllib.parse import urlparse
from collections import OrderedDict
import re
from enum import Enum
import time
import logging

Expand Down Expand Up @@ -46,7 +45,13 @@


def _get_moment_tensor_info(tensor, get_angles=False, get_moment_supplement=False):
"""Internal - gather up tensor components and focal mechanism angles."""
"""Internal - gather up tensor components and focal mechanism angles.
Args:
tensor:
get_angles(bool):
get_moment_supplement(bool):
"""
msource = tensor["eventsource"]
if tensor.hasProperty("derived-magnitude-type"):
msource += "_" + tensor["derived-magnitude-type"]
Expand Down Expand Up @@ -95,7 +100,11 @@ def _get_moment_tensor_info(tensor, get_angles=False, get_moment_supplement=Fals


def _get_focal_mechanism_info(focal):
"""Internal - gather up focal mechanism angles."""
"""Internal - gather up focal mechanism angles.
Args:
focal():
"""
msource = focal["eventsource"]
eventid = msource + focal["eventsourcecode"]
edict = OrderedDict()
Expand Down Expand Up @@ -195,7 +204,7 @@ def time(self):
"""Authoritative origin time.
Returns:
datetime: Authoritative origin time.
dt (datetime): Authoritative origin time.
"""
time_in_msec = self._jdict["properties"]["time"]
time_in_sec = time_in_msec // 1000
Expand Down Expand Up @@ -374,7 +383,7 @@ def __init__(self, url):
response = requests.get(url, timeout=TIMEOUT, headers=HEADERS)
self._jdict = response.json()
self._actual_url = url
except requests.exceptions.ReadTimeout as rt:
except requests.exceptions.ReadTimeout:
try:
response = requests.get(url, timeout=TIMEOUT, headers=HEADERS)
self._jdict = response.json()
Expand Down Expand Up @@ -576,7 +585,7 @@ def toDict(
extracted (when available.)
get_focals (str): String option of 'none', 'preferred', or 'all'.
Returns:
dict: OrderedDict with the same fields as returned by
edict: OrderedDict with the same fields as returned by
SummaryEvent.toDict(), *preferred* moment tensor and focal
mechanism data. If all magnitudes are requested, then
those will be returned as well. Generally speaking, the
Expand Down Expand Up @@ -961,7 +970,7 @@ def getContent(self, regexp, filename):
regexp (str): Regular expression which should match one of the
content files
in the Product.
filename (str): Filename to which content should be downloaded.
filename (str): Filename to which content should be downloaded.
Returns:
str: The URL from which the content was downloaded.
Raises:
Expand Down
17 changes: 0 additions & 17 deletions libcomcat/dataframes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import json
from io import StringIO
from datetime import datetime, timedelta
import socket
import logging

# third party imports
Expand All @@ -15,13 +14,10 @@
from scipy.special import erfcinv
from obspy.geodetics.base import gps2dist_azimuth
from impactutils.mapping.compass import get_compass_dir_azimuth
from obspy.imaging.beachball import aux_plane, mt2plane, MomentTensor

# local imports
from libcomcat.search import get_event_by_id
from libcomcat import search
from libcomcat.exceptions import (
ConnectionError,
ParsingError,
ProductNotFoundError,
ProductNotSpecifiedError,
Expand Down Expand Up @@ -1645,19 +1641,6 @@ def _describe_moment_tensor(event, product):
strike = fm.nodal_planes.nodal_plane_1.strike
dip = fm.nodal_planes.nodal_plane_1.dip
rake = fm.nodal_planes.nodal_plane_1.rake
else:
if mt.tensor is not None:
tensor = MomentTensor(
mt.tensor.m_rr,
mt.tensor.m_tt,
mt.tensor.m_pp,
mt.tensor.m_rt,
mt.tensor.m_rp,
mt.tensor.m_tp,
1,
)
np1 = mt2plane(tensor)
strike, dip, rake = np1.strike, np1.dip, np1.rake
if np.isnan(derived_mag):
derived_mag = evt.magnitudes[0].mag
if np.isnan(derived_depth):
Expand Down
3 changes: 1 addition & 2 deletions libcomcat/logging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import logging.config
import sys

LEVELDICT = {'debug': logging.DEBUG,
'info': logging.INFO,
Expand All @@ -20,7 +19,7 @@ def setup_logger(logfile, level='info'):
used if args is None).
Args:
args (argparse):
logfile (str):
Must contain logging options in gmprocess.args.add_shared_args.
level (str):
String indicating logging level; either 'info', 'debug', or
Expand Down
14 changes: 8 additions & 6 deletions libcomcat/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,20 @@ def get_event_by_id(
Args:
eventid (str): Select a specific event by ID; event identifiers are
data center specific.
eventid (str):
Select a specific event by ID; event identifiers are data center specific.
catalog (str):
Limit to events from a specified catalog.
includesuperseded (bool):
Specify if superseded products should be included. This also
includes all deleted products, and is mutually exclusive to the
includedeleted parameter.
includedeleted (bool): Specify if deleted products should be incuded.
scenario (bool): Specify if the event ID being searched is a scenario.
host (str): Replace default ComCat host (earthquake.usgs.gov) with a
custom host.
includedeleted (bool):
Specify if deleted products should be incuded.
scenario (bool):
Specify if the event ID being searched is a scenario.
host (str):
Replace default ComCat host (earthquake.usgs.gov) with a custom host.
Returns: DetailEvent object.
"""
# getting the inputargs must be the first line of the method!
Expand Down
2 changes: 0 additions & 2 deletions libcomcat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
from xml.dom import minidom
import os.path
import math
import string
from functools import partial
import argparse

# third party imports
import pandas as pd
from shapely.geometry import shape as sShape, Point, MultiPolygon
import fiona
from obspy.clients.fdsn import Client
from impactutils.time.ancient_time import HistoricTime
from openpyxl import load_workbook
import pkg_resources
Expand Down

0 comments on commit bbfe6ec

Please sign in to comment.