Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92135486
grid_extractor.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Nov 17, 16:34
Size
3 KB
Mime Type
text/x-python
Expires
Tue, Nov 19, 16:34 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22381569
Attached To
rCTRACKER ctracker3
grid_extractor.py
View Options
###########################################################################
# #
# Copyright 2017 Andrea Cimatoribus #
# EPFL ENAC IIE ECOL #
# GR A1 435 (Batiment GR) #
# Station 2 #
# CH-1015 Lausanne #
# Andrea.Cimatoribus@epfl.ch #
# #
# Alexandre Serex #
# alexandre.serex@epfl.ch #
# #
# This file is part of ctracker #
# #
# ctracker is free software: you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# ctracker is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty #
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #
# See the GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with ctracker. If not, see <http://www.gnu.org/licenses/>. #
# #
###########################################################################
import
numpy
as
np
from
xmitgcm
import
open_mdsdataset
as
mitgcmds
def
mitgcm
(
data
):
grid
=
mitgcm_raw
(
data
)
return
{
'xG'
:
grid
.
XG
.
to_masked_array
()
.
filled
(
0
)
.
astype
(
"float32"
),
'yG'
:
grid
.
YG
.
to_masked_array
()
.
filled
(
0
)
.
astype
(
"float32"
),
'dX'
:
grid
.
dxG
.
to_masked_array
()
.
filled
(
0
)
.
astype
(
"float32"
),
'dY'
:
grid
.
dyG
.
to_masked_array
()
.
filled
(
0
)
.
astype
(
"float32"
),
'dxdy'
:
grid
.
rA
.
to_masked_array
()
.
filled
(
0
)
.
astype
(
"float32"
),
# we invert to have at the first position the bottom
'dzt'
:
np
.
ascontiguousarray
((
grid
.
drF
*
grid
.
hFacC
)
.
to_masked_array
()
.
filled
(
0
)[::
-
1
,
:,
:]),
'dzu'
:
np
.
ascontiguousarray
((
grid
.
drF
*
grid
.
hFacW
*
grid
.
dyG
)
.
to_masked_array
()
.
filled
(
0
)[::
-
1
,
:,
:]),
'dzv'
:
np
.
ascontiguousarray
((
grid
.
drF
*
grid
.
hFacS
*
grid
.
dxG
)
.
to_masked_array
()
.
filled
(
0
)[::
-
1
,
:,
:]),
'kmtb'
:
(
grid
.
hFacC
.
sum
(
dim
=
"k"
))
.
to_masked_array
()
.
filled
(
0
),
'CS'
:
grid
.
CS
.
to_masked_array
()
.
filled
(
0
)
.
astype
(
"float32"
)
\
if
data
.
gcm_geometry
==
"curvilinear"
else
np
.
ones
(
grid
.
XG
.
shape
),
'SN'
:
grid
.
SN
.
to_masked_array
()
.
filled
(
0
)
.
astype
(
"float32"
)
\
if
data
.
gcm_geometry
==
"curvilinear"
else
np
.
zeros
(
grid
.
XG
.
shape
),
'grid_zero_volume'
:
grid
.
hFacC
[::
-
1
,
:,
:]
!=
0.0
}
def
mitgcm_raw
(
data
):
return
mitgcmds
(
data
.
gcm_directory
,
read_grid
=
True
,
iters
=
[],
prefix
=
[
data
.
u_root
,
data
.
v_root
,
data
.
w_root
],
swap_dims
=
False
,
geometry
=
data
.
gcm_geometry
,
ref_date
=
data
.
gcm_start
,
delta_t
=
data
.
gcm_dt
)
Event Timeline
Log In to Comment