Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
963da40c
Commit
963da40c
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
correct Datafield::crop[2]
parent
31381d37
No related branches found
No related tags found
1 merge request
!1974
Pt fit example now loading data the ba way
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Base/Axis/Frame.cpp
+6
-0
6 additions, 0 deletions
Base/Axis/Frame.cpp
Base/Axis/Frame.h
+1
-0
1 addition, 0 deletions
Base/Axis/Frame.h
Base/Types/OwningVector.h
+10
-3
10 additions, 3 deletions
Base/Types/OwningVector.h
Device/Data/Datafield.cpp
+18
-9
18 additions, 9 deletions
Device/Data/Datafield.cpp
with
35 additions
and
12 deletions
Base/Axis/Frame.cpp
+
6
−
0
View file @
963da40c
...
...
@@ -165,3 +165,9 @@ Frame* Frame::flat() const
outaxes
.
emplace_back
(
s
->
clone
());
return
new
Frame
(
std
::
move
(
outaxes
));
}
void
Frame
::
setScale
(
size_t
k_axis
,
Scale
*
scale
)
{
m_axes
.
replace_at
(
k_axis
,
scale
);
m_size
=
FrameUtil
::
product_size
(
m_axes
.
reference
());
}
This diff is collapsed.
Click to expand it.
Base/Axis/Frame.h
+
1
−
0
View file @
963da40c
...
...
@@ -83,6 +83,7 @@ public:
Frame
*
flat
()
const
;
#ifndef SWIG
void
setScale
(
size_t
k_axis
,
Scale
*
scale
);
std
::
vector
<
const
Scale
*>
clonedAxes
()
const
;
private:
...
...
This diff is collapsed.
Click to expand it.
Base/Types/OwningVector.h
+
10
−
3
View file @
963da40c
...
...
@@ -18,6 +18,7 @@
#ifndef BORNAGAIN_BASE_TYPES_OWNINGVECTOR_H
#define BORNAGAIN_BASE_TYPES_OWNINGVECTOR_H
#include
"Base/Util/Assert.h"
#include
<cstddef>
#include
<utility>
#include
<vector>
...
...
@@ -45,9 +46,6 @@ public:
OwningVector
&
operator
=
(
OwningVector
&&
other
)
=
default
;
void
reserve
(
size_t
n
)
{
m_v
.
reserve
(
n
);
}
void
emplace_back
(
T
*
e
)
{
m_v
.
emplace_back
(
e
);
}
void
insert_at
(
size_t
index
,
T
*
e
)
{
m_v
.
insert
(
m_v
.
begin
()
+
index
,
e
);
}
void
clear
()
{
for
(
T
*
e
:
*
this
)
...
...
@@ -82,6 +80,15 @@ public:
m_v
.
erase
(
m_v
.
begin
()
+
i
);
return
result
;
}
void
emplace_back
(
T
*
e
)
{
m_v
.
emplace_back
(
e
);
}
void
insert_at
(
size_t
i
,
T
*
e
)
{
m_v
.
insert
(
m_v
.
begin
()
+
i
,
e
);
}
void
replace_at
(
size_t
i
,
T
*
e
)
{
ASSERT
(
i
<
m_v
.
size
());
delete
m_v
[
i
];
m_v
[
i
]
=
e
;
}
T
*
release_back
()
{
...
...
This diff is collapsed.
Click to expand it.
Device/Data/Datafield.cpp
+
18
−
9
View file @
963da40c
...
...
@@ -255,6 +255,7 @@ double Datafield::minVal() const
Datafield
*
Datafield
::
crop
(
double
xmin
,
double
ymin
,
double
xmax
,
double
ymax
)
const
{
ASSERT
(
false
);
// needs renovation, similar to Datafield::crop(double xmin, double xmax)
const
auto
xclipped
=
std
::
make_unique
<
Scale
>
(
xAxis
().
clipped
(
xmin
,
xmax
));
const
auto
yclipped
=
std
::
make_unique
<
Scale
>
(
yAxis
().
clipped
(
ymin
,
ymax
));
...
...
@@ -271,22 +272,30 @@ Datafield* Datafield::crop(double xmin, double ymin, double xmax, double ymax) c
Datafield
*
Datafield
::
crop
(
double
xmin
,
double
xmax
)
const
{
const
auto
xclipped
=
std
::
make_unique
<
Scale
>
(
xAxis
().
clipped
(
xmin
,
xmax
));
std
::
vector
<
Bin1D
>
outbins
;
for
(
size_t
i
=
0
;
i
<
xAxis
().
size
();
++
i
)
{
const
double
x
=
xAxis
().
binCenter
(
i
);
if
(
xmin
<=
x
&&
x
<=
xmax
)
outbins
.
push_back
(
xAxis
().
bin
(
i
));
}
auto
*
xclipped
=
new
Scale
(
xAxis
().
axisLabel
(),
outbins
);
const
size_t
N
=
size
();
std
::
vector
<
double
>
out
(
N
);
std
::
vector
<
double
>
errout
(
hasErrorSigmas
()
?
N
:
0
);
size_t
iout
=
0
;
std
::
vector
<
double
>
out
;
std
::
vector
<
double
>
errout
;
for
(
size_t
i
=
0
;
i
<
N
;
++
i
)
{
const
double
x
=
frame
().
projectedCoord
(
i
,
0
);
if
(
x
clipped
->
rangeComprises
(
x
)
)
{
out
[
iout
]
=
m_values
[
i
];
if
(
x
min
<=
x
&&
x
<=
xmax
)
{
out
.
push_back
(
m_values
[
i
]
)
;
if
(
hasErrorSigmas
())
errout
[
iout
]
=
m_errSigmas
[
i
];
++
iout
;
errout
.
push_back
(
m_errSigmas
[
i
]);
}
}
return
new
Datafield
(
frame
().
clone
(),
out
,
errout
);
Frame
*
outframe
=
frame
().
clone
();
outframe
->
setScale
(
0
,
xclipped
);
ASSERT
(
outframe
->
xAxis
().
size
()
==
out
.
size
());
return
new
Datafield
(
outframe
,
out
,
errout
);
}
#ifdef BORNAGAIN_PYTHON
...
...
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