-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding example runs for diagnostic models (#331)
- Loading branch information
1 parent
f840933
commit 1bc63e8
Showing
3 changed files
with
1,398 additions
and
1,388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
from typing import Callable | ||
|
||
import matplotlib.pylab as plt | ||
|
||
from indica.defaults.read_write_defaults import load_default_objects | ||
from indica.models import Bolometer | ||
from indica.models import ChargeExchange | ||
from indica.models import HelikeSpectrometer | ||
from indica.models import Interferometry | ||
from indica.models import ThomsonScattering | ||
|
||
|
||
def run_example_diagnostic_model( | ||
machine: str, instrument: str, model: Callable, plot: bool = False | ||
): | ||
transforms = load_default_objects(machine, "geometry") | ||
equilibrium = load_default_objects(machine, "equilibrium") | ||
plasma = load_default_objects(machine, "plasma") | ||
|
||
plasma.set_equilibrium(equilibrium) | ||
transform = transforms[instrument] | ||
transform.set_equilibrium(equilibrium) | ||
model = model(instrument) | ||
model.set_transform(transform) | ||
model.set_plasma(plasma) | ||
|
||
bckc = model(sum_beamlets=False) | ||
|
||
if plot and hasattr(model, "plot"): | ||
plt.ioff() | ||
model.plot() | ||
plt.show() | ||
|
||
return plasma, model, bckc | ||
|
||
|
||
def example_thomson_scattering( | ||
plot=False, | ||
): | ||
machine = "st40" | ||
instrument = "ts" | ||
_model = ThomsonScattering | ||
return run_example_diagnostic_model(machine, instrument, _model, plot=plot) | ||
|
||
|
||
def example_bolometer( | ||
plot=False, | ||
): | ||
machine = "st40" | ||
instrument = "blom_xy1" | ||
_model = Bolometer | ||
return run_example_diagnostic_model(machine, instrument, _model, plot=plot) | ||
|
||
|
||
def example_axuv_unfiltered( | ||
plot=False, | ||
): | ||
machine = "st40" | ||
instrument = "sxrc_xy1" | ||
_model = Bolometer | ||
return run_example_diagnostic_model(machine, instrument, _model, plot=plot) | ||
|
||
|
||
def example_charge_exchange( | ||
plot=False, | ||
): | ||
machine = "st40" | ||
instrument = "cxff_pi" | ||
_model = ChargeExchange | ||
return run_example_diagnostic_model(machine, instrument, _model, plot=plot) | ||
|
||
|
||
def example_helike_spectroscopy( | ||
plot=False, | ||
): | ||
machine = "st40" | ||
instrument = "xrcs" | ||
_model = HelikeSpectrometer | ||
return run_example_diagnostic_model(machine, instrument, _model, plot=plot) | ||
|
||
|
||
def example_interferometer( | ||
plot=False, | ||
): | ||
machine = "st40" | ||
instrument = "smmh" | ||
_model = Interferometry | ||
return run_example_diagnostic_model(machine, instrument, _model, plot=plot) | ||
|
||
|
||
if __name__ == "__main__": | ||
example_helike_spectroscopy(plot=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.