Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
juobs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Javier Ugarrio
juobs
Commits
8aa2abdb
Commit
8aa2abdb
authored
Nov 18, 2025
by
Antonino D'Anna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes in fit_routines plus tests
parent
bf1b33cf
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
230 additions
and
738 deletions
+230
-738
dev/read_meson_vec_gamma.jl
dev/read_meson_vec_gamma.jl
+0
-194
src/juobs_tools.jl
src/juobs_tools.jl
+199
-542
src/juobs_types.jl
src/juobs_types.jl
+3
-2
test/test_fit_routines.jl
test/test_fit_routines.jl
+28
-0
No files found.
dev/read_meson_vec_gamma.jl
deleted
100644 → 0
View file @
bf1b33cf
using
juobs
function
dev_read_mesons
(
path
::
String
,
gamma
::
Vector
{
Tuple
{
String
,
String
}};
id
::
Union
{
String
,
Nothing
}
=
nothing
,
legacy
::
Bool
=
false
,
nnoise_trunc
::
Union
{
Int64
,
Nothing
}
=
nothing
)
type
=
Vector
{
Tuple
{
Int64
,
Int64
}}(
undef
,
length
(
gamma
))
for
i
in
eachindex
(
gamma
)
G1
,
G2
=
gamma
[
i
]
type
[
i
]
=
(
findfirst
(
x
->
x
==
G1
,
juobs
.
gamma_name
)
-
1
,
findfirst
(
x
->
x
==
G2
,
juobs
.
gamma_name
)
-
1
)
end
if
isnothing
(
id
)
bname
=
basename
(
path
)
m
=
findfirst
(
r
"[A-Z][0-9]{3}r[0-9]{3}"
,
bname
)
id
=
bname
[
m
[
1
:
4
]]
end
data
=
open
(
path
,
"r"
)
g_header
=
juobs
.
read_GHeader
(
path
)
c_header
=
juobs
.
read_CHeader
(
path
,
legacy
=
legacy
)
ncorr
=
g_header
.
ncorr
tvals
=
g_header
.
tvals
nnoise
=
g_header
.
nnoise
nnoise_trunc
=
isnothing
(
nnoise_trunc
)
?
nnoise
:
min
(
nnoise
,
nnoise_trunc
)
fsize
=
filesize
(
path
)
datsize
=
4
+
sum
(
getfield
.
(
c_header
,
:
dsize
))
*
tvals
*
nnoise
#data_size / ncnfg
ncfg
=
div
(
fsize
-
g_header
.
hsize
-
sum
(
getfield
.
(
c_header
,
:
hsize
)),
datsize
)
#(total size - header_size) / data_size
corr_match
=
findall
(
x
->
(
x
.
type1
,
x
.
type2
)
in
type
,
c_header
)
seek
(
data
,
g_header
.
hsize
+
sum
(
c
.
hsize
for
c
in
c_header
))
res
=
Array
{
juobs
.
CData
}(
undef
,
length
(
corr_match
))
data_re
=
Array
{
Float64
}(
undef
,
length
(
corr_match
),
ncfg
,
tvals
)
data_im
=
zeros
(
length
(
corr_match
),
ncfg
,
tvals
)
vcfg
=
Array
{
Int32
}(
undef
,
ncfg
)
for
icfg
=
1
:
ncfg
vcfg
[
icfg
]
=
read
(
data
,
Int32
)
c
=
1
for
k
=
1
:
ncorr
if
k
in
corr_match
if
c_header
[
k
]
.
is_real
==
1
tmp
=
Array
{
Float64
}(
undef
,
tvals
*
nnoise
)
read!
(
data
,
tmp
)
tmp2
=
reshape
(
tmp
,
(
nnoise
,
tvals
))
tmp2
=
mean
(
tmp2
[
1
:
nnoise_trunc
,
:
],
dims
=
1
)
data_re
[
c
,
icfg
,
:
]
=
tmp2
[
1
,
:
]
elseif
c_header
[
k
]
.
is_real
==
0
tmp
=
Array
{
Float64
}(
undef
,
2
*
tvals
*
nnoise
)
read!
(
data
,
tmp
)
tmp2
=
reshape
(
tmp
,
(
2
,
nnoise
,
tvals
))
tmp2
=
mean
(
tmp2
[
:
,
1
:
nnoise_trunc
,
:
],
dims
=
2
)
data_re
[
c
,
icfg
,
:
]
=
tmp2
[
1
,
1
,
:
]
data_im
[
c
,
icfg
,
:
]
=
tmp2
[
2
,
1
,
:
]
end
c
+=
1
else
seek
(
data
,
position
(
data
)
+
c_header
[
k
]
.
dsize
*
tvals
*
nnoise
)
end
end
end
for
c
in
eachindex
(
corr_match
)
res
[
c
]
=
juobs
.
CData
(
c_header
[
corr_match
[
c
]],
vcfg
,
data_re
[
c
,
:
,
:
],
data_im
[
c
,
:
,
:
],
id
)
end
close
(
data
)
return
res
end
function
dev_read_mesons
(
path
::
Vector
{
String
},
gamma
::
Vector
{
Tuple
{
String
,
String
}};
id
::
Union
{
String
,
Nothing
}
=
nothing
,
legacy
::
Bool
=
false
,
nnoise_trunc
::
Union
{
Int64
,
Nothing
}
=
nothing
)
res
=
[
dev_read_mesons
(
p
,
gamma
,
id
=
id
,
legacy
=
legacy
,
nnoise_trunc
=
nnoise_trunc
)
for
p
in
path
]
nrep
=
length
(
res
)
ncorr
=
length
(
res
[
1
])
cdata
=
Vector
{
Vector
{
juobs
.
CData
}}(
undef
,
ncorr
)
for
icorr
=
1
:
ncorr
cdata
[
icorr
]
=
Vector
{
juobs
.
CData
}(
undef
,
nrep
)
for
r
=
1
:
nrep
cdata
[
icorr
][
r
]
=
res
[
r
][
icorr
]
end
end
return
cdata
end
function
dev_read_mesons_correction
(
path
::
String
,
gamma
::
Vector
{
Tuple
{
String
,
String
}};
id
::
Union
{
String
,
Nothing
}
=
nothing
,
legacy
::
Bool
=
false
,
nnoise_trunc
::
Union
{
Int64
,
Nothing
}
=
nothing
)
type
=
Vector
{
Tuple
{
Int64
,
Int64
}}(
undef
,
length
(
gamma
))
for
i
in
eachindex
(
gamma
)
G1
,
G2
=
gamma
[
i
]
type
[
i
]
=
(
findfirst
(
x
->
x
==
G1
,
juobs
.
gamma_name
)
-
1
,
findfirst
(
x
->
x
==
G2
,
juobs
.
gamma_name
)
-
1
)
end
if
isnothing
(
id
)
bname
=
basename
(
path
)
m
=
findfirst
(
r
"[A-Z][0-9]{3}r[0-9]{3}"
,
bname
)
id
=
bname
[
m
[
1
:
4
]]
#id = parse(Int64, bname[m[2:4]])
end
data
=
open
(
path
,
"r"
)
g_header
=
juobs
.
read_GHeader
(
path
)
c_header
=
juobs
.
read_CHeader
(
path
,
legacy
=
legacy
)
ncorr
=
g_header
.
ncorr
tvals
=
g_header
.
tvals
nnoise
=
g_header
.
nnoise
nnoise_trunc
=
isnothing
(
nnoise_trunc
)
?
nnoise
:
min
(
nnoise
,
nnoise_trunc
)
fsize
=
filesize
(
path
)
datsize
=
4
+
sum
(
getfield
.
(
c_header
,
:
dsize
))
*
tvals
*
nnoise
#data_size / ncnfg
ncfg
=
div
(
fsize
-
g_header
.
hsize
-
sum
(
getfield
.
(
c_header
,
:
hsize
)),
datsize
)
#(total size - header_size) / data_size
corr_match
=
findall
(
x
->
(
x
.
type1
,
x
.
type2
)
in
type
,
c_header
)
seek
(
data
,
g_header
.
hsize
+
sum
(
c
.
hsize
for
c
in
c_header
))
res
=
Array
{
juobs
.
CData
}(
undef
,
div
(
length
(
corr_match
),
2
))
# Modification: total length is divided by 2
data_re
=
zeros
(
div
(
length
(
corr_match
),
2
),
ncfg
,
tvals
)
# Modification: total length is divided by 2
data_im
=
zeros
(
div
(
length
(
corr_match
),
2
),
ncfg
,
tvals
)
# Modification: total length is divided by 2
vcfg
=
Array
{
Int32
}(
undef
,
ncfg
)
for
icfg
=
1
:
ncfg
vcfg
[
icfg
]
=
read
(
data
,
Int32
)
c
=
1
sgn
=
+
1
# sign it changes at ncorr / 2. O_exact - O_sloppy
for
k
=
1
:
ncorr
if
k
in
corr_match
if
c_header
[
k
]
.
is_real
==
1
tmp
=
Array
{
Float64
}(
undef
,
tvals
*
nnoise
)
read!
(
data
,
tmp
)
tmp2
=
reshape
(
tmp
,
(
nnoise
,
tvals
))
tmp2
=
mean
(
tmp2
[
1
:
nnoise_trunc
,
:
],
dims
=
1
)
data_re
[
c
,
icfg
,
:
]
=
data_re
[
c
,
icfg
,
:
]
+
sgn
*
tmp2
[
1
,
:
]
elseif
c_header
[
k
]
.
is_real
==
0
tmp
=
Array
{
Float64
}(
undef
,
2
*
tvals
*
nnoise
)
read!
(
data
,
tmp
)
tmp2
=
reshape
(
tmp
,
(
2
,
nnoise
,
tvals
))
tmp2
=
mean
(
tmp2
[
:
,
1
:
nnoise_trunc
,
:
],
dims
=
2
)
data_re
[
c
,
icfg
,
:
]
=
data_re
[
c
,
icfg
,
:
]
+
sgn
*
tmp2
[
1
,
1
,
:
]
data_im
[
c
,
icfg
,
:
]
=
data_im
[
c
,
icfg
,
:
]
+
sgn
*
tmp2
[
2
,
1
,
:
]
end
c
+=
1
else
seek
(
data
,
position
(
data
)
+
c_header
[
k
]
.
dsize
*
tvals
*
nnoise
)
end
if
k
==
div
(
ncorr
,
2
)
c
=
1
sgn
=
-
1
end
end
end
for
c
=
1
:
div
(
length
(
corr_match
),
2
)
res
[
c
]
=
juobs
.
CData
(
c_header
[
corr_match
[
c
]],
vcfg
,
data_re
[
c
,
:
,
:
],
data_im
[
c
,
:
,
:
],
id
)
end
close
(
data
)
return
res
end
function
dev_read_mesons_correction
(
path
::
Vector
{
String
},
gamma
::
Vector
{
Tuple
{
String
,
String
}};
id
::
Union
{
String
,
Nothing
}
=
nothing
,
legacy
::
Bool
=
false
,
nnoise_trunc
::
Union
{
Int64
,
Nothing
}
=
nothing
)
res
=
[
dev_read_mesons_correction
(
p
,
gamma
,
id
=
id
,
legacy
=
legacy
,
nnoise_trunc
=
nnoise_trunc
)
for
p
in
path
]
nrep
=
length
(
res
)
ncorr
=
length
(
res
[
1
])
cdata
=
Vector
{
Vector
{
juobs
.
CData
}}(
undef
,
ncorr
)
for
icorr
=
1
:
ncorr
cdata
[
icorr
]
=
Vector
{
juobs
.
CData
}(
undef
,
nrep
)
for
r
=
1
:
nrep
cdata
[
icorr
][
r
]
=
res
[
r
][
icorr
]
end
end
return
cdata
end
\ No newline at end of file
src/juobs_tools.jl
View file @
8aa2abdb
This diff is collapsed.
Click to expand it.
src/juobs_types.jl
View file @
8aa2abdb
##############UTILITY NAMES##############
##############UTILITY NAMES##############
#= STARTING AT 0
#= STARTING AT 0
noise_name=['Z2', 'GAUSS', 'U1', 'Z4']
noise_name=['Z2', 'GAUSS', 'U1', 'Z4']
gamma_name = ['G0', 'G1', 'G2', 'G3',
gamma_name = ['G0', 'G1', 'G2', 'G3',
...
...
test/test_fit_routines.jl
0 → 100644
View file @
8aa2abdb
using
Revise
,
juobs
,
ADerrors
true_model
(
x
)
=
0.5
+
0.02
*
x
+
0.001
*
x
^
2
xdata
=
collect
(
0.0
:
0.1
:
1
)
ydata
=
let
yaux
=
true_model
.
(
xdata
)
[
uwreal
(
randn
(
1000
)
*
0.0003
.+
y
,
"fit_test"
)
for
y
in
yaux
]
end
uwerr
.
(
ydata
)
@.model
(
x
,
p
)
=
p
[
1
]
+
p
[
2
]
*
x
+
p
[
3
]
*
x
^
2
println
(
"true model: 0.5 + 0.02x + 0.0001x^2"
)
println
(
"fit model: p[1]+ p[2]x + p[3]x^2 "
)
fit
=
fit_routine
(
model
,
xdata
,
ydata
,
3
,
logfile
=
stdout
,
corr
=
false
);
xdata_s
=
[
uwreal
(
randn
(
1000
)
*
0.0003
.+
x
,
"xdata"
)
for
x
in
xdata
]
fit2
=
fit_routine
(
model
,
xdata_s
,
ydata
,
3
,
logfile
=
stdout
,
corr
=
false
)
@.model2
(
x
,
p
)
=
p
[
1
]
+
(
p
[
2
]
+
p
[
3
]
*
x
)
^
2
Cy
=
[
y
.
err
^
2
for
y
in
ydata
]
Cy
=
[
i
==
j
?
Cy
[
i
]
:
0
for
i
in
eachindex
(
ydata
),
j
in
eachindex
(
ydata
)]
W
=
[
C
==
0
?
0
:
1
/
C
for
C
in
Cy
]
fit3
=
fit_routine
([
model
,
model2
],[
xdata
,
xdata
],[
ydata
,
ydata
],[
3
,
3
],
corr
=
false
,
logfile
=
stdout
,
W
=
[
W
,
W
],
C
=
[
Cy
,
Cy
])
true
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment