goldpan.rqdata¶
The RQs of a whole list of series at once, as numpy arrays, with an on-disk cache: the second read is fast.
The call is that of the collaboration’s rqdata, so that an analysis can move over with its lines unchanged:
from goldpan.rqdata import load
RQS = ["EventType", "PTOFamps", "P*max", "P*std"] # P* = all 12 phonon channels
data = load("24260424_145101", RQS) # a series name, a list of them, or a CSV with a `series` column
data["PTOFamps"] # one numpy array over every event of every series
data["series"] # which series each row came from (also "dump" and "event")
data.files # series -> the file that was read
Each branch comes back as one array with the rows of the files one after the other. A branch name is looked up in eventTree
first, then in zip<N>; a branch a file does not have is filled with NaN for that file; a name with *, ? or [ is a pattern
(see goldpan.adapters.rq_root.read, which does the reading), except P*, which is expanded first into the phonon channels
(P*max is PAS1max, PAS2max, …). The channels are those of the Z7 detector unless you pass phonon_channels=.
Where the files are is not in this library. Say it once, in the environment, and the call above needs nothing more:
GOLDPAN_RQ_FILES(orfiles=in the call): a pattern with{series}in it, for example"/data/R*/Processed/Prompt/*/Submerged/*_{series}.root"; of the files that match, the last in name order is read (a series with one file per dump, like Run 76, isfiles="/data/{series}_F*.root"withall_files=True: every match is read, in name order);GOLDPAN_RQ_DETECTOR(ordetector=): the numberNof thezip<N>tree.
The cache. load saves what it read in $GOLDPAN_CACHE/rqdata (default ~/.cache/goldpan/rqdata, a folder of your own, never
inside a repository). A later load of the same files reuses any cached read that contains all the branches asked for, so asking
for fewer RQs than before costs nothing; refresh=True reads again and cache=False neither reads nor writes the cache. Unlike a
cache keyed on file names, this one is keyed on the state of the files (size and modification time) and on the version of
goldpan: a file that was rewritten is read again, never served from an old entry. Entries are written to a temporary file and
renamed, so a reader never sees half of one. cache_info() lists them and cache_clear() removes them.
Module Attributes
what |
Functions
Delete every entry of the RQ cache; returns how many there were. |
|
The folder of the RQ cache: |
|
|
The entries of the RQ cache as a list of |
|
|
|
The file of |
|
Every file of |
|
All the requested RQs of every series of |
|
The series names of |
Classes
|
- goldpan.rqdata.PHONON_CHANNELS = ['PAS1', 'PAS2', 'PBS1', 'PBS2', 'PCS1', 'PCS2', 'PDS1', 'PDS2', 'PES1', 'PES2', 'PFS1', 'PFS2']¶
what
P*stands for unlessphonon_channels=is given.- Type:
The twelve phonon channels of Z7, in RQ naming
- class goldpan.rqdata.RQData[source]¶
Bases:
dictdictof branch name -> numpy array (plusseries,dumpandeventper row), with.skipped(series with no file),.files(series -> the file that was read) and.dataset(what was asked for).- dataset = None¶
- goldpan.rqdata.cache_dir()[source]¶
The folder of the RQ cache:
$GOLDPAN_CACHE/rqdata, by default~/.cache/goldpan/rqdata.- Return type:
- goldpan.rqdata.series_list(dataset)[source]¶
The series names of
dataset: a series name ("24260424_145101"), a list of them, or the path of a CSV with aseriescolumn (lines starting with#are skipped).- Return type:
- goldpan.rqdata.find_file(series, files=None)[source]¶
The file of
series:filesis a pattern with{series}in it (default:$GOLDPAN_RQ_FILES), or a function of the series name that returns a path orNone. Of several matches the last in name order is taken.Noneif there is no file.
- goldpan.rqdata.find_files(series, files=None)[source]¶
Every file of
series, in name order: the matches of the patternfiles(default:$GOLDPAN_RQ_FILES), or what the functionfiles(series)returns (a path, a list of paths orNone). The empty list if there is none. For a series that is stored as many files, such as the dumps of Run 76.
- goldpan.rqdata.expand_branches(rqs, phonon_channels=None)[source]¶
rqswith everyP*replaced by the phonon channels (P*max->PAS1max, …), each name once, in order.
- goldpan.rqdata.load(dataset, rqs, detector=None, cache=True, refresh=False, verbose=True, files=None, phonon_channels=None, all_files=False)[source]¶
All the requested RQs of every series of
dataset, concatenated (see the module documentation).dataset: a series name, a list of series names, or the path of a CSV with aseriescolumn.rqs: branch names, patterns andP*names.detector: the numberNof thezip<N>tree (default$GOLDPAN_RQ_DETECTOR).files: where the files are (default$GOLDPAN_RQ_FILES), seefind_file.cache=Falsebypasses the cache andrefresh=Truereads again and replaces the entry.all_files=Truereads every file that matches a series (its dumps, in name order) instead of the last one;data.filesthen maps each series to a list of files. Series with no file are skipped and listed indata.skipped.