diff --git a/CHANGELOG.md b/CHANGELOG.md index ae350dc..e2de675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -122,3 +122,10 @@ - #137: More control over RecSec kwargs and better warning messages - #138: Improved SAC header creation for SPECFEM synthetics - #139: Improved RecSec preprocessing setup, more manual control for the User + +## Version 0.6.1 + +- Change log level from warning -> info for empty origin time when reading SPECFEM sources +- Remove README doc page about publishing to PyPi, moved this to adjDocs +- Hotfix: incorrect sorting in CAP weights file related to #144 +- Added some more to the RecSec docstring diff --git a/docs/README.md b/docs/README.md index 8640531..ff048de 100644 --- a/docs/README.md +++ b/docs/README.md @@ -26,28 +26,3 @@ make html See your locally built documentation by opening *_build/html/index.html* -## Publishing Package on PyPi -*Useful link: https://realpython.com/pypi-publish-python-package/* - -1. Ensure your `pyproject.toml` file is set up properly; required fields are name and version -2. Set dependencies, do **not(( pin exact versions but allow for upper and lower bounds; only list direct dependencies -3. Include `tests/`, `docs/`, license, and MANIFEST files (MANIFIST used for including non-source code material -4. Ensure you have an account on PyPi and TestPyPi (for testing publishing) -5. Install `twine` and `build` which are used to build and push packages to PyPi -6. Build your packages locally, which creates the `.tar.gz` and `.whl` dist files -```bash -python -m build -``` -6. Check that files in your .whl (zip file) are as expected (including everything in 3) -7. Check dist files with: -```bash -twine check dist/* -``` -8. Upload test package (note: requires TestPyPi account) -```bash -twine upload -r testpypi dist/* -``` -9. Upload real package (note: requires PyPi account) -```bash -twine upload dist/* -``` diff --git a/pyproject.toml b/pyproject.toml index 673c2d8..35fa7a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pysep-adjtomo" -version = "0.6.0" +version = "0.6.1" description = "Python Seismogram Extraction and Processing" readme = "README.md" requires-python = ">=3.8" diff --git a/pysep/recsec.py b/pysep/recsec.py index 90147e9..8fcb8a0 100755 --- a/pysep/recsec.py +++ b/pysep/recsec.py @@ -340,6 +340,12 @@ def __init__( :type trim: bool :param trim: trim waveforms to the same length, and if any data gaps are present, fill with mean values by default + :type taper: bool + :param taper: if True, taper ends of waveform during preprocessing. Uses + keyword arguments `max_percentage` (float) to define the percentage + to taper, and `taper_type` (str) to define shape of the taper. See + ObsPy's stream.taper() function for acceptable values for these + arguments. :type integrate: int :param integrate: apply integration `integrate` times on all traces. acceptable values [-inf, inf], where positive values are integration diff --git a/pysep/tests/test_utils.py b/pysep/tests/test_utils.py index 0b4221b..1078028 100644 --- a/pysep/tests/test_utils.py +++ b/pysep/tests/test_utils.py @@ -11,7 +11,8 @@ from obspy import read, read_events, read_inventory, Stream from obspy.io.sac.sactrace import SACTrace from pysep.utils.cap_sac import (append_sac_headers, - format_sac_header_w_taup_traveltimes) + format_sac_header_w_taup_traveltimes, + write_cap_weights_files) from pysep.utils.curtail import (remove_for_clipped_amplitudes, rename_channels, remove_stations_for_missing_channels, remove_stations_for_insufficient_length, @@ -101,6 +102,32 @@ def test_sac_header_correct_origin_time(tmpdir, test_st, test_inv, test_event): assert(sac.reftime == test_event.preferred_origin().time) +def test_write_cap_weights_files(tmpdir, test_st, test_inv, test_event): + """ + Test writing out CAP weight files and make sure sorting works for distance + and code works as advertised. No testing for az sorting + """ + st = append_sac_headers(st=test_st, inv=test_inv, event=test_event) + + # Check sorting by dist + write_cap_weights_files(st=st, path_out=tmpdir, order_by="dist") + assert(os.path.exists(os.path.join(tmpdir, "weights.dat"))) + dists = np.loadtxt(os.path.join(tmpdir, "weights.dat"), usecols=1) + # Check that distances are in ascending order + assert(np.all(np.diff(dists) >= 0)) + + # Remove so we know that new files are being made each time + os.remove(os.path.join(tmpdir, "weights.dat")) + + # Check sorting by code + write_cap_weights_files(st=st, path_out=tmpdir, order_by="code") + assert(os.path.exists(os.path.join(tmpdir, "weights.dat"))) + codes = np.loadtxt(os.path.join(tmpdir, "weights.dat"), usecols=0, + dtype=str) + # Check that distances are in ascending order + assert(np.all(codes == np.sort(codes))) + + def test_rename_channels(test_st): """ Edit some waveforms to be obviously bad and make sure we can catch it diff --git a/pysep/utils/cap_sac.py b/pysep/utils/cap_sac.py index e8994b2..59ba429 100644 --- a/pysep/utils/cap_sac.py +++ b/pysep/utils/cap_sac.py @@ -98,7 +98,7 @@ def write_cap_weights_files(st, path_out="./", order_by="dist"): # Order codes based on distance, name or azimuth idx = ["code", "dist", "az"].index(order_by) - code_list = np.array(code_list) + code_list = np.array(code_list, dtype="object") ordered_codes = code_list[code_list[:, idx].argsort()] logger.info("writing CAP weight files") diff --git a/pysep/utils/io.py b/pysep/utils/io.py index 4bdfeb6..baa2c3b 100644 --- a/pysep/utils/io.py +++ b/pysep/utils/io.py @@ -269,7 +269,7 @@ def read_specfem2d_source(path_to_source, origin_time=None): # First set dummy origin time if origin_time is None: origin_time = "1970-01-01T00:00:00" - logger.warning("no origin time set for SPECFEM2D source, setting " + logger.info("no origin time set for SPECFEM2D source, setting " f"dummy value: {origin_time}") with open(path_to_source, "r") as f: