Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
thopri
PyNEMO
Commits
fd274644
Commit
fd274644
authored
4 years ago
by
thopri
Browse files
Options
Download
Email Patches
Plain Diff
added I/O defined by NCML
parent
0eb2053e
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
660 additions
and
167 deletions
+660
-167
inputs/CMEMS.ncml
inputs/CMEMS.ncml
+0
-1
inputs/namelist_cmems.bdy
inputs/namelist_cmems.bdy
+6
-4
pynemo/nemo_bdy_extr_tm3.py
pynemo/nemo_bdy_extr_tm3.py
+13
-9
pynemo/nemo_bdy_ncgen.py
pynemo/nemo_bdy_ncgen.py
+180
-142
pynemo/nemo_bdy_ncpop.py
pynemo/nemo_bdy_ncpop.py
+7
-4
pynemo/nemo_ncml_parse.py
pynemo/nemo_ncml_parse.py
+94
-0
pynemo/output_NCML/NEMO_output_I.ncml
pynemo/output_NCML/NEMO_output_I.ncml
+85
-0
pynemo/output_NCML/NEMO_output_T.ncml
pynemo/output_NCML/NEMO_output_T.ncml
+73
-0
pynemo/output_NCML/NEMO_output_U.ncml
pynemo/output_NCML/NEMO_output_U.ncml
+67
-0
pynemo/output_NCML/NEMO_output_V.ncml
pynemo/output_NCML/NEMO_output_V.ncml
+67
-0
pynemo/profile.py
pynemo/profile.py
+20
-7
test_scripts/jars/netcdfAll-4.6.jar
test_scripts/jars/netcdfAll-4.6.jar
+0
-0
test_scripts/ncml_gen_nc.py
test_scripts/ncml_gen_nc.py
+48
-0
No files found.
inputs/CMEMS.ncml
View file @
fd274644
...
...
@@ -24,7 +24,6 @@
<ns0:variable name="votemper" orgName="thetao" />
<ns0:variable name="vozocrtx" orgName="uo" />
<ns0:variable name="vomecrty" orgName="vo" />
<ns0:variable name="sossheig" orgName="zos" />
<ns0:variable name="time_counter" orgName="time" />
<ns0:dimension name="time_counter" orgName="time" />
</ns0:netcdf>
This diff is collapsed.
Click to expand it.
inputs/namelist_cmems.bdy
View file @
fd274644
...
...
@@ -40,8 +40,10 @@
!------------------------------------------------------------------------------
! I/O
!------------------------------------------------------------------------------
sn_src_dir = '/Users/thopri/Projects/PyNEMO/inputs/CMEMS.ncml' ! src_files/'
sn_dst_dir = '/Users/thopri/Projects/PyNEMO/outputs'
sn_src_dir = '/Users/thopri/Projects/PyNEMO/inputs/CMEMS.ncml' ! src_files/'
sn_dst_dir = '/Users/thopri/Projects/PyNEMO/outputs'
sn_ncml_out = '/Users/thopri/Projects/PyNEMO/pynemo/output_NCML'
sn_model_prefix = 'NEMO'
sn_fn = 'NNA_R12' ! prefix for output files
nn_fv = -1e20 ! set fill value for output files
...
...
@@ -91,9 +93,9 @@
ln_mask_file = .false. ! =T : read mask from file
cn_mask_file = 'mask.nc' ! name of mask file
! (if ln_mask_file=.TRUE.)
ln_dyn2d = .
fals
e. ! boundary conditions for
ln_dyn2d = .
tru
e. ! boundary conditions for
! barotropic fields
ln_dyn3d = .
fals
e. ! boundary conditions for
ln_dyn3d = .
tru
e. ! boundary conditions for
! baroclinic velocities
ln_tra = .true. ! boundary conditions for T and S
ln_ice = .false. ! ice boundary condition
...
...
This diff is collapsed.
Click to expand it.
pynemo/nemo_bdy_extr_tm3.py
View file @
fd274644
...
...
@@ -37,6 +37,7 @@ import logging
import
numpy
as
np
import
scipy.spatial
as
sp
from
calendar
import
monthrange
,
isleap
from
glob
import
glob
from
scipy.interpolate
import
interp1d
from
cftime
import
datetime
,
utime
from
pynemo
import
nemo_bdy_ncgen
as
ncgen
...
...
@@ -886,6 +887,9 @@ class Extract:
f_out
=
self
.
settings
[
'dst_dir'
]
+
self
.
settings
[
'fn'
]
+
\
'_bdy'
+
self
.
g_type
.
upper
()
+
'_y'
+
str
(
year
)
+
'm'
+
'%02d'
%
month
+
'.nc'
ncml_out
=
glob
(
self
.
settings
[
'ncml_out'
]
+
'/*'
+
str
(
self
.
g_type
.
upper
())
+
'.ncml'
)
ncml_out
=
ncml_out
[
0
]
ncgen
.
CreateBDYNetcdfFile
(
f_out
,
self
.
num_bdy
,
self
.
jpi
,
self
.
jpj
,
self
.
jpk
,
...
...
@@ -894,7 +898,7 @@ class Extract:
unit_origin
,
self
.
settings
[
'fv'
],
self
.
settings
[
'dst_calendar'
],
self
.
g_type
.
upper
(),
self
.
var_nam
)
self
.
g_type
.
upper
(),
self
.
var_nam
,
ncml_out
)
self
.
logger
.
info
(
'Writing out BDY data to: %s'
,
f_out
)
...
...
@@ -913,17 +917,17 @@ class Extract:
# Write variable to file
ncpop
.
write_data_to_file
(
f_out
,
v
,
tmp_var
)
ncpop
.
write_data_to_file
(
f_out
,
v
,
tmp_var
,
ncml_out
)
# Write remaining data to file (indices are in Python notation
# therefore we must add 1 to i,j and r)
ncpop
.
write_data_to_file
(
f_out
,
'nav_lon'
,
self
.
nav_lon
)
ncpop
.
write_data_to_file
(
f_out
,
'nav_lat'
,
self
.
nav_lat
)
ncpop
.
write_data_to_file
(
f_out
,
'depth'
+
self
.
g_type
,
self
.
dst_dep
)
ncpop
.
write_data_to_file
(
f_out
,
'nbidta'
,
ind
.
bdy_i
[:,
0
]
+
1
)
ncpop
.
write_data_to_file
(
f_out
,
'nbjdta'
,
ind
.
bdy_i
[:,
1
]
+
1
)
ncpop
.
write_data_to_file
(
f_out
,
'nbrdta'
,
ind
.
bdy_r
[:
]
+
1
)
ncpop
.
write_data_to_file
(
f_out
,
'time_counter'
,
self
.
time_counter
)
ncpop
.
write_data_to_file
(
f_out
,
'nav_lon'
,
self
.
nav_lon
,
ncml_out
)
ncpop
.
write_data_to_file
(
f_out
,
'nav_lat'
,
self
.
nav_lat
,
ncml_out
)
ncpop
.
write_data_to_file
(
f_out
,
'depth'
+
self
.
g_type
,
self
.
dst_dep
,
ncml_out
)
ncpop
.
write_data_to_file
(
f_out
,
'nbidta'
,
ind
.
bdy_i
[:,
0
]
+
1
,
ncml_out
)
ncpop
.
write_data_to_file
(
f_out
,
'nbjdta'
,
ind
.
bdy_i
[:,
1
]
+
1
,
ncml_out
)
ncpop
.
write_data_to_file
(
f_out
,
'nbrdta'
,
ind
.
bdy_r
[:
]
+
1
,
ncml_out
)
ncpop
.
write_data_to_file
(
f_out
,
'time_counter'
,
self
.
time_counter
,
ncml_out
)
...
...
This diff is collapsed.
Click to expand it.
pynemo/nemo_bdy_ncgen.py
View file @
fd274644
This diff is collapsed.
Click to expand it.
pynemo/nemo_bdy_ncpop.py
View file @
fd274644
...
...
@@ -8,7 +8,9 @@ Netcdf writer for the bdy output
# pylint: disable=no-name-in-module
from
netCDF4
import
Dataset
import
numpy
as
np
def
write_data_to_file
(
filename
,
variable_name
,
data
):
from
pynemo
import
nemo_ncml_parse
as
ncml_parse
def
write_data_to_file
(
filename
,
variable_name
,
data
,
ncml_out
):
""" Writes the data to the netcdf templete file.
Keyword arguments:
filename -- output filename
...
...
@@ -17,9 +19,10 @@ def write_data_to_file(filename, variable_name, data):
"""
ncid
=
Dataset
(
filename
,
'a'
,
clobber
=
False
,
format
=
'NETCDF4'
)
count
=
data
.
shape
three_dim_variables
=
[
'votemper'
,
'vosaline'
,
'N1p'
,
'N3n'
,
'N5s'
,
'vobtcrtx'
,
'vozocrtx'
,
'vobtcrty'
,
'vomecrty'
]
two_dim_variables
=
[
'sossheig'
,
'iicethic'
,
'ileadfra'
,
'isnowthi'
]
time
=
ncml_parse
.
gen_dims_NCML
(
ncml_out
,
'time_counter'
)
var_list
=
ncml_parse
.
gen_var_list_NCML
(
ncml_out
,
time
)
three_dim_variables
=
var_list
[
'3D_vars'
]
#['votemper', 'vosaline', 'N1p', 'N3n', 'N5s','vobtcrtx','vozocrtx','vobtcrty','vomecrty']
two_dim_variables
=
var_list
[
'2D_vars'
]
#['sossheig', 'iicethic', 'ileadfra', 'isnowthi']
if
variable_name
in
three_dim_variables
:
if
len
(
count
)
==
3
:
...
...
This diff is collapsed.
Click to expand it.
pynemo/nemo_ncml_parse.py
0 → 100644
View file @
fd274644
'''
NCML python parser using XML to Dict
'''
import
xml.etree.ElementTree
as
ET
import
xmltodict
import
logging
logger
=
logging
.
getLogger
(
__name__
)
def
gen_dims_NCML
(
ncmlfile
,
orgName
):
ncml_dict
=
xmltodict
.
parse
(
ET
.
tostring
(
ET
.
parse
(
ncmlfile
).
getroot
()))
dimensions
=
ncml_dict
[
'ns0:netcdf'
][
'ns0:dimension'
]
if
type
(
dimensions
)
is
not
list
:
dimensions
=
[
dimensions
]
if
not
any
(
d
[
'@orgName'
]
==
orgName
for
d
in
dimensions
):
raise
ValueError
(
'dimension name not defined in NCML output specification file'
)
for
i
in
range
(
len
(
dimensions
)):
if
dimensions
[
i
][
'@orgName'
]
==
orgName
:
dim_name
=
dimensions
[
i
][
'@name'
]
break
return
dim_name
def
gen_var_list_NCML
(
ncmlfile
,
time
):
ncml_dict
=
xmltodict
.
parse
(
ET
.
tostring
(
ET
.
parse
(
ncmlfile
).
getroot
()))
variables
=
ncml_dict
[
'ns0:netcdf'
][
'ns0:variable'
]
var_3D
=
[]
var_2D
=
[]
for
i
in
range
(
len
(
variables
)):
if
len
(
variables
[
i
][
'@shape'
].
split
(
' '
))
==
4
and
variables
[
i
][
'@shape'
].
split
(
' '
)[
0
]
==
time
:
var_3D
.
append
(
variables
[
i
][
'@name'
])
if
len
(
variables
[
i
][
'@shape'
].
split
(
' '
))
==
3
and
variables
[
i
][
'@shape'
].
split
(
' '
)[
0
]
==
time
:
var_2D
.
append
(
variables
[
i
][
'@name'
])
var_type
=
{
'3D_vars'
:
var_3D
,
'2D_vars'
:
var_2D
,
}
return
var_type
def
gen_src_var_list_NCML
(
ncmlfile
):
ncml_dict
=
xmltodict
.
parse
(
ET
.
tostring
(
ET
.
parse
(
ncmlfile
).
getroot
()))
variables
=
ncml_dict
[
'ns0:netcdf'
][
'ns0:variable'
]
var_list
=
[]
for
i
in
range
(
len
(
variables
)):
var_list
.
append
(
variables
[
i
][
'@name'
])
return
var_list
def
gen_var_NCML
(
ncmlfile
,
orgName
):
ncml_dict
=
xmltodict
.
parse
(
ET
.
tostring
(
ET
.
parse
(
ncmlfile
).
getroot
()))
variables
=
ncml_dict
[
'ns0:netcdf'
][
'ns0:variable'
]
if
type
(
variables
)
is
not
list
:
variables
=
[
variables
]
if
not
any
(
d
[
'@orgName'
]
==
orgName
for
d
in
variables
):
raise
ValueError
(
'variable name not defined in NCML output specification file'
)
var
=
{}
for
i
in
range
(
len
(
variables
)):
if
variables
[
i
][
'@orgName'
]
==
orgName
:
var
[
'name'
]
=
variables
[
i
][
'@name'
]
var
[
'shape'
]
=
variables
[
i
][
'@shape'
].
split
(
' '
)
if
variables
[
i
][
'@type'
]
==
'float'
:
var
[
'type'
]
=
'f4'
if
variables
[
i
][
'@type'
]
==
'int'
:
var
[
'type'
]
=
'i4'
break
return
var
def
gen_attrib_NCML
(
ncmlfile
,
name
):
ncml_dict
=
xmltodict
.
parse
(
ET
.
tostring
(
ET
.
parse
(
ncmlfile
).
getroot
()))
nc_attrib
=
ncml_dict
[
'ns0:netcdf'
][
'ns0:attribute'
]
if
type
(
nc_attrib
)
is
not
list
:
nc_attrib
=
[
nc_attrib
]
if
not
any
(
d
[
'@name'
]
==
name
for
d
in
nc_attrib
):
logger
.
warning
(
'Global attribute name not found, writing attribute not specified'
)
return
'Global attribute not specified in NCML file'
for
i
in
range
(
len
(
nc_attrib
)):
if
nc_attrib
[
i
][
'@name'
]
==
name
:
attrib_val
=
nc_attrib
[
i
][
'@value'
]
return
attrib_val
def
gen_var_attrib_NCML
(
ncmlfile
,
variable
,
name
):
ncml_dict
=
xmltodict
.
parse
(
ET
.
tostring
(
ET
.
parse
(
ncmlfile
).
getroot
()))
variables
=
ncml_dict
[
'ns0:netcdf'
][
'ns0:variable'
]
if
type
(
variables
)
is
not
list
:
variables
=
[
variables
]
for
i
in
range
(
len
(
variables
)):
if
variables
[
i
][
'@name'
]
==
variable
:
if
not
any
(
d
[
'@name'
]
==
name
for
d
in
variables
[
i
][
'ns0:attribute'
]):
logging
.
warning
(
'variable attribute name not found, writing attribute not specified'
)
return
'Variable attribute not specified in NCML file'
for
j
in
range
(
len
(
variables
[
i
][
'ns0:attribute'
])):
if
variables
[
i
][
'ns0:attribute'
][
j
][
'@name'
]
==
name
:
attrib
=
variables
[
i
][
'ns0:attribute'
][
j
][
'@value'
]
break
break
return
attrib
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pynemo/output_NCML/NEMO_output_I.ncml
0 → 100644
View file @
fd274644
<?xml version="1.0" encoding="UTF-8"?>
<netcdf
xmlns=
"http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"
>
<dimension
name=
"y"
orgName=
"y"
/>
<dimension
name=
"x"
orgName=
"x"
/>
<dimension
name=
"z"
orgName=
"z"
/>
<dimension
name=
"yb"
orgName=
"yb"
/>
<dimension
name=
"xb"
orgName=
"xb"
/>
<dimension
name=
"time_counter"
orgName=
"time_counter"
isUnlimited=
"true"
/>
<attribute
name=
"institution"
value=
"National Oceanography Centre, Livepool, U.K."
/>
<variable
name=
"bdy_msk"
orgName=
"bdy_msk"
shape=
"y x"
type=
"float"
>
<attribute
name=
"short_name"
value=
"bdy_msk"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Structured boundary mask"
/>
</variable>
<variable
name=
"deptht"
orgName=
"deptht"
shape=
"z yb xb"
type=
"float"
>
<attribute
name=
"axis"
value=
"Depth"
/>
<attribute
name=
"short_name"
value=
"deptht"
/>
<attribute
name=
"units"
value=
"m"
/>
<attribute
name=
"long_name"
value=
"Depth"
/>
</variable>
<variable
name=
"nav_lat"
orgName=
"nav_lat"
shape=
"y x"
type=
"float"
>
<attribute
name=
"axis"
value=
"Latitude"
/>
<attribute
name=
"short_name"
value=
"nav_lat"
/>
<attribute
name=
"units"
value=
"degrees_east"
/>
<attribute
name=
"long_name"
value=
"Latitude"
/>
</variable>
<variable
name=
"nav_lon"
orgName=
"nav_lon"
shape=
"y x"
type=
"float"
>
<attribute
name=
"axis"
value=
"Longitude"
/>
<attribute
name=
"short_name"
value=
"nav_lon"
/>
<attribute
name=
"units"
value=
"degrees_east"
/>
<attribute
name=
"long_name"
value=
"Longitude"
/>
</variable>
<variable
name=
"nbidta"
orgName=
"nbidta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbidta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy i indices"
/>
</variable>
<variable
name=
"nbjdta"
orgName=
"nbjdta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbjdta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy j indices"
/>
</variable>
<variable
name=
"nbrdta"
orgName=
"nbrdta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbrdta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy discrete distance"
/>
</variable>
<variable
name=
"time_counter"
orgName=
"time_counter"
shape=
"time_counter"
type=
"float"
>
<attribute
name=
"axis"
value=
"T"
/>
<attribute
name=
"standard_name"
value=
"time"
/>
<attribute
name=
"units"
value=
"seconds since 1960-01-01 00:00:00"
/>
<attribute
name=
"title"
value=
"Time"
/>
<attribute
name=
"long_name"
value=
"Time axis"
/>
</variable>
<variable
name=
"vosaline"
orgName=
"vosaline"
shape=
"time_counter z yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"PSU"
/>
<attribute
name=
"short_name"
value=
"vosaline"
/>
<attribute
name=
"long_name"
value=
"Salinity"
/>
<attribute
name=
"grid"
value=
"bdyT"
/>
</variable>
<variable
name=
"votemper"
orgName=
"votemper"
shape=
"time_counter z yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"C"
/>
<attribute
name=
"short_name"
value=
"votemper"
/>
<attribute
name=
"long_name"
value=
"Temperature"
/>
<attribute
name=
"grid"
value=
"bdyT"
/>
</variable>
<variable
name=
"ileadfra"
orgName=
"ileadfra"
shape=
"time_counter yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"%"
/>
<attribute
name=
"short_name"
value=
"ileadfra"
/>
<attribute
name=
"long_name"
value=
"Ice lead fraction"
/>
<attribute
name=
"grid"
value=
"bdyT"
/>
</variable>
<variable
name=
"iicethic"
orgName=
"iicethic"
shape=
"time_counter yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m"
/>
<attribute
name=
"short_name"
value=
"iicethic"
/>
<attribute
name=
"long_name"
value=
"Ice thickness"
/>
<attribute
name=
"grid"
value=
"bdyT"
/>
</variable>
<variable
name=
"isnowthi"
orgName=
"isnowthi"
shape=
"time_counter yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m"
/>
<attribute
name=
"short_name"
value=
"isnowthi"
/>
<attribute
name=
"long_name"
value=
"Snow thickness"
/>
<attribute
name=
"grid"
value=
"bdyT"
/>
</variable>
</netcdf>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pynemo/output_NCML/NEMO_output_T.ncml
0 → 100644
View file @
fd274644
<?xml version="1.0" encoding="UTF-8"?>
<netcdf
xmlns=
"http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"
>
<dimension
name=
"y"
orgName=
"y"
/>
<dimension
name=
"x"
orgName=
"x"
/>
<dimension
name=
"z"
orgName=
"z"
/>
<dimension
name=
"yb"
orgName=
"yb"
/>
<dimension
name=
"xb"
orgName=
"xb"
/>
<dimension
name=
"time_counter"
orgName=
"time_counter"
isUnlimited=
"true"
/>
<attribute
name=
"institution"
value=
"National Oceanography Centre, Livepool, U.K."
/>
<variable
name=
"bdy_msk"
orgName=
"bdy_msk"
shape=
"y x"
type=
"float"
>
<attribute
name=
"short_name"
value=
"bdy_msk"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Structured boundary mask"
/>
</variable>
<variable
name=
"deptht"
orgName=
"deptht"
shape=
"z yb xb"
type=
"float"
>
<attribute
name=
"axis"
value=
"Depth"
/>
<attribute
name=
"short_name"
value=
"deptht"
/>
<attribute
name=
"units"
value=
"m"
/>
<attribute
name=
"long_name"
value=
"Depth"
/>
</variable>
<variable
name=
"nav_lat"
orgName=
"nav_lat"
shape=
"y x"
type=
"float"
>
<attribute
name=
"axis"
value=
"Latitude"
/>
<attribute
name=
"short_name"
value=
"nav_lat"
/>
<attribute
name=
"units"
value=
"degrees_east"
/>
<attribute
name=
"long_name"
value=
"Latitude"
/>
</variable>
<variable
name=
"nav_lon"
orgName=
"nav_lon"
shape=
"y x"
type=
"float"
>
<attribute
name=
"axis"
value=
"Longitude"
/>
<attribute
name=
"short_name"
value=
"nav_lon"
/>
<attribute
name=
"units"
value=
"degrees_east"
/>
<attribute
name=
"long_name"
value=
"Longitude"
/>
</variable>
<variable
name=
"nbidta"
orgName=
"nbidta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbidta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy i indices"
/>
</variable>
<variable
name=
"nbjdta"
orgName=
"nbjdta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbjdta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy j indices"
/>
</variable>
<variable
name=
"nbrdta"
orgName=
"nbrdta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbrdta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy discrete distance"
/>
</variable>
<variable
name=
"time_counter"
orgName=
"time_counter"
shape=
"time_counter"
type=
"float"
>
<attribute
name=
"axis"
value=
"T"
/>
<attribute
name=
"standard_name"
value=
"time"
/>
<attribute
name=
"units"
value=
"seconds since 1960-01-01 00:00:00"
/>
<attribute
name=
"title"
value=
"Time"
/>
<attribute
name=
"long_name"
value=
"Time axis"
/>
</variable>
<variable
name=
"vosaline"
orgName=
"vosaline"
shape=
"time_counter z yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"PSU"
/>
<attribute
name=
"short_name"
value=
"vosaline"
/>
<attribute
name=
"long_name"
value=
"Salinity"
/>
<attribute
name=
"grid"
value=
"bdyT"
/>
</variable>
<variable
name=
"votemper"
orgName=
"votemper"
shape=
"time_counter z yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"C"
/>
<attribute
name=
"short_name"
value=
"votemper"
/>
<attribute
name=
"long_name"
value=
"Temperature"
/>
<attribute
name=
"grid"
value=
"bdyT"
/>
</variable>
<variable
name=
"votemper"
orgName=
"votemper"
shape=
"time_counter z yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"C"
/>
<attribute
name=
"short_name"
value=
"votemper"
/>
<attribute
name=
"long_name"
value=
"Temperature"
/>
<attribute
name=
"grid"
value=
"bdyT"
/>
</variable>
</netcdf>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pynemo/output_NCML/NEMO_output_U.ncml
0 → 100644
View file @
fd274644
<?xml version="1.0" encoding="UTF-8"?>
<netcdf
xmlns=
"http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"
>
<dimension
name=
"y"
orgName=
"y"
/>
<dimension
name=
"x"
orgName=
"x"
/>
<dimension
name=
"z"
orgName=
"z"
/>
<dimension
name=
"yb"
orgName=
"yb"
/>
<dimension
name=
"xb"
orgName=
"xb"
/>
<dimension
name=
"time_counter"
orgName=
"time_counter"
isUnlimited=
"true"
/>
<attribute
name=
"institution"
value=
"National Oceanography Centre, Livepool, U.K."
/>
<variable
name=
"bdy_msk"
orgName=
"bdy_msk"
shape=
"y x"
type=
"float"
>
<attribute
name=
"short_name"
value=
"bdy_msk"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Structured boundary mask"
/>
</variable>
<variable
name=
"depthu"
orgName=
"depthu"
shape=
"z yb xb"
type=
"float"
>
<attribute
name=
"axis"
value=
"Depth"
/>
<attribute
name=
"short_name"
value=
"depthu"
/>
<attribute
name=
"units"
value=
"m"
/>
<attribute
name=
"long_name"
value=
"Depth"
/>
</variable>
<variable
name=
"nav_lat"
orgName=
"nav_lat"
shape=
"y x"
type=
"float"
>
<attribute
name=
"axis"
value=
"Latitude"
/>
<attribute
name=
"short_name"
value=
"nav_lat"
/>
<attribute
name=
"units"
value=
"degrees_east"
/>
<attribute
name=
"long_name"
value=
"Latitude"
/>
</variable>
<variable
name=
"nav_lon"
orgName=
"nav_lon"
shape=
"y x"
type=
"float"
>
<attribute
name=
"axis"
value=
"Longitude"
/>
<attribute
name=
"short_name"
value=
"nav_lon"
/>
<attribute
name=
"units"
value=
"degrees_east"
/>
<attribute
name=
"long_name"
value=
"Longitude"
/>
</variable>
<variable
name=
"nbidta"
orgName=
"nbidta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbidta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy i indices"
/>
</variable>
<variable
name=
"nbjdta"
orgName=
"nbjdta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbjdta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy j indices"
/>
</variable>
<variable
name=
"nbrdta"
orgName=
"nbrdta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbrdta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy discrete distance"
/>
</variable>
<variable
name=
"time_counter"
orgName=
"time_counter"
shape=
"time_counter"
type=
"float"
>
<attribute
name=
"axis"
value=
"T"
/>
<attribute
name=
"standard_name"
value=
"time"
/>
<attribute
name=
"units"
value=
"seconds since 1960-01-01 00:00:00"
/>
<attribute
name=
"title"
value=
"Time"
/>
<attribute
name=
"long_name"
value=
"Time axis"
/>
</variable>
<variable
name=
"vobtcrtx"
orgName=
"vobtcrtx"
shape=
"time_counter yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m/s"
/>
<attribute
name=
"short_name"
value=
"vobtcrtx"
/>
<attribute
name=
"long_name"
value=
"Thickness-weighted depth-averaged zonal Current"
/>
<attribute
name=
"grid"
value=
"bdyU"
/>
</variable>
<variable
name=
"vozocrtx"
orgName=
"vozocrtx"
shape=
"time_counter z yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m/s"
/>
<attribute
name=
"short_name"
value=
"vozocrtx"
/>
<attribute
name=
"long_name"
value=
"Zonal Current"
/>
<attribute
name=
"grid"
value=
"bdyU"
/>
</variable>
</netcdf>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pynemo/output_NCML/NEMO_output_V.ncml
0 → 100644
View file @
fd274644
<?xml version="1.0" encoding="UTF-8"?>
<netcdf
xmlns=
"http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"
>
<dimension
name=
"y"
orgName=
"y"
/>
<dimension
name=
"x"
orgName=
"x"
/>
<dimension
name=
"z"
orgName=
"z"
/>
<dimension
name=
"yb"
orgName=
"yb"
/>
<dimension
name=
"xb"
orgName=
"xb"
/>
<dimension
name=
"time_counter"
orgName=
"time_counter"
isUnlimited=
"true"
/>
<attribute
name=
"institution"
value=
"National Oceanography Centre, Livepool, U.K."
/>
<variable
name=
"bdy_msk"
orgName=
"bdy_msk"
shape=
"y x"
type=
"float"
>
<attribute
name=
"short_name"
value=
"bdy_msk"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Structured boundary mask"
/>
</variable>
<variable
name=
"depthv"
orgName=
"depthv"
shape=
"z yb xb"
type=
"float"
>
<attribute
name=
"axis"
value=
"Depth"
/>
<attribute
name=
"short_name"
value=
"depthv"
/>
<attribute
name=
"units"
value=
"m"
/>
<attribute
name=
"long_name"
value=
"Depth"
/>
</variable>
<variable
name=
"nav_lat"
orgName=
"nav_lat"
shape=
"y x"
type=
"float"
>
<attribute
name=
"axis"
value=
"Latitude"
/>
<attribute
name=
"short_name"
value=
"nav_lat"
/>
<attribute
name=
"units"
value=
"degrees_east"
/>
<attribute
name=
"long_name"
value=
"Latitude"
/>
</variable>
<variable
name=
"nav_lon"
orgName=
"nav_lon"
shape=
"y x"
type=
"float"
>
<attribute
name=
"axis"
value=
"Longitude"
/>
<attribute
name=
"short_name"
value=
"nav_lon"
/>
<attribute
name=
"units"
value=
"degrees_east"
/>
<attribute
name=
"long_name"
value=
"Longitude"
/>
</variable>
<variable
name=
"nbidta"
orgName=
"nbidta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbidta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy i indices"
/>
</variable>
<variable
name=
"nbjdta"
orgName=
"nbjdta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbjdta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy j indices"
/>
</variable>
<variable
name=
"nbrdta"
orgName=
"nbrdta"
shape=
"yb xb"
type=
"int"
>
<attribute
name=
"short_name"
value=
"nbrdta"
/>
<attribute
name=
"units"
value=
"unitless"
/>
<attribute
name=
"long_name"
value=
"Bdy discrete distance"
/>
</variable>
<variable
name=
"time_counter"
orgName=
"time_counter"
shape=
"time_counter"
type=
"float"
>
<attribute
name=
"axis"
value=
"T"
/>
<attribute
name=
"standard_name"
value=
"time"
/>
<attribute
name=
"units"
value=
"seconds since 1960-01-01 00:00:00"
/>
<attribute
name=
"title"
value=
"Time"
/>
<attribute
name=
"long_name"
value=
"Time axis"
/>
</variable>
<variable
name=
"vobtcrty"
orgName=
"vobtcrty"
shape=
"time_counter yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m/s"
/>
<attribute
name=
"short_name"
value=
"vobtcrty"
/>
<attribute
name=
"long_name"
value=
"Thickness-weighted depth-averaged meridional Current"
/>
<attribute
name=
"grid"
value=
"bdyV"
/>
</variable>
<variable
name=
"vomecrty"
orgName=
"vomecrty"
shape=
"time_counter z yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m/s"
/>
<attribute
name=
"short_name"
value=
"vomecrty"
/>
<attribute
name=
"long_name"
value=
"Meridional Current"
/>
<attribute
name=
"grid"
value=
"bdyV"
/>
</variable>
</netcdf>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pynemo/profile.py
View file @
fd274644
...
...
@@ -38,6 +38,7 @@ from PyQt5.QtWidgets import QMessageBox
from
calendar
import
monthrange
import
sys
#Local imports
from
pynemo
import
pynemo_settings_editor
from
pynemo
import
nemo_bdy_ncgen
as
ncgen
...
...
@@ -49,6 +50,7 @@ from pynemo import nemo_bdy_gen_c as gen_grid
from
pynemo
import
nemo_coord_gen_pop
as
coord
from
pynemo
import
nemo_bdy_zgrv2
as
zgrv
from
pynemo
import
nemo_bdy_extr_tm3
as
extract
from
pynemo
import
nemo_ncml_parse
as
ncml_parse
from
pynemo.reader.factory
import
GetFile
from
pynemo.reader
import
factory
...
...
@@ -434,7 +436,7 @@ def process_bdy(setup_filepath=0, mask_gui=False):
# Extract source data on dst grid
if
settings
[
'tide'
]:
if
settings
[
'tide'
]
==
True
:
if
settings
[
'tide_model'
]
==
'tpxo'
:
cons
=
tide
.
nemo_bdy_tide_rot
(
Setup
,
DstCoord
,
bdy_ind
[
't'
],
bdy_ind
[
'u'
],
bdy_ind
[
'v'
],
...
...
@@ -518,22 +520,31 @@ def process_bdy(setup_filepath=0, mask_gui=False):
# can be included in the ln_tra = .true. option without having to
# explicitly declaring them.
var_list
=
ncml_parse
.
gen_src_var_list_NCML
(
settings
[
'src_dir'
])
var_in
=
{}
for
g
in
range
(
len
(
grd
)):
var_in
[
grd
[
g
]]
=
[]
if
ln_tra
:
var_in
[
't'
].
extend
([
'votemper'
])
#, 'vosaline'])
if
'votemper'
and
'vosaline'
in
var_list
:
var_in
[
't'
].
extend
([
'votemper'
,
'vosaline'
])
if
'votemper'
and
not
'vosaline'
in
var_list
:
var_in
[
't'
].
extend
([
'votemper'
])
if
'vosaline'
and
not
'votemper'
in
var_list
:
var_in
[
't'
].
extend
([
'vosaline'
])
if
ln_dyn2d
or
ln_dyn3d
:
var_in
[
'u'
].
extend
([
'vozocrtx'
])
var_in
[
'v'
].
extend
([
'vomecrty'
])
if
'vozocrtx'
and
'vomecrty'
in
var_list
:
var_in
[
'u'
].
extend
([
'vozocrtx'
])
var_in
[
'v'
].
extend
([
'vomecrty'
])
if
ln_dyn2d
:
var_in
[
't'
].
extend
([
'sossheig'
])
if
'sossheig'
in
var_list
:
var_in
[
't'
].
extend
([
'sossheig'
])
if
ln_ice
:
var_in
[
't'
].
extend
([
'iicethic'
,
'ileadfra'
,
'isnowthi'
])
if
'iicethic'
and
'ileadfra'
and
'isnowthi'
in
var_list
:
var_in
[
't'
].
extend
([
'iicethic'
,
'ileadfra'
,
'isnowthi'
])
# As variables are associated with grd there must be a filename attached
# to each variable
...
...
@@ -579,7 +590,9 @@ def process_bdy(setup_filepath=0, mask_gui=False):
logger
.
info
(
'End NRCT Logging: '
+
time
.
asctime
())
logger
.
info
(
'=========================================='
)
def
write_tidal_data
(
setup_var
,
dst_coord_var
,
grid
,
tide_cons
,
cons
):
"""
...
...
This diff is collapsed.
Click to expand it.
test_scripts/jars/netcdfAll-4.6.jar
0 → 100644
View file @
fd274644
File added
This diff is collapsed.
Click to expand it.
test_scripts/ncml_gen_nc.py
0 → 100644
View file @
fd274644
# import os
# import jnius_config
# ncmlpath, file_name = os.path.split(__file__)
# ncmlpath = os.path.join(ncmlpath, "jars", "netcdfAll-4.6.jar")
# jnius_config.set_classpath('.',ncmlpath)
#
# from jnius import autoclass
#
# ncml_template = "/Users/thopri/Projects/PyNEMO/inputs/NEMO_output_T.ncml"
# nc_file = "/Users/thopri/Projects/PyNEMO/test_scripts/test.nc"
#
# NcMLReader = autoclass('ucar.nc2.ncml.NcMLReader')
# dataset2 = NcMLReader.writeNcMLToFile(ncml_template,nc_file)
#NetcdfDataset ncfileIn = NcMLReader.readNcML (ncml_filename, null);
import
xml.etree.ElementTree
as
ET
import
xmltodict
ncml
=
"/Users/thopri/Projects/PyNEMO/inputs/NEMO_output_T.ncml"
ncml_xml
=
xmltodict
.
parse
(
ET
.
tostring
(
ET
.
parse
(
ncml
).
getroot
()))
dimensions
=
ncml_xml
[
'ns0:netcdf'
][
'ns0:dimension'
]
variables
=
ncml_xml
[
'ns0:netcdf'
][
'ns0:variable'
]
nc_attrib
=
ncml_xml
[
'ns0:netcdf'
][
'ns0:attribute'
]
var_attrib
=
ncml_xml
[
'ns0:netcdf'
][
'ns0:variable'
][
0
][
'ns0:attribute'
]
print
(
'the end'
)
# for key in ncml_meta:
# for key2 in ncml_meta[key]:
# if 'dimension' in key2:
# print(key2)
# def find(key, dictionary):
# for k, v in dictionary.items():
# if k in key:
# yield dictionary
# elif isinstance(v, dict):
# for result in find(key, v):
# yield result
# elif isinstance(v, list):
# for d in v:
# if isinstance(d, dict):
# for result in find(key, d):
# yield result
#
# print(list(find("ns0:dimension", ncml_meta)))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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