@@ -24,6 +24,7 @@ export Gaussian
2424export GetAtomicData
2525export Jy2Ecm2sA
2626export Mag2Counts
27+ export NorrisPulse
2728export PL
2829export Pol2Stokes
2930export SBPL
@@ -221,7 +222,7 @@ Compute the discrete Fourier periodogram for the inpout signal.
221222
222223- `signal` array of input data.
223224- `fs` sampling in frequency of the input data (1/dt).
224- - 'zerofreq' is true (false) to (not) include the zero frequency in the output.
225+ - 'zerofreq' is true (false) to (not) include the zero frequency in the output.
225226
226227Outputs are two arrays: the frequencies and the powers.
227228
420421
421422
422423
424+
425+ """
426+ NorrisPulse(x;pulsNorm,tmax,σ_rise,σ_decay,pulsSharpness,base)
427+
428+ Compute an asymmetric pulse shape according to the recipe reported in [Norris et al. (1996).](https://ui.adsabs.harvard.edu/abs/1996ApJ...459..393N/abstract).
429+
430+ # Arguments
431+
432+ - `x` input vector.
433+ - `pulsNorm` the nornalization of the pulse.
434+ - `tmax` the maximum of the pulse.
435+ - `σ_rise` the time-scale of the rising phase.
436+ - `σ_decay` the time-scale of the decaying phase.
437+ - `pulsSharpness` pulse sharpness parameter.
438+ - `base` signal level without the pulse.
439+
440+
441+ # Examples
442+ ```jldoctest
443+
444+ NorrisPulse([1.,2.,3.,4.,5.],pulsNorm=1.5,tmax=3.,σ_rise=1.,σ_decay=2.,pulsSharpness=1.1,base=0.3)
445+
446+ # output
447+
448+ 5-element Vector{Float64}:
449+ 0.47585740398559895
450+ 0.8518191617571635
451+ 1.8
452+ 1.2407748943132098
453+ 0.8518191617571635
454+ ```
455+ """
456+ function NorrisPulse (x;pulsNorm,tmax,σ_rise,σ_decay,pulsSharpness,base)
457+ #
458+ f1 (x) = base .+ pulsNorm .* exp .(- ((abs .(x .- tmax)) ./ σ_rise). ^ pulsSharpness)
459+ f2 (x) = base .+ pulsNorm .* exp .(- ((abs .(x .- tmax)) ./ σ_decay). ^ pulsSharpness)
460+ #
461+ fv = [f1,f2]
462+ #
463+ return piecewise (x,[tmax,],fv)
464+ end
465+
466+
467+
468+ function piecewise (x:: Float64 , breakpts:: Vector{Float64} , f:: Vector{Function} )
469+ @assert (issorted (breakpts))
470+ @assert (length (f) == length (breakpts)+ 1 )
471+ b = searchsortedfirst (breakpts, x)
472+ return f[b](x)
473+ end
474+
475+ piecewise (X:: Vector{Float64} , bpts, f) = [piecewise (x,bpts,f) for x in X ]
476+
477+
478+
479+
480+
481+
423482"""
424483 PL(E,N,α;E0=1.)
425484
0 commit comments