IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue 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
Air Shower Physics
corsika
Commits
41befaeb
Commit
41befaeb
authored
3 years ago
by
ralfulrich
Browse files
Options
Downloads
Patches
Plain Diff
fixed magnetic model interpolation
parent
20dd176f
No related branches found
No related tags found
1 merge request
!404
adding Geomagnetic Models
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
corsika/detail/media/GeomagneticModel.inl
+28
-17
28 additions, 17 deletions
corsika/detail/media/GeomagneticModel.inl
tests/media/testMagneticField.cpp
+1
-0
1 addition, 0 deletions
tests/media/testMagneticField.cpp
with
29 additions
and
17 deletions
corsika/detail/media/GeomagneticModel.inl
+
28
−
17
View file @
41befaeb
...
...
@@ -123,14 +123,21 @@ namespace corsika {
if
(
longitude
<
-
180
||
longitude
>
180
)
{
CORSIKA_LOG_WARN
(
"Longitude should be between -180 and 180 degree."
);
}
double
epoch
=
double
(
iEpoch
->
first
);
const
double
lat_geo
=
latitude
*
constants
::
pi
/
180
;
const
double
lon
=
longitude
*
constants
::
pi
/
180
;
double
const
epoch
=
double
(
iEpoch
->
first
);
auto
iNextEpoch
=
iEpoch
;
// next epoch for interpolation
--
iNextEpoch
;
bool
const
lastEpoch
=
(
iEpoch
==
parameters_
.
rbegin
());
auto
const
delta_t
=
year
-
epoch
;
CORSIKA_LOG_DEBUG
(
"identified: t_epoch={}, delta_t={}, lastEpoch={} (false->interpolate)"
,
epoch
,
delta_t
,
lastEpoch
);
double
const
lat_geo
=
latitude
*
constants
::
pi
/
180
;
double
const
lon
=
longitude
*
constants
::
pi
/
180
;
// Transform into spherical coordinates
const
double
f
=
1
/
298.257223563
;
const
double
e_squared
=
f
*
(
2
-
f
);
double
constexpr
f
=
1
/
298.257223563
;
double
constexpr
e_squared
=
f
*
(
2
-
f
);
LengthType
R_c
=
constants
::
EarthRadius
::
Equatorial
/
sqrt
(
1
-
e_squared
*
pow
(
sin
(
lat_geo
),
2
));
LengthType
p
=
(
R_c
+
altitude
)
*
cos
(
lat_geo
);
...
...
@@ -141,26 +148,30 @@ namespace corsika {
double
legendre
,
next_legendre
,
derivate_legendre
;
double
magneticfield
[
3
]
=
{
0
,
0
,
0
};
// loop the different l-functions
for
(
size_t
j
=
0
;
j
<
iEpoch
->
second
.
size
();
j
++
)
{
ParameterLine
p
=
iEpoch
->
second
[
j
];
// Time interpolation
if
(
iEpoch
==
parameters_
.
rbegin
()
||
p
.
dg
!=
0
||
p
.
dh
!=
0
)
{
if
(
iEpoch
==
parameters_
.
rbegin
())
{
// this is the latest epoch in time, or time-dependence (dg/dh) was specified
// we use the extrapolation factors dg/dh:
p
.
g
=
p
.
g
+
(
year
-
epoch
)
*
p
.
dg
;
p
.
h
=
p
.
h
+
(
year
-
epoch
)
*
p
.
dh
;
p
.
g
=
p
.
g
+
delta_t
*
p
.
dg
;
p
.
h
=
p
.
h
+
delta_t
*
p
.
dh
;
}
else
{
// we linearly interpolate between two epochs
auto
const
nextEpoch
=
--
iEpoch
;
// next epoch
ParameterLine
const
next_p
=
nextEpoch
->
second
[
j
];
const
double
length
=
nextEpoch
->
first
-
epoch
;
CORSIKA_LOG_WARN
(
"Length {}."
,
length
);
CORSIKA_LOG_WARN
(
"year {}. Epoch {}"
,
year
,
epoch
);
CORSIKA_LOG_WARN
(
"g {}. h {}"
,
next_p
.
g
,
next_p
.
h
);
p
.
g
=
p
.
g
+
(
next_p
.
g
-
p
.
g
)
*
(
year
-
epoch
)
/
length
;
p
.
h
=
p
.
h
+
(
next_p
.
h
-
p
.
h
)
*
(
year
-
epoch
)
/
length
;
ParameterLine
const
next_p
=
iNextEpoch
->
second
[
j
];
double
const
length
=
iNextEpoch
->
first
-
epoch
;
double
p_g
=
p
.
g
+
(
next_p
.
g
-
p
.
g
)
*
delta_t
/
length
;
double
p_h
=
p
.
h
+
(
next_p
.
h
-
p
.
h
)
*
delta_t
/
length
;
CORSIKA_LOG_TRACE
(
"interpolation: delta-g={}, delta-h={}, delta-t={}, length={} g1={} g2={} "
"g={} h={} "
,
next_p
.
g
-
p
.
g
,
next_p
.
h
-
p
.
h
,
year
-
epoch
,
length
,
next_p
.
g
,
p
.
g
,
p_g
,
p_h
);
p
.
g
=
p_g
;
p
.
h
=
p_h
;
}
legendre
=
pow
(
-
1
,
p
.
m
)
*
std
::
assoc_legendre
(
p
.
n
,
p
.
m
,
sin
(
lat_sph
));
...
...
This diff is collapsed.
Click to expand it.
tests/media/testMagneticField.cpp
+
1
−
0
View file @
41befaeb
...
...
@@ -105,6 +105,7 @@ TEST_CASE("UniformMagneticField w/ Homogeneous Medium") {
CHECK
(
WMM_B_4
.
getY
(
gCS
)
/
1
_nT
==
Approx
(
186
).
margin
(
0.5
));
CHECK
(
WMM_B_4
.
getZ
(
gCS
)
/
1
_nT
==
Approx
(
-
52429
).
margin
(
0.5
));
}
{
GeomagneticModel
igrf
(
gOrigin
,
corsika_data
(
"GeoMag/IGRF13.COF"
));
...
...
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