Skip to content

Commit

Permalink
Minor changes to CONTRIBUTING.md to explain release workflow and to
Browse files Browse the repository at this point in the history
doc gallery example following migration of data simulation functions
  • Loading branch information
loicdtx committed Aug 29, 2024
1 parent f875820 commit 68c848f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ We use `pytest` for unit tests.
- You can run tests locally by simply calling `pytest` in the root directory of the project.


### Releasing a new version

Package version is set via git tags thanks to [setuptools-scm](https://setuptools-scm.readthedocs.io/en/latest/). A new release
is made for every tagged commit pushed to github and that passes unit tests.
Examples git tag command: `git tag -a v0.3.0 -m "version 0.3.0"

34 changes: 17 additions & 17 deletions docs/gallery/plot_simulation_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
# Synthetic data generation
# -------------------------
#
# The data module of the nrt package contains functionalities to create synthetic
# The simulate module of the nrt-data package contains functionalities to create synthetic
# data with controlled parameters such as position of structural change, phenological
# amplitude, noise level, etc
# One such example can be visualized using the ``make_ts`` function, which
# creates a single time-series.
import random

import numpy as np
from nrt import data
from nrt.data import simulate
import matplotlib.pyplot as plt
import matplotlib.dates as mdates

Expand All @@ -27,10 +27,10 @@
for row, amplitude in zip(axes, [0.1, 0.2, 0.3]):
for ax, noise in zip(row, [0.02, 0.05, 0.1]):
break_idx = random.randint(30,100)
ts = data.make_ts(dates=dates,
break_idx=break_idx,
sigma_noise=noise,
amplitude=amplitude)
ts = simulate.make_ts(dates=dates,
break_idx=break_idx,
sigma_noise=noise,
amplitude=amplitude)
ax.plot(dates, ts)
ax.axvline(x=dates[break_idx], color='magenta')
ax.set_ylim(-0.1,1.1)
Expand All @@ -53,14 +53,14 @@
# a time-series of simulated values with varying levels of noise, seasonality, outliers
# and in some cases a structural break point

params_ds = data.make_cube_parameters(shape=(50,50),
n_outliers_interval=(0,5),
n_nan_interval=(0,7),
break_idx_interval=(105,dates.size - 20))
params_ds = simulate.make_cube_parameters(shape=(50,50),
n_outliers_interval=(0,5),
n_nan_interval=(0,7),
break_idx_interval=(105,dates.size - 20))
# Convert break_idx to dates
print('Early breakpoint: %s' % dates[105])
print('Late breakpoint: %s' % dates[dates.size - 20])
cube = data.make_cube(dates=dates, params_ds=params_ds)
cube = simulate.make_cube(dates=dates, params_ds=params_ds)

#################################################################
# In the ndvi datacube created, 50 percents of the pixels contain a break point
Expand Down Expand Up @@ -169,12 +169,12 @@ def accuracy(nrtInstance, params_ds, dates, delta=180):
# process. With such low noise levels, that threshold is easily reached and breaks missed.

def make_cube_fit_and_monitor(dates, noise_level):
params_ds = data.make_cube_parameters(shape=(20,20),
n_outliers_interval=(4,5),
n_nan_interval=(3,4),
sigma_noise_interval=(noise_level, noise_level),
break_idx_interval=(105,dates.size - 20))
cube = data.make_cube(dates=dates, params_ds=params_ds)
params_ds = simulate.make_cube_parameters(shape=(20,20),
n_outliers_interval=(4,5),
n_nan_interval=(3,4),
sigma_noise_interval=(noise_level, noise_level),
break_idx_interval=(105,dates.size - 20))
cube = simulate.make_cube(dates=dates, params_ds=params_ds)
cube_history = cube.sel(time=slice('2018-01-01','2019-12-31'))
cube_monitor = cube.sel(time=slice('2020-01-01', '2022-12-31'))
# Monitoring class instantiation and fitting
Expand Down

0 comments on commit 68c848f

Please sign in to comment.