Skip to content

Conversation

@ehtkarim
Copy link

The processor "gaussian-noise-generator" (from KTGaussianNoiseGenerator.cc) now correctly adds White Gaussian Noise to the signal. I've added an example config file (named KatydidPSConfig_noise.yaml) demonstrating the processor usage. One can also use a random number seed using the "seed" parameter in the config file

@ehtkarim ehtkarim requested a review from nsoblath May 27, 2025 23:15
@ehtkarim ehtkarim assigned ehtkarim and unassigned ehtkarim May 27, 2025
@ehtkarim ehtkarim requested a review from psurukuc May 27, 2025 23:21
@ehtkarim ehtkarim force-pushed the feature/cavity_noise_simulation branch from 94b00d2 to 9be0933 Compare September 17, 2025 16:23
…enerator' processor. Updated 'CMakeLists.txt'
@ehtkarim
Copy link
Author

ehtkarim commented Oct 1, 2025

  • KTGaussianNoiseGenerator

    • Has a working random seed feature now
    • Can configure noise-psd-floor values. Defaults to 2.2e-13 W/Hz (default CCA scenario)
  • KTCavityNoiseGenerator

    • Inherited from KTGaussianNoiseGenerator
    • Has a working random seed feature now
    • Implements Wouter/Arina's frequency dependent cavity noise model
    • Can configure model parameters in the Katydid config file
  • KTMeasuredNoiseGenerator

    • Inherited from KTGaussianNoiseGenerator
    • Takes a .yaml file with psd-mean and psd-variance values at different frequencies as input, interpolates them using a 3rd order spline, and implements the psd-mean and psd-variance values per frequency bin to generate noise

    I'm attaching some freq. and time slices with each of the three noises applied to a nominal 90 degree Locust_MC signal:

Freq_Spectrum_PSD_Mean_1e-19_Variance_2e-36 Time_Series_PSD_Mean_1e-19_Variance_2e-36 Freq_Spectrum_cavity_retuned_parameters Time_Series_cavity_retuned_parameters Freq_Spectrum_aWGN_2 2e-13_PSD_floor Time_Series_aWGN_2 2e-13_PSD_floor

@ehtkarim ehtkarim changed the title feature/cavity_noise_simulation (aWGN implementation) feature/cavity_noise_simulation (additive noise implementation) Oct 10, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this to KatydidPSNoiseConfig.yaml to stick with CamelCase and have the "noise" modifier before "Config"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this to KatydidPSNoiseCavityConfig.yaml to stick with CamelCase and have the "NoiseCavity" modifier before "Config"

virtual bool ConfigureDerivedGenerator(const scarab::param_node* node);

protected:
struct ModelPars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the model parameters contained within a struct? I don't see any particular design reason for it. They should just be member variables of the processor.

I suggest making them all member variables in the class using the MEMVAR macros. Try to stick with the CamelCase naming convention.

const double g = fPars.Q0 / fPars.Q_L;
const double lor = 1.0 / ( 1.0 + std::pow( 2.0 * fPars.Q_L * (f - fPars.f0) / fPars.f0, 2.0 ) ); // Lorentzian

const double kB = 1.380649e-23;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These constants should be added to KTMath (in the Utility directory). Please add them there.

Also, while you're editing those files, can you please make the functions that return numeric constants constexpr? Originally the minimum version of C++ I used didn't have that when I first started Katydid, but we require C++17, so we an use it.


double KTCavityNoiseGenerator::NoisePSD(double f) const
{
const double g = fPars.Q0 / fPars.Q_L;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you add g as a private member variable (no setter). And then you calculate it in the setters for Q0 and Q_L. That way you're not calculating it every time NoisePSD is calculated.


const double P_cav = kB*Tcav * (4.*g/std::pow(1.+g,2)) * lor;
const double P_loss = kB*( fPars.A*fPars.T_line_start + (1.-fPars.A)*fPars.T_line_end );
const double P_isol = kB*Tisol * (1. - (4.*g/std::pow(1.+g,2))*lor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pow() is quite slow. For a simple thing like this one I suggest you just use (1.+g)*(1.+g).

const double hbar= 1.054571817e-34;
const double omega = 2.0 * M_PI * f;

auto eta = [](double x){ return x/(std::exp(x)-1.0) + 0.5; }; // Bose-Einstein factor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest implementing this as a member function. That way you can have unit tests for it, and you won't have memory being allocated for the lambda at runtime.

- egg

egg:
filename: "locust_mc_Seed600_Angle90.000000000_Pos0.0040000_Energy18563.251000000.egg"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an example, please give a generic filename.

- egg

egg:
filename: "locust_mc_Seed600_Angle90.000000000_Pos0.0040000_Energy18563.251000000.egg"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please give a generic filename


protected:
// Simple natural cubic spline for doubles
class KCubicSpline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of re-implementing a spline here, I suggest using Utility/KTSpline

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you could take your implementation and replace the use of ROOT's TSpline3. I've always been bothered by requiring ROOT for the use of KTSpline, but never enough to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants