From 4b36e245ceda08611b2cfe47e015ba27efe8a596 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Sep 2025 13:02:51 +0000 Subject: [PATCH 1/2] Initial plan From 6703af5472d18623aa2fb46c49f3e246ff5fb904 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Sep 2025 13:08:14 +0000 Subject: [PATCH 2/2] Complete Python repository setup with conda environment Co-authored-by: mdenolle <18743724+mdenolle@users.noreply.github.com> --- .gitignore | 136 +++++++++++++++++++++++++++++++++++ README.md | 85 ++++++++++++++++++++++ environment.yml | 14 ++++ ess563/__init__.py | 9 +++ examples/test_environment.py | 114 +++++++++++++++++++++++++++++ requirements.txt | 6 ++ setup.py | 43 +++++++++++ 7 files changed, 407 insertions(+) create mode 100644 .gitignore create mode 100644 environment.yml create mode 100644 ess563/__init__.py create mode 100644 examples/test_environment.py create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f38e9f --- /dev/null +++ b/.gitignore @@ -0,0 +1,136 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# Data files +*.hdf5 +*.h5 +*.sac +*.mseed +*.seed \ No newline at end of file diff --git a/README.md b/README.md index 3fe168b..48a2ad3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,87 @@ # ESS563-2025 Advanced Seismology + +This repository contains the Python environment setup and utilities for the ESS563 Advanced Seismology course. + +## Environment Setup + +### Prerequisites + +- [Anaconda](https://www.anaconda.com/products/distribution) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html) installed on your system + +### Installation + +1. Clone this repository: + ```bash + git clone https://github.com/UW-geophysics-edu/ESS563-2025.git + cd ESS563-2025 + ``` + +2. Create the conda environment: + ```bash + conda env create -f environment.yml + ``` + +3. Activate the environment: + ```bash + conda activate ess563 + ``` + +### Alternative Installation (pip only) + +If you prefer to use pip instead of conda: + +```bash +pip install -r requirements.txt +``` + +## Testing the Environment + +To verify that all packages are installed correctly, run the test script: + +```bash +python examples/test_environment.py +``` + +This will check that all required packages are installed and functioning properly. + +## Included Packages + +This environment includes the following key packages for seismological analysis: + +- **obspy**: Seismic data processing and analysis +- **matplotlib**: Plotting and visualization +- **scipy**: Scientific computing +- **numpy**: Numerical computing +- **pandas**: Data manipulation and analysis +- **h5py**: HDF5 file format support + +## Usage + +After activating the environment, you can start using any of the included packages in your Python scripts or Jupyter notebooks. + +Example: +```python +import obspy +from obspy import read +import matplotlib.pyplot as plt +import numpy as np + +# Your seismological analysis code here... +``` + +## Directory Structure + +``` +ESS563-2025/ +├── environment.yml # Conda environment specification +├── requirements.txt # Pip requirements file +├── ess563/ # Main package directory +│ └── __init__.py # Package initialization +└── examples/ # Example scripts and tests + └── test_environment.py # Environment verification script +``` + +## Contributing + +This repository is for educational purposes as part of the ESS563 Advanced Seismology course. diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..d108ee5 --- /dev/null +++ b/environment.yml @@ -0,0 +1,14 @@ +name: ess563 +channels: + - conda-forge + - defaults +dependencies: + - python=3.11 + - pip + - pip: + - obspy + - matplotlib + - scipy + - numpy + - pandas + - h5py \ No newline at end of file diff --git a/ess563/__init__.py b/ess563/__init__.py new file mode 100644 index 0000000..97db64f --- /dev/null +++ b/ess563/__init__.py @@ -0,0 +1,9 @@ +""" +ESS563 - Advanced Seismology Package + +This package provides utilities and examples for the ESS563 Advanced Seismology course. +""" + +__version__ = "0.1.0" +__author__ = "ESS563 Course" +__description__ = "Advanced Seismology utilities and examples" \ No newline at end of file diff --git a/examples/test_environment.py b/examples/test_environment.py new file mode 100644 index 0000000..eb2d554 --- /dev/null +++ b/examples/test_environment.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python +""" +Test script to verify that all required packages are installed and working. + +This script imports all the main packages used in ESS563 and performs +basic operations to ensure they're functioning correctly. +""" + +import sys +import matplotlib +matplotlib.use('Agg') # Use non-interactive backend for testing + +def test_imports(): + """Test that all required packages can be imported.""" + print("Testing package imports...") + + try: + import numpy as np + print(f"✓ numpy {np.__version__}") + except ImportError as e: + print(f"✗ numpy: {e}") + return False + + try: + import scipy + print(f"✓ scipy {scipy.__version__}") + except ImportError as e: + print(f"✗ scipy: {e}") + return False + + try: + import pandas as pd + print(f"✓ pandas {pd.__version__}") + except ImportError as e: + print(f"✗ pandas: {e}") + return False + + try: + import matplotlib.pyplot as plt + print(f"✓ matplotlib {matplotlib.__version__}") + except ImportError as e: + print(f"✗ matplotlib: {e}") + return False + + try: + import h5py + print(f"✓ h5py {h5py.__version__}") + except ImportError as e: + print(f"✗ h5py: {e}") + return False + + try: + import obspy + print(f"✓ obspy {obspy.__version__}") + except ImportError as e: + print(f"✗ obspy: {e}") + return False + + return True + +def test_basic_functionality(): + """Test basic functionality of key packages.""" + print("\nTesting basic functionality...") + + try: + import numpy as np + import matplotlib.pyplot as plt + import pandas as pd + import h5py + from obspy import UTCDateTime + + # Test numpy + arr = np.array([1, 2, 3, 4, 5]) + print(f"✓ numpy array created: {arr}") + + # Test pandas + df = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]}) + print(f"✓ pandas DataFrame created with shape: {df.shape}") + + # Test matplotlib + fig, ax = plt.subplots() + ax.plot([1, 2, 3], [1, 4, 2]) + plt.close(fig) + print("✓ matplotlib plot created and closed") + + # Test obspy UTCDateTime + t = UTCDateTime() + print(f"✓ obspy UTCDateTime created: {t}") + + return True + + except Exception as e: + print(f"✗ Basic functionality test failed: {e}") + return False + +def main(): + """Main test function.""" + print("ESS563 Environment Test") + print("=" * 30) + + # Test imports + if not test_imports(): + print("\n❌ Import tests failed!") + sys.exit(1) + + # Test basic functionality + if not test_basic_functionality(): + print("\n❌ Functionality tests failed!") + sys.exit(1) + + print("\n✅ All tests passed! Environment is ready for ESS563.") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9acbb08 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +obspy +matplotlib +scipy +numpy +pandas +h5py \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..76b551b --- /dev/null +++ b/setup.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +"""Setup script for ESS563 package.""" + +from setuptools import setup, find_packages + +with open("README.md", "r", encoding="utf-8") as fh: + long_description = fh.read() + +with open("requirements.txt", "r", encoding="utf-8") as fh: + requirements = [line.strip() for line in fh if line.strip() and not line.startswith("#")] + +setup( + name="ess563", + version="0.1.0", + author="ESS563 Course", + description="Advanced Seismology utilities and examples", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/UW-geophysics-edu/ESS563-2025", + packages=find_packages(), + classifiers=[ + "Development Status :: 3 - Alpha", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering :: Physics", + ], + python_requires=">=3.9", + install_requires=requirements, + extras_require={ + "dev": [ + "pytest", + "pytest-cov", + "black", + "flake8", + ], + }, +) \ No newline at end of file