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
21e9a431
Commit
21e9a431
authored
4 years ago
by
thopri
Browse files
Options
Download
Email Patches
Plain Diff
added NCML templace to Tide output
parent
173865a1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
269 additions
and
84 deletions
+269
-84
inputs/namelist_cmems.bdy
inputs/namelist_cmems.bdy
+5
-5
pynemo/nemo_bdy_extr_tm3.py
pynemo/nemo_bdy_extr_tm3.py
+1
-1
pynemo/output_NCML/NEMO_tide_U.ncml
pynemo/output_NCML/NEMO_tide_U.ncml
+53
-0
pynemo/output_NCML/NEMO_tide_V.ncml
pynemo/output_NCML/NEMO_tide_V.ncml
+53
-0
pynemo/output_NCML/NEMO_tide_Z.ncml
pynemo/output_NCML/NEMO_tide_Z.ncml
+53
-0
pynemo/profile.py
pynemo/profile.py
+17
-10
pynemo/tide/nemo_bdy_tide_ncgen.py
pynemo/tide/nemo_bdy_tide_ncgen.py
+87
-68
No files found.
inputs/namelist_cmems.bdy
View file @
21e9a431
...
@@ -93,18 +93,18 @@
...
@@ -93,18 +93,18 @@
ln_mask_file = .false. ! =T : read mask from file
ln_mask_file = .false. ! =T : read mask from file
cn_mask_file = 'mask.nc' ! name of mask file
cn_mask_file = 'mask.nc' ! name of mask file
! (if ln_mask_file=.TRUE.)
! (if ln_mask_file=.TRUE.)
ln_dyn2d = .
tru
e. ! boundary conditions for
ln_dyn2d = .
fals
e. ! boundary conditions for
! barotropic fields
! barotropic fields
ln_dyn3d = .
tru
e. ! boundary conditions for
ln_dyn3d = .
fals
e. ! boundary conditions for
! baroclinic velocities
! baroclinic velocities
ln_tra = .
tru
e. ! boundary conditions for T and S
ln_tra = .
fals
e. ! boundary conditions for T and S
ln_ice = .false. ! ice boundary condition
ln_ice = .false. ! ice boundary condition
nn_rimwidth = 9 ! width of the relaxation zone
nn_rimwidth = 9 ! width of the relaxation zone
!------------------------------------------------------------------------------
!------------------------------------------------------------------------------
! unstructured open boundaries tidal parameters
! unstructured open boundaries tidal parameters
!------------------------------------------------------------------------------
!------------------------------------------------------------------------------
ln_tide = .
fals
e. ! =T : produce bdy tidal conditions
ln_tide = .
tru
e. ! =T : produce bdy tidal conditions
sn_tide_model = 'fes' ! Name of tidal model (fes|tpxo)
sn_tide_model = 'fes' ! Name of tidal model (fes|tpxo)
clname(1) = 'M2' ! constituent name
clname(1) = 'M2' ! constituent name
clname(2) = 'S2'
clname(2) = 'S2'
...
@@ -122,7 +122,7 @@
...
@@ -122,7 +122,7 @@
!clname(14) = '2N2'
!clname(14) = '2N2'
!clname(15) = 'MU2'
!clname(15) = 'MU2'
ln_trans = .false. ! interpolate transport rather than velocities
ln_trans = .false. ! interpolate transport rather than velocities
ln_tide_checker = .
tru
e. ! run tide checker on PyNEMO tide output
ln_tide_checker = .
fals
e. ! run tide checker on PyNEMO tide output
sn_ref_model = 'fes' ! which model to check output against (FES only)
sn_ref_model = 'fes' ! which model to check output against (FES only)
!------------------------------------------------------------------------------
!------------------------------------------------------------------------------
! Time information
! Time information
...
...
This diff is collapsed.
Click to expand it.
pynemo/nemo_bdy_extr_tm3.py
View file @
21e9a431
...
@@ -921,7 +921,7 @@ class Extract:
...
@@ -921,7 +921,7 @@ class Extract:
f_out
=
self
.
settings
[
'dst_dir'
]
+
self
.
settings
[
'fn'
]
+
\
f_out
=
self
.
settings
[
'dst_dir'
]
+
self
.
settings
[
'fn'
]
+
\
'_bdy'
+
self
.
g_type
.
upper
()
+
'_y'
+
str
(
year
)
+
'm'
+
'%02d'
%
month
+
'.nc'
'_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
=
glob
(
self
.
settings
[
'ncml_out'
]
+
'/*'
+
'output_'
+
str
(
self
.
g_type
.
upper
())
+
'.ncml'
)
if
len
(
ncml_out
)
==
0
:
if
len
(
ncml_out
)
==
0
:
raise
RuntimeError
(
'NCML out file for grid '
+
str
(
self
.
g_type
.
upper
())
+
' missing, please add into NCML directory'
)
raise
RuntimeError
(
'NCML out file for grid '
+
str
(
self
.
g_type
.
upper
())
+
' missing, please add into NCML directory'
)
ncml_out
=
ncml_out
[
0
]
ncml_out
=
ncml_out
[
0
]
...
...
This diff is collapsed.
Click to expand it.
pynemo/output_NCML/NEMO_tide_U.ncml
0 → 100644
View file @
21e9a431
<?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=
"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=
"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=
"u1"
orgName=
"u1"
shape=
"yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m/s"
/>
<attribute
name=
"short_name"
value=
"u1"
/>
<attribute
name=
"long_name"
value=
"Tidal east velocity: cosine"
/>
<attribute
name=
"grid"
value=
"bdyU"
/>
</variable>
<variable
name=
"u2"
orgName=
"u2"
shape=
"yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m/s"
/>
<attribute
name=
"short_name"
value=
"u2"
/>
<attribute
name=
"long_name"
value=
"Tidal east velocity: sine"
/>
<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_tide_V.ncml
0 → 100644
View file @
21e9a431
<?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=
"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=
"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=
"v1"
orgName=
"v1"
shape=
"yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m/s"
/>
<attribute
name=
"short_name"
value=
"v1"
/>
<attribute
name=
"long_name"
value=
"Tidal north velocity: cosine"
/>
<attribute
name=
"grid"
value=
"bdyV"
/>
</variable>
<variable
name=
"v2"
orgName=
"v2"
shape=
"yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m/s"
/>
<attribute
name=
"short_name"
value=
"v2"
/>
<attribute
name=
"long_name"
value=
"Tidal north velocity: sine"
/>
<attribute
name=
"grid"
value=
"bdyV"
/>
</variable>
</netcdf>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pynemo/output_NCML/NEMO_tide_Z.ncml
0 → 100644
View file @
21e9a431
<?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=
"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=
"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=
"z1"
orgName=
"z1"
shape=
"yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m"
/>
<attribute
name=
"short_name"
value=
"z1"
/>
<attribute
name=
"long_name"
value=
"Tidal elevation: cosine"
/>
<attribute
name=
"grid"
value=
"bdyT"
/>
</variable>
<variable
name=
"z2"
orgName=
"z2"
shape=
"yb xb"
type=
"float"
>
<attribute
name=
"units"
value=
"m"
/>
<attribute
name=
"short_name"
value=
"z2"
/>
<attribute
name=
"long_name"
value=
"Tidal elevation: sine"
/>
<attribute
name=
"grid"
value=
"bdyT"
/>
</variable>
</netcdf>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pynemo/profile.py
View file @
21e9a431
...
@@ -37,6 +37,7 @@ import numpy as np
...
@@ -37,6 +37,7 @@ import numpy as np
from
PyQt5.QtWidgets
import
QMessageBox
from
PyQt5.QtWidgets
import
QMessageBox
from
calendar
import
monthrange
from
calendar
import
monthrange
import
sys
import
sys
from
glob
import
glob
#Local imports
#Local imports
...
@@ -650,30 +651,36 @@ def write_tidal_data(setup_var, dst_coord_var, grid, tide_cons, cons):
...
@@ -650,30 +651,36 @@ def write_tidal_data(setup_var, dst_coord_var, grid, tide_cons, cons):
setup_var
.
settings
[
'fn'
]
+
\
setup_var
.
settings
[
'fn'
]
+
\
'_bdytide_'
+
const_name
+
'_grd_'
+
\
'_bdytide_'
+
const_name
+
'_grd_'
+
\
val
[
'nam'
].
upper
()
+
'.nc'
val
[
'nam'
].
upper
()
+
'.nc'
ncml_out
=
glob
(
setup_var
.
settings
[
'ncml_out'
]
+
'/*'
+
'tide_'
+
str
(
val
[
'nam'
].
upper
())
+
'.ncml'
)
if
len
(
ncml_out
)
==
0
:
raise
RuntimeError
(
'NCML out tide file for grid '
+
str
(
val
[
'nam'
].
upper
())
+
' missing, please add into NCML directory'
)
ncml_out
=
ncml_out
[
0
]
nemo_bdy_tide_ncgen
.
CreateBDYTideNetcdfFile
(
fout_tide
,
nemo_bdy_tide_ncgen
.
CreateBDYTideNetcdfFile
(
fout_tide
,
val
[
'nx'
],
val
[
'nx'
],
dst_coord_var
.
lonlat
[
't'
][
'lon'
].
shape
[
1
],
dst_coord_var
.
lonlat
[
't'
][
'lon'
].
shape
[
1
],
dst_coord_var
.
lonlat
[
't'
][
'lon'
].
shape
[
0
],
dst_coord_var
.
lonlat
[
't'
][
'lon'
].
shape
[
0
],
val
[
'des'
]
+
tide_con
,
val
[
'des'
]
+
tide_con
,
setup_var
.
settings
[
'fv'
],
key
.
upper
())
setup_var
.
settings
[
'fv'
],
key
.
upper
()
,
ncml_out
)
ncpop
.
write_data_to_file
(
fout_tide
,
val
[
'nam'
]
+
'1'
,
ncpop
.
write_data_to_file
(
fout_tide
,
val
[
'nam'
]
+
'1'
,
cons
[
'cos'
][
val
[
'nam'
]][
indx
])
cons
[
'cos'
][
val
[
'nam'
]][
indx
]
,
ncml_out
)
ncpop
.
write_data_to_file
(
fout_tide
,
val
[
'nam'
]
+
'2'
,
ncpop
.
write_data_to_file
(
fout_tide
,
val
[
'nam'
]
+
'2'
,
cons
[
'sin'
][
val
[
'nam'
]][
indx
])
cons
[
'sin'
][
val
[
'nam'
]][
indx
]
,
ncml_out
)
ncpop
.
write_data_to_file
(
fout_tide
,
'bdy_msk'
,
ncpop
.
write_data_to_file
(
fout_tide
,
'bdy_msk'
,
dst_coord_var
.
bdy_msk
)
dst_coord_var
.
bdy_msk
,
ncml_out
)
ncpop
.
write_data_to_file
(
fout_tide
,
'nav_lon'
,
ncpop
.
write_data_to_file
(
fout_tide
,
'nav_lon'
,
dst_coord_var
.
lonlat
[
't'
][
'lon'
])
dst_coord_var
.
lonlat
[
't'
][
'lon'
]
,
ncml_out
)
ncpop
.
write_data_to_file
(
fout_tide
,
'nav_lat'
,
ncpop
.
write_data_to_file
(
fout_tide
,
'nav_lat'
,
dst_coord_var
.
lonlat
[
't'
][
'lat'
])
dst_coord_var
.
lonlat
[
't'
][
'lat'
]
,
ncml_out
)
ncpop
.
write_data_to_file
(
fout_tide
,
'nbidta'
,
ncpop
.
write_data_to_file
(
fout_tide
,
'nbidta'
,
grid
[
key
].
bdy_i
[
val
[
'ind'
],
0
]
+
1
)
grid
[
key
].
bdy_i
[
val
[
'ind'
],
0
]
+
1
,
ncml_out
)
ncpop
.
write_data_to_file
(
fout_tide
,
'nbjdta'
,
ncpop
.
write_data_to_file
(
fout_tide
,
'nbjdta'
,
grid
[
key
].
bdy_i
[
val
[
'ind'
],
1
]
+
1
)
grid
[
key
].
bdy_i
[
val
[
'ind'
],
1
]
+
1
,
ncml_out
)
ncpop
.
write_data_to_file
(
fout_tide
,
'nbrdta'
,
ncpop
.
write_data_to_file
(
fout_tide
,
'nbrdta'
,
grid
[
key
].
bdy_r
[
val
[
'ind'
]]
+
1
)
grid
[
key
].
bdy_r
[
val
[
'ind'
]]
+
1
,
ncml_out
)
# Iterate over constituents
# Iterate over constituents
...
...
This diff is collapsed.
Click to expand it.
pynemo/tide/nemo_bdy_tide_ncgen.py
View file @
21e9a431
...
@@ -7,8 +7,9 @@ Creates Tide netcdf file ready for population
...
@@ -7,8 +7,9 @@ Creates Tide netcdf file ready for population
from
netCDF4
import
Dataset
from
netCDF4
import
Dataset
import
datetime
import
datetime
import
logging
import
logging
from
pynemo
import
nemo_ncml_parse
as
ncml_parse
def
CreateBDYTideNetcdfFile
(
filename
,
N
,
I
,
J
,
h
,
fv
,
grd
):
def
CreateBDYTideNetcdfFile
(
filename
,
N
,
I
,
J
,
h
,
fv
,
grd
,
ncml_out
):
gridNames
=
[
'T'
,
'U'
,
'V'
]
gridNames
=
[
'T'
,
'U'
,
'V'
]
# Dimension Lengths
# Dimension Lengths
...
@@ -21,106 +22,124 @@ def CreateBDYTideNetcdfFile(filename, N,I,J,h,fv,grd):
...
@@ -21,106 +22,124 @@ def CreateBDYTideNetcdfFile(filename, N,I,J,h,fv,grd):
ncid
=
Dataset
(
filename
,
'w'
,
clobber
=
True
,
format
=
'NETCDF4'
)
ncid
=
Dataset
(
filename
,
'w'
,
clobber
=
True
,
format
=
'NETCDF4'
)
#define dimensions
#define dimensions
dimxbID
=
ncid
.
createDimension
(
'xb'
,
xb_len
)
xb
=
ncml_parse
.
dst_dims
(
ncml_out
,
'xb'
)
dimybID
=
ncid
.
createDimension
(
'yb'
,
yb_len
)
dimxbID
=
ncid
.
createDimension
(
xb
,
xb_len
)
dimxID
=
ncid
.
createDimension
(
'x'
,
x_len
)
yb
=
ncml_parse
.
dst_dims
(
ncml_out
,
'yb'
)
dimyID
=
ncid
.
createDimension
(
'y'
,
y_len
)
dimybID
=
ncid
.
createDimension
(
yb
,
yb_len
)
x
=
ncml_parse
.
dst_dims
(
ncml_out
,
'x'
)
dimxID
=
ncid
.
createDimension
(
x
,
x_len
)
y
=
ncml_parse
.
dst_dims
(
ncml_out
,
'y'
)
dimyID
=
ncid
.
createDimension
(
y
,
y_len
)
#define variable
lon_var
=
ncml_parse
.
dst_var
(
ncml_out
,
'nav_lon'
)
varlonID
=
ncid
.
createVariable
(
lon_var
[
'name'
],
lon_var
[
'type'
],
(
lon_var
[
'shape'
][
0
],
lon_var
[
'shape'
][
1
],
))
lat_var
=
ncml_parse
.
dst_var
(
ncml_out
,
'nav_lat'
)
varlatID
=
ncid
.
createVariable
(
lat_var
[
'name'
],
lat_var
[
'type'
],
(
lat_var
[
'shape'
][
0
],
lat_var
[
'shape'
][
1
],
))
#define variable
varlonID
=
ncid
.
createVariable
(
'nav_lon'
,
'f4'
,(
'y'
,
'x'
,))
varlatID
=
ncid
.
createVariable
(
'nav_lat'
,
'f4'
,(
'y'
,
'x'
,))
if
grd
==
'T'
:
if
grd
==
'T'
:
varmskID
=
ncid
.
createVariable
(
'bdy_msk'
,
'f4'
,(
'y'
,
'x'
,),
fill_value
=
fv
)
bdy_msk
=
ncml_parse
.
dst_var
(
ncml_out
,
'bdy_msk'
)
varz1ID
=
ncid
.
createVariable
(
'z1'
,
'f4'
,(
'yb'
,
'xb'
,),
fill_value
=
fv
)
varmskID
=
ncid
.
createVariable
(
bdy_msk
[
'name'
],
bdy_msk
[
'type'
],
(
bdy_msk
[
'shape'
][
0
],
bdy_msk
[
'shape'
][
1
],),
fill_value
=
fv
)
varz2ID
=
ncid
.
createVariable
(
'z2'
,
'f4'
,(
'yb'
,
'xb'
,),
fill_value
=
fv
)
z1
=
ncml_parse
.
dst_var
(
ncml_out
,
'z1'
)
varz1ID
=
ncid
.
createVariable
(
z1
[
'name'
],
z1
[
'type'
],(
z1
[
'shape'
][
0
],
z1
[
'shape'
][
1
],),
fill_value
=
fv
)
z2
=
ncml_parse
.
dst_var
(
ncml_out
,
'z2'
)
varz2ID
=
ncid
.
createVariable
(
z2
[
'name'
],
z2
[
'type'
],(
z2
[
'shape'
][
0
],
z2
[
'shape'
][
1
],),
fill_value
=
fv
)
elif
grd
==
'U'
:
elif
grd
==
'U'
:
varmskID
=
ncid
.
createVariable
(
'bdy_msk'
,
'f4'
,
(
'y'
,
'x'
,),
fill_value
=
fv
)
bdy_msk
=
ncml_parse
.
dst_var
(
ncml_out
,
'bdy_msk'
)
varu1ID
=
ncid
.
createVariable
(
'u1'
,
'f4'
,(
'yb'
,
'xb'
,),
fill_value
=
fv
)
varmskID
=
ncid
.
createVariable
(
bdy_msk
[
'name'
],
bdy_msk
[
'type'
],
(
bdy_msk
[
'shape'
][
0
],
bdy_msk
[
'shape'
][
1
],),
fill_value
=
fv
)
varu2ID
=
ncid
.
createVariable
(
'u2'
,
'f4'
,(
'yb'
,
'xb'
,),
fill_value
=
fv
)
u1
=
ncml_parse
.
dst_var
(
ncml_out
,
'u1'
)
varu1ID
=
ncid
.
createVariable
(
u1
[
'name'
],
u1
[
'type'
],(
u1
[
'shape'
][
0
],
u1
[
'shape'
][
1
],),
fill_value
=
fv
)
u2
=
ncml_parse
.
dst_var
(
ncml_out
,
'u2'
)
varu2ID
=
ncid
.
createVariable
(
u2
[
'name'
],
u2
[
'type'
],(
u2
[
'shape'
][
0
],
u2
[
'shape'
][
1
],),
fill_value
=
fv
)
elif
grd
==
'V'
:
elif
grd
==
'V'
:
varmskID
=
ncid
.
createVariable
(
'bdy_msk'
,
'f4'
,
(
'y'
,
'x'
,),
fill_value
=
fv
)
bdy_msk
=
ncml_parse
.
dst_var
(
ncml_out
,
'bdy_msk'
)
varv1ID
=
ncid
.
createVariable
(
'v1'
,
'f4'
,(
'yb'
,
'xb'
,),
fill_value
=
fv
)
varmskID
=
ncid
.
createVariable
(
bdy_msk
[
'name'
],
bdy_msk
[
'type'
],
(
bdy_msk
[
'shape'
][
0
],
bdy_msk
[
'shape'
][
1
],),
fill_value
=
fv
)
varv2ID
=
ncid
.
createVariable
(
'v2'
,
'f4'
,(
'yb'
,
'xb'
,),
fill_value
=
fv
)
v1
=
ncml_parse
.
dst_var
(
ncml_out
,
'v1'
)
varv1ID
=
ncid
.
createVariable
(
v1
[
'name'
],
v1
[
'type'
],(
v1
[
'shape'
][
0
],
v1
[
'shape'
][
1
],),
fill_value
=
fv
)
v2
=
ncml_parse
.
dst_var
(
ncml_out
,
'v2'
)
varv2ID
=
ncid
.
createVariable
(
v2
[
'name'
],
v2
[
'type'
],(
v2
[
'shape'
][
0
],
v2
[
'shape'
][
1
],),
fill_value
=
fv
)
else
:
else
:
logging
.
error
(
"Unknown Grid input"
)
logging
.
error
(
"Unknown Grid input"
)
varnbiID
=
ncid
.
createVariable
(
'nbidta'
,
'i4'
,(
'yb'
,
'xb'
,))
nbidta
=
ncml_parse
.
dst_var
(
ncml_out
,
'nbidta'
)
varnbjID
=
ncid
.
createVariable
(
'nbjdta'
,
'i4'
,(
'yb'
,
'xb'
,))
varnbiID
=
ncid
.
createVariable
(
nbidta
[
'name'
],
nbidta
[
'type'
],
(
nbidta
[
'shape'
][
0
],
nbidta
[
'shape'
][
1
],
))
varnbrID
=
ncid
.
createVariable
(
'nbrdta'
,
'i4'
,(
'yb'
,
'xb'
,))
nbjdta
=
ncml_parse
.
dst_var
(
ncml_out
,
'nbjdta'
)
varnbjID
=
ncid
.
createVariable
(
nbjdta
[
'name'
],
nbjdta
[
'type'
],
(
nbjdta
[
'shape'
][
0
],
nbjdta
[
'shape'
][
1
],
))
nbrdta
=
ncml_parse
.
dst_var
(
ncml_out
,
'nbrdta'
)
varnbrID
=
ncid
.
createVariable
(
nbrdta
[
'name'
],
nbrdta
[
'type'
],
(
nbrdta
[
'shape'
][
0
],
nbrdta
[
'shape'
][
1
],
))
#Global Attributes
#Global Attributes
ncid
.
file_name
=
filename
ncid
.
file_name
=
filename
ncid
.
creation_date
=
str
(
datetime
.
datetime
.
now
())
ncid
.
creation_date
=
str
(
datetime
.
datetime
.
now
())
ncid
.
history
=
h
ncid
.
history
=
h
ncid
.
institution
=
'National Oceanography Centre, Livepool, U.K.'
ncid
.
institution
=
ncml_parse
.
dst_glob_attrib
(
ncml_out
,
'institution'
)
#Longitude axis attributes
#Longitude axis attributes
varlonID
.
axis
=
'Longitude'
varlonID
.
axis
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
lon_var
[
'name'
],
'axis'
)
varlonID
.
short_name
=
'nav_lon'
varlonID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
lon_var
[
'name'
],
'short_name'
)
varlonID
.
units
=
'degrees_east'
varlonID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
lon_var
[
'name'
],
'units'
)
varlonID
.
long_name
=
'Longitud
e'
varlonID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
lon_var
[
'name'
],
'long_nam
e'
)
#Latitude axis attributes
#Latitude axis attributes
varlatID
.
axis
=
'Latitude'
varlatID
.
axis
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
lat_var
[
'name'
],
'axis'
)
varlatID
.
short_name
=
'nav_lat'
varlatID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
lat_var
[
'name'
],
'short_name'
)
varlatID
.
units
=
'degrees_east'
varlatID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
lat_var
[
'name'
],
'units'
)
varlatID
.
long_name
=
'Latitude'
varlatID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
lat_var
[
'name'
],
'long_name'
)
#nbidta attributes
#nbidta attributes
varnbiID
.
short_name
=
'nbidta'
varnbiID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
nbidta
[
'name'
],
'short_name'
)
varnbiID
.
units
=
'unit
les
s'
varnbiID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
nbidta
[
'name'
],
'units'
)
varnbiID
.
long_name
=
'Bdy i indices'
varnbiID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
nbidta
[
'name'
],
'long_name'
)
#nbjdta attributes
#nbjdta attributes
varnbjID
.
short_name
=
'nbjdta'
varnbjID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
nbjdta
[
'name'
],
'short_name'
)
varnbjID
.
units
=
'unit
les
s'
varnbjID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
nbjdta
[
'name'
],
'units'
)
varnbjID
.
long_name
=
'Bdy j indices'
varnbjID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
nbjdta
[
'name'
],
'long_name'
)
#nbrdta attributes
#nbrdta attributes
varnbrID
.
short_name
=
'nbrdta'
varnbrID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
nbrdta
[
'name'
],
'short_name'
)
varnbrID
.
units
=
'unitless'
varnbrID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
nbrdta
[
'name'
],
'units'
)
varnbrID
.
long_name
=
'Bdy discrete distance'
varnbrID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
nbrdta
[
'name'
],
'long_name'
)
if
grd
==
'T'
:
if
grd
==
'T'
:
varmskID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varmskID
.
name
,
'short_name'
)
varmskID
.
short_name
=
'bdy_msk'
varmskID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varmskID
.
name
,
'units'
)
varmskID
.
units
=
'unitless'
varmskID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varmskID
.
name
,
'long_name'
)
varmskID
.
long_name
=
'Structured boundary mask'
varz1ID
.
units
=
'm'
varz1ID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varz1ID
.
name
,
'units'
)
varz1ID
.
short_name
=
'z1'
varz1ID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varz1ID
.
name
,
'short_name'
)
varz1ID
.
long_name
=
'tidal elevation: cosin
e'
varz1ID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varz1ID
.
name
,
'long_nam
e'
)
varz1ID
.
grid
=
'bdyT'
varz1ID
.
grid
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varz1ID
.
name
,
'grid'
)
varz2ID
.
units
=
'm'
varz2ID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varz2ID
.
name
,
'units'
)
varz2ID
.
short_name
=
'z2'
varz2ID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varz2ID
.
name
,
'short_name'
)
varz2ID
.
long_name
=
'tidal elevation: sin
e'
varz2ID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varz2ID
.
name
,
'long_nam
e'
)
varz2ID
.
grid
=
'bdyT'
varz2ID
.
grid
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varz2ID
.
name
,
'grid'
)
elif
grd
==
'U'
:
elif
grd
==
'U'
:
varu1ID
.
units
=
'm/
s'
varu1ID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varu1ID
.
name
,
'unit
s'
)
varu1ID
.
short_name
=
'u1'
varu1ID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varu1ID
.
name
,
'short_name'
)
varu1ID
.
long_name
=
'tidal east velocity: cosin
e'
varu1ID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varu1ID
.
name
,
'long_nam
e'
)
varu1ID
.
grid
=
'bdyU'
varu1ID
.
grid
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varu1ID
.
name
,
'grid'
)
varu2ID
.
units
=
'm/
s'
varu2ID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varu2ID
.
name
,
'unit
s'
)
varu2ID
.
short_name
=
'u2'
varu2ID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varu2ID
.
name
,
'short_name'
)
varu2ID
.
long_name
=
'tidal east velocity: sin
e'
varu2ID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varu2ID
.
name
,
'long_nam
e'
)
varu2ID
.
grid
=
'bdyU'
varu2ID
.
grid
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varu2ID
.
name
,
'grid'
)
elif
grd
==
'V'
:
elif
grd
==
'V'
:
varv1ID
.
units
=
'm/
s'
varv1ID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varv1ID
.
name
,
'unit
s'
)
varv1ID
.
short_name
=
'v1'
varv1ID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varv1ID
.
name
,
'short_name'
)
varv1ID
.
long_name
=
'tidal north velocity: cosin
e'
varv1ID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varv1ID
.
name
,
'long_nam
e'
)
varv1ID
.
grid
=
'bdyV'
varv1ID
.
grid
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varv1ID
.
name
,
'grid'
)
varv2ID
.
units
=
'm/
s'
varv2ID
.
units
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varv2ID
.
name
,
'unit
s'
)
varv2ID
.
short_name
=
'v2'
varv2ID
.
short_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varv2ID
.
name
,
'short_name'
)
varv2ID
.
long_name
=
'tidal north velocity: sin
e'
varv2ID
.
long_name
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varv2ID
.
name
,
'long_nam
e'
)
varv2ID
.
grid
=
'bdyV'
varv2ID
.
grid
=
ncml_parse
.
dst_var_attrib
(
ncml_out
,
varv2ID
.
name
,
'grid'
)
else
:
else
:
logging
.
error
(
'Unknown Grid'
)
logging
.
error
(
'Unknown Grid'
)
...
...
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