Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
c55c4575
Commit
c55c4575
authored
2 years ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
remove development pieces
parent
2ac3e42e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!738
New calcat interface
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cal_tools/calcat_interface.py
+21
-31
21 additions, 31 deletions
src/cal_tools/calcat_interface.py
with
21 additions
and
31 deletions
src/cal_tools/calcat_interface.py
+
21
−
31
View file @
c55c4575
...
...
@@ -611,7 +611,7 @@ class CalibrationData:
return
self
.
_load_ccv_data
(
metadata
,
module
,
calibration
)
def
_allocate_const_arrays
(
self
,
metadata
,
const_load_mp
,
const_data
):
def
_allocate_const
ant
_arrays
(
self
,
metadata
,
const_load_mp
,
const_data
):
for
mod
,
ccv_entry
in
metadata
.
items
():
const_data
[
mod
]
=
{}
...
...
@@ -625,8 +625,23 @@ class CalibrationData:
shape
=
shape
,
dtype
=
dtype
)
def
load_constants_data
(
self
,
metadata
):
def
load_constant_dataset
(
wid
,
index
,
mod
):
def
load_constants_from_metadata
(
self
,
metadata
):
"""
Load the data for all constants in metadata object.
Args:
metadata (CCVMetadata, optional): CCV metadata to load
constant data for, may be None to query metadata.
Returns:
(Dict): A dictionary of constant data.
{module: {calibration: ndarray}}.
"""
def
_load_constant_dataset
(
wid
,
index
,
mod
):
"""
Load constant dataset from the CCVMetadata `metadata` into
a shared allocated array.
Args:
mod (str): module key in `metadata` object
"""
for
cname
,
mdata
in
metadata
[
mod
].
items
():
with
h5py
.
File
(
self
.
caldb_root
/
mdata
[
"
path
"
],
"
r
"
)
as
cf
:
cf
[
f
"
{
mdata
[
'
dataset
'
]
}
/data
"
].
read_direct
(
...
...
@@ -635,8 +650,8 @@ class CalibrationData:
const_data
=
dict
()
const_load_mp
=
psh
.
ProcessContext
(
num_workers
=
24
)
self
.
_allocate_const_arrays
(
metadata
,
const_load_mp
,
const_data
)
const_load_mp
.
map
(
load_constant_dataset
,
list
(
metadata
.
keys
()))
self
.
_allocate_const
ant
_arrays
(
metadata
,
const_load_mp
,
const_data
)
const_load_mp
.
map
(
_
load_constant_dataset
,
list
(
metadata
.
keys
()))
return
const_data
...
...
@@ -663,32 +678,7 @@ class CalibrationData:
if
metadata
is
None
:
metadata
=
self
.
metadata
(
calibrations
)
return
self
.
load_constants_data
(
metadata
)
def
data_map
(
self
,
calibrations
=
None
,
metadata
=
None
,
):
"""
Load all CCV data in a nested map of ndarrays.
Args:
calibrations (Iterable of str, optional): Calibration constants
or None for all available (default).
metadata (CCVMetadata, optional): CCV metadata to load constant
for or None to query metadata automatically (default).
Returns:
(dict of dict of ndarray): CCV data by module number and
calibration constant name.
{module: {calibration: ndarray}}
"""
if
self
.
caldb_root
is
None
:
raise
RuntimeError
(
"
calibration database store unavailable
"
)
if
metadata
is
None
:
metadata
=
self
.
metadata
(
calibrations
)
return
self
.
load_constants_data
(
metadata
)
return
self
.
load_constants_from_metadata
(
metadata
)
def
_build_condition
(
self
,
parameters
):
cond
=
dict
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment