Skip to content

Instantly share code, notes, and snippets.

@llondon6
Created November 1, 2017 12:40
Show Gist options
  • Save llondon6/879023065bd1ab6f0e3b20a684b89ef9 to your computer and use it in GitHub Desktop.
Save llondon6/879023065bd1ab6f0e3b20a684b89ef9 to your computer and use it in GitHub Desktop.
Quick example for using maketaper in positive.maths
# The maketaper functoin takes in a time series (any function domain really), and a 2x1 iterable of indeces defining the start and end of the taper.
# For example:
# Make fake data
mock_times = arange(1,10)
mock_range_values = ones_like( dummy_times )
index_start = 1
index_end = 4
# Create a taper function
the_taper = maketaper( mock_times, [index_start,index_end] )
# Plot the taper function against the dummy data
plot( mock_times, mock_range_values, '-o', label='mock data' )
plot( mock_times, the_taper, '-rs', label='taper function' )
xlim([0,10])
ylim([-0.25,1.25])
xlabel('mock times')
ylabel('mock data')
legend(frameon=False,loc='best')
# To apply the taper, simply multiply the data by the taper
tapered_mock_values = the_taper * mock_range_values
# Plot the result
figure()
plot( mock_times, tapered_mock_values, '-og' )
ylim([-0.25,1.25])
xlabel('mock times')
ylabel('tapered mock data')
legend(frameon=False,loc='best')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment