Skip to content

Commit

Permalink
Avoid importing from sub-submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodsf committed Jun 20, 2024
1 parent 0c61936 commit 077b49c
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 42 deletions.
4 changes: 4 additions & 0 deletions requake/catalog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
GNU General Public License v3.0 or later
(https://www.gnu.org/licenses/gpl-3.0-standalone.html)
"""
from .catalog import ( # noqa
RequakeCatalog, RequakeEvent, generate_evid,
fix_non_locatable_events, read_stored_catalog
)
from .read_catalog import read_catalog # noqa
from .print_catalog import print_catalog # noqa
4 changes: 2 additions & 2 deletions requake/catalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import numpy as np
from obspy import UTCDateTime
from ..config import config
from ..formulas.conversion import float_or_none
from ..waveforms.station_metadata import get_traceid_coords
from ..formulas import float_or_none
from ..waveforms import get_traceid_coords


class RequakeEvent():
Expand Down
3 changes: 1 addition & 2 deletions requake/catalog/print_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
(https://www.gnu.org/licenses/gpl-3.0-standalone.html)
"""
import logging
from ..config import rq_exit
from ..config import rq_exit, generic_printer
from .catalog import read_stored_catalog
from ..config.generic_printer import generic_printer
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])


Expand Down
2 changes: 1 addition & 1 deletion requake/catalog/read_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import logging
import contextlib
from ..config import config, rq_exit
from ..catalog.catalog import RequakeCatalog
from ..catalog import RequakeCatalog
from .read_catalog_from_fdsnws import read_catalog_from_fdsnws
from .read_catalog_from_quakeml import read_catalog_from_quakeml
from .read_catalog_from_csv import read_catalog_from_csv
Expand Down
5 changes: 2 additions & 3 deletions requake/catalog/read_catalog_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
import logging
import csv
from obspy import UTCDateTime
from ..formulas.conversion import float_or_none, int_or_none
from ..catalog.catalog import (
RequakeCatalog, RequakeEvent, generate_evid)
from ..formulas import float_or_none, int_or_none
from ..catalog import RequakeCatalog, RequakeEvent, generate_evid
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])


Expand Down
2 changes: 1 addition & 1 deletion requake/catalog/read_catalog_from_fdsnws.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from obspy import UTCDateTime
from obspy.clients.fdsn.header import URL_MAPPINGS
from ..config import config
from ..catalog.catalog import RequakeCatalog, RequakeEvent
from ..catalog import RequakeCatalog, RequakeEvent
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])


Expand Down
2 changes: 1 addition & 1 deletion requake/catalog/read_catalog_from_quakeml.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""
import logging
from obspy import read_events
from ..catalog.catalog import RequakeCatalog, RequakeEvent
from ..catalog import RequakeCatalog, RequakeEvent
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])


Expand Down
1 change: 1 addition & 0 deletions requake/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
(https://www.gnu.org/licenses/gpl-3.0-standalone.html)
"""
from .rq_setup import rq_exit # noqa
from .generic_printer import generic_printer # noqa
# The config object is created in config.py and needs to be populated
# when using requake from command line, this is done by the configure()
# function in rq_setup.py
Expand Down
5 changes: 5 additions & 0 deletions requake/families/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@
from .print_families import print_families # noqa
from .flag_family import flag_family # noqa
from .build_templates import build_templates # noqa
from .families import ( # noqa
read_families, read_selected_families,
get_family_aligned_waveforms_and_template,
FamilyNotFoundError
)
9 changes: 3 additions & 6 deletions requake/families/families.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
from obspy import UTCDateTime, Stream
from obspy.geodetics import gps2dist_azimuth
from ..config import config
from ..formulas.conversion import float_or_none
from ..catalog.catalog import RequakeEvent
from ..waveforms.waveforms import (
get_event_waveform, align_traces, build_template)
from ..formulas.slip import mag_to_slip_in_cm
from ..formulas.moment import mag_to_moment
from ..formulas import float_or_none, mag_to_slip_in_cm, mag_to_moment
from ..catalog import RequakeEvent
from ..waveforms import get_event_waveform, align_traces, build_template
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])


Expand Down
4 changes: 2 additions & 2 deletions requake/families/pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import csv
from obspy import UTCDateTime
from ..config import config
from ..formulas.conversion import float_or_none
from ..catalog.catalog import RequakeEvent
from ..formulas import float_or_none
from ..catalog import RequakeEvent
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])


Expand Down
3 changes: 1 addition & 2 deletions requake/families/print_families.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
"""
import logging
import numpy as np
from ..config import generic_printer, rq_exit
from .families import FamilyNotFoundError, read_selected_families
from ..config.generic_printer import generic_printer
from ..config import rq_exit
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])


Expand Down
3 changes: 1 addition & 2 deletions requake/families/print_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
(https://www.gnu.org/licenses/gpl-3.0-standalone.html)
"""
import logging
from ..config import config, rq_exit
from ..config.generic_printer import generic_printer
from ..config import config, rq_exit, generic_printer
from .pairs import read_pairs_file
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])

Expand Down
3 changes: 2 additions & 1 deletion requake/formulas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
(https://www.gnu.org/licenses/gpl-3.0-standalone.html)
"""
from .moment import mag_to_moment # noqa
from .slip import mag_to_slip_in_cm # noqa
from .slip import mag_to_slip_in_cm # noqa
from .conversion import float_or_none, int_or_none # noqa
2 changes: 1 addition & 1 deletion requake/plot/map_families.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import cartopy.feature as cfeature
from obspy.geodetics import gps2dist_azimuth
from ..config import config, rq_exit
from ..families import FamilyNotFoundError, read_selected_families
from .plot_utils import (
plot_title, hover_annotation, duration_string, family_colors, plot_colorbar
)
Expand All @@ -29,7 +30,6 @@
StamenTerrain,
WorldStreetMap
)
from ..families.families import FamilyNotFoundError, read_selected_families
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# Reduce logging level for Matplotlib to avoid DEBUG messages
mpl_logger = logging.getLogger('matplotlib')
Expand Down
4 changes: 2 additions & 2 deletions requake/plot/plot_cumulative.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
from ..config import config, rq_exit
from ..families import FamilyNotFoundError, read_selected_families
from ..formulas import mag_to_slip_in_cm, mag_to_moment
from .plot_utils import (
format_time_axis, plot_title, hover_annotation, duration_string,
family_colors, plot_colorbar
)
from ..families.families import FamilyNotFoundError, read_selected_families
from ..formulas import mag_to_slip_in_cm, mag_to_moment
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# Reduce logging level for Matplotlib to avoid DEBUG messages
mpl_logger = logging.getLogger('matplotlib')
Expand Down
7 changes: 4 additions & 3 deletions requake/plot/plot_families.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
from obspy.signal.filter import envelope
from obspy.signal.util import smooth
from ..config import config, rq_exit
from ..families.families import (
from ..families import (
FamilyNotFoundError,
read_selected_families,
get_family_aligned_waveforms_and_template)
from ..waveforms.waveforms import process_waveforms
get_family_aligned_waveforms_and_template
)
from ..waveforms import process_waveforms
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# Reduce logging level for Matplotlib to avoid DEBUG messages
mpl_logger = logging.getLogger('matplotlib')
Expand Down
5 changes: 2 additions & 3 deletions requake/plot/plot_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
import matplotlib as mpl
import matplotlib.pyplot as plt
from ..config import config, rq_exit
from ..catalog.catalog import fix_non_locatable_events, read_stored_catalog
from ..waveforms.waveforms import (
get_waveform_pair, process_waveforms, align_pair)
from ..catalog import fix_non_locatable_events, read_stored_catalog
from ..waveforms import get_waveform_pair, process_waveforms, align_pair
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# Reduce logging level for Matplotlib to avoid DEBUG messages
mpl_logger = logging.getLogger('matplotlib')
Expand Down
2 changes: 1 addition & 1 deletion requake/plot/plot_timespans.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import matplotlib.pyplot as plt
import numpy as np
from ..config import config, rq_exit
from ..families import FamilyNotFoundError, read_selected_families
from .plot_utils import (
format_time_axis, plot_title, hover_annotation, duration_string,
family_colors, plot_colorbar
)
from ..families.families import FamilyNotFoundError, read_selected_families
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# Reduce logging level for Matplotlib to avoid DEBUG messages
mpl_logger = logging.getLogger('matplotlib')
Expand Down
8 changes: 4 additions & 4 deletions requake/scan/scan_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from tqdm import tqdm
from obspy.geodetics import gps2dist_azimuth
from ..config import config, rq_exit
from ..catalog.catalog import fix_non_locatable_events, read_stored_catalog
from ..waveforms.station_metadata import NoMetadataError, MetadataMismatchError
from ..waveforms.waveforms import (
get_waveform_pair, cc_waveform_pair, NoWaveformError,
from ..catalog import fix_non_locatable_events, read_stored_catalog
from ..waveforms import (
get_waveform_pair, cc_waveform_pair,
NoWaveformError, NoMetadataError, MetadataMismatchError
)
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])

Expand Down
10 changes: 5 additions & 5 deletions requake/scan/scan_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import sys
from obspy import read
from ..config import config, rq_exit
from ..families.families import (
FamilyNotFoundError, read_families, read_selected_families)
from ..waveforms.waveforms import get_waveform, cc_waveform_pair
from ..waveforms.arrivals import get_arrivals
from ..catalog.catalog import RequakeEvent, generate_evid
from ..families import (
FamilyNotFoundError, read_families, read_selected_families
)
from ..waveforms import get_waveform, cc_waveform_pair, get_arrivals
from ..catalog import RequakeEvent, generate_evid
from .._version import get_versions
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
trace_cache = {}
Expand Down
12 changes: 12 additions & 0 deletions requake/waveforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@
GNU General Public License v3.0 or later
(https://www.gnu.org/licenses/gpl-3.0-standalone.html)
"""
from .waveforms import ( # noqa
get_waveform, get_event_waveform,
get_waveform_pair, cc_waveform_pair,
process_waveforms,
align_pair, align_traces,
build_template,
NoWaveformError
)
from .station_metadata import ( # noqa
get_traceid_coords, NoMetadataError, MetadataMismatchError
)
from .arrivals import get_arrivals # noqa

0 comments on commit 077b49c

Please sign in to comment.