Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Topic/ca timing #33

Open
wants to merge 49 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
bfb2041
functions for testing with real data
Jul 18, 2017
0f8576d
Only use the detection bands for coefficient fitting during change de…
Aug 8, 2017
c67525f
fix some looping
Aug 8, 2017
f6989c6
data org timing scripts
Aug 9, 2017
cabba03
detect baseline: chip/pixel(rc) (-2094585/1682805)/(97/57), 1.617s
Aug 9, 2017
1970d60
detect skip np.array on inputs: no improvement
Aug 9, 2017
6e39641
detect remove pandas: chip/pixel(rc) (-2094585/1682805)/(97/57), 1.524
Aug 9, 2017
4f6545f
data org w/ rainbow+xarray 25.829 seconds
Aug 9, 2017
76533d9
data org w/ lcmap-merlin 3.376 seconds
Aug 9, 2017
7003f27
add QA_NAN value to default parameters
Aug 9, 2017
72a5233
detect use map() in qa unpackqa: chip/pixel(rc) (-2094585/1682805)/(9…
Aug 9, 2017
ecb8dcc
detect use map() in procedures.py initialize fitter: chip/pixel(rc) (…
Aug 9, 2017
b3dc6a8
reduce lookups in procedures.py
Aug 10, 2017
162bed4
merge kelcys band optimization
Aug 10, 2017
19dde3f
remove sklearn import from robust_fit, unused
Aug 11, 2017
3510a0b
ccd/qa.py map to list comp, np.array pointer
Aug 11, 2017
dd240ab
dot method pointers, move lasso inclusion
Aug 11, 2017
a8b9620
WIP extracting lasso code
Aug 13, 2017
1e6ad5a
lasso mods, add lasso cython
Aug 15, 2017
fdd5143
more precise Lasso import, half % less time spent in fitted_model
Aug 16, 2017
2a2c946
WIP tmask optimizations and cython
Aug 16, 2017
113f31f
cythonization of the tmask pipeline
Aug 17, 2017
bb624ec
update gitignore, cleanup lasso extraction attempt
Aug 21, 2017
970cabe
cythonization type defs
Aug 21, 2017
26c4e57
move robust_fit import to tmask module, slight improvement
Aug 22, 2017
355c46b
move lasso import
Aug 22, 2017
a7cd17d
proc_params to dict, move tmask import and coef func declaration
Aug 22, 2017
a93ea75
cdef tmask funcs, add pxd for header and type defs
Aug 22, 2017
a5d78e3
moar cython func type defs
Aug 22, 2017
d8fdc15
update travis config, setup.py for install with C extensions
Aug 23, 2017
29abca3
add c files for dist
Aug 23, 2017
f89fa0a
todo - learn how to spell install
Aug 23, 2017
7dad24a
add xarray to test deps
Aug 23, 2017
0354931
fix tests and setup.py
Aug 24, 2017
3d709db
fix lasso coefficient test
Aug 24, 2017
af67243
fix travis distribution tag
Aug 24, 2017
a6c6d87
add MANIFEST.in to package up pyx and pxd files, in event cython avai…
Aug 24, 2017
c5e3bbf
fix up the stability check some
Aug 28, 2017
5ac586a
Fix what bands get used for Tmask. There was a mismatch before relate…
Aug 28, 2017
c7579af
small organizational and cleanup changes
Aug 28, 2017
929ca2b
move cython type defs into pxd files, cython to compile .py instead o…
Aug 28, 2017
cd9f78b
cpdef tmask tmask
Aug 29, 2017
1243df9
set dtype for observations to int16 instead of float, cpdef lasso coe…
Aug 29, 2017
d91a26e
update MANIFEST.in for cythons pure python model, set dtype to intege…
Aug 30, 2017
7027d75
Merge branch 'optimization/band-regression' of github.com:USGS-EROS/l…
Aug 30, 2017
7884668
Merge branch 'feature/nt-to-dict' of github.com:USGS-EROS/lcmap-pyccd…
Aug 30, 2017
67b9151
remove unused logging
Aug 30, 2017
f022ce7
undo move to inner functions
Aug 30, 2017
1a90364
Merge branch 'develop' of github.com:USGS-EROS/lcmap-pyccd into topic…
Aug 30, 2017
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ pip-selfcheck.json
*.venv/*
*.ipynb_checkpoints
.idea/
*.svg
*.stat
*.dot
*.so


6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
language: python

python:
- '3.4'
- '3.5'
- '3.6'

install:
- pip install --upgrade pip
- pip install numpy
- pip install .[test]
- python setup.py build_ext --inplace

script: pytest

Expand All @@ -20,7 +22,7 @@ deploy:
user: klsmith-usgs
password:
secure: F/24kis1e5y35lX//3f9ASpJFVVrXIOn0pOYY008brOhNU5joT6BY0urW6QPbb7nocR4iRE+SVAH9DX+x8SnVwsvEonts46QNakaUc12f15EDkSdX5b1SOwbDC/s44BDdM8f3oFP46C6myqqHJ/5qKJpfmJI8Dy3C6xzB6ZhY5eMaLuUlNkKS+D9FRLNNT3zMqwVFeOo9+M/welCSWoOh9YMZom1ZWAbH6k2EFa8HRed9kF+EISZ+lJgT+A6gFY7O3nlHCN2HiRXb3JqgVsb4ZQ290FEAP8F8OUK1JfiwLL51qzUsKC2Fbg+jHy0sHsSanOwvrGwe9yN0vaU4yi0Ob1P2i6fZzoyKGO95x5bkIGPQyiuLMiwFUPE4M5dPUsxbtpNAEv8W4K1aPYiRx6uBxeI/ul5aQ4MZ5XrcaAX7t4cGfqoQilJmPeeStvx0Qvtr1ikPivrQKNW7GTOZs179dIe+u9F/qMbxpIsf4cZlY4b+AfXtWjvpILKoVY/v16kK3CYgc8JJFRiPFazyK7JzY3dQNH75sWYcN2EV9d0Ikc2Foko7vv0P09xoT1gF5HxpRQaZ6bKNOF4smIhIDOZAFFieQV1moZUYqzS/ll/7VmnNqRo9d5mL19iIGrSItn8gidjqyzSiPwL4c+QOjR+zIC7EMDSs71zM6xA5boQo7Y=
distributions: sdist bdist_wheel
on:
distributions: sdist bdist_wheel
repo: USGS-EROS/lcmap-pyccd
branch: master
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include ccd/models/lasso.pxd
include ccd/models/robust_fit.pxd
include ccd/models/tmask.pxd
include ccd/procedures.pxd
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ System requirements (Centos)
* graphviz
* python-virtualenv

Python requirements
* numpy (for install of C compiled extensions)

It's highly recommended to do all your development & testing in a virtual environment.
```bash
user@dev:/home/user/$ mkdir pyccd
Expand Down
2 changes: 1 addition & 1 deletion ccd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def detect(dates, blues, greens, reds, nirs,
# Determine which procedure to use for the detection
procedure = __determine_fit_procedure(quality, proc_params)

results = procedure(dates, spectra, fitter_fn, quality, proc_params)
results = procedure(dates, spectra, fitter_fn, quality, dict(proc_params))
log.debug('Total time for algorithm: %s', time.time() - t1)

# call detect and return results as the detections namedtuple
Expand Down
37 changes: 24 additions & 13 deletions ccd/change.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,48 @@
log = logging.getLogger(__name__)


def stable(models, dates, variogram, t_cg, detection_bands):
"""Determine if we have a stable model to start building with
def stable(models, dates, variogram, t_cg):
"""
Determine if we have a stable model to start building a time segment.

The basis of this is to ensure that the delta between the start and end of
the model are not too offset from each other.

Models and variogram must of be of the same shape and the representative
bands must be in the same order.

Args:
models: list of current representative/fitted models
variogram: 1-d array of variogram values to compare against for the
normalization factor
dates: array of ordinal date values
t_cg: change threshold
detection_bands: index locations of the spectral bands that are used
to determine stability

Returns:
Boolean on whether stable or not
"""
# This could be written differently, or more performant using numpy in the
# future
# future.
check_vals = []
for idx in detection_bands:
rmse_norm = max(variogram[idx], models[idx].rmse)
slope = models[idx].fitted_model.coef_[0] * (dates[-1] - dates[0])
for model, vario in zip(models, variogram):
# Our normalization factor.
rmse_norm = max(vario, model.rmse)

# Look at the difference between the predicted values for the beginning
# and end.
slope_diff = model.fitted_model.coef_[0] * (dates[-1] - dates[0])

check_val = (abs(slope) + abs(models[idx].residual[0]) +
abs(models[idx].residual[-1])) / rmse_norm
# Look at the start and end residuals, while also looking at the
# predicted delta.
check_val = (abs(slope_diff) + abs(model.residual[0]) +
abs(model.residual[-1])) / rmse_norm

check_vals.append(check_val)

euc_norm = sum_of_squares(np.array(check_vals))
log.debug('Stability norm: %s, Check against: %s', euc_norm, t_cg)
check = sum_of_squares(np.array(check_vals))
log.debug('Stability check: %s against: %s', check, t_cg)

return euc_norm < t_cg
return check < t_cg


def change_magnitude(residuals, variogram, comparison_rmse):
Expand Down
84 changes: 0 additions & 84 deletions ccd/cli.py

This file was deleted.

22 changes: 0 additions & 22 deletions ccd/functions.py

This file was deleted.

Loading