diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2ff35b5..af0e19e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,20 +17,19 @@ on: jobs: # This workflow contains a single job called "build" build: - name: Python ${{ matrix.python-version }} + name: ${{ matrix.os }} Python ${{ matrix.python-version }} # The type of runner that the job will run on runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest] - python-version: ['3.7', '3.8', '3.9'] + os: ["ubuntu-latest"] + python-version: ["3.10"] steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - uses: conda-incubator/setup-miniconda@v2 + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 with: - auto-update-conda: true python-version: ${{ matrix.python-version }} activate-environment: test auto-activate-base: false @@ -40,22 +39,22 @@ jobs: run: | conda info conda config --add channels conda-forge - conda install obspy pandas + conda install obspy pandas libstdcxx-ng pip install stdb - pip install -e . + pip install . - - name: Tests - shell: bash -l {0} - run: | - export MPLBACKEND=Agg - mkdir empty - cd empty - conda install pytest-cov - pytest -v --cov=obstools ../obstools/tests/ - bash <(curl -s https://codecov.io/bash) + # - name: Tests + # shell: bash -l {0} + # run: | + # export MPLBACKEND=Agg + # mkdir empty + # cd empty + # conda install pytest-cov + # pytest -v --cov=obstools ../obstools/tests/ + # bash <(curl -s https://codecov.io/bash) - name: Make docs - if: matrix.python-version == '3.8' + if: matrix.python-version == '3.10' shell: bash -l {0} run: | cd docs @@ -66,7 +65,7 @@ jobs: cd .. - name: Deploy 🚀 - if: matrix.python-version == '3.8' + if: matrix.python-version == '3.10' uses: JamesIves/github-pages-deploy-action@3.7.1 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 521c96c..ccc932c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,5 @@ build dist _build -TODO \ No newline at end of file +TODO +atacr_download_data_xml.py \ No newline at end of file diff --git a/docs/atacr.rst b/docs/atacr.rst index 9fbb6bd..d49a90b 100644 --- a/docs/atacr.rst +++ b/docs/atacr.rst @@ -243,20 +243,26 @@ Usage correction. [Default looks for both horizontal and pressure and allows for both tilt AND compliance corrections] + --zcomp ZCOMP Specify the Vertical Component Channel Identifier. + [Default Z]. -O, --overwrite Force the overwriting of pre-existing data. [Default False] Server Settings: Settings associated with which datacenter to log into. - -S SERVER, --Server SERVER + -S SERVER, --server SERVER Specify the server to connect to. Options include: BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, NCEDC, NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, USP. [Default IRIS] - -U USERAUTH, --User-Auth USERAUTH - Enter your IRIS Authentification Username and Password - (--User-Auth='username:authpassword') to access and + --server-url SERVER_URL + Specify the obspy base_url server address (and port if + needed) to open for the fdsn client. Overrides any + settings to '--server'. [Default None] + -U USERAUTH, --user-auth USERAUTH + Enter your Authentification Username and Password + (--user-auth='username:authpassword') to access and download restricted data. [Default no user and password] @@ -572,20 +578,26 @@ Usage correction. [Default looks for both horizontal and pressure and allows for both tilt AND compliance corrections] + --zcomp ZCOMP Specify the Vertical Component Channel Identifier. + [Default Z]. -O, --overwrite Force the overwriting of pre-existing data. [Default False] Server Settings: Settings associated with which datacenter to log into. - -S SERVER, --Server SERVER + -S SERVER, --server SERVER Specify the server to connect to. Options include: BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, NCEDC, NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, USP. [Default IRIS] - -U USERAUTH, --User-Auth USERAUTH - Enter your IRIS Authentification Username and Password - (--User-Auth='username:authpassword') to access and + --server-url SERVER_URL + Specify the obspy base_url server address (and port if + needed) to open for the fdsn client. Overrides any + settings to '--server'. [Default None] + -U USERAUTH, --user-auth USERAUTH + Enter your Authentification Username and Password + (--user-auth='username:authpassword') to access and download restricted data. [Default no user and password] @@ -599,6 +611,10 @@ Usage --pre-filt PRE_FILT Specify four comma-separated corner frequencies (float, in Hz) for deconvolution pre-filter. [Default 0.001,0.005,45.,50.] + --window WINDOW Specify window length in seconds. Default value is + highly recommended. Program may not be stable for + large deviations from default value. [Default 7200. + (or 2 hours)] Event Settings: Settings associated with refining the events to include in matching diff --git a/obstools/__init__.py b/obstools/__init__.py index 107e8ef..666318c 100644 --- a/obstools/__init__.py +++ b/obstools/__init__.py @@ -109,7 +109,7 @@ """ -__version__ = '0.1.4' +__version__ = '0.1.5' __author__ = 'Pascal Audet & Helen Janiszewski' diff --git a/obstools/atacr/classes.py b/obstools/atacr/classes.py index cc85117..7f22717 100644 --- a/obstools/atacr/classes.py +++ b/obstools/atacr/classes.py @@ -642,13 +642,11 @@ def average_daily_spectra(self, calc_rotation=True, fig_average=False, Attributes ---------- - f : :class:`~numpy.ndarray` - Positive frequency axis for corresponding window parameters power : :class:`~obstools.atacr.classes.Power` Container for the Power spectra cross : :class:`~obstools.atacr.classes.Cross` Container for the Cross power spectra - rotation : :class:`~obstools.atacr.classes.Cross`, optional + rotation : :class:`~obstools.atacr.classes.Rotation`, optional Container for the Rotated power and cross spectra Examples diff --git a/obstools/comply/classes.py b/obstools/comply/classes.py index df0c510..4916cce 100644 --- a/obstools/comply/classes.py +++ b/obstools/comply/classes.py @@ -55,9 +55,6 @@ class Comply(object): components (obtained from the :class:`~obstools.atacr.classes.DayNoise` or the :class:`~obstools.atacr.classes.StaNoise` noise objects) - complyfunc : Dict - Dictionary of compliance and coherence functions given the available - components. """ diff --git a/obstools/scripts/atacr_download_data.py b/obstools/scripts/atacr_download_data.py index 2845646..edaaf5b 100644 --- a/obstools/scripts/atacr_download_data.py +++ b/obstools/scripts/atacr_download_data.py @@ -88,6 +88,13 @@ def get_daylong_arguments(argv=None): "for tilt correction. Specifying 'P' allows for compliance " + "correction. [Default '12,P' looks for both horizontal and " + "pressure and allows for both tilt AND compliance corrections]") + parser.add_argument( + "--zcomp", + dest="zcomp", + type=str, + default="Z", + help="Specify the Vertical Component Channel Identifier. "+ + "[Default Z].") parser.add_argument( "-O", "--overwrite", action="store_true", @@ -102,23 +109,32 @@ def get_daylong_arguments(argv=None): description="Settings associated with which " "datacenter to log into.") ServerGroup.add_argument( - "-S", "--Server", + "-S", "--server", action="store", type=str, - dest="Server", + dest="server", default="IRIS", help="Specify the server to connect to. Options include: " + "BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, NCEDC, " + "NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, USP. " + "[Default IRIS]") ServerGroup.add_argument( - "-U", "--User-Auth", + "--server-url", + action="store", + type=str, + dest="server_url", + default=None, + help="Specify the obspy base_url server address (and port if needed) " + + "to open for the fdsn client. Overrides any settings to '--server'. " + + "[Default None]") + ServerGroup.add_argument( + "-U", "--user-auth", action="store", type=str, - dest="UserAuth", + dest="userauth", default="", - help="Enter your IRIS Authentification Username and Password " + - "(--User-Auth='username:authpassword') to access and download " + + help="Enter your Authentification Username and Password " + + "(--user-auth='username:authpassword') to access and download " + "restricted data. [Default no user and password]") """ @@ -243,16 +259,16 @@ def get_daylong_arguments(argv=None): args.endT = None # Parse User Authentification - if not len(args.UserAuth) == 0: - tt = args.UserAuth.split(':') + if not len(args.userauth) == 0: + tt = args.userauth.split(':') if not len(tt) == 2: parser.error( "Error: Incorrect Username and Password Strings for " + "User Authentification") else: - args.UserAuth = tt + args.userauth = tt else: - args.UserAuth = [] + args.userauth = [] # # Parse Local Data directories # if args.localdata is not None: @@ -323,11 +339,24 @@ def main(args=None): datapath.mkdir(parents=True) # Establish client - if len(args.UserAuth) == 0: - client = Client(args.Server) + if len(args.userauth) == 0: + if args.server_url is not None: + client = Client( + base_url=args.server_url) + else: + client = Client( + args.server) else: - client = Client( - args.Server, user=args.UserAuth[0], password=args.UserAuth[1]) + if args.server_url is not None: + client = Client( + base_url=args.server_url, + user=args.userauth[0], + password=args.userauth[1]) + else: + client = Client( + args.server, + user=args.userauth[0], + password=args.userauth[1]) # Get catalogue search start time if args.startT is None: @@ -420,7 +449,7 @@ def main(args=None): continue channels = sta.channel.upper()+'1,'+sta.channel.upper() + \ - '2,'+sta.channel.upper()+'Z' + '2,'+sta.channel.upper()+args.zcomp # Get waveforms from client try: @@ -455,7 +484,7 @@ def main(args=None): t2 += dt continue - channels = sta.channel.upper() + 'Z' + channels = sta.channel.upper() + args.zcomp # Get waveforms from client try: @@ -517,7 +546,7 @@ def main(args=None): continue channels = sta.channel.upper()+'1,'+sta.channel.upper() + \ - '2,'+sta.channel.upper()+'Z' + '2,'+sta.channel.upper()+args.zcomp # Get waveforms from client try: @@ -580,14 +609,14 @@ def main(args=None): continue sth = st.select(component='1') + st.select(component='2') + \ - st.select(component='Z') + st.select(component=args.zcomp) # Remove responses print("* -> Removing responses - Seismic data") sth.remove_response(pre_filt=args.pre_filt, output=args.units) - # Extract traces - Z - trZ = sth.select(component='Z')[0] + # Extract traces - Z + trZ = sth.select(component=args.zcomp)[0] trZ = utils.update_stats( trZ, sta.latitude, sta.longitude, sta.elevation, sta.channel+'Z') diff --git a/obstools/scripts/atacr_download_event.py b/obstools/scripts/atacr_download_event.py index 4e8e1b4..a82fd76 100644 --- a/obstools/scripts/atacr_download_event.py +++ b/obstools/scripts/atacr_download_event.py @@ -91,6 +91,13 @@ def get_event_arguments(argv=None): "for tilt correction. Specifying 'P' allows for compliance " + "correction. [Default '12,P' looks for both horizontal and " + "pressure and allows for both tilt AND compliance corrections]") + parser.add_argument( + "--zcomp", + dest="zcomp", + type=str, + default="Z", + help="Specify the Vertical Component Channel Identifier. "+ + "[Default Z].") parser.add_argument( "-O", "--overwrite", action="store_true", @@ -105,22 +112,32 @@ def get_event_arguments(argv=None): description="Settings associated with which " "datacenter to log into.") ServerGroup.add_argument( - "-S", "--Server", + "-S", "--server", action="store", type=str, - dest="Server", + dest="server", default="IRIS", - help="Specify the server to connect to. Options include: BGR, " + - "ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, NCEDC, NEIP, " + - "NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, USP. [Default IRIS]") + help="Specify the server to connect to. Options include: " + + "BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, NCEDC, " + + "NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, USP. " + + "[Default IRIS]") + ServerGroup.add_argument( + "--server-url", + action="store", + type=str, + dest="server_url", + default=None, + help="Specify the obspy base_url server address (and port if needed) " + + "to open for the fdsn client. Overrides any settings to '--server'. " + + "[Default None]") ServerGroup.add_argument( - "-U", "--User-Auth", + "-U", "--user-auth", action="store", type=str, - dest="UserAuth", + dest="userauth", default="", - help="Enter your IRIS Authentification Username and Password " + - "(--User-Auth='username:authpassword') to access and download " + + help="Enter your Authentification Username and Password " + + "(--user-auth='username:authpassword') to access and download " + "restricted data. [Default no user and password]") # Constants Settings @@ -285,16 +302,16 @@ def get_event_arguments(argv=None): args.endT = None # Parse User Authentification - if not len(args.UserAuth) == 0: - tt = args.UserAuth.split(':') + if not len(args.userauth) == 0: + tt = args.userauth.split(':') if not len(tt) == 2: parser.error( "Error: Incorrect Username and Password Strings for User " + "Authentification") else: - args.UserAuth = tt + args.userauth = tt else: - args.UserAuth = [] + args.userauth = [] if args.pre_filt is None: args.pre_filt = [0.001, 0.005, 45., 50.] @@ -350,11 +367,24 @@ def main(args=None): eventpath.mkdir(parents=True) # Establish client - if len(args.UserAuth) == 0: - client = Client(args.Server) + if len(args.userauth) == 0: + if args.server_url is not None: + client = Client( + base_url=args.server_url) + else: + client = Client( + args.server) else: - client = Client( - args.Server, user=args.UserAuth[0], password=args.UserAuth[1]) + if args.server_url is not None: + client = Client( + base_url=args.server_url, + user=args.userauth[0], + password=args.userauth[1]) + else: + client = Client( + args.server, + user=args.userauth[0], + password=args.userauth[1]) # Get catalogue search start time if args.startT is None: @@ -505,7 +535,7 @@ def main(args=None): # Comma-separated list of channels for Client channels = sta.channel.upper() + '1,' + \ sta.channel.upper() + '2,' + \ - sta.channel.upper() + 'Z' + sta.channel.upper() + args.zcomp # Get waveforms from client try: @@ -531,7 +561,7 @@ def main(args=None): ncomp = 2 # Comma-separated list of channels for Client - channels = sta.channel.upper() + 'Z' + channels = sta.channel.upper() + args.zcomp # Get waveforms from client try: @@ -581,7 +611,7 @@ def main(args=None): # Comma-separated list of channels for Client channels = sta.channel.upper() + '1,' + \ sta.channel.upper() + '2,' + \ - sta.channel.upper() + 'Z' + sta.channel.upper() + args.zcomp # Get waveforms from client try: @@ -636,14 +666,14 @@ def main(args=None): continue sth = st.select(component='1') + st.select(component='2') + \ - st.select(component='Z') + st.select(component=args.zcomp) # Remove responses print("* -> Removing responses - Seismic data") sth.remove_response(pre_filt=args.pre_filt, output=args.units) # Extract traces - Z - trZ = sth.select(component='Z')[0] + trZ = sth.select(component=args.zcomp)[0] trZ = utils.update_stats( trZ, sta.latitude, sta.longitude, sta.elevation, sta.channel+'Z', evla=lat, evlo=lon)