Skip to content

Commit

Permalink
v1.56
Browse files Browse the repository at this point in the history
### v1.56 ###
	* Bug Fix in asymptotic_mm_freeDp_numaxspread_curvepmodes_v3_GRANscaled_Kallinger2014:
	  The model was set with legacynoise=true instead of legacynoise=false, leading to completely wrong noise backgrounds

A few debug lines were also added to allow to see the frequency, Height, HNR and Width of modes for each iteration on screen.
  • Loading branch information
OthmanB committed Feb 29, 2024
1 parent 31b9f02 commit 1b013a3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Version history #

### v1.56 ###
* Bug Fix in asymptotic_mm_freeDp_numaxspread_curvepmodes_v3_GRANscaled_Kallinger2014:
The model was set with legacynoise=true instead of legacynoise=false, leading to completely wrong noise backgrounds

### v1.55 ###
* Change in the definition of d0l for aj MS models so that it is consistent with RGB models that are based on the ARMM code. thus the prescription nu = (n + l/2 + epsilon)*Dnu - d0l is used now
* Cleanup configuration directory
Expand Down
28 changes: 16 additions & 12 deletions external/ARMM/bump_DP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,17 +621,6 @@ Params_synthetic_star make_synthetic_asymptotic_star(Cfg_synthetic_star cfg_star

// Allow to debug content of cfg_star
//displayCfgSyntheticStar(cfg_star);
if(legacynoise == true){
//noise_params_harvey_like=[A_Pgran , B_Pgran , C_Pgran , A_taugran , B_taugran , C_taugran , p N0] //
noise_params_harvey1985[0] = cfg_star.noise_params_harvey_like[0] * std::pow(cfg_star.numax_star*1e-6,cfg_star.noise_params_harvey_like[1]) + cfg_star.noise_params_harvey_like[2]; // Granulation Amplitude
noise_params_harvey1985[1] = cfg_star.noise_params_harvey_like[3] * std::pow(cfg_star.numax_star*1e-6, cfg_star.noise_params_harvey_like[4]) + cfg_star.noise_params_harvey_like[5]; // Granulation timescale (in seconds)
noise_params_harvey1985[0] = noise_params_harvey1985[0]/noise_params_harvey1985[1];
noise_params_harvey1985[1]= noise_params_harvey1985[1]/1000.;

noise_params_harvey1985[2]=cfg_star.noise_params_harvey_like[6];
noise_params_harvey1985[3]=cfg_star.noise_params_harvey_like[7];
}

// Fix the resolution to 4 years (converted into microHz)
resol=1e6/(4*365.*86400.);
// ----- l=0 modes -----
Expand Down Expand Up @@ -660,12 +649,27 @@ Params_synthetic_star make_synthetic_asymptotic_star(Cfg_synthetic_star cfg_star
noise_l0.resize(nu_l0.size());
noise_l0.setZero();
if(legacynoise == true){
//noise_params_harvey_like=[A_Pgran , B_Pgran , C_Pgran , A_taugran , B_taugran , C_taugran , p N0] //
noise_params_harvey1985[0] = cfg_star.noise_params_harvey_like[0] * std::pow(cfg_star.numax_star*1e-6,cfg_star.noise_params_harvey_like[1]) + cfg_star.noise_params_harvey_like[2]; // Granulation Amplitude
noise_params_harvey1985[1] = cfg_star.noise_params_harvey_like[3] * std::pow(cfg_star.numax_star*1e-6, cfg_star.noise_params_harvey_like[4]) + cfg_star.noise_params_harvey_like[5]; // Granulation timescale (in seconds)
noise_params_harvey1985[0] = noise_params_harvey1985[0]/noise_params_harvey1985[1];
noise_params_harvey1985[1]= noise_params_harvey1985[1]/1000.;

noise_params_harvey1985[2]=cfg_star.noise_params_harvey_like[6];
noise_params_harvey1985[3]=cfg_star.noise_params_harvey_like[7];
noise_l0=harvey1985(noise_params_harvey1985, nu_l0, noise_l0, 1); // Iterate on Noise_l0 to update it by putting the noise profile with one harvey profile
} else{
int Nharvey=(cfg_star.noise_params_harvey_like.size() -1)/3; // Assumes that we have Nharvey + white noise
noise_l0=harvey_like(cfg_star.noise_params_harvey_like, nu_l0, noise_l0, Nharvey);
//std::cout << " Nharvey : " << Nharvey << std::endl;
}

/*std::cout << "noise within make_asymptotic_star :" << std::endl;
for (int i=0 ; i<nu_l0.size();i++){
std::cout << nu_l0[i] << std::setw(15) << noise_l0[i] << std::endl;
}
std::cout << " noise parameters within make_asymptotic_star :" << std::endl;
std::cout << " " << cfg_star.noise_params_harvey_like.transpose() << std::endl;
*/
c=1; // This is the ratio of HNR between the reference star and the target simulated star: maxHNR_l0/maxHNR_ref.
hmax_l0=cfg_star.maxHNR_l0*noise_l0*c;
height_l0=height_l0.cwiseProduct(hmax_l0); // height_l0 being normalised to 1 on width_height_load_rescale, getting the desired hmax_l0 requires just to multiply height_l0 by hmax_l0
Expand Down
28 changes: 25 additions & 3 deletions models_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,8 @@ bool asymptotic_mm_freeDp_numaxspread_curvepmodes_v3_GRANscaled_Kallinger2014(Ve
cfg_star.alpha_p_star=cfg_star.beta_p_star/cfg_star.nmax_star;
cfg_star.sigma_m=0;
cfg_star.sigma_p=0;

cfg_star.legacynoise=false; // added on 29 Feb 2024

if (std::abs(nmax_spread) > 0)
{
try
Expand Down Expand Up @@ -1333,7 +1334,7 @@ bool asymptotic_mm_freeDp_numaxspread_curvepmodes_v3_GRANscaled_Kallinger2014(Ve
inc_star=inc_rad*180./PI;

// b. Generate the mode profiles and frequencies
params=make_synthetic_asymptotic_star(cfg_star);
params=make_synthetic_asymptotic_star(cfg_star, cfg_star.legacynoise);
if (params.failed == false){
mode_params=bumpoutputs_2_MatrixXd(params, inc_star); // get the output in a format that can be written with the writting function
write_star_mode_params_aj(mode_params, file_out_modes);
Expand All @@ -1353,8 +1354,28 @@ bool asymptotic_mm_freeDp_numaxspread_curvepmodes_v3_GRANscaled_Kallinger2014(Ve
noise_params(3, 2)=-2;
// A FUNCTION THAT WRITES THE Noise
write_star_noise_params(noise_params, file_out_noise);
// ADDING on 29 Feb 2024
VectorXd tmp(mode_params.rows());
tmp.setConstant(0);
const VectorXd local_noise=harvey_like(noise_params, mode_params.col(1), tmp); // Generate a list of local noise values for each frequencies
std::cout << "Using the Noise profile of the New star, using provided noise parameters and Kallinger+2014 prescription" << std::endl;
std::cout << "Target max(HNR):" << cfg_star.maxHNR_l0 << std::endl;
std::cout << "HNR of all modes:" << std::endl;
std::cout << " " << std::setw(15) << "degree" << std::setw(15) << "frequency" << std::setw(15) << "Height" << std::setw(15) << "HNR" << std::setw(15) << "local_noise" << std::setw(15) << "Width" << std::endl;
for(int i =0; i<mode_params.rows(); i++){
double HNR=mode_params(i,2)/local_noise[i];
std::cout << " " << std::setw(15) << mode_params(i,0) << std::setw(15) << mode_params(i,1) << std::setw(15) << mode_params(i,2) << std::setw(15) << HNR << std::setw(15) << local_noise[i] << std::setw(15) << mode_params(i,3) << std::endl;
}
/*
std::cout << "Noise parameters:" << std::endl;
for (int i=0; i<noise_params.rows();i++){
std::cout << noise_params.row(i) << std::endl;
}
exit(EXIT_SUCCESS);
*/
//
}
return params.failed;
return params.failed;
}


Expand Down Expand Up @@ -2638,6 +2659,7 @@ void generate_cfg_from_synthese_file_Wscaled_aj_GRANscaled_Kallinger2014(VectorX
//h_star=Height_factor * HNRref * N0;
if (local_noise_new.sum()!= 0){
std::cout << "Using the Noise profile of the New star, using provided noise parameters and Karoff et al. 2010 prescription" << std::endl;
std::cout << "Target HNR : " << HNR << std::endl;
std::cout << "HNR of all modes:" << std::endl;
std::cout << " " << std::setw(15) << "degree" << std::setw(15) << "freq_template" << std::setw(15) << "freq_rescaled" << std::setw(15) << "HNR" << std::setw(15) << "Height" << std::setw(15) << "local_noise" << std::endl;
for(i =0; i<ref_star.mode_params.rows(); i++){
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
#define APP_ID "CPPSpecSim" /**< Application ID */
#define APP_NAME "CPPSpecSim" /**< Application Name */
#define APP_DESC "Spectrum Simulator for Asteroseismology" /**< Application Description */
#define APP_VERSION "1.55" /**< Application Version */
#define APP_VERSION "1.56" /**< Application Version */
#define APP_DOMAIN "" /**< Application Domain */
#define APP_SITE "https://othmanbenomar.dev" /**< Application Site */
#define APP_COPYRIGHT "Othman Benomar" /**< Application Copyright */

#define APP_VER_MAJOR 1 /**< Application Major Version */
#define APP_VER_MINOR 55 /**< Application Minor Version */
#define APP_VER_MINOR 56 /**< Application Minor Version */
//#define APP_VER_BUILD 0
//#define APP_VER_REV 0

Expand Down

0 comments on commit 1b013a3

Please sign in to comment.