Commit 86262449 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Merge branch 'option_near_tafforensis' into 'master'

Composite cor finder

See merge request !182
parents bdade8fb 91565f40
Pipeline #78334 passed with stages
in 7 minutes and 5 seconds
__version__ = "2022.1.10"
__version__ = "2022.1.11"
__nabu_modules__ = [
"app",
"cuda",
......
This diff is collapsed.
import pytest
import numpy as np
from nabu.testutils import utilstest
from nabu.resources.dataset_analyzer import HDF5DatasetAnalyzer
from nabu.pipeline.estimators import CompositeCOREstimator
@pytest.fixture(scope="class")
def bootstrap(request):
cls = request.cls
dataset_downloaded_path = utilstest.getfile("test_composite_cor_finder_data.h5")
cls.theta_interval = 4.5 * 1 # this is given. Radios in the middle of steps 4.5 degree long
# are set to zero for compression
# You can still change it to a multiple of 4.5
cls.cor_pix = 1321.375
cls.abs_tol = 0.0001
cls.dataset_info = HDF5DatasetAnalyzer(dataset_downloaded_path)
cls.cor_options = """side="near"; near_pos = 300.0; near_width = 20.0 """
@pytest.mark.usefixtures("bootstrap")
class TestCompositeCorFinder:
def test(self):
cor_finder = CompositeCOREstimator(
self.dataset_info, theta_interval=self.theta_interval, cor_options=self.cor_options
)
cor_position = cor_finder.find_cor()
message = "Computed CoR %f " % cor_position + " and real CoR %f do not coincide" % self.cor_pix
assert np.isclose(self.cor_pix, cor_position, atol=self.abs_tol), message
......@@ -111,6 +111,29 @@ def extract_parameters(params_str, sep=";"):
res[param_name] = param_val
return res
def compact_parameters(params_dict, sep=";"):
"""
Compact the parameters from a dict into a string.
This is the inverse of extract_parameters. It can be used for example in tomwer to convert
parameters into a string, for example for cor_options, prior to calling a nabu method which
is expecting an argument to be in the form of a string containing options.
Example
--------
The function can be used as follows:
>>> compact_parameters( {"side":"near", "near_pos":300 } )
... "side=near; nearpos= 300;"
"""
if params_dict in ({}, None):
return ""
res = ""
for key, val in params_dict.items():
res = res + "{key} = {val} " + sep
return res
def is_hdf5_extension(ext, errors="ignore"):
if ext.lower() in ["h5", "hdf5", "nx"]:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment