API
Modules
Types and constants
LegendDataManagement.AbstractSetupData
LegendDataManagement.AnyProps
LegendDataManagement.AnyValiditySelection
LegendDataManagement.ChannelId
LegendDataManagement.ChannelIdLike
LegendDataManagement.DataCategory
LegendDataManagement.DataCategoryLike
LegendDataManagement.DataPartition
LegendDataManagement.DataPartitionLike
LegendDataManagement.DataPeriod
LegendDataManagement.DataPeriodLike
LegendDataManagement.DataRun
LegendDataManagement.DataRunLike
LegendDataManagement.DataSelector
LegendDataManagement.DataTier
LegendDataManagement.DataTierLike
LegendDataManagement.DetectorId
LegendDataManagement.DetectorIdLike
LegendDataManagement.ExpSetup
LegendDataManagement.ExpSetupLike
LegendDataManagement.FileKey
LegendDataManagement.FileKeyLike
LegendDataManagement.LJlExprLike
LegendDataManagement.LegendData
LegendDataManagement.LegendDataConfig
LegendDataManagement.LegendReport
LegendDataManagement.LegendTierData
LegendDataManagement.NoSuchPropsDBEntry
LegendDataManagement.PeriodSelLike
LegendDataManagement.ProcessStatus
LegendDataManagement.PropsDB
LegendDataManagement.RunCategorySelLike
LegendDataManagement.RunSelLike
LegendDataManagement.SetupConfig
LegendDataManagement.Timestamp
LegendDataManagement.TimestampLike
LegendDataManagement.ValiditySelection
Functions and macros
LegendDataManagement.LDMUtils.channel2detector
LegendDataManagement.LDMUtils.create_logtbl
LegendDataManagement.LDMUtils.create_metadatatbl
LegendDataManagement.LDMUtils.create_pars
LegendDataManagement.LDMUtils.create_validity
LegendDataManagement.LDMUtils.data_starttime
LegendDataManagement.LDMUtils.detector2channel
LegendDataManagement.LDMUtils.detector_type
LegendDataManagement.LDMUtils.get_hitchfilename
LegendDataManagement.LDMUtils.get_mltrainfilename
LegendDataManagement.LDMUtils.get_partitionfilekeys
LegendDataManagement.LDMUtils.get_partitionvalidity
LegendDataManagement.LDMUtils.get_peaksfilename
LegendDataManagement.LDMUtils.get_plottitle
LegendDataManagement.LDMUtils.get_pltfilename
LegendDataManagement.LDMUtils.get_pltfolder
LegendDataManagement.LDMUtils.get_preportfilename
LegendDataManagement.LDMUtils.get_preportfolder
LegendDataManagement.LDMUtils.get_rreportfilename
LegendDataManagement.LDMUtils.get_rreportfolder
LegendDataManagement.LDMUtils.get_totalTimer
LegendDataManagement.LDMUtils.load_partition_ch
LegendDataManagement.LDMUtils.load_raw_evt
LegendDataManagement.LDMUtils.load_run_ch
LegendDataManagement.LDMUtils.savelfig
LegendDataManagement.LDMUtils.writevalidity
LegendDataManagement.analysis_runs
LegendDataManagement.atomic_fcreate
LegendDataManagement.bad_filekeys
LegendDataManagement.channelinfo
LegendDataManagement.data_path
LegendDataManagement.data_path
LegendDataManagement.data_path
LegendDataManagement.data_path
LegendDataManagement.dataprod_config
LegendDataManagement.dataprod_parameters
LegendDataManagement.dataprod_pars_aoe_window
LegendDataManagement.get_aux_cal_propfunc
LegendDataManagement.get_aux_evt_chdata_propfunc
LegendDataManagement.get_aux_evt_chsel_propfunc
LegendDataManagement.get_aux_evt_levelname_propfunc
LegendDataManagement.get_ged_aoe_cut_propfunc
LegendDataManagement.get_ged_cal_propfunc
LegendDataManagement.get_ged_evt_chdata_propfunc
LegendDataManagement.get_ged_evt_chsel_propfunc
LegendDataManagement.get_ged_evt_hitchsel_propfunc
LegendDataManagement.get_ged_evt_kwargs
LegendDataManagement.get_ged_psd_propfunc
LegendDataManagement.get_ged_qc_cuts_propfunc
LegendDataManagement.get_ged_qc_is_baseline_propfunc
LegendDataManagement.get_ged_qc_is_physical_propfunc
LegendDataManagement.get_ged_qc_is_trig_propfunc
LegendDataManagement.get_partition_combined_periods
LegendDataManagement.get_setup_config
LegendDataManagement.get_spm_cal_propfunc
LegendDataManagement.get_spms_evt_chdata_propfunc
LegendDataManagement.get_spms_evt_chsel_propfunc
LegendDataManagement.get_uncertainties
LegendDataManagement.get_values
LegendDataManagement.is_analysis_cal_run
LegendDataManagement.is_analysis_phy_run
LegendDataManagement.is_analysis_run
LegendDataManagement.is_lrun
LegendDataManagement.livetime
LegendDataManagement.ljl_propfunc
LegendDataManagement.ljl_propfunc
LegendDataManagement.lpy_propfunc
LegendDataManagement.lreport
LegendDataManagement.lreport!
LegendDataManagement.lreport_for_show!
LegendDataManagement.map_datafiles
LegendDataManagement.parse_ljlexpr
LegendDataManagement.parse_lpyexpr
LegendDataManagement.partitioninfo
LegendDataManagement.process_ljlexpr
LegendDataManagement.pydataprod_config
LegendDataManagement.pydataprod_parameters
LegendDataManagement.read_filekeys
LegendDataManagement.read_ldata
LegendDataManagement.readlprops
LegendDataManagement.runinfo
LegendDataManagement.search_disk
LegendDataManagement.start_filekey
LegendDataManagement.tmp_filename
LegendDataManagement.write_filekeys
LegendDataManagement.writelprops
LegendDataManagement.writelreport
Documentation
LegendDataManagement.AbstractSetupData
— Typeabstract type AbstractSetupData
Subtypes wrap SetupConfig for specific experiments.
LegendDataManagement.ChannelId
— Typestruct ChannelId <: DataSelector
Represents a LEGEND data channel.
Example:
ch = ChannelId(1083204)
# ch = ChannelId(98) # with old channel numbering
ch.no == 1083204
string(ch) == "ch1083204"
ChannelId("ch1083204") == ch
LegendDataManagement.DataCategory
— Typestruct DataCategory <: DataSelector
Represents a LEGEND data category (related to a DAQ/measuring mode) like "cal" or "phy".
Example:
category = DataCategory(:cal)
category.label == :cal
string(category) == "cal"
DataCategory("cal") == category
LegendDataManagement.DataPartition
— Typestruct DataPartition <: DataSelector
Represents a LEGEND data-taking partition.
Example:
partition = DataPartition(1)
partition.no == 1
string(partition) == "partition01"
DataPartition("partiton01") == partition
LegendDataManagement.DataPeriod
— Typestruct DataPeriod <: DataSelector
Represents a LEGEND data-taking period.
Example:
period = DataPeriod(2)
period.no == 2
string(period) == "p02"
DataPeriod("p02") == period
LegendDataManagement.DataRun
— Typestruct DataRun <: DataSelector
Represents a LEGEND data-taking run.
Example:
r = DataRun(6)
r.no == 6
string(r) == "r006"
DataRun("r006") == r
LegendDataManagement.DataSelector
— Typeabstract type DataSelector
Abstract type for data selectors like ExpSetup
, DataTier
, DataPeriod
, DataRun
, DataCategory
, Timestamp
and FileKey
.
LegendDataManagement.DataTier
— Typestruct DataTier <: DataSelector
Represents a LEGEND data tier like "raw, "dsp", etc.
Example:
tier = DataTier(:raw)
tier.label == :raw
string(tier) == "raw"
DataTier("raw") == tier
LegendDataManagement.DetectorId
— Typestruct DetectorId <: DataSelector
Represents a LEGEND detector id id.
Example:
detector = DetectorId(:V99000A)
detector.label == :V99000A
string(detector) == "V99000A"
DetectorId("V99000A") == detector
LegendDataManagement.ExpSetup
— Typestruct ExpSetup <: DataSelector
Represents a LEGEND experimental setup like "l200".
Example:
setup = ExpSetup(:l200)
setup.label == :l200
string(setup) == "l200"
ExpSetup("l200") == setup
LegendDataManagement.FileKey
— Typestruct FileKey <: DataSelector
Represents a LEGEND file key.
Example:
filekey = FileKey("l200-p02-r006-cal-20221226T200846Z")
See also read_filekeys
and write_filekeys
.
LegendDataManagement.LegendData
— Typestruct LegendData <: AbstractSetupData
Provides access to LEGEND data and metadata.
Constructors:
LegendData(setup_config::SetupConfig)
.LegendData(setup::Symbol)
- requires the$LEGEND_DATA_CONFIG
environment variable to be set.
Examples:
config_filename = "/path/to/config.json"
config = LegendDataConfig(config_filename)
l200 = LegendData(config.setups.l200)
filekey = FileKey("l200-p02-r006-cal-20221226T200846Z")
or simply (if $LEGEND_DATA_CONFIG
is set):
l200 = LegendData(:l200)
LegendData
has the (virtual) properties metadata
and tier
.
The full path to "tier" data files can be retrieved using
(data::LegendData)[tier::Symbol, filekey::FileKey]
(data::LegendData).tier[tier::Symbol, filekey::AbstractString]
Example:
l200.tier[:raw]
l200.tier[:raw, FileKey("l200-p02-r006-cal-20221226T200846Z")]
LegendData comes with an extension for SolidStateDetectors:
l200 = LegendData(:l200)
SolidStateDetector(l200, :V99000A)
LegendDataManagement.LegendDataConfig
— Typestruct LegendDataConfig
Data configuration multiple experimental setups.
Contains a single field setups::PropertyDict{Symbol,SetupConfig}
.
Can be read from a config file via LegendDataConfig(config_filename[s])
, or simply LegendDataConfig()
if the environment variable $LEGEND_DATA_CONFIG
is set. $LEGEND_DATA_CONFIG
may be a list of colon-separated config filenames, which are applied/merged in reverse order (analog to the order of prioritiy in $PATH
and similar).
Example:
config = LegendDataConfig("/path/to/config.json")
setup = config.setups.l200
data_path(setup, "tier", "raw", "cal", "p02", "r006", "l200-p02-r006-cal-20221226T200846Z-tier_raw.lh5")
See also SetupConfig
.
LegendDataManagement.LegendReport
— TypeLegendDataManagement.LegendTierData
— Typestruct LegendDataManagement.LegendTierData
Constructors:
(data::LegendData).tier
LegendDataManagement.LegendTierData(data::LegendData)
The path to data directories and files can be accessed via getindex
on tier_data::LegendTierData
:
tier_data[]
tier_data[tier::DataTierLike]
tier_data[tier::DataTierLike, category::DataCategoryLike]
tier_data[tier::DataTierLike, category::DataCategoryLike, period::DataPeriodLike]
tier_data[tier::DataTierLike, category::DataCategoryLike, period::DataPeriodLike, run::DataRunLike]
tier_data[tier::DataTierLike, category::DataCategoryLike, period::DataPeriodLike, run::DataRunLike, ch::ChannelIdLike]
tier_data[tier::DataTierLike, filekey::FileKeyLike]
tier_data[tier::DataTierLike, filekey::FileKeyLike, ch::ChannelIdLike]
Examples:
```julia l200 = LegendData(:l200)
filekey = FileKey("l200-p02-r006-cal-20221226T200846Z") isfile(l200.tier[:raw, filekey])
isdir(l200.tier[:raw, :cal]) isdir(l200.tier[:raw, :cal, "p02"]) isdir(l200.tier[:raw, :cal, "p02", "r006"]) isdir(l200.tier[DataTier(:raw), DataCategory(:cal), DataPeriod(2), DataRun(6)])
LegendDataManagement.NoSuchPropsDBEntry
— Typestruct LegendDataManagement.NoSuchPropsDBEntry
Indicates that a given property (path) of a LegendDataManagementPropsDB
[@ref] does not exist.
Supports PropDicts.writeprops(missing_props::NoSuchPropsDBEntry, props::PropDicts.PropDict)
to create the missing directories and file for the property path.
LegendDataManagement.PeriodSelLike
— Typestruct PeriodSelLike = Tuple{<:DataPeriodLike, <:DataCategoryLike}
Represents a LEGEND period selection for a specific category
.
LegendDataManagement.ProcessStatus
— Type@enum ProcessStatus
May be succeeded
, pending
, or failed
.
LegendDataManagement.PropsDB
— Typestruct LegendDataManagement.PropsDB
A PropsDB instance, e.g. myprops
, presents an on-disk directory containing JSON files or sub-directories (that contains JSON files in leaf directories) as a dictionary of properties.
PropsDB
supports Base.keys
and Base.getindex
as well as Base.propertynames
and Base.getproperty
to access it's contents. getindex
and getproperty
will return either another PropsDB
or a PropDicts.PropDict
, depending on whether the accessed property is stored as a sub-directory or a JSON file. We recommend to use getproperty
where the properties/keys of the PropDict are more or less standardized and where they may be arbitrary (see examples below).
The contents of PropsDB
may be time- and category-dependent, determined by the presence of a "validity.json" file. In this case, use myprops(sel::LegendDataManagement.ValiditySelection)
or myprops(filekey::FileKey)
to select the desired time and category. The selection can be made at some point during traversal of properties or at the leaf PropsDB
(see the examples below).
Examples:
l200 = LegendData(:l200)
propertynames(l200.metadata.hardware)
l200.metadata.hardware.detectors.germanium
keys(l200.metadata.hardware.detectors.germanium.diodes)
l200.metadata.hardware.detectors.germanium.diodes[:V99000A]
diodes = l200.metadata.hardware.detectors.germanium.diodes
diodes[keys(diodes)]
sel = ValiditySelection("20221226T194007Z", :cal)
filekey = FileKey("l200-p02-r006-cal-20221226T194007Z")
data.metadata.hardware(sel).configuration.channelmaps
data.metadata.hardware.configuration.channelmaps(filekey)
Use code should not instantiate PropsDB
directly, use LegendDataManagement.AnyProps(path::AbstractString)
instead, which may return a PropsDB
or a PropDicts.PropDict
depending on what on-disk content path
points to.
LegendDataManagement.RunCategorySelLike
— Typestruct RunCategorySelLike = Tuple{<:DataPeriodLike, <:DataRunLike}
Represents a LEGEND run selection for a specific category
.
LegendDataManagement.RunSelLike
— Typestruct RunSelLike = Tuple{<:DataPeriodLike, <:DataRunLike}
Represents a LEGEND run selection.
LegendDataManagement.SetupConfig
— Typestruct SetupConfig
Data configuration for an experimental setup.
Supports
data_path(setup, path_components)
Examples:
data_path(setup, "tier", "raw", "cal", "p02", "r006", "l200-p02-r006-cal-20221226T200846Z-tier_raw.lh5")
LegendDataManagement.Timestamp
— Typestruct Timestamp <: DataSelector
Represents a LEGEND timestamp.
Example:
julia timestamp = Timestamp("20221226T200846Z") timestamp.unixtime == 1672085326 string(timestamp) == "20221226T200846Z"
`
LegendDataManagement.ValiditySelection
— Typestruct LegendDataManagement.ValiditySelection
Representy validiy selection for a LegendDataManagement.PropsDB
[@ref].
LegendDataManagement.AnyProps
— TypeLegendDataManagement.AnyProps = Union{LegendDataManagement.PropsDB,PropDicts.PropDict}
Properties stored either in a directory managed via [LegendDataManagement.PropsDB
][@ref] or loaded from one or several files into a PropDicts.PropDict
.
Constructors:
LegendDataManagement.AnyProps(base_path::AbstractString; override_base::AbstractString = "")
LegendDataManagement.AnyValiditySelection
— Typeconst AnyValiditySelection = Union{ValiditySelection,FileKey}
Anything that can be used in time/category-based data selection.
LegendDataManagement.ChannelIdLike
— TypeChannelIdLike = Union{ChannelId, Integer, AbstractString}
Anything that can represent a data channel, like ChannelId(1083204)
or "ch1083204".
LegendDataManagement.DataCategoryLike
— TypeDataCategoryLike = Union{DataCategory, Symbol, AbstractString}
Anything that can represent a data category, like DataCategory(:cal)
, :cal
or "cal"
.
LegendDataManagement.DataPartitionLike
— TypeDataPartitionLike = Union{DataPartition, Symbol, AbstractString}
Anything that can represent a data partition, like DataPartition(2)
or "partition02".
LegendDataManagement.DataPeriodLike
— TypeDataPeriodLike = Union{DataPeriod, Symbol, AbstractString}
Anything that can represent a data period, like DataPeriod(2)
or "p02".
LegendDataManagement.DataRunLike
— TypeDataRunLike = Union{DataRun, Symbol, AbstractString}
Anything that can represent a data run, like DataRun(6)
or "r006".
LegendDataManagement.DataTierLike
— TypeDataTierLike = Union{DataTier, Symbol, AbstractString}
Anything that can represent a data tier, like DataTier(:raw)
, :raw
or "raw"
.
LegendDataManagement.DetectorIdLike
— TypeDetectorIdLike = Union{DetectorId, Symbol, AbstractString}
Anything that can represent a detector id.
LegendDataManagement.ExpSetupLike
— TypeExpSetupLike = Union{ExpSetup, Symbol, AbstractString}
Anything that can represent a setup label, like ExpSetup(:l200)
, :l200
or "l200"
.
LegendDataManagement.FileKeyLike
— TypeFileKeyLike = Union{FileKey, AbstractString}
Anything that can represent a file key, like FileKey("l200-p02-r006-cal-20221226T200846Z")
or "l200-p02-r006-cal-20221226T200846Z"
.
LegendDataManagement.LJlExprLike
— Typeconst LJlExprLike = Union{Expr, Symbol, Integer, AbstractFloat}
Anything that can represent a parsed LEGEND Julia expression.
LegendDataManagement.TimestampLike
— TypeTimestampLike = Union{Timestamp, AbstractString, Integer}
Anything that can represent a timestamp, like Timestamp("20221226T200846Z")
or "20221226T200846Z".
LegendDataManagement.analysis_runs
— Methodanalysis_runs(data::LegendData)
Return cross-period analysis runs.
LegendDataManagement.atomic_fcreate
— Methodfunction atomic_fcreate(
body, filenames::AbstractString...;
create_dirs::Bool = true, overwrite::Bool = true, delete_on_error::Bool=true
)
Creates filenames
in an atomic fashion.
Creates temporary files in the same directories as filenames
, then calls body(temporary_filenames...)
. If body
returns successfully, the files temporary_filenames
are renamed to filenames
. If body
throws an exception, the temporary files are either deleted (if delete_on_error
is true
) or left in place (e.g. for debugging purposes).
If create_dirs
is true
, directories are created if necessary.
If all of files already exist and overwrite
is false
, takes no action (or, if the file is created by other code running in parallel, while body
is running, does not overwrite it).
Throws an error if only some of the files exist and overwrite
is false
.
Returns nothing
.
Example:
atomic_fcreate("foo.txt", "bar.txt") do foo, bar
write(foo, "Hello")
write(bar, "World")
end
LegendDataManagement.bad_filekeys
— Methodbad_filekeys(data::LegendData)
Get the list of filekeys to ignore for data
.
LegendDataManagement.channelinfo
— Methodchannelinfo(data::LegendData, sel::AnyValiditySelection; system::Symbol = :all, only_processable::Bool = false)
channelinfo(data::LegendData, sel::RunCategorySelLike; system::Symbol = :all, only_processable::Bool = false)
Get all channel information for the given LegendData
and ValiditySelection
.
LegendDataManagement.data_path
— Functiondata_path(setup::SetupConfig, path_components::AbstractString...)
Get the full absolute path for the given path_components
as configured for setup
.
Converts between "/" and "\" inside of path_components if necessary (for Windows compatibility).
LegendDataManagement.data_path
— Methoddata_path(setup::AbstractSetupData, path_components::AbstractString...)
Get the full absolute path for the given path_components
as configured for setup
.
LegendDataManagement.data_path
— Methoddata_path(tier_data::LegendTierData, path_components::AbstractString...)
Get the full absolute path for the given path_components
relative to tier_data
.
LegendDataManagement.data_path
— Methoddata_path(pd::LegendDataManagement.PropsDB)
Return the path to the data directory that contains pd
.
LegendDataManagement.dataprod_config
— Methoddataprod_config(data::LegendData)
Get the Julia data production configuration for data
.
Use dataprod_config(data)(valsel::AnyValiditySelection)
to also set the time/category validity selection for the configuration.
Examples:
l200 = LegendData(:l200)
filekey = FileKey("l200-p02-r006-cal-20221226T200846Z")
dataprod_config(l200)(filekey)
or
l200 = LegendData(:l200)
vsel = ValiditySelection("20221226T200846Z", :cal)
dataprod_config(l200)(vsel)
LegendDataManagement.dataprod_parameters
— Methoddataprod_parameters(data::LegendData)
Get the Julia data production parameters data
.
Examples:
l200 = LegendData(:l200)
dataprod_config(l200)
LegendDataManagement.dataprod_pars_aoe_window
— MethodLegendDataManagement.dataprod_pars_aoe_window(data::LegendData, sel::AnyValiditySelection, detector::DetectorId)
Get the A/E cut window for the given data, validity selection and detector.
LegendDataManagement.get_aux_cal_propfunc
— Methodget_aux_cal_propfunc(data::LegendData, sel::AnyValiditySelection, detector::DetectorId)
Get the aux calibration function for the given data, validity selection and the aux channel referred to by detector
.
LegendDataManagement.get_aux_evt_chdata_propfunc
— Methodget_aux_evt_chdata_propfunc(data::LegendData, sel::AnyValiditySelection)
Get the aux channel data output PropertyFunction.
LegendDataManagement.get_aux_evt_chsel_propfunc
— Methodget_aux_evt_chsel_propfunc(data::LegendData, sel::AnyValiditySelection)
Get the aux channel selection PropertyFunction.
LegendDataManagement.get_aux_evt_levelname_propfunc
— Methodget_aux_evt_levelname_propfunc(data::LegendData, sel::AnyValiditySelection)
Get the aux event level name.
LegendDataManagement.get_ged_aoe_cut_propfunc
— MethodLegendDataManagement.get_ged_aoe_cut_propfunc(data::LegendData, sel::AnyValiditySelection, detector::DetectorId; pars_type::Symbol=:ppars, pars_cat::Symbol=:aoe)
Get the A/E cut propfuncs for the given data, validity selection and detector.
LegendDataManagement.get_ged_cal_propfunc
— Methodget_ged_cal_propfunc(data::LegendData, sel::AnyValiditySelection, detector::DetectorId)
Get the HPGe calibration function for the given data, validity selection and detector.
Note: Caches configuration/calibration data internally, use a fresh data
object if on-disk configuration/calibration data may have changed.
LegendDataManagement.get_ged_evt_chdata_propfunc
— Methodget_ged_evt_chdata_propfunc(data::LegendData, sel::AnyValiditySelection)
Get the Ge-detector channel data output PropertyFunction.
LegendDataManagement.get_ged_evt_chsel_propfunc
— Methodget_ged_evt_chsel_propfunc(data::LegendData, sel::AnyValiditySelection)
Get the Ge-detector channel selection PropertyFunction.
LegendDataManagement.get_ged_evt_hitchsel_propfunc
— Methodget_ged_evt_hitchsel_propfunc(data::LegendData, sel::AnyValiditySelection)
Get the hit Ge-detector channel selection PropertyFunction.
LegendDataManagement.get_ged_evt_kwargs
— Methodget_ged_evt_kwargs(data::LegendData, sel::AnyValiditySelection)
Get the Ge-detector evt kwargs.
LegendDataManagement.get_ged_psd_propfunc
— Methodget_ged_psd_propfunc(data::LegendData, sel::AnyValiditySelection, detector::DetectorId; pars_type::Symbol=:ppars, pars_cat::Symbol=:aoe)
Get the HPGe psd calibration function for the given data, validity selection and detector.
Note: Caches configuration/calibration data internally, use a fresh data
object if on-disk configuration/calibration data may have changed.
LegendDataManagement.get_ged_qc_cuts_propfunc
— Methodget_ged_qc_cuts_propfunc(data::LegendData, sel::AnyValiditySelection, detector::DetectorId)
Get the Ge-detector QC cut definitions for the given data and validity selection.
LegendDataManagement.get_ged_qc_is_baseline_propfunc
— Methodget_ged_qc_is_baseline_propfunc(data::LegendData, sel::AnyValiditySelection)
Get a PropertyFunction
that returns true
for events that fullfill the is_baseline
definition.
LegendDataManagement.get_ged_qc_is_physical_propfunc
— Methodget_ged_qc_is_physical_propfunc(data::LegendData, sel::AnyValiditySelection, detector::DetectorId)
Get a PropertyFunction
that returns true
for events that fullfill the is_physical
definition.
LegendDataManagement.get_ged_qc_is_trig_propfunc
— Methodget_ged_qc_istrig_propfunc(data::LegendData, sel::AnyValiditySelection, detector::DetectorId)
Get the Ge-detector trigger condition for the given data and validity selection.
LegendDataManagement.get_partition_combined_periods
— Methodget_partition_combined_periods(data::LegendData, period::DataPeriodLike; chs::Vector{ChannelIdLike}=ChannelIdLike[])
Get a list periods which are combined in any partition for the given period and list of channels.
LegendDataManagement.get_setup_config
— FunctionLegendDataManagement.get_setup_config(data::AbstractSetupData)::SetupConfig
Must be specialized for each subtype of AbstractSetupData
.
LegendDataManagement.get_spm_cal_propfunc
— Methodget_spm_cal_propfunc(data::LegendData, sel::AnyValiditySelection, detector::DetectorId)
Get the LAr/SPMS calibration function for the given data, validity selection and detector.
LegendDataManagement.get_spms_evt_chdata_propfunc
— Methodget_spms_evt_chdata_propfunc(data::LegendData, sel::AnyValiditySelection)
Get the Ge-detector channel data output PropertyFunction.
LegendDataManagement.get_spms_evt_chsel_propfunc
— Methodget_spms_evt_chsel_propfunc(data::LegendData, sel::AnyValiditySelection)
Get the SiPM channel selection PropertyFunction.
LegendDataManagement.get_uncertainties
— Functionget_uncertainties(x::Unitful.Quantity{<:Measurements.Measurement{<:Real}})
get_uncertainties(x::Unitful.Quantity{<:Real})
get_uncertainties(pd::PropDict)
get_uncertainties(A::AbstractArray)
Get the uncertainty of a Unitful.Quantity
or Measurements.Measurement
object or a PropDict
or an array of Unitful.Quantity
or Measurements.Measurement
objects.
LegendDataManagement.get_values
— Functionget_values(x::Unitful.Quantity{<:Measurements.Measurement{<:Real}})
get_values(x::Unitful.Quantity{<:Real})
get_values(pd::PropDict)
get_values(A::AbstractArray)
Get the value of a Unitful.Quantity
or Measurements.Measurement
object or a PropDict
or an array of Unitful.Quantity
or Measurements.Measurement
objects.
LegendDataManagement.is_analysis_cal_run
— Methodis_analysis_cal_run(data::LegendData, (period::DataPeriodLike, run::DataRunLike))
Return true
if run
is an analysis run for data
in period
.
ATTENTION: This is only valid for cal
runs.
LegendDataManagement.is_analysis_phy_run
— Methodis_analysis_phy_run(data::LegendData, (period::DataPeriodLike, run::DataRunLike))
Return true
if run
is an analysis run for data
in period
.
ATTENTION: This is only valid for phy
runs.
LegendDataManagement.is_analysis_run
— Functionis_analysis_run(data::LegendData, (period::DataPeriodLike, run::DataRunLike, cat::DataCategoryLike))
Return true
if run
is an cat
analysis run for data
in period
.
LegendDataManagement.is_lrun
— Methodis_lrun(data::LegendData, runsel::RunSelLike)
Return true
if runsel
is a valid run for data
and therefore appears in the metadata.
LegendDataManagement.livetime
— Functionlivetime(data::LegendData, runsel::RunSelLike)
Get the livetime for data
in physics data taking of run
in period
.
LegendDataManagement.ljl_propfunc
— Functionljl_propfunc(expr::LJlExprLike)
ljl_propfunc(expr_string::AbstractString)
Compiles a PropertyFunctions.PropertyFunction
from a LEGEND Julia expression.
See also parse_lpyexpr
.
LegendDataManagement.ljl_propfunc
— Methodljl_propfunc(expr_map::AbstractDict{Symbol,<:LJlExprLike})
ljl_propfunc(expr_map::AbstractDict{Symbol,<:AbstractString})
ljl_propfunc(expr_map::PropDict)
Compiles a map between output field-names and LEGEND Julia expressions to a single PropertyFunctions.PropertyFunction
.
The generated function will return NamedTuple
s with the same property names as the keys of expr_map
.
LegendDataManagement.lpy_propfunc
— Methodlpy_propfunc(expr_string::AbstractString)::PropertyFunctions.PropertyFunction
Generate a PropertyFunctions.PropertyFunction
from a LEGEND Python expression.
See also parse_lpyexpr
and ljl_propfunc
.
LegendDataManagement.lreport
— Functionlreport()
lreport(contents...)
Generate a LEGEND report, e.g. a data processing report.
Use lreport!(rpt, contents...)
to add more content to a report.
Example:
using LegendDataManagement, StructArrays, IntervalSets, Plots
tbl = StructArray(
col1 = rand(5), col2 = ClosedInterval.(rand(5), rand(5).+1),
col3 = [rand(3) for i in 1:5], col4 = ProcessStatus.(rand(-1:1, 5)),
col5 = [:a, :b, :c, :d, :e], col6 = ["a", "b", "c", "d", "e"],
col7 = [:(a[1]), :(a[2]), :(a[3]), :(a[4]), :(a[5])]
)
rpt = lreport(
"# New report",
"Table 1:", tbl
)
lreport!(rpt, "Figure 1:", stephist(randn(10^3)))
lreport!(rpt, "Figure 2:", histogram2d(randn(10^4), randn(10^4), format = :png))
show(stdout, MIME"text/plain"(), rpt)
show(stdout, MIME"text/html"(), rpt)
show(stdout, MIME"text/markdown"(), rpt)
writelreport("report.txt", rpt)
writelreport("report.html", rpt)
writelreport("report.md", rpt)
See LegendDataManagement.lreport_for_show!
for how to specialize the behavior of show
for specific report content types.
LegendDataManagement.lreport!
— Functionlreport!(rpt::LegendReport, contents...)
Add more content to report rpt
. See lreport
for an example.
LegendDataManagement.lreport_for_show!
— FunctionLegendDataManagement.lreport_for_show!(rpt::LegendReport, mime::MIME, content)
Add the contents of content
to rpt
in a way that is optimized for being displayed (e.g. via show
) with the given mime
type.
show(output, mime, rpt)
first transforms rpt
by converting all contents of rpt
using lreport_for_show!(rpt::LegendReport, mime, content)
.
Defaults to lreport!(rpt, content)
, except for tables (Tables.istable(content) == true
), which are converted to Markdown tables by default for uniform appearance.
lreport_for_show!
is not inteded to be called by users, but to be specialized for specific types of content content
. Content types not already supported will primarily require specialization of
lreport_for_show!(rpt::LegendReport, ::MIME"text/markdown", content::SomeType)
In some cases it may be desireable to specialize lreport_for_show!
for MIME types like MIME"text/html"
and MIME"text/plain"
as well.
LegendDataManagement.map_datafiles
— Methodmap_datafiles(
f_process, f_open, data::LegendData,
category::DataCategoryLike, filekeys::AbstractVector{<:FileKey}
)
Processes all filekeys
in data
for category
.
Opens the files using f_open
and processes them using f_process
.
Returns a @NamedTuple{result::Dict{Filekey}, failed::Dict{Filekey}, success::Bool}
:
values(result)
contains the resultsf_process(f_open(filename))
for all filenames referred to bycategory
andfilekeys
.values(result)
contains the error where processing failed.success
equalsisempty(failed)
LegendDataManagement.parse_ljlexpr
— Methodparse_ljlexpr(expr_string::AbstractString)::LJlExprLike
Parse an LEGEND Julia expression and return a Julia syntax tree.
LegendDataManagement.parse_lpyexpr
— Methodparse_lpyexpr(expr_string::AbstractString)::LJlExprLike
Parse an expression compatible with the LEGEND Python software and return a Julia syntax tree.
LegendDataManagement.partitioninfo
— Functionpartitioninfo(data::LegendData, ch::ChannelId)
partitioninfo(data::LegendData, ch::ChannelId, part::DataPartitionLike)
partitioninfo(data::LegendData, ch::ChannelId, period::DataPeriodLike)
Return cross-period data partitions.
LegendDataManagement.process_ljlexpr
— Functionprocess_ljlexpr(expr::LJlExprLike, f_varsubst = identity)::LJlExprLike
Verify that expr
is a valid LEGEND Julia expression and return it, with modifications if necessary.
Optionally substitute variables in expr
using f_varsubst
.
LegendDataManagement.pydataprod_config
— Methodpydataprod_config(data::LegendData)
Get the Python data production configuration for data
.
Use pydataprod_config(data)(valsel::AnyValiditySelection)
to also set the time/category validity selection for the configuration.
Examples:
l200 = LegendData(:l200)
filekey = FileKey("l200-p02-r006-cal-20221226T200846Z")
pydataprod_config(l200)(filekey)
or
l200 = LegendData(:l200)
vsel = ValiditySelection("20221226T200846Z", :cal)
pydataprod_config(l200)(vsel)
LegendDataManagement.pydataprod_parameters
— Methodpydataprod_parameters(data::LegendData)
Get the Julia data production parameters data
.
Examples:
l200 = LegendData(:l200)
dataprod_config(l200)
LegendDataManagement.read_filekeys
— Methodread_filekeys(filename::AbstractString)::AbstractVector{FileKey}
Reads a list of FileKey
from a text file, one file key per line.
Ignores empty lines. #
may be used to start a comment in the file.
LegendDataManagement.read_ldata
— Functionread_ldata(data::LegendData, selectors...; kwargs...)
read_ldata(f, data::LegendData, selectors...; kwargs...)
read_ldata(columns::NTuple{<:Any, Symbol}, data::LegendData, selectors::Tuple; kwargs...)
read_ldata(column::Symbol, data::LegendData, selectors::Tuple; kwargs...)
Read lh5
data from disk for a given set of selectors
. After reading in, a PropertyFunction f
can be applied to the data. If a tuple of Symbol
s is given, the properties from the tuple are selected. If the n_evts
kwarg is provided, a random selection with n_evts
number of events per file is performed. ch
can be either a ChannelId
or a DetectorId
.
Examples
dsp = read_ldata(l200, :jldsp, filekey, ch)
dsp = read_ldata((:e_cusp, :e_trap, :blmean), l200, :jldsp, filekey, ch)
dsp = read_ldata(:e_cusp, l200, :jldsp, filekey, ch)
dsp = read_ldata(l200, :jldsp, :cal, :p03, :r000, ch)
dsp = read_ldata(l200, :jldsp, :cal, DataPartition(1), ch)
dsp = read_ldata(l200, :jldsp, :cal, DataPeriod(3), ch)
dsp = read_ldata(l200, :jldsp, :cal, runinfo(l200)[1:3], ch)
dsp = read_ldata(l200, :jldsp, filekey, ch; n_evts=1000)
LegendDataManagement.readlprops
— Functionreadlprops(filename::AbstractString)
readprops(filenames::Vector{<:AbstractString})
Read a PropDict from a file and parse it to Unitful.Quantity
and Measurements.Measurement
objects.
Returns
pd::PropDict
with all:val
fields converted toUnitful.Quantity
objects and all:val
fields converted toMeasurements.Measurement
objects.
LegendDataManagement.runinfo
— Methodruninfo(data::LegendData)::Table
runinfo(data::LegendData, runsel::RunSelLike)::NamedTuple
runinfo(data::LegendData, filekey::FileKey)::NamedTuple
Get the run information for data
.
LegendDataManagement.search_disk
— Functionsearch_disk(::Type{<:DataSelector}, path::AbstractString)
Search on-disk data for data categories, periods, runs, and filekeys.
Examples:
l200 = LegendData(:l200)
search_disk(DataCategory, l200.tier[:raw])
search_disk(DataPeriod, l200.tier[:raw, :cal])
search_disk(DataRun, l200.tier[:raw, :cal, "p02"])
search_disk(FileKey, l200.tier[DataTier(:raw), :cal, DataPeriod(2), "r006"])
LegendDataManagement.start_filekey
— Functionstart_filekey(data::LegendData, runsel::RunCategorySelLike)
Get the starting filekey for data
in period
, run
, category
.
LegendDataManagement.tmp_filename
— MethodLegendDataManagement.tmp_filename(fname::AbstractString)
Returns a temporary filename, based on fname
, in the same directory.
Does not create the temporary file.
LegendDataManagement.write_filekeys
— Methodwrite_filekeys(filename::AbstractString, filekeys::AbstractVector{<:FileKey})
Writes a list of FileKey
to a text file, one file key per line.
LegendDataManagement.writelprops
— Functionwritelprops(f::IO, p::PropDict; write_units::Bool=true, write_errors::Bool=true, mutliline::Bool=true, indent::Int=4)
writelprops(filename::AbstractString, p::PropDict; multiline::Bool=true, indent::Int=4)
writelprops(db::PropsDB, key::Union{Symbol, DataSelector}, p::PropDict; kwargs...)
Write a PropDict to a file and strip it to :val
and :unit
fields and :val
and :err
fields.
LegendDataManagement.writelreport
— Functionwritelreport(filename::AbstractString, rpt::LegendReport)
writelreport(filename::AbstractString, mime::MIME, rpt::LegendReport)
Write lreport rpt
to file filename
.
LegendDataManagement.LDMUtils.channel2detector
— Methodchannel2detector(data::LegendData, sel::Union{AnyValiditySelection, RunCategorySelLike}, channel::ChannelIdLike)
Get the DetectorId for a given ChannelId input:
data
, e.g.LegendData(:l200)
`runsel
: runselection, e.g.(DataPeriod(3), DataRun(0), :cal)
channel
: ChannelId e.g.ChannelId(1080005)
`
output:
DetectorId
of corresponding channel
LegendDataManagement.LDMUtils.create_logtbl
— Methodcreate_logtbl(result)
Create a log table for a given result which can be added in a report.
LegendDataManagement.LDMUtils.create_metadatatbl
— Functioncreate_metadatatbl(filekey::FileKey)
create_metadatatbl(filekey::FileKey, part::DataPartitionLike)
Create a metadata table for a given filekey which can be added in a report.
LegendDataManagement.LDMUtils.create_pars
— Methodcreate_pars(pd::PropDict, result::Dict{ChannelInfo, ChannelResult}) -> PropDict
Create a PropDict from a result of the parallel processing
LegendDataManagement.LDMUtils.create_validity
— Methodcreate_validity(result) -> StructArray
Create a StructArray from a result of the parallel processing
LegendDataManagement.LDMUtils.data_starttime
— Methoddata_starttime(data::LegendData, runsel::Union{AnyValiditySelection, RunCategorySelLike})
Extract startime as DateTime from file for a given run selection Input: * data: LegendData, e.g. LegendData(:l200) * runsel: runselection, e.g. (DataPeriod(3), DataRun(0), :cal)
LegendDataManagement.LDMUtils.detector2channel
— Methoddetector2channel(data::LegendData, sel::Union{AnyValiditySelection, RunCategorySelLike}, detector::DetectorIdLike)
Get the ChannelId for a given detectorId input:
data
, e.g.LegendData(:l200)
`runsel
: runselection, e.g.(DataPeriod(3), DataRun(0), :cal)
detector
: DetectorID e.g.DetectorId(:P00573A)
OR ChannelID e.g.
ChannelId(1080005)``
output:
ChannelId
of corresponding detector
LegendDataManagement.LDMUtils.detector_type
— Methodget_det_type(data::LegendData, det::DetectorIdLike)
Looks up the detector type for a given DetectorID.
LegendDataManagement.LDMUtils.get_hitchfilename
— Methodget_hitchfilename(data::LegendData, setup::ExpSetupLike, period::DataPeriodLike, run::DataRunLike, category::DataCategoryLike, ch::ChannelIdLike)
get_hitchfilename(data::LegendData, filekey::FileKey, ch::ChannelIdLike)
Get the filename for the hitch data for a given channel.
LegendDataManagement.LDMUtils.get_mltrainfilename
— Functionget_mltrainfilename(data::LegendData, period::DataPeriodLike, category::DataCategoryLike)
get_mltrainfilename(data::LegendData, filekey::FileKey)
Get the filename for the machine learning training data.
LegendDataManagement.LDMUtils.get_partitionfilekeys
— Methodget_partitionfilekeys(data::LegendData, part::DataPartitionLike, tier::DataTierLike, category::DataCategoryLike; only_good::Bool=true)
Get filekeys for a given partition.
Arguments
data::LegendData
: data objectpart::DataPartitionLike
: partition to be searched intier::DataTierLike
: tiercategory::DataCategoryLike
: categoryonly_good::Bool=true
: only get good filekeys
Return
Vector{FileKey}
: filekeys
LegendDataManagement.LDMUtils.get_partitionvalidity
— Functionget_partitionvalidity(data::LegendData, ch::ChannelIdLike, part::DataPartitionLike, cat::DataCategoryLike=:cal) -> Vector{@NamedTuple{period::DataPeriod, run::DataRun, validity::String}}
Get partition validity for a given channel and partition.
LegendDataManagement.LDMUtils.get_peaksfilename
— Methodget_peaksfilename(data::LegendData, setup::ExpSetupLike, period::DataPeriodLike, run::DataRunLike, category::DataCategoryLike, ch::ChannelIdLike)
get_peaksfilename(data::LegendData, filekey::FileKey, ch::ChannelIdLike)
Get the filename for the peaks data for a given channel.
LegendDataManagement.LDMUtils.get_plottitle
— Functionget_plottitle(setup::ExpSetupLike, period::DataPeriodLike, run::DataRunLike, category::DataCategoryLike, det::DetectorIdLike, process::String; additiional_type::String="")
get_plottitle(filekey::FileKey, det::DetectorIdLike, process::String; kwargs...)
get_plottitle(setup::ExpSetupLike, partition::DataPartitionLike, category::DataCategoryLike, det::DetectorIdLike, process::String; additiional_type::String="")
Get the title for a plot.
LegendDataManagement.LDMUtils.get_pltfilename
— Functionget_pltfilename(data::LegendData, setup::ExpSetupLike, period::DataPeriodLike, run::DataRunLike, category::DataCategoryLike, ch::ChannelIdLike, process::Symbol)
get_pltfilename(data::LegendData, filekey::FileKey, ch::ChannelIdLike, process::Symbol)
get_pltfilename(data::LegendData, partition::DataPartitionLike, setup::ExpSetupLike, category::DataCategoryLike, ch::ChannelIdLike, process::Symbol)
Get the filename for the plot file for a given setup, period, run, category, channel and process.
LegendDataManagement.LDMUtils.get_pltfolder
— Functionget_pltfolder(data::LegendData, period::DataPeriodLike, run::DataRunLike, category::DataCategoryLike, process::Symbol)
get_pltfolder(data::LegendData, filekey::FileKey, process::Symbol)
get_pltfolder(data::LegendData, partition::DataPartitionLike, category::DataCategoryLike, process::Symbol, ch::ChannelIdOrDetectorIDLike)
Get the folder for the plot files for a given period, run, category and process.
LegendDataManagement.LDMUtils.get_preportfilename
— Functionget_preportfilename(data::LegendData, setup::ExpSetupLike, period::DataPeriodLike, category::DataCategoryLike, process::Symbol)
Get the filename for the log file for a given setup, period, category and process.
LegendDataManagement.LDMUtils.get_preportfolder
— Functionget_preportfolder(data::LegendData, period::DataPeriodLike, category::DataCategoryLike)
Get the preport
folder for the log files for a given period and category.
LegendDataManagement.LDMUtils.get_rreportfilename
— Functionget_rreportfilename(data::LegendData, setup::ExpSetupLike, period::DataPeriodLike, run::DataRunLike, category::DataCategoryLike, process::Symbol)
get_rreportfilename(data::LegendData, filekey::FileKey, process::Symbol)
Get the filename for the log file for a given setup, period, run, category and process.
LegendDataManagement.LDMUtils.get_rreportfolder
— Functionget_rreportfolder(data::LegendData, period::DataPeriodLike, run::DataRunLike, category::DataCategoryLike)
Get the rreport
folder for the log files for a given period, run and category.
LegendDataManagement.LDMUtils.get_totalTimer
— Methodget_totalTimer(result::Vector)
Get the total timer from a result vector.
LegendDataManagement.LDMUtils.load_partition_ch
— Methodload_partition_ch(open_func::Function, flatten_func::Function, data::LegendData, partinfo::StructVector, tier::DataTierLike, cat::DataCategoryLike, ch::ChannelIdLike; data_keys::Tuple=(), n_evts::Int=-1, select_random::Bool=false)
load_partition_ch(open_func::Function, flatten_func::Function, data::LegendData, part::DataPartition, tier::DataTierLike, cat::DataCategoryLike, ch::ChannelIdLike; kwargs...)
Load data for a channel from a partition.
Arguments
open_func::Function
: function to open a fileflatten_func::Function
: function to flatten datadata::LegendData
: data objectpartinfo::StructVector
: partition infotier::DataTierLike
: tiercat::DataCategoryLike
: categorych::ChannelIdLike
: channeldata_keys::Tuple=()
: data keys, empty tuple selects all keysn_evts::Int=-1
: number of events, -1 selects all eventsselect_random::Bool=false
: select events randomly
Return
Table
: data table with flattened events
LegendDataManagement.LDMUtils.load_raw_evt
— Functionload_raw_evt(open_func::Function, data::LegendData, ch::ChannelIdLike, data_hit::Table, sel_evt::Int)
load_raw_evt(open_func::Function, data::LegendData, ch::ChannelIdLike, data_hit::Table, sel_evt::UnitRange{Int})
Load data for a channel from a hitch file for a given selected event index or index range.
Arguments
open_func::Function
: function to open a filedata::LegendData
: data objectch::ChannelIdLike
: channeldata_hit::Table
: hitch datasel_evt::Int/UnitRange{Int}
: selected event index
Return
Table
: data table of raw events
LegendDataManagement.LDMUtils.load_run_ch
— Functionload_run_ch(open_func::Function, flatten_func::Function, data::LegendData, filekeys::Vector{FileKey}, tier::DataTierLike, ch::ChannelIdLike; check_filekeys::Bool=true)
Load data for a channel from a list of filekeys in a given tier.
Arguments
open_func::Function
: function to open a fileflatten_func::Function
: function to flatten datadata::LegendData
: data objectfilekeys::Vector{FileKey}
: list of filekeystier::DataTierLike
: tier to load data fromch::ChannelIdLike
: channel to load data forcheck_filekeys::Bool=true
: check if filekeys are valid
LegendDataManagement.LDMUtils.savelfig
— Functionsavelfig(save_func::Function, p, data::LegendData, setup::ExpSetupLike, period::DataPeriodLike, run::DataRunLike, category::DataCategoryLike, ch::ChannelIdLike, process::Symbol; kwargs...)
savelfig(save_func::Function, p, data::LegendData, filekey::FileKey, ch::ChannelIdLike, process::Symbol; kwargs...)
savelfig(save_func::Function, p, data::LegendData, partition::DataPartitionLike, setup::ExpSetupLike, category::DataCategoryLike, ch::ChannelIdLike, process::Symbol; kwargs...)
Save a lplot.
LegendDataManagement.LDMUtils.writevalidity
— Functionwritevalidity(props_db::LegendDataManagement.PropsDB, filekey::FileKey; category::Symbol=:all)
writevalidity(props_db::LegendDataManagement.PropsDB, filekey::FileKey, part::DataPartitionLike; category::Symbol=:all)
Write validity for a given filekey.