readers
Module
Module to provide objects for reading fusion data from the
filesystem or databases. These objects are all subclasses of
readers.DataReader
, with each subclass providing
functionality for a different format of data.
- class indica.readers.ADASReader(path=PosixPath('.'), sess=<indica.session.Session object>)[source]
Class for reading atomic data from ADAS files.
- Parameters
path (Union[str, Path]) – Location from which relative paths should be evaluated. Default is to download files from OpenADAS, storing them in your home directory for later use.
session (session.Session) – An object representing the session being run. Contains information such as provenance data.
sess (indica.session.Session) –
- close()[source]
Closes connections to database/files. For this class it does not need to do anything.
- create_provenance(filename, start_time)[source]
Create a provenance entity for the given ADAS file.
Note that this method just creates the provenance data appropriate for the arguments it has been provided with. It does not check that these arguments are actually valid and that the provenance corresponds to actually existing data.
- Parameters
filename (pathlib.Path) –
start_time (datetime.datetime) –
- Return type
- get_adf11(quantity, element, year)[source]
Read data from the specified ADAS file.
- Parameters
- Returns
The data in the specified file. Dimensions are density and temperature. Each members of the dataset correspond to a different charge state.
- Return type
- get_adf15(element, charge, filetype, year='')[source]
Read data from the specified ADF15 ADAS file.
Implementation is capable of reading files with compact and expanded formatting e.g. pec96][ne_pju][ne9.dat and pec40][ar_cl][ar16.dat respectively
- Parameters
element (str) – The atomic symbol for the element which will be retrieved.
charge (str) – Charge state of the ion (e.g. 16 for Ar 16+), can also include other string for more complicated path (transport_llu][ar15ic.dat setting charge to “15ic”)
filetype (str) – The type of data to retrieve. Options: ic, cl, ca, ls, llu, …
year – The two-digit year label for the data. = “transport” if special transport path
- Returns
The data in the specified file. Dimensions are density and temperature. Each members of the dataset correspond to a different charge state.
- Return type
- property requires_authentication: Literal[False]
Reading ADAS data never requires authentication.
- class indica.readers.DataReader(tstart, tend, max_freq, sess, selector=<function choose_on_plot>, **kwargs)[source]
Abstract base class to read data in from a database.
This defines the interface used by all concrete objects which read data from the disc, a database, etc. It is a context manager and can be used in a with statement.
- Parameters
tstart (float) –
tend (float) –
max_freq (float) –
sess (indica.session.Session) –
selector (Callable[[xarray.core.dataarray.DataArray, str, Collection[numbers.Number], Iterable[numbers.Number]], Iterable[numbers.Number]]) –
kwargs (Any) –
- agent
An agent representing this object in provenance documents. DataArray objects can be attributed to it.
- Type
- INSTRUMENT_METHODS
Mapping between instrument (DDA in JET) names and method to use to assemble that data. Implementation-specific.
- entity
An entity representing this object in provenance documents. It is used to provide information on the object’s own provenance.
- NAMESPACE
The abbreviation and full URL for the PROV namespace of the database the class reads from.
- classmethod available_quantities(instrument)[source]
Return the quantities which can be read for the specified instrument.
- create_provenance(diagnostic, uid, instrument, revision, quantity, data_objects, ignored)[source]
Create a provenance entity for the given set of data. This should be attached as metadata.
Note that this method just creates the provenance data appropriate for the arguments it has been provided with. It does not check that these arguments are actually valid and that the provenance corresponds to actually existing data.
- Parameters
key – Identifies what data was read. Should be present in
AVAILABLE_DATA
.revision (Union[str, int]) – Object indicating which version of data should be used.
data_objects (Iterable[str]) – Identifiers for the database entries or files which the data was read from.
ignored (Iterable[numbers.Number]) – A list of channels which were ignored/dropped from the data.
diagnostic (str) –
uid (str) –
instrument (str) –
quantity (str) –
- Returns
A provenance entity for the newly read-in data.
- Return type
- get(uid, instrument, revision=0, quantities={})[source]
Reads data for the requested instrument. In general this will be the method you want to use when reading.
- Parameters
uid (str) – User ID (i.e., which user created this data)
instrument (str) – The instrument which measured this data (DDA at JET)
revision (Union[str, int]) – An object (of implementation-dependent type) specifying what version of data to get. Default is the most recent.
quantities (Set[str]) – Which physical quantitie(s) to read from the database. Defaults to all available quantities for that instrument.
- Returns
A dictionary containing the requested physical quantities.
- Return type
- get_bremsstrahlung_spectroscopy(uid, instrument, revision, quantities)[source]
Reads spectroscopic measurements of effective charge.
- Parameters
uid (str) – User ID (i.e., which user created this data)
instrument (str) – Name of the instrument which measured this data
revision (Union[str, int]) – An object (of implementation-dependent type) specifying what version of data to get. Default is the most recent.
quantities (Set[str]) – Which physical quantitie(s) to read from the database.
- Returns
A dictionary containing the requested effective charge data.
- Return type
- get_charge_exchange(uid, instrument, revision, quantities)[source]
Reads charge exchange data.
- Parameters
uid (str) – User ID (i.e., which user created this data)
instrument (str) – Name of the instrument which measured this data
revision (Union[str, int]) – An object (of implementation-dependent type) specifying what version of data to get. Default is the most recent.
quantities (Set[str]) – Which physical quantitie(s) to read from the database.
- Returns
A dictionary containing the requested physical quantities.
- Return type
- get_cyclotron_emissions(uid, instrument, revision, quantities)[source]
Reads electron temperature measurements from cyclotron data.
- Parameters
uid (str) – User ID (i.e., which user created this data)
instrument (str) – Name of the instrument which measured this data
revision (Union[str, int]) – An object (of implementation-dependent type) specifying what version of data to get. Default is the most recent.
quantities (Set[str]) – Which physical quantitie(s) to fetch the data for.
- Returns
A dictionary containing the electron temperature.
- Return type
- get_equilibrium(uid, instrument, revision, quantities)[source]
Reads equilibrium data.
- Parameters
uid (str) – User ID (i.e., which user created this data)
instrument (str) – Name of the code used to calculate this data
revision (Union[str, int]) – An object (of implementation-dependent type) specifying what version of data to get. Default is the most recent.
quantities (Set[str]) – Which physical quantitie(s) to read from the database.
- Returns
A dictionary containing the requested physical quantities.
- Return type
- get_filters(uid, instrument, revision, quantities)[source]
Reads filtered radiation diodes
- Parameters
uid (str) – User ID (i.e., which user created this data)
instrument (str) – Name of the instrument which measured this data
revision (Union[str, int]) – An object (of implementation-dependent type) specifying what version of data to get. Default is the most recent.
quantities (Set[str]) – Which physical quantitie(s) to read from the database.
- Returns
A dictionary containing the requested data.
- Return type
- get_helike_spectroscopy(uid, instrument, revision, quantities)[source]
Reads spectroscopic measurements of He-like emission.
- Parameters
uid (str) – User ID (i.e., which user created this data)
instrument (str) – Name of the instrument which measured this data
revision (Union[str, int]) – An object (of implementation-dependent type) specifying what version of data to get. Default is the most recent.
quantities (Set[str]) – Which physical quantitie(s) to read from the database.
- Returns
A dictionary containing the requested data.
- Return type
- get_interferometry(uid, instrument, revision, quantities)[source]
Reads interferometer electron density.
- Parameters
uid (str) – User ID (i.e., which user created this data)
instrument (str) – Name of the instrument which measured this data
revision (Union[str, int]) – An object (of implementation-dependent type) specifying what version of data to get. Default is the most recent.
quantities (Set[str]) – Which physical quantitie(s) to read from the database.
- Returns
A dictionary containing the requested data.
- Return type
- get_radiation(uid, instrument, revision, quantities)[source]
Reads data on irradiance.
- Parameters
uid (str) – User ID (i.e., which user created this data)
instrument (str) – Name of the instrument which measured this data
revision (Union[str, int]) – An object (of implementation-dependent type) specifying what version of data to get. Default is the most recent.
quantities (Set[str]) – Which cameras to read quantitie(s) from.
- Returns
A dictionary containing the requested radiation values.
- Return type
- get_thomson_scattering(uid, instrument, revision, quantities)[source]
Reads data based on Thomson Scattering.
- Parameters
uid (str) – User ID (i.e., which user created this data)
instrument (str) – Name of the instrument which measured this data
revision (Union[str, int]) – An object (of implementation-dependent type) specifying what version of data to get. Default is the most recent.
quantities (Set[str]) – Which physical quantitie(s) to read from the database..
- Returns
A dictionary containing the requested physical quantities.
- Return type
- class indica.readers.PPFReader(pulse, tstart, tend, server='https://sal.jet.uk', default_error=0.05, max_freq=1000000.0, selector=<function choose_on_plot>, session=<indica.session.Session object>)[source]
Class to read JET PPF data using SAL.
- Parameters
times (np.ndarray) – An ordered array of times to which data will be downsampled/interpolated.
pulse (int) – The ID number for the pulse from which to get data.
uid (str) – The UID for the particular data to be read.
server (str) – The URL for the SAL server to read data from.
default_error (float) – Relative uncertainty to use for diagnostics which do not provide a value themselves.
sess (session.Session) – An object representing the session being run. Contains information such as provenance data.
tstart (float) –
tend (float) –
max_freq (float) –
selector (Callable[[xarray.core.dataarray.DataArray, str, Collection[numbers.Number], Iterable[numbers.Number]], Iterable[numbers.Number]]) –
session (indica.session.Session) –
- DIAGNOSTIC_QUANTITIES
Hierarchical information on the quantities which are available for reading. These are indexed by (in order) diagnostic name, UID, instrument name, and quantity name. The values of the innermost dictionary describe the physical type of the data to be read.
- NAMESPACE
The abbreviation and full URL for the PROV namespace of the reader class.
- get_sal_path(uid, instrument, quantity, revision)[source]
Return the path in the PPF database to for the given INSTRUMENT (DDA in JET).
- property requires_authentication
Indicates whether authentication is required to read data.
- Returns
True if authentication is needed, otherwise false.
- indica.readers.choose_on_plot(data, channel_dim, bad_channels, unselected_channels=[])[source]
Produces a plot in its own window, on which the user can click data from channels which they wish to be discarded.
Instructions are printed to the command line, so it is probably not suitable for use in a GUI.
- Parameters
data (xarray.core.dataarray.DataArray) – The data from which channels should be selected to discard.
channel_dim (str) – The name of the dimension used for storing separate channels. This will be used for the x-axis in the plot.
bad_channels (Collection[numbers.Number]) – A (possibly empty) list of channel labels which are known to be incorrectly calibrated, faulty, or otherwise untrustworty. These will be plotted in red, but must still be specifically selected by the user to be discared.
unselected_channels (Iterable[numbers.Number]) – A (possibly empty) list of channels which will be ignored by default. These could be, e.g., cached values from a previous run. The user is welcome to change this.
- Returns
A list of channel labels which the user has selected to be discarded.
- Return type
Reader classes (along with writer classes) inherit from the BaseIO
class, which provides common functionality.
- class indica.abstractio.BaseIO[source]
An abstract class defining methods needed by all IO objects.
- authenticate(name, password)[source]
Confirms user has permission to write data.
This must be called before writing data to some locations. The default implementation does nothing. If the value of py:meth:requires_authentication is
False
then it does not need to be called.