Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SMB Salvus ENSI
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
koronima
SMB Salvus ENSI
Commits
2f7845ff
Commit
2f7845ff
authored
3 weeks ago
by
koronima
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
821e5914
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools.py
+42
-0
42 additions, 0 deletions
tools.py
with
42 additions
and
0 deletions
tools.py
0 → 100644
+
42
−
0
View file @
2f7845ff
import
typing
import
numpy
as
np
import
xarray
as
xr
def
_parse_lines
(
lines
:
typing
.
List
[
str
]):
return
np
.
fromstring
(
""
.
join
(
lines
).
replace
(
"
\n
"
,
""
).
replace
(
"
-
"
,
"
-
"
).
strip
(),
sep
=
"
"
)
def
read_velomod
(
filename
:
str
)
->
xr
.
DataArray
:
"""
Read a velomod file and return an xarray DataArray.
Args:
filename: The filename to read.
Returns:
A DataArray.
"""
with
open
(
filename
,
mode
=
"
r
"
)
as
fh
:
lines
=
fh
.
readlines
()
x
=
_parse_lines
(
lines
[
1
:
4
])
*
-
1000.0
y
=
_parse_lines
(
lines
[
4
:
7
])
*
1000.0
z
=
_parse_lines
(
lines
[
7
:
8
])
*
-
1000.0
v
=
_parse_lines
(
lines
[
9
:])
*
1000.0
nx
,
ny
,
nz
=
len
(
x
),
len
(
y
),
len
(
z
)
# Reference locations HERE IN ED50 N32, epsg23032: 462069.582191081, 5205484.598682921
rx
,
ry
=
(
462069.582191081
,
5205484.598682921
)
# reference location in epsg32632:
#(461987.2450072905, 5205285.41538475)
return
xr
.
DataArray
(
np
.
reshape
(
v
,
(
nz
,
ny
,
nx
),
order
=
"
C
"
),
[(
"
z
"
,
z
),
(
"
y
"
,
y
+
ry
),
(
"
x
"
,
x
+
rx
)]
).
transpose
(
"
x
"
,
"
y
"
,
"
z
"
)
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