Skip to content

feat: add solar wind dm gp#72

Closed
jeremy-baier wants to merge 4 commits intonanograv:mainfrom
jeremy-baier:feat/jgb-sw-gp
Closed

feat: add solar wind dm gp#72
jeremy-baier wants to merge 4 commits intonanograv:mainfrom
jeremy-baier:feat/jgb-sw-gp

Conversation

@jeremy-baier
Copy link
Copy Markdown
Collaborator

@jeremy-baier jeremy-baier commented Nov 3, 2024

Copying over from enterprise extensions.

Adds Fourier basis solar wind dm gp and time domain sw gp with a linear interpolation.

Bug fix (taken from Pat) for deterministic solar wind.

@jeremy-baier jeremy-baier changed the title WIP: Fourier basis solar dm gp WIP: Solar wind dm gp Nov 3, 2024
@jeremy-baier
Copy link
Copy Markdown
Collaborator Author

preliminary testing show that the Fourier basis SWGP is >2x faster overall than the time independent deterministic solar wind gp.
(comparison is single likelihood evaluation time using a fixed white noise + varied dmgp model + varied solar wind model)

@jeremy-baier jeremy-baier changed the title WIP: Solar wind dm gp feat: add solar wind dm gp Nov 4, 2024
@jeremy-baier jeremy-baier marked this pull request as draft November 4, 2024 04:59
return (n_earth * AU_light_sec * AU_pc / r_earth)


def _dm_solar(n_earth, theta, r_earth):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think this is necessary. I think the np.sinc in make_solardm should be faster than using a jnp.where. Note that the definition of np.sinc is sin(pi * x) / (pi * x) hence the 1 - theta / pi in the argument. But make_solardm above should give back the You 2007 function.

@davecwright3
Copy link
Copy Markdown
Collaborator

davecwright3 commented May 13, 2025

@jeremy-baier @meyers-academic I've been testing this PR out with some slight modifications to fourierbasis_solar_dm:

def fourierbasis_solar_dm(psr,
                          components,
                          T=None):
    """
    From enterprise_extions: construct DM-Solar Model Fourier design matrix.
    :param psr: Pulsar object
    :param components: Number of Fourier components in the model
    :param T: Total timespan of the data
    :return: F: SW DM-variation fourier design matrix
    :return: f: Sampling frequencies
    """

    # get base Fourier design matrix and frequencies
    f, df, fmat = fourierbasis(psr, components, T)
    dm_sol_wind = make_solardm(psr)(1.0)

    return f, df, fmat * dm_sol_wind[:, None]

Solar wind can now be put in commongp for the ArrayLikelihood. Example:

commongp = [                                                                           
    ds.makecommongp_fourier(                    
        psrs,                                   
        ds.powerlaw,                            
        30,                                     
        fourierbasis=ds.fourierbasis_solar_dm,  
        T=Tspan ,
        common=["sw_gp_log10_A", "sw_gp_gamma"],
        name="sw_gp",                           
    ),                                          
]                                               

@jeremy-baier
Copy link
Copy Markdown
Collaborator Author

i think this branch was on my old fork of discovery. i am going to close this and open a new PR. see #98

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