Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish to PyPI
# Put a version on PyPI when a GitHub release is created
on:
release:
types: [published]

permissions: {}

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244
with:
# Install a specific version of uv.
version: "0.9.13"
python-version: "3.14"
enable-cache: false
- name: Build a binary wheel and a source tarball
run: uv build
- name: Store the distribution packages
uses: actions/upload-artifact@v5
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish distribution
needs:
- build
runs-on: ubuntu-latest
environment:
name: test-pypi
url: https://test.pypi.org/p/prem4derg
permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v6
with:
name: python-package-distributions
path: dist/
- name: Publish distribution
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
repository-url: https://test.pypi.org/legacy/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ venv/

# Notebooks
.ipynb_checkpoints

# UV lock file - don't store this for lib code
uv.lock
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-24 Andrew Walker <andrew.walker@earth.ox.ac.uk>
Copyright (c) 2019-25 Andrew Walker <andrew.walker@earth.ox.ac.uk>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
46 changes: 29 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
# prem4derg
# premlike

This is a python module and some example notebooks to allow us (the Deep Earth Research Group at Leeds) to play around with
This is a python module and some example notebooks to work with
PREM, a famous 1D model of the Earth's interior published by Dziewonski and Anderson in 1981.
The module was initially created to allow the Deep Earth Research Group at Leeds the University
of Leeds to run a summer project to look at the structure of the core but the code has subsequently
been used for a number of other research projects.

## Installation
## Features and limitations

This module relies on python (version 3), Numpy and Scipy. Examples are distributed as Jupyter notebooks, which need Jupyter
and Matplotlib to run. Calculation of travel time curves (in the third example notebook) needs Obspy. Installation and managment
of all these dependencies is most easily done in a conda environment. This can be done using the command:
Premlike allows the creation and evaluation of models that are "like" PREM in terms of their
parameterization. That is, the P- and S-wave velocity, density and attenuation
are described by piecewise polynomials. The module allows the calculation of the corresponding
acceleration due to gravity, pressure, frequency dependent velocities and elastic moduli as
a function of radius. These calculations are analytic (i.e. there is no numerical integration
in the calculation of pressure). The module can easily be used to generate input for Obspy's
TauPy module for the calculation of travel times, and for Mineos for the calculation of e.g.
normal mode center frequencies.

conda create -n p4d -c conda-forge python=3.7 obspy scipy numpy matplotlib jupyter
This creates a new environment called `p4d`. Once an environment is created, this module can be downloaded by running:
Currently, Premlike does not support radial anisotropy although adding this is planned
(however, note that TauPy does not currently support such models either). In addition,
the creation of complete documentation and a more robust set of tests is ongoing.

git clone https://github.com/andreww/prem4derg.git
This creates a directory called `prem4derg`. Experianced users of git who want to contribute to the code may want to fork this
repository in github and clone from their fork.
## Installation and use

This module relies on python (version 3) and Numpy. The software can
be installed with `pip install premlike`

Two final steps will need to be done each time you want to use the code. These are to change directory into the `prem4derg` directory,
and activate the `p4d` environemnt by running `source activate p4d`.
Examples are distributed as Jupyter notebooks, which need Jupyter
and Matplotlib to run.
Calculation of travel time curves (in the third example notebook) needs Obspy.

Experienced users of git who want to contribute to the code may want to fork this
repository in github and clone from their fork.

### Mineos

Expand Down Expand Up @@ -52,10 +64,10 @@ These examples are only starting point. For example, the code could be used to f

## Development and support

Prem4derg is new software, bugs and rough edges may abound. Users who are interested in
Premlike is software under development, bugs and rough edges may abound. Users who are interested in
changing the code are encouraged to [create a fork on GitHub and submit
changes via pull requests](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests).
Problems can be reported via [issues](https://github.com/andreww/prem4derg/issues), which also list areas
Problems can be reported via [issues](https://github.com/andreww/premlike/issues), which also list areas
where further development may be useful.


Expand Down
4 changes: 2 additions & 2 deletions notebooks/PREM_density_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"metadata": {},
"outputs": [],
"source": [
"from prem4derg import OneDModel, R_EARTH"
"from premlike import OneDModel, R_EARTH"
]
},
{
Expand Down Expand Up @@ -283,7 +283,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.0"
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/PREM_travel_times_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"metadata": {},
"outputs": [],
"source": [
"from prem4derg import PREM"
"from premlike import PREM"
]
},
{
Expand Down Expand Up @@ -385,7 +385,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.0"
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down
22 changes: 11 additions & 11 deletions notebooks/PREM_velocity_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -14,11 +14,11 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from prem4derg import OneDModel"
"from premlike import OneDModel"
]
},
{
Expand Down Expand Up @@ -63,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -147,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -187,7 +187,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -210,7 +210,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -233,7 +233,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -289,7 +289,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -308,7 +308,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -370,7 +370,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.0"
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[project]
name = "prem4derg"
version = "0.1.0"
description = "Add your description here"
name = "premlike"
version = "0.1.0a1"
description = "A PREMlike model"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"numpy",
"scipy",
]

[dependency-groups]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_peice_poly.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import numpy.testing as npt

import prem4derg.peice_poly as pp
import premlike.peice_poly as pp


def test_constant():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_prem.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy.testing as npt
import pytest

from prem4derg import PREM
from premlike import PREM

# PREM data (from Table A.1. in intro to
# physics of Earth's interior)
Expand Down
Loading