Skip to content

Commit

Permalink
Merge pull request #87 from xumi1993/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
xumi1993 authored Apr 25, 2024
2 parents bb915ab + b9081cd commit c02b5c8
Show file tree
Hide file tree
Showing 15 changed files with 539 additions and 210 deletions.
76 changes: 59 additions & 17 deletions .github/workflows/doc_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,36 @@ name: Seispy docs

on:
push:
branches: [ docs ]
branches: [ docs, dev ]
pull_request:
branches: [ master ]
workflow_call:
inputs:
config-path:
required: true
type: string
secrets:
token:
required: true


# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
deploy:
build_deploy:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Set branch name
id: vars
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo ::set-output name=branch::${{ github.event.pull_request.head.ref }}
else
echo ::set-output name=branch::dev
fi
echo ${{ steps.vars.outputs.branch }}
- name: Cancel Previous Runs
uses: styfle/[email protected]

- name: Checkout
uses: actions/checkout@v2.4.0
- name: Checkout to docs branch
uses: actions/checkout@v4
with:
ref: docs

Expand All @@ -41,20 +43,60 @@ jobs:
with:
activate-environment: docs
environment-file: environment.yml
miniforge-variant: Mambaforge
use-mamba: true

# miniforge-variant: Mambaforge
# use-mamba: true

- name: Checkout to source branch
uses: actions/checkout@v4
with:
ref: ${{ steps.vars.outputs.branch }}
path: seispy_source
fetch-depth: 0

- name: Install Seispy
run: |
cd seispy_source
pip install .
cd ..
- name: Build documentation
run: |
make html
- name: Checkout the gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
# Checkout to this folder instead of the current one
path: deploy
# Download the entire history
fetch-depth: 0

- name: Copy documentation
run: |
cd seispy_source
if [[ ${{ steps.vars.outputs.branch }} == "dev" ]]; then
version=“$(python setup.py --version)_$(git rev-parse --short HEAD)”
else
version=$(python setup.py --version)
fi
cd ../deploy
touch .nojekyll
echo -e "\nRemoving old files from previous builds of ${version}:"
rm -rvf dev_* ${version}
echo -e "\nCopying new files from ${version}:"
cp -rvf ../build/html ${version}
rm -rfv latest
ln -sfv ${version} latest
cd ..
- name: Deploy documentation
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/html
publish_dir: deploy
# Only keep the latest commit to avoid bloating the repository
force_orphan: true
cname: seispy.xumijian.me
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
user_email: 'github-actions[bot]@users.noreply.github.com'
23 changes: 16 additions & 7 deletions seispy/ccpprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def _prof_range(lat, lon):

def create_center_bin_profile(stations, val=5, method='linear'):
"""Create bins along a profile with given stations
:param stations: Stations along a profile
:type stations: :class:`seispy.rf2depth_makedata.Station`
:param val: The interval between two points in km
Expand Down Expand Up @@ -109,6 +110,7 @@ def init_profile(lat1, lon1, lat2, lon2, val):
class CCPProfile():
def __init__(self, cfg_file=None, log:SetupLog=SetupLog()):
"""CCPProfile class for CCP stacking along a profile
:param cfg_file: Configure file for CCP stacking
:type cfg_file: str
:param log: Log class for logging
Expand All @@ -118,12 +120,12 @@ def __init__(self, cfg_file=None, log:SetupLog=SetupLog()):
if cfg_file is None:
self.cpara = CCPPara()
elif isinstance(cfg_file, str):
self.load_para(cfg_file)
self._load_para(cfg_file)
else:
raise ValueError('cfg_file must be str format.')
self.stack_data = []

def load_para(self, cfg_file):
def _load_para(self, cfg_file):
try:
self.cpara = ccppara(cfg_file)
except Exception as e:
Expand Down Expand Up @@ -277,12 +279,19 @@ def stack(self):
self.stack_data.append(boot_stack)

def save_stack_data(self, format='npz'):
"""If format is \'npz\', saving stacked data and parameters to local as a npz file. To load the file, please use data = np.load(fname, allow_pickle=True).
data['cpara'] is the parameters when CCP stacking.
data['stack_data'] is the result of stacked data.
"""If format is ``npz``, saving stacked data and parameters to local as a npz file. To load the file, please use data = np.load(fname, allow_pickle=True).
``data['cpara']`` is the parameters when CCP stacking.
``data['stack_data']`` is the result of stacked data.
If format is \'dat\' the stacked data will be save into a txt file with 8 columns, including bin_lat, bin_lon, profile_dis, depth, amp, ci_low, ci_high and count.
where bin_lat and bin_lon represent the position of each bin; profile_dis represents the distance in km between each bin and the start point of the profile; depth represents depth of each bin; amp means the stacked amplitude; ci_low and ci_high mean confidence interval with bootstrap method; count represents stacking number of each bin.
If format is ``dat`` the stacked data will be save into a txt file with 8 columns,
including ``bin_lat``, ``bin_lon``, ``profile_dis``, ``depth``, ``amp``, ``ci_low``, ``ci_high`` and ``count``.
- ``bin_lat`` and ``bin_lon`` represent the position of each bin;
- ``profile_dis`` represents the distance in km between each bin and the start point of the profile;
- ``depth`` represents depth of each bin;
- ``amp`` means the stacked amplitude;
- ``ci_low`` and ``ci_high`` mean confidence interval with bootstrap method;
- ``count`` represents stacking number of each bin.
:param format: Format for stacked data
:type format: str
Expand Down
3 changes: 3 additions & 0 deletions seispy/core/RFStation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
class Trace_Clust(UserList):
"""
user can accese traces from self.data or like a default list
.. rubric:: Example
>>> st= obspy.read();tt=Trace_Clust()
>>> for _i in st:
... _i.stats.sac ={};
Expand Down
Loading

0 comments on commit c02b5c8

Please sign in to comment.