Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for scattering fitting #82

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions fitburst/routines/derivative.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,10 @@ def deriv_model_wrt_scattering_index(parameters: dict, model: float, component:
num_freq, num_time, num_component = model.timediff_per_component.shape
deriv_mod_int = np.zeros((num_freq, num_time, num_component), dtype=float)

burst_width = parameters["burst_width"][component]
spectral_index = parameters["spectral_index"][component]
spectral_running = parameters["spectral_running"][component]

# now loop over each model component and compute contribution to derivative.
for current_component in range(num_component):
current_amplitude = model.amplitude_per_component[:, :, current_component]
Expand All @@ -744,8 +748,6 @@ def deriv_model_wrt_scattering_index(parameters: dict, model: float, component:
scattering_timescale = parameters["scattering_timescale"][0]
current_timediff = model.timediff_per_component[:, :, current_component]
scat_times_freq = scattering_timescale * freq_ratio ** scattering_index
spectrum = 10 ** amplitude * freq_ratio ** (spectral_index + spectral_running * log_freq)
spectrum *= freq_ratio ** (-scattering_index)

# define argument of error and scattering timescales over frequency.
spectrum = current_amplitude * freq_ratio[:, None] ** (-scattering_index)
Expand Down Expand Up @@ -1649,7 +1651,7 @@ def deriv2_model_wrt_burst_width_scattering_index(parameters: dict, model: float
# now loop over each frequency and compute mixed-derivative array per channel.
for freq in range(current_model.shape[0]):
freq_ratio = model.freqs[freq] / ref_freq
log_freq = np.log_freq_ratio
log_freq = np.log(freq_ratio)
sc_time_freq = sc_time * freq_ratio ** sc_index
spectrum = 10 ** amplitude * freq_ratio ** (spectral_index + spectral_running * np.log(freq_ratio))
spectrum *= freq_ratio ** (-sc_index)
Expand Down
Loading