Skip to content

Commit c17c5ad

Browse files
author
dquartul
committed
folder name in noise generation, c++ where routine
1 parent 95b059c commit c17c5ad

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

cpp_routines/mean_std_whereint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern "C" int where(const double *__restrict__ dt, const int n_macroparticles,
3131
int s = 0;
3232
#pragma omp parallel for reduction(+:s)
3333
for (int i = 0; i < n_macroparticles; i++) {
34-
s += (dt[i]< constant) ? 1 : 0;
34+
s += (dt[i]< constant && dt[i]>0) ? 1 : 0;
3535
}
3636
return s;
3737
}

llrf/rf_noise.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class FlatSpectrum(object):
3434
def __init__(self, GeneralParameters, RFSectionParameters, delta_f = 1,
3535
corr_time = 10000, fmin_s0 = 0.8571, fmax_s0 = 1.1,
3636
initial_amplitude = 1.e-6, seed1 = 1234, seed2 = 7564,
37-
predistortion = None, continuous_phase = False):
37+
predistortion = None, continuous_phase = False, folder_plots = 'fig_noise'):
3838

3939
'''
4040
Generate phase noise from a band-limited spectrum.
@@ -65,6 +65,7 @@ def __init__(self, GeneralParameters, RFSectionParameters, delta_f = 1,
6565
self.continuous_phase = continuous_phase
6666
if self.continuous_phase:
6767
self.dphi2 = np.zeros(self.n_turns+1+self.corr/4)
68+
self.folder_plots = folder_plots
6869

6970

7071
def spectrum_to_phase_noise(self, freq, spectrum, transform=None):
@@ -205,11 +206,12 @@ def generate(self):
205206
self.seed2 +=158
206207
self.dphi2[(k+self.corr/4):(kmax+self.corr/4)] = self.dphi_output[0:(kmax-k)]
207208

208-
fig_folder('fig_noise')
209-
plot_noise_spectrum(freq, spectrum, sampling=1, figno=i,
210-
dirname = 'fig_noise')
211-
plot_phase_noise(self.t[0:(kmax-k)], self.dphi_output[0:(kmax-k)],
212-
sampling=1, figno=i, dirname = 'fig_noise')
209+
if self.folder_plots != None:
210+
fig_folder(self.folder_plots)
211+
plot_noise_spectrum(freq, spectrum, sampling=1, figno=i,
212+
dirname = self.folder_plots)
213+
plot_phase_noise(self.t[0:(kmax-k)], self.dphi_output[0:(kmax-k)],
214+
sampling=1, figno=i, dirname = self.folder_plots)
213215
rms_noise = np.std(self.dphi_output)
214216
print("RF noise for time step %.4e s (iter %d) has r.m.s. phase %.4e rad (%.3e deg)" \
215217
%(self.t[1], i, rms_noise, rms_noise*180/np.pi))

0 commit comments

Comments
 (0)