Skip to content

Commit

Permalink
Merge pull request #107 from ocefpaf/update_freqs-take2
Browse files Browse the repository at this point in the history
Update freqs take2
  • Loading branch information
ocefpaf committed Apr 27, 2022
2 parents 6afd379 + 2562a32 commit c730b18
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/tests.yml
Expand Up @@ -18,28 +18,33 @@ jobs:
exclude:
- python-version: "3.10"
numpy-version: "1.19"
fail-fast: false

steps:
- uses: actions/checkout@v2

- name: Setup Conda
uses: s-weigand/setup-conda@v1
- name: Setup
uses: mamba-org/provision-with-micromamba@main
with:
activate-conda: false
conda-channels: conda-forge
environment-file: false

- name: Python ${{ matrix.python-version }} numpy ${{ matrix.numpy-version }}
shell: bash -l {0}
run: |
conda create --name TEST python=${{ matrix.python-version }} --file requirements.txt --file requirements-dev.txt
source activate TEST
conda install numpy=${{ matrix.numpy-version }}
micromamba create --name TEST python=${{ matrix.python-version }} --file requirements.txt --file requirements-dev.txt --channel conda-forge
micromamba activate TEST
micromamba install numpy=${{ matrix.numpy-version }}
pip install -e . --no-deps --force-reinstall
conda info --all
conda list
- name: Debug Info
shell: bash -l {0}
run: |
micromamba activate TEST
micromamba info --all
micromamba list
- name: Tests
shell: bash -l {0}
run: |
source activate TEST
micromamba activate TEST
pytest -n 2 -rxs --cov=utide tests
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -42,6 +42,6 @@ repos:
- --py36-plus

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.2.2
rev: v2.2.3
hooks:
- id: add-trailing-comma
19 changes: 5 additions & 14 deletions utide/constituent_selection.py
Expand Up @@ -3,7 +3,7 @@
import numpy as np

from ._ut_constants import constit_index_dict, ut_constants
from .astronomy import ut_astron
from .harmonics import linearized_freqs
from .utilities import Bunch


Expand Down Expand Up @@ -31,21 +31,12 @@ def ut_cnstitsel(tref, minres, incnstit, infer):
coef.aux.reftime = tref
"""

shallow = ut_constants.shallow
const = ut_constants.const

cnstit = Bunch()
coef = Bunch()

astro, ader = ut_astron(tref)

ii = np.isfinite(const.ishallow)
const.freq[~ii] = np.dot(const.doodson[~ii, :], ader[:, 0]) / 24

for k in ii.nonzero()[0]:
ik = const.ishallow[k] + np.arange(const.nshallow[k])
ik = ik.astype(int) - 1
const.freq[k] = np.sum(const.freq[shallow.iname[ik] - 1] * shallow.coef[ik])
freqs = linearized_freqs(tref)

# cnstit.NR
cnstit["NR"] = Bunch()
Expand All @@ -62,7 +53,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer):
RI_index_set = {constit_index_dict[n] for n in RIset}
cnstit.NR.lind = [ind for ind in cnstit.NR.lind if ind not in RI_index_set]

cnstit.NR.frq = const.freq[cnstit.NR.lind]
cnstit.NR.frq = freqs[cnstit.NR.lind]
cnstit.NR.name = const.name[cnstit.NR.lind]
nNR = len(cnstit.NR.frq)

Expand All @@ -80,7 +71,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer):
for k, name in enumerate(allrefs):
refstruct = Bunch(name=name)
refstruct.lind = constit_index_dict[name]
refstruct.frq = const.freq[refstruct.lind]
refstruct.frq = freqs[refstruct.lind]
ind = [i for i, rname in enumerate(infer.reference_names) if name == rname]
refstruct.nI = len(ind)
refstruct.I = Bunch(Rp=[], Rm=[], name=[], lind=[], frq=[]) # noqa
Expand All @@ -101,7 +92,7 @@ def ut_cnstitsel(tref, minres, incnstit, infer):
refstruct.I.name.append(iname)
lind = constit_index_dict[iname]
refstruct.I.lind.append(lind)
refstruct.I.frq.append(const.freq[lind])
refstruct.I.frq.append(freqs[lind])

refstruct.I.Rp = np.array(refstruct.I.Rp)
refstruct.I.Rm = np.array(refstruct.I.Rm)
Expand Down

0 comments on commit c730b18

Please sign in to comment.