Support for the log.TAG
files¶
-
class
magic.
MagicSetup
(datadir='.', nml='input.nml', quiet=False)[source]¶ This class allows to read the input namelist or the log file of a current job and creates an object that contains all the parameters found in the namelist/log file.
>>> stp = MagicSetup(nml='log.test', quiet=True) >>> print(stp.ra) # print the Rayleigh number >>> print(stp.n_r_max) # print n_r_max
-
__init__
(datadir='.', nml='input.nml', quiet=False)[source]¶ - Parameters
datadir (str) – the working directory
nml (str) – name of the input namelist/ log file
quiet (bool) – when set to True, makes the output silent (default False)
-
__weakref__
¶ list of weak references to the object (if defined)
-
Support for the time series¶
-
class
magic.
MagicTs
(datadir='.', field='e_kin', iplot=True, all=False, tag=None)[source]¶ This python class is used to read and plot the different time series written by the code:
Kinetic energy: e_kin.TAG
Magnetic energy of the outer core: e_mag_oc.TAG
Magnetic energy of the inner core: e_mag_ic.TAG
Dipole information: dipole.TAG
Rotation: rot.TAG
Diagnostic parameters: par.TAG
Geostrophy: geos.TAG
Taylorization measures: Tay.TAG
Heat transfer: heat.TAG
Helicity: helicity.TAG
Velocity square: u_square.TAG
Angular momentum: AM.TAG
Power budget: power.TAG
Earth-likeness of the CMB field: earth_like.TAG
Parallel and perpendicular decomposition: perpPar.TAG
Phase field: phase.TAG
Hemisphericity: hemi.TAG
RMS force balance: dtVrms.TAG
RMS induction terms: dtBrms.TAG
Time-evolution of m-spectra: am_[kin|mag]_[pol|tor].TAG
Here are a couple of examples of how to use this function.
>>> # plot the most recent e_kin.TAG file found in the directoy >>> MagicTs(field='e_kin') >>> >>> # stack **all** the power.TAG file found in the directory >>> ts = MagicTs(field='power', all=True) >>> print(ts.time, ts.buoPower) # print time and buoyancy power >>> >>> # If you only want to read the file ``heat.N0m2z`` >>> ts = MagicTs(field='heat', tag='N0m2z', iplot=False)
-
__init__
(datadir='.', field='e_kin', iplot=True, all=False, tag=None)[source]¶ - Parameters
datadir (str) – working directory
field (str) – the file you want to plot
iplot (bool) – when set to True, display the plots (default True)
all (bool) – when set to True, the complete time series is reconstructed by stacking all the corresponding files from the working directory (default False)
tag (str) – read the time series that exactly corresponds to the specified tag
Averaging the time series¶
-
class
magic.
AvgField
(tag=None, tstart=None, model='/home/gastine/magic/python/magic/model.json', datadir='.', std=False, write=True)[source]¶ This class computes the time-average properties from time series, spectra and radial profiles. It will store the input starting time in a small file named
tInitAvg
, such that the next time you use it you don’t need to providetstart
again. By default, the outputs are stored in a fully documented JSON file named avg.json: this is split into several categories, namely numerical parameters, physical parameters, time averaged scalar quantities, time averaged spectra and time-averaged radial profiles. The quantities stored in the JSON file are entirely controlled by an input model file wich enlists the different quantities of interest. A default example file namedmodel.json
is provided in$MAGIC_HOME/python/magic
, and an example of how to build a dedicated one is provided below.>>> # Average from t=2.11 >>> a = AvgField(tstart=2.11) >>> # Average only the files that match the pattern N0m2[a-c] >>> a = AvgField(tstart=2.11, tag='N0m2[a-c]') >>> print(a) # print the formatted output >>> # Custom JSON model to select averages >>> json_model = { 'phys_params': ['ek'], 'time_series': { 'heat': ['topnuss', 'botnuss'], 'e_kin': ['ekin_pol', 'ekin_tor'], 'par': ['rm'] }, 'spectra': {}, 'radial_profiles': {'powerR': ['viscDiss', 'buoPower']} } >>> # Compute the selected averages in the dirctory mydir >>> a = AvgField(datadir='mydir', model=json_model)
-
__init__
(tag=None, tstart=None, model='/home/gastine/magic/python/magic/model.json', datadir='.', std=False, write=True)[source]¶ - Parameters
tag (str) – if you specify an input tag (generic regExp pattern), the averaging process will only happen on the time series that match this input pattern
tstart (float) – the starting time for averaging
datadir (str) – working directory
std (bool) – compute the standard deviation when set to True
write (bool) – write the outputs in a JSON file
model (str) – this is the path of a JSON file which defines which fields will be handled in the time-averaging process. This can be any python attributes wich is defined in MagicTs, MagicSpectrum or MagicRadial.
-
__weakref__
¶ list of weak references to the object (if defined)
This routine returns a list of tags which have been generated after tstart
- Parameters
tstart (float) – starting averaging time
- Returns
a list of tags
- Return type
list
-
Some resolution/convergence checks¶
-
magic.checker.
MagicCheck
(tstart=None)[source]¶ This function is used to compute several sanity checks that can be evaluated if the power.TAG and some spectra have been produced in the current directory. If in addition the tInitAvg file is also there in the directory it averages only from this starting time.
>>> MagicCheck(tstart=10.)