Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
SWIFT
SWIFTsim
Commits
c7262ad3
Commit
c7262ad3
authored
5 years ago
by
rttw52
Browse files
Options
Downloads
Patches
Plain Diff
Tidied some LOS params in the param file
parent
79aa06ea
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1050
Line-of-sight output along the z-axis
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/line_of_sight.c
+45
-47
45 additions, 47 deletions
src/line_of_sight.c
src/line_of_sight.h
+6
-6
6 additions, 6 deletions
src/line_of_sight.h
with
51 additions
and
53 deletions
src/line_of_sight.c
+
45
−
47
View file @
c7262ad3
...
...
@@ -53,30 +53,31 @@
void
los_init
(
double
dim
[
3
],
struct
los_props
*
los_params
,
struct
swift_params
*
params
)
{
/* How many line of sights in each plane. */
los_params
->
num_along_xy
=
parser_get_opt_param_int
(
params
,
"LineOfSight:num_along_xy"
,
0
);
los_params
->
num_along_yz
=
parser_get_opt_param_int
(
params
,
"LineOfSight:num_along_yz"
,
0
);
los_params
->
num_along_xz
=
parser_get_opt_param_int
(
params
,
"LineOfSight:num_along_xz"
,
0
);
/* Min/max range across x,y and z where random LOS's are allowed. */
los_params
->
xmin
=
parser_get_opt_param_double
(
params
,
"LineOfSight:xmin"
,
0
.);
los_params
->
xmax
=
parser_get_opt_param_double
(
params
,
"LineOfSight:xmax"
,
dim
[
0
]);
los_params
->
ymin
=
parser_get_opt_param_double
(
params
,
"LineOfSight:ymin"
,
0
.);
los_params
->
ymax
=
parser_get_opt_param_double
(
params
,
"LineOfSight:ymax"
,
dim
[
1
]);
los_params
->
zmin
=
parser_get_opt_param_double
(
params
,
"LineOfSight:zmin"
,
0
.);
los_params
->
zmax
=
parser_get_opt_param_double
(
params
,
"LineOfSight:zmax"
,
dim
[
2
]);
los_params
->
num_along_z
=
parser_get_opt_param_int
(
params
,
"LineOfSight:num_along_z"
,
0
);
los_params
->
num_along_x
=
parser_get_opt_param_int
(
params
,
"LineOfSight:num_along_x"
,
0
);
los_params
->
num_along_y
=
parser_get_opt_param_int
(
params
,
"LineOfSight:num_along_y"
,
0
);
/* Min/max range across x,y and z (simulation axes) where random
* LOS's are allowed. */
los_params
->
allowed_losrange_x
[
0
]
=
0
.;
los_params
->
allowed_losrange_x
[
1
]
=
dim
[
0
];
parser_get_opt_param_double_array
(
params
,
"LineOfSight:allowed_los_range_x"
,
2
,
los_params
->
allowed_losrange_x
);
los_params
->
allowed_losrange_y
[
0
]
=
0
.;
los_params
->
allowed_losrange_y
[
1
]
=
dim
[
1
];
parser_get_opt_param_double_array
(
params
,
"LineOfSight:allowed_los_range_y"
,
2
,
los_params
->
allowed_losrange_y
);
los_params
->
allowed_losrange_z
[
0
]
=
0
.;
los_params
->
allowed_losrange_z
[
1
]
=
dim
[
2
];
parser_get_opt_param_double_array
(
params
,
"LineOfSight:allowed_los_range_z"
,
2
,
los_params
->
allowed_losrange_z
);
/* Compute total number of sightlines. */
los_params
->
num_tot
=
los_params
->
num_along_
xy
+
los_params
->
num_along_
yz
+
los_params
->
num_along_
xz
;
los_params
->
num_tot
=
los_params
->
num_along_
z
+
los_params
->
num_along_
x
+
los_params
->
num_along_
y
;
/* Where are we saving them? */
parser_get_param_string
(
params
,
"LineOfSight:basename"
,
los_params
->
basename
);
...
...
@@ -100,33 +101,33 @@ void generate_sightlines(struct line_of_sight *Los,
double
Xpos
,
Ypos
;
/* Sightlines in XY plane, shoots down Z. */
for
(
int
i
=
0
;
i
<
params
->
num_along_
xy
;
i
++
)
{
Xpos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
xmax
-
params
->
xmin
))
+
params
->
xmin
;
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
ymax
-
params
->
ymin
))
+
params
->
ymin
;
for
(
int
i
=
0
;
i
<
params
->
num_along_
z
;
i
++
)
{
Xpos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_x
[
1
]
-
params
->
allowed_losrange_x
[
0
]
))
+
params
->
allowed_losrange_x
[
0
]
;
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_y
[
1
]
-
params
->
allowed_losrange_y
[
0
]
))
+
params
->
allowed_losrange_y
[
0
]
;
create_sightline
(
Xpos
,
Ypos
,
simulation_x_axis
,
simulation_y_axis
,
simulation_z_axis
,
periodic
,
dim
,
&
Los
[
count
]);
count
+=
1
;
}
/* Sightlines in YZ plane, shoots down X. */
for
(
int
i
=
0
;
i
<
params
->
num_along_
yz
;
i
++
)
{
Xpos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
ymax
-
params
->
ymin
))
+
params
->
ymin
;
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
zmax
-
params
->
zmin
))
+
params
->
zmin
;
for
(
int
i
=
0
;
i
<
params
->
num_along_
x
;
i
++
)
{
Xpos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_y
[
1
]
-
params
->
allowed_losrange_y
[
0
]
))
+
params
->
allowed_losrange_y
[
0
]
;
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_z
[
1
]
-
params
->
allowed_losrange_z
[
0
]
))
+
params
->
allowed_losrange_z
[
0
]
;
create_sightline
(
Xpos
,
Ypos
,
simulation_y_axis
,
simulation_z_axis
,
simulation_x_axis
,
periodic
,
dim
,
&
Los
[
count
]);
count
+=
1
;
}
/* Sightlines in XZ plane, shoots down Y. */
for
(
int
i
=
0
;
i
<
params
->
num_along_
xz
;
i
++
)
{
Xpos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
xmax
-
params
->
xmin
))
+
params
->
xmin
;
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
zmax
-
params
->
zmin
))
+
params
->
zmin
;
for
(
int
i
=
0
;
i
<
params
->
num_along_
y
;
i
++
)
{
Xpos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_x
[
1
]
-
params
->
allowed_losrange_x
[
0
]
))
+
params
->
allowed_losrange_x
[
0
]
;
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_z
[
1
]
-
params
->
allowed_losrange_z
[
0
]
))
+
params
->
allowed_losrange_z
[
0
]
;
create_sightline
(
Xpos
,
Ypos
,
simulation_x_axis
,
simulation_z_axis
,
simulation_y_axis
,
periodic
,
dim
,
&
Los
[
count
]);
count
+=
1
;
...
...
@@ -901,16 +902,13 @@ void write_hdf5_header(hid_t h_file, const struct engine *e,
if
(
h_grp
<
0
)
error
(
"Error while creating LOS group"
);
/* Record this LOS attributes */
io_write_attribute
(
h_grp
,
"NumAlongXY"
,
INT
,
&
LOS_params
->
num_along_xy
,
1
);
io_write_attribute
(
h_grp
,
"NumAlongYZ"
,
INT
,
&
LOS_params
->
num_along_yz
,
1
);
io_write_attribute
(
h_grp
,
"NumAlongXZ"
,
INT
,
&
LOS_params
->
num_along_xz
,
1
);
io_write_attribute
(
h_grp
,
"NumLineOfSight"
,
INT
,
&
LOS_params
->
num_tot
,
1
);
io_write_attribute
(
h_grp
,
"Minx"
,
DOUBLE
,
&
LOS_params
->
xmin
,
1
);
io_write_attribute
(
h_grp
,
"Maxx"
,
DOUBLE
,
&
LOS_params
->
xmax
,
1
);
io_write_attribute
(
h_grp
,
"Miny"
,
DOUBLE
,
&
LOS_params
->
ymin
,
1
);
io_write_attribute
(
h_grp
,
"Maxy"
,
DOUBLE
,
&
LOS_params
->
ymax
,
1
);
io_write_attribute
(
h_grp
,
"Minz"
,
DOUBLE
,
&
LOS_params
->
zmin
,
1
);
io_write_attribute
(
h_grp
,
"Maxz"
,
DOUBLE
,
&
LOS_params
->
zmax
,
1
);
const
int
num_los_per_axis
[
3
]
=
{
LOS_params
->
num_along_x
,
LOS_params
->
num_along_y
,
LOS_params
->
num_along_z
};
io_write_attribute
(
h_grp
,
"NumLineOfSight_PerAxis"
,
INT
,
num_los_per_axis
,
3
);
io_write_attribute
(
h_grp
,
"NumLineOfSight_Total"
,
INT
,
&
LOS_params
->
num_tot
,
1
);
io_write_attribute
(
h_grp
,
"AllowedLOSRangeX"
,
DOUBLE
,
LOS_params
->
allowed_losrange_x
,
2
);
io_write_attribute
(
h_grp
,
"AllowedLOSRangeY"
,
DOUBLE
,
LOS_params
->
allowed_losrange_y
,
2
);
io_write_attribute
(
h_grp
,
"AllowedLOSRangeZ"
,
DOUBLE
,
LOS_params
->
allowed_losrange_z
,
2
);
H5Gclose
(
h_grp
);
}
...
...
This diff is collapsed.
Click to expand it.
src/line_of_sight.h
+
6
−
6
View file @
c7262ad3
...
...
@@ -73,28 +73,28 @@ struct line_of_sight {
struct
los_props
{
/* Number of sightlines shooting down simulation z axis. */
int
num_along_
xy
;
int
num_along_
z
;
/* Number of sightlines shooting down simulation x axis. */
int
num_along_
yz
;
int
num_along_
x
;
/* Number of sightlines shooting down simulation y axis. */
int
num_along_
xz
;
int
num_along_
y
;
/* Total number of sightlines. */
int
num_tot
;
/* The min--max range along the simulation x axis random sightlines are
* allowed. */
double
xmin
,
xmax
;
double
allowed_losrange_x
[
2
]
;
/* The min--max range along the simulation y axis random sightlines are
* allowed. */
double
ymin
,
ymax
;
double
allowed_losrange_y
[
2
]
;
/* The min--max range along the simulation z axis random sightlines are
* allowed. */
double
zmin
,
zmax
;
double
allowed_losrange_z
[
2
]
;
/* Basename for line of sight HDF5 files. */
char
basename
[
200
];
...
...
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