Skip to content

Commit b355262

Browse files
committed
measurements and constraints [compat]
1 parent cbd9f54 commit b355262

17 files changed

Lines changed: 1496 additions & 43 deletions

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
1818

1919
[compat]
2020
DataFrames = "1"
21-
DocStringExtensions = "0.9.5"
21+
DocStringExtensions = "0.9"
2222
IterTools = "1"
23-
OrderedCollections = "1.8.1"
23+
OrderedCollections = "1"
2424
ProgressMeter = "1"
2525
Sobol = "1"
26+
TOML = "1"
2627
YAML = "0.4"
2728
julia = "1.6"

Readme.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,66 @@ result = analyse_program(command, content, "param.txt", pspace, analyse;
208208
folder="output", filename="results.csv")
209209
```
210210

211+
### Experiment Data Management
212+
213+
Manage experimental data, constraints, and analysis results:
214+
215+
```julia
216+
using ParameterSpace
217+
218+
# Create a dataset for experimental data
219+
ds = DataSet{ExperimentData}("axion-mass-constraints")
220+
221+
# Add experiment data points
222+
add!(ds, ExperimentData(
223+
DataSource(citekey="Smith2020", paper="Axion Search",
224+
year=2020, method="Haloscope"),
225+
params=(mass=1e-6, coupling=1e-12),
226+
results=(sigma=2.5,),
227+
uncertainty=(sigma=0.3,)
228+
))
229+
230+
# Add constraint data
231+
add!(ds, ConstraintData(
232+
DataSource(citekey="Jones2021", paper="Dark Matter Limits",
233+
year=2021, method="CMB"),
234+
param=:mass,
235+
lower=1e-9, upper=1e-7,
236+
constraint_type=:exclude
237+
))
238+
239+
# Query and filter data
240+
subset = filter(ds) do e
241+
e.source.year >= 2020 && haskey(e.params, :mass)
242+
end
243+
244+
# Statistical analysis
245+
stats = compute_statistics(ds, :sigma)
246+
# Returns: mean, std, median, min, max, count
247+
248+
# Find gaps in parameter space coverage
249+
gaps = find_gaps(ds, pspace; n_gaps=10)
250+
```
251+
252+
### Data Sources and Citations
253+
254+
Track data provenance with `DataSource`:
255+
256+
```julia
257+
source = DataSource(
258+
citekey="Smith2020",
259+
paper="Axion Dark Matter Search",
260+
year=2020,
261+
method="Haloscope",
262+
notes="First results from new detector"
263+
)
264+
265+
# Access source information
266+
source.citekey # "Smith2020"
267+
source.year # 2020
268+
source.method # "Haloscope"
269+
```
270+
211271
## Legacy API (Backward Compatibility)
212272

213273
The original `Parameter` type is still supported:
@@ -246,6 +306,13 @@ result = analyse_function(g, params, 1.0) # x is fixed at 1.0
246306
- `CoupledParamDim{T}`: Coupled parameter dimension
247307
- `Parameter{A}`: Legacy parameter type
248308

309+
### Experiment Data Types
310+
- `DataSet{T}`: Generic dataset container
311+
- `ExperimentData`: Experimental data point with params, results, and uncertainty
312+
- `ConstraintData`: Constraint data with parameter bounds
313+
- `DataSource`: Source metadata (citekey, paper, year, method, notes)
314+
- `GapRegion`: Gap region in parameter space with center and priority
315+
249316
### Sampling Strategies
250317
- `AbstractSamplingStrategy`: Abstract base type
251318
- `RandomSampling(seed=nothing)`: Random uniform sampling
@@ -261,6 +328,15 @@ result = analyse_function(g, params, 1.0) # x is fixed at 1.0
261328
- `load_yaml(filepath)`, `load_toml(filepath)`: Load from config files
262329
- `save_yaml(pspace, filepath)`, `save_toml(pspace, filepath)`: Save to config files
263330

331+
### Experiment Data Functions
332+
- `add!(dataset, data)`: Add data to dataset
333+
- `filter(f, dataset)`: Filter dataset with predicate
334+
- `compute_statistics(dataset, field)`: Compute statistics for a field
335+
- `find_gaps(dataset, pspace; n_gaps)`: Find gaps in parameter space coverage
336+
- `get_param(data, param)`: Get parameter value
337+
- `get_result(data, result)`: Get result value
338+
- `source(data)`: Get data source information
339+
264340
## Examples
265341

266342
See the `examples/` directory for more detailed examples:

src/ParameterSpace.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,32 @@ using DocStringExtensions
88
using YAML
99
using TOML
1010

11-
import Base: iterate, length, eltype, show, getindex
11+
import Base: iterate, length, eltype, show, getindex, filter
1212

13+
include("datacore.jl")
14+
include("dataset.jl")
15+
include("dataio.jl")
1316
include("paramdim.jl")
1417
include("coupled.jl")
1518
include("paramspace.jl")
19+
include("analysis.jl")
1620
include("sampling.jl")
1721
include("mask.jl")
1822
include("config.jl")
1923
include("compat.jl")
2024
include("analyse.jl")
2125

26+
export DataSource, AbstractDataPoint, source
27+
export ConstraintData, is_valid, width, in_constraint, merge_constraints
28+
export is_include_constraint, is_exclude_constraint
29+
export ExperimentData, param_names, result_names, get_param, get_result
30+
export to_namedtuple, extract_paramdim
31+
export DataSet, name, add!, remove!, query
32+
export save_dataset, load_dataset
33+
export CoverageReport, analyze_coverage
34+
export GapRegion, find_gaps, recommend_points
35+
export ConstraintIntersection, intersect_constraints, allowed_region, is_allowed
36+
export filter_by_constraints, constraint_summary
2237
export Parameter, parameter_dimension, parameter_count
2338
export write_parameter_file, emptyfunction, mkoutputdir
2439
export analyse_function, analyse_program

0 commit comments

Comments
 (0)