From 7901e5dd7291308f0ebfd65f017624a3e0964d9a Mon Sep 17 00:00:00 2001 From: tlecocq Date: Mon, 25 Nov 2024 11:29:09 +0100 Subject: [PATCH] cleaning and doc --- .gitignore | 1 + msnoise/api.py | 32 ++++++++++++++++---------------- msnoise/preprocessing.py | 8 ++++---- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 9721d7ba..63ee6fd9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist msnoise.egg-info /.idea /msnoise/RELEASE-VERSION +/data/ diff --git a/msnoise/api.py b/msnoise/api.py index 5d5e7499..cdf4ee87 100644 --- a/msnoise/api.py +++ b/msnoise/api.py @@ -1163,9 +1163,9 @@ def add_corr(session, station1, station2, filterid, date, time, duration, :param session: A :class:`~sqlalchemy.orm.session.Session` object, as obtained by :func:`connect` :type station1: str - :param station1: The name of station 1 (formatted NET.STA) + :param station1: The name of station 1 (formatted NET.STA.LOC) :type station2: str - :param station2: The name of station 2 (formatted NET.STA) + :param station2: The name of station 2 (formatted NET.STA.LOC) :type filterid: int :param filterid: The ID (ref) of the filter :type date: datetime.date or str @@ -1377,9 +1377,9 @@ def get_ref(session, station1, station2, filterid, components, params=None): :param session: A :class:`~sqlalchemy.orm.session.Session` object, as obtained by :func:`connect` :type station1: str - :param station1: The name of station 1 (formatted NET.STA) + :param station1: The name of station 1 (formatted NET.STA.LOC) :type station2: str - :param station2: The name of station 2 (formatted NET.STA) + :param station2: The name of station 2 (formatted NET.STA.LOC) :type filterid: int :param filterid: The ID (ref) of the filter :type components: str @@ -1416,9 +1416,9 @@ def get_results(session, station1, station2, filterid, components, dates, :param session: A :class:`~sqlalchemy.orm.session.Session` object, as obtained by :func:`connect` :type station1: str - :param station1: The name of station 1 (formatted NET.STA) + :param station1: The name of station 1 (formatted NET.STA.LOC) :type station2: str - :param station2: The name of station 2 (formatted NET.STA) + :param station2: The name of station 2 (formatted NET.STA.LOC) :type filterid: int :param filterid: The ID (ref) of the filter :type components: str @@ -1518,9 +1518,9 @@ def get_results_all(session, station1, station2, filterid, components, dates, :param session: A :class:`~sqlalchemy.orm.session.Session` object, as obtained by :func:`connect` :type station1: str - :param station1: The name of station 1 (formatted NET.STA) + :param station1: The name of station 1 (formatted NET.STA.LOC) :type station2: str - :param station2: The name of station 2 (formatted NET.STA) + :param station2: The name of station 2 (formatted NET.STA.LOC) :type filterid: int :param filterid: The ID (ref) of the filter :type components: str @@ -1952,21 +1952,21 @@ def make_same_length(st): def preload_instrument_responses(session, return_format="dataframe"): """ - This function preloads all instrument responses from ``response_format`` + This function preloads all instrument responses from ``response_path`` and stores the seed ids, start and end dates, and paz for every channel - in a DataFrame. - - .. warning:: - This function only works for ``response_format`` being "inventory" - or "dataless". + in a DataFrame. Any file readable by obspy's read_inventory will be processed. :type session: :class:`sqlalchemy.orm.session.Session` :param session: A :class:`~sqlalchemy.orm.session.Session` object, as obtained by :func:`connect` - :rtype: pandas.DataFrame + :type return_format: str + :param return_format: The format of the returned object, either + ``dataframe`` or ``inventory``. + + :rtype: :class:`~pandas.DataFrame` or :class:`~obspy.core.inventory.inventory.Inventory` :returns: A table containing all channels with the time of operation and - poles and zeros. + poles and zeros (DataFrame), or an obspy Inventory object. """ from obspy.core.inventory import Inventory diff --git a/msnoise/preprocessing.py b/msnoise/preprocessing.py index b722cc58..88ea7b8f 100644 --- a/msnoise/preprocessing.py +++ b/msnoise/preprocessing.py @@ -73,7 +73,7 @@ def preprocess(stations, comps, goal_day, params, responses=None, loglevel="INFO :param db: A :class:`~sqlalchemy.orm.session.Session` object, as obtained by :func:`msnoise.api.connect`. :type stations: list of str - :param stations: a list of station names, in the format NET.STA. + :param stations: a list of station names, in the format NET.STA.LOC :type comps: list of str :param comps: a list of component names, in Z,N,E,1,2. :type goal_day: str @@ -201,11 +201,11 @@ def preprocess(stations, comps, goal_day, params, responses=None, loglevel="INFO stream[i] = check_and_phase_shift(trace, params.preprocess_taper_length) logger.debug("%s Checking Gaps" % stream[0].id) - if len(getGaps(stream)) > 0: - logger.debug(" found %i gaps" % len(getGaps(stream))) + gaps = getGaps(stream) + if len(gaps) > 0: + logger.debug(" found %i gaps" % len(gaps)) max_gap = params.preprocess_max_gap*stream[0].stats.sampling_rate - gaps = getGaps(stream) while len(gaps): too_long = 0 for gap in gaps: