ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
readSample.m File Reference

Go to the source code of this file.

Functions

function readSample (in sampler, in pattern, in sep)
 Return a list of objects of superclass pm.sampling.FileContentsSample containing the contents of a (set of) ParaMonte simulation output sample file(s) whose paths match the specified input pattern or the simulation specification sampler.spec.outputFileName.
More...
 

Function Documentation

◆ readSample()

function readSample ( in  sampler,
in  pattern,
in  sep 
)

Return a list of objects of superclass pm.sampling.FileContentsSample containing the contents of a (set of) ParaMonte simulation output sample file(s) whose paths match the specified input pattern or the simulation specification sampler.spec.outputFileName.

Warning
This function is to be only used for post-processing of the output sample file(s) of an already finished simulation.
Although possible, this method is NOT meant to be called by all processes in MPI-parallel simulations.
Parameters
[in]sampler: The input object of superclass pm.sampling.Sampler whose type and properties determine the type of the output object(s).
(optional. If empty, it is set to pm.sampling.Sampler().)
[in]pattern: The input scalar MATLAB string containing the pattern matching the desired sample file(s) whose contents is to be read.
The specified pattern only needs to partially identify the name of the simulation to which the sample file belongs.
For example, specifying "./mydir/mysim" as input will lead to a search for file(s) beginning with "mysim" and ending with "_sample.txt" inside the directory "./mydir/".
If there are multiple files matching in the input pattern, then all such files will be read and returned as elements of a list.
If the specified pattern is a valid existing URL, the file will be downloaded as a temporary file to the local system, its contents shall be parsed and the file will be subsequently removed.
If the input pattern is empty, then the method will search for any possible candidate files with the appropriate suffix in the current working directory.
(optional. If empty, it is set to sampler.spec.outputFileName or if empty, it is set to "./".)
[in]sep: The input MATLAB string containing the field separator used in the file(s).
(optional. If empty, it is set to sampler.spec.outputSeparator or if empty, it is automatically inferred.)
Returns
sampleList : The output MATLAB cell array of objects of superclass pm.sampling.FileContentsSample, each of which corresponds to the contents of a unique ParaMonte sampler sample file.
  1. If the input argument sampler is of type pm.sampling.Sampler, then the output array elements are of type pm.sampling.FileContentsSample.
  2. If the input argument sampler is of type pm.sampling.Paradram, then the output array elements are of type pm.sampling.FileContentsSample.


Possible calling interfaces

sampleList = pm.sampling.readSample();
sampleList = pm.sampling.readSample([]);
sampleList = pm.sampling.readSample([], []);
sampleList = pm.sampling.readSample(pattern);
sampleList = pm.sampling.readSample([], sep);
sampleList = pm.sampling.readSample(pattern, sep);
Note
See the documentation of the subclasses of pm.sampling.Sampler (e.g., pm.sampling.Paradram) for example usage in action.


Example usage

sampler = pm.sampling.Sampler();
sampleList = pm.sampling.readSample([], "./out/test_run_");
sampleList = pm.sampling.readSample(sampler, "./out/test_run_");
sampler.spec.outputFileName = "./out/test_run_";
sampleList = pm.sampling.readSample(sampler, []);
sampleList = pm.sampling.readSample(sampler);
sampler.spec.outputSeparator = ",";
pm.sampling.readSample(sampler, "./out/test_run_");
pm.sampling.readSample(sampler, "./out/test_run_", []);
sampleList = pm.sampling.readSample(sampler, "./out/test_run_", ",");


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, Saturday Nov 2 2024, 11:11 PM, Dallas, TX.
Fatemeh Bagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.