Skip to content

Commit

Permalink
update tutorials for sim signal objects
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Aug 29, 2024
1 parent 7792e7e commit da362f7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tutorials/sim/plot_06_SimParams.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

###################################################################################################
#
# The object can also be used to 'register' (:method:`~.SimParams.register`) a set of
# The object can also be used to 'register' (:func:`~.SimParams.register`) a set of
# simulation parameters, meaning they can be defined and stored in the object,
# with an associated label to access them.
#
Expand Down Expand Up @@ -73,7 +73,7 @@
#
# To manage multiple parameters, they can all be registered to the object.
# For convenience, multiple definitions can be registered together with the
# (:method:`~.SimParams.register_group`) method.
# (:func:`~.SimParams.register_group`) method.
#

###################################################################################################
Expand Down Expand Up @@ -115,8 +115,8 @@

###################################################################################################

# Re-initialize a SimIters object, inheriting from the SimParams object
sim_iters = SimIters(sim_params=sim_params)
# Re-initialize a SimIters object, exporting from existing SimParams object
sim_iters = sim_params.to_iters()

###################################################################################################
#
Expand Down Expand Up @@ -251,8 +251,8 @@

###################################################################################################

# Initialize base set of simulation parameters
sim_samplers = SimSamplers(sim_params=sim_params, n_samples=3)
# Initialize simulation samplers, from pre-initialized SimParams object
sim_samplers = sim_params.to_samplers(n_samples=3)

###################################################################################################
#
Expand Down
37 changes: 37 additions & 0 deletions tutorials/sim/plot_07_SimMulti.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
# Simulate multiple iterations from the same parameter definition
sigs = sim_multiple(sim_powerlaw, params, 3)

###################################################################################################
#
# The output the above function is a :class:~.Simulations object that stores multiple simulated
# signals along with relevant metadata.
#

###################################################################################################

# Check the metadata stored in the simulations object
print(sigs.sim_func, ':', sigs.params)

###################################################################################################

# Plot the simulated signals
Expand Down Expand Up @@ -77,6 +88,18 @@
# Simulate a set of signals
sims_across_params = sim_across_values(sim_powerlaw, multi_params, 3)

###################################################################################################
#
# The output of the above is a :class:~.MultiSimulations object that stores sets of simulations
# across different parameters, and relevant metadata. Each set of simulations is stored within
# this object as a :class:~.Simulations object.
#

###################################################################################################

# The length of the object is the number of parameter sets
print('# of sets of signals:', len(sims_across_params))

###################################################################################################
#
# In the above, we created a set of parameters per definition, which by default are returned
Expand Down Expand Up @@ -114,6 +137,20 @@
# Simulate a set of signals from the defined sampler
sampled_sims = sim_from_sampler(sim_powerlaw, sampler, 3)

###################################################################################################
#
# The output of the above is a :class:~.SampledSimulations object that stores simulations
# created from sampled simulations, as well as the metadata, including the simulation
# parameters for each simulated signal.
#

###################################################################################################

# Check some of the metadata stored in the SampledSimulations object
print(sampled_sims.sim_func)
for paramdef in sampled_sims.params:
print(paramdef)

###################################################################################################

# Plot the set of sampled simulations
Expand Down

0 comments on commit da362f7

Please sign in to comment.