Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jmwood94 0/107 add neutral beam #271

Open
wants to merge 86 commits into
base: st40
Choose a base branch
from

Conversation

jmwood94-0
Copy link
Collaborator

Pull request for adding a new Neutral Beam model class to Indica and working on forward modelling using the existing Charge Exchange class on ST40 data.

The main changes include:

  • New Neutral Beam class which stores useful input data, no call functions yet implemented.
  • Significant update to the ChargeExchange class, adding call to FIDASIM inside the call function and a new method that calls and runs a local version of FIDASIM.
  • An example workflow for running the FIDASIM forward model using ST40 data.

There are some places highlighted in the code where code hasn't yet been implemented, or I have had to use a work around to bypass some python environment issues I have been facing.

jmwood94-0 and others added 30 commits March 28, 2022 10:19
@marcosertoli
Copy link
Contributor

Added most recent changes to st40 in a separate pull request that @michael-gemmell is going to look into, as it changes some of his previous work.
Once that is taken care of, I'll tackle this pull request.

@jmwood94-0
Copy link
Collaborator Author

@marcosertoli, I've tested the new workflow example function and it works. I've just pushed this change to the branch!

jmwood94-0 and others added 16 commits August 15, 2023 14:18
* Move catch import errors in machine-specific readers

Use try..except block when adding PPFReader and ST40Reader to __all__
for readers/__init__.py

Prevents exception if missing reader-specific package (e.g. MDSPlus
for ST40Reader) when not using that reader

* Move import of ST40Reader in plasma.py to inside example_run function
* Fixed boundary estimation

* Moved rho_theta converter to abstract class

* Fixed bug in channel assignement -> no integer starting at 0 as all other readers

* Adapted for beamlet LOS & moved plotting to model method

* Adapted for beamlet LOS

* Simplified error handling and added raw_data_trange for easier comparing vs binned data

* Added unit reading, deleted temporary fix of SXR geometry

* Harmonised 1D and asymmetry inversion/inference and plotting of results

* Added attributes to TS fit including Rshift

* Deleted writing to HDA and created HDA reader.

* Deleted npz file of 1D reconstruction

* Simplified and modularised Zeff workflows --> will make this into an operator soon

* Fixed linting issue

* Added global paths for plotting and data to utilities.py

* Refactored all plotting/writing methods to use common path from utilities.py

* Fixed bug in fit_profile_and_Rshift call

---------

Co-authored-by: Marco Sertoli <[email protected]>
* function autocorr plot added

* ion density added to kinetic profiles saved

* inital commit of abstract workflow and example of usage

* doc strings

* renaming workflow

* Ti_ref as default

* abstract methods added

* Changed to new MDSPlus structure

* Adding default methods

* moved sampling to it's own function in abstract class

* moved sampling to it's own function in abstract class

* renamed abstract class to AbstractBayesWorkflow

* comments

* added high density sampling as method

* added attributes to __init__

* error handling __init__

* error handling __init__

* moved read data to abstract class

* initial commit

* kwargs added

* xrcs wavelength units corrected

* background to int

* stash

* renamed impurities

* stashing

* stashing

* stashing

* fixing key names

* updating and testing example

* added background as attribute of helike model

* fixed phantom methods

* rearranged methods

* moved background to call kwarg

* params and kwargs now are given as model_{var} and model prefix is removed before model call

* adding _phantom_data and _exp_data abstract methods

* renaming to BayesWorkflowExample

* initial commit

* renamed phantom_params to profile_params

* renamed bayesopt -> bayesmodel

* renamed bayesopt -> bayesmodel

* moved start point sampling to its own method _sample_start_points

* fixed variable name

* fixed bug with start_points being overwritten

* removed workflow_dev

* moving equilibrium to workflow object

* when reading raw data save transforms to their own attribute

* transforms saved to workflow class

* fixed name

* renamed example transform

* made example los function

* minor name fix

* made read_test_data function

* made example los function

* minor type

* added reader to read_test_data method

* fixed copying workflow object states

* updated example to work with assign_profiles

* can now run with pulse = None and synthetic transforms/equilibrium

* formatting

* refactoring names

* deleted old bayes_models tests

* reformatted _build_bckc for readability

* moved percentage error to class attribute

* fixing init percent error

* black formatting

* renamed kin_prof -> plasma_profiles

* refactored window handling

* replaced doppler_broaden with physics.ev_doppler

* removed methods from __init__

* stashing

* setup_plasma now takes kwargs

* adding plasma to models now happens in setup_opt_data

* workflow broken up into methods

* removed redundant kwargs

* fixed non_plasma call option

* fixed plasma_initialisation

* fixing violin plotting

* units for xrcs.spectra.wavelength fixed

* nchannels added to example_los

* adding print message for fake data reading

* adjusting example los

* bckc method not printing spectra/fit not available everytime

* adjusting priors

* moved kwargs to sample function

* nsamples kwarg added to sample_from_high_density_region

* mocked bda_tree module

* fixed import

* fixed import

* black formatting

* black formatting

* fixed where mocked module is imported

* black formatting

* mocking bda_tree import

* precommit

* precommit

* moving read_data tvector to kwargs

* precommit formatting

* precommit formatting

* precommit types

* precommit types

* precommit types

* precommit types

* precommit types

* precommit types

* precommit types

* moving kwargs/args around

* adding mode/run to main call

* pressure/stored energy are now saved/written

* removing for loops from pressure/ion density/zeff calculations

* removing for loops from ion density calculations

* defaulting to using cached calculations -> factor 2 speed upgit add indica/models/plasma.py

* example transform moved to own function

* t = time_to_calculate and bckc don't print if chi2 not included

* Thompson Scattering added

* error checking for missing data

* in _make_spectra moved sorting wavelengths to end of method and fixed wavelength co-ordinates that were added incorrectly

* integrating spectra was removing nans so added them back post integration

* pixel offset added as __call__ option

* time vector in INPUTS added

* adjusting calibration factor

* max-min ranges now 0.5-99.5

* high_density_sampling now uses 3 best points

* Gelmin-Rubin diagnostic added to optimisation node

* Gelman-Rubin diagnostic added to tree

* stashing

* now accepts variable number of input parameters and fills missing values with default settings

* priors now more constrained for wped/wcenter

* priors now more constrained for wped/wcenter

* fast particles from ASTRA included

* ASTRA options added to BDA

* chers added

* chers added

* Extra ASTRA options implemented

* prior for ne.wped increased to 30

* not automatically adding equil to transforms now

* Fixed plotting for multiple time points

* save_pickle now takes dictionary as argument

* stashing

* stashing

* Rough batch script for running BDA

* sampler stopping condition based on moments added

* cleaned up and added virtual observations

* normalising TS profiles before fitting

* background can be class attribute or call argument

* placeholder for filtering methods

* gutted workflow class / methods removed to context objects

* gutted workflow class / methods removed to context objects

* moved ln_prior to stand alone func

* Initialisation fixed

* fixed formatting/plotting of optimiser results and adjusted moments stopping criteria to normalise for chain length

* TS dimension bug fix added

* formatting for results dict fixed

* Now plots for all time points

* renamed some nodes and removed TIME_BINS

* renamed bayes_workflow_example -> bayes_workflow

* missing self.

* missing self.

* removed debug printing from sample_with_moments

* renamed batch_bda -> bda_run

* debug printing for stopping condition is now an optional input

* moved back to flat delta moment stopping condition

* default to plotting to test

* comments

* moved sample_from_priors to external function

* moved checking of prior keys from sample_from_priors to BayesSettings dataclass

* _build_bckc now creates nested dictionary instead of flat

* filtering now works on spectra with t dim

* renamed bayes_settings -> blackbox_settings

* renamed bayes_settings -> blackbox_settings

* renamed bayes_settings -> blackbox_settings

* renamed bayes_settings -> blackbox_settings

* added mock transforms to default_factory

* cxfi_tws_c example transform added

* ModelSettings dataclass created to handle model initialisation and calling settings

* missing .self

* stopping criteria sampling rate added to OptimiserSettings

* typo

* added moments tests

* adjusted nimp.y0 prior

* example run updated

* more tests for walkers

* typo

* 11089 pulse added

* temporarily added channel filters for TS / CXFF_TWS_C

* 11089 run added

* expanded wped prior for fitting the pedestal

* Test for walker moves

* testing DE-MCMC

* Full 11089 run with DEMOVES

* testing without emcee move.DESnookerMove

* Testing without DESnookerMove

* fixed rho_poloidal -> rhop

* removed wrapper of kernels

* dt added to read_ts

* using binned data for fits instead of raw

* hack to prevent dtype interpolation error

* closing plots after use

* set_ts_profiles added to plasma_context

* update_profiles now only updates profiles which match parameters provided

* __main__ params adjusted

* reformatting __main__ to run mock example

* fixed error in zeff calculatio

* removed reading ts and added post_process_ts

* reorganising post_processing args

* R_midplane added to profiles

* gitcommit and user added

* R_midplane added

* R_midplane co-ordinate transform added

* violin plots take error as input

* example workflow corrected

* error handling for empty data dicts

* updated to include set_ts option

* python 3.8 -> poetry 3.9

* python >= 3.9 required

* pint added for standard_utility

* default to 43000000

* bda_nodes function is now a global var

* check for tree and use NEW or EDIT mode

* check for tree and use NEW or EDIT mode

* renaming Nimp -> niz1

* Plasma updating now works with Niz1/2_prof instead of Nimp_prof

* Changing default use case

* Nimp_prof -> Niz1_prof

* Option for fitting rho profiles as if symmetric in -rho

* Option for fitting rho profiles as if symmetric in -rho

* Alsu's 11XXX runs added

* default values adjusted for Nimp

* priors adjusted for Nimp

* 11032 added

* fixed missing self.

* fixed missing self.

* initial commit

* mocking opt_data keys

* speeding up run by limiting iterations

* reverting temporary bugfix

* removing comment

* if neither mds_write or plot is true -> don't save pickle

* gitpython added

* commenting out failing test due to helike model using sel instead of interp in call

* pre-commit

* mypy fixes

* Reinstated set_equilibrium with default == False; removed additional raw_data_ dictionary

* Ran: poetry update

---------

Co-authored-by: marcosertoli <[email protected]>
Co-authored-by: Marco Sertoli <[email protected]>
* Impact parameter fix to account for beamlets

* Removed hard-coded inputs and made them keywords.

* Substituted .sel with .interp for wider application.

* Minor mods to profile fitting, including R-shift dependent TS fits.

* Cleaned up readers & created draft PhantomReader to generate fully phantom data.

* Minor fixes to models.

* Moved default ADAS atomic data files to adas.py where it belongs - to be reviewed when/if default settings moved to separate files/directory altogether

* Added TODOs for future refactoring of phantom equilibrium.

* Minor mod for consistency.

* Revised Zeff workflow - included for consistency, but can be ignored in current pull request as is stand-alone and will be reviewed separately.

* All files passing pre-commit

* Fixed ReadST40 wrapper call to set equilibrium

* Included example in fit_ts_rshift.py for clarity

---------

Co-authored-by: Marco Sertoli <[email protected]>
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.

6 participants