Normalize Data by Source Spectrum #122
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the SimulationData object loads the raw field, flux, and mode data.
This PR provides a way to normalize frequency-dependent data by the spectrum of one of the original sources.
This eliminates the need to run a separate normalization simulation in some cases.
Main changes to the API:
FreqData(frequency-dependent monitor data) has a.normalize(source_amps)abstract method, that changes their.valuesin place given some source amplitude spectrum.ScalarFieldData,FluxData, andModeDataimplement.normalize(source_amps)methods for their respective data types (depending on whether they are field-like or power-like data).sim_data_normalized = SimulationData.normalize(normalize_index)normalizes all of theFreqDatain theSimulationDatausing the respective.normalize()functions defined above.normalize_indexindexes into theSimulation.sourceslist to grab the source time-dependence to normalize by. A copy is created, as to preserve the original data in case one wants to normalize by a different source later.web.load()adds anormalize_indexargument to allow users to normalize upon loading the data intoSimulationDataobjects.normalize_indexis propagated to all places in web API and web container that callweb.load().Tests show Flux==1 to 1e-4 tolerance for plane wave.