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
d35c2587
Commit
d35c2587
authored
5 years ago
by
thopri
Browse files
Options
Download
Email Patches
Plain Diff
fixed rotated grid test case
parent
12043a0e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
15 deletions
+22
-15
pynemo/nemo_bdy_extr_tm3.py
pynemo/nemo_bdy_extr_tm3.py
+2
-0
unit_tests/gen_tools.py
unit_tests/gen_tools.py
+3
-5
unit_tests/namelist_unit_test_orth.bdy
unit_tests/namelist_unit_test_orth.bdy
+1
-1
unit_tests/test_gen.py
unit_tests/test_gen.py
+16
-9
No files found.
pynemo/nemo_bdy_extr_tm3.py
View file @
d35c2587
...
...
@@ -275,6 +275,8 @@ class Extract:
dist_merid
=
diff_lon_rv
*
np
.
cos
(
dst_lat_rep
*
np
.
pi
/
180
)
dist_zonal
=
sc_lat_rv
[
ind_rv
]
-
dst_lat_rep
# TODO: would a greater circle distance function be better here?
dist_tot
=
np
.
power
((
np
.
power
(
dist_merid
,
2
)
+
np
.
power
(
dist_zonal
,
2
)),
0.5
)
dist_tot
=
dist_tot
.
reshape
(
ind
.
shape
,
order
=
'F'
).
T
...
...
This diff is collapsed.
Click to expand it.
unit_tests/gen_tools.py
View file @
d35c2587
...
...
@@ -534,7 +534,7 @@ def write_mask(fileout,grid_h,grid_z):
return
0
def
write_parameter
(
fileout
,
grid_h
,
grid_z
,
params
):
def
write_parameter
(
fileout
,
grid_h
,
grid_z
,
params
,
grid
):
'''
Writes out a
...
...
@@ -543,10 +543,8 @@ def write_parameter(fileout, grid_h,grid_z,params):
Returns:
'''
#TODO: implement multiple parameters using params dict.
# Open pointer to netcdf file
dataset
=
Dataset
(
fileout
,
'w'
,
format
=
'NETCDF4_CLASSIC'
)
dataset
=
Dataset
(
fileout
+
'_'
+
grid
.
upper
()
+
'.nc'
,
'w'
,
format
=
'NETCDF4_CLASSIC'
)
# Get input size and create appropriate dimensions
# TODO: add some sort of error handling
...
...
@@ -560,7 +558,7 @@ def write_parameter(fileout, grid_h,grid_z,params):
# Create Variables
longitude
=
dataset
.
createVariable
(
'longitude'
,
np
.
float32
,
(
'y'
,
'x'
))
latitude
=
dataset
.
createVariable
(
'latitude'
,
np
.
float32
,
(
'y'
,
'x'
))
depth
=
dataset
.
createVariable
(
'depth'
,
np
.
float32
,
'z'
)
depth
=
dataset
.
createVariable
(
'depth'
+
grid
,
np
.
float32
,
'z'
)
time_counter
=
dataset
.
createVariable
(
'time'
,
np
.
float32
,
(
'time'
))
longitude
.
units
,
longitude
.
long_name
=
'km'
,
'X'
latitude
.
units
,
latitude
.
long_name
=
'km'
,
'Y'
...
...
This diff is collapsed.
Click to expand it.
unit_tests/namelist_unit_test_orth.bdy
View file @
d35c2587
...
...
@@ -61,7 +61,7 @@
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 = .false. ! boundary conditions for
ln_dyn2d = .false. ! boundary conditions for
! barotropic fields
ln_dyn3d = .false. ! boundary conditions for
! baroclinic velocities
...
...
This diff is collapsed.
Click to expand it.
unit_tests/test_gen.py
View file @
d35c2587
...
...
@@ -80,8 +80,8 @@ def _main():
dy
=
100
# units in Km
jpi
=
100
jpj
=
100
zoffx
=
2
5
zoffy
=
2
5
zoffx
=
3
5
zoffy
=
3
5
jpk
=
10
max_dep
=
100
min_dep
=
10
...
...
@@ -100,17 +100,24 @@ def _main():
print
(
"Offset child grid gneration successful!"
)
# plot orginal, rotatated and source lat and lon
gt
.
plot_grids
(
grid_h2
[
'latt'
],
grid_h2
[
'lont'
],
grid_rot
[
'latt'
],
grid_rot
[
'lont'
],
grid_h3
[
'latt'
],
\
grid_h3
[
'lont'
],
grid_h1
[
'latt'
],
grid_h1
[
'lont'
])
#
gt.plot_grids(grid_h2['latt'],grid_h2['lont'],grid_rot['latt'],grid_rot['lont'],grid_h3['latt'], \
#
grid_h3['lont'],grid_h1['latt'],grid_h1['lont'])
# write boundary files (constant parameters)
out_fname
=
'unit_tests/test_data/output_boundary_T.nc'
params
=
{
'param1'
:
{
'name'
:
'thetao'
,
'const_value'
:
15.0
,
'longname'
:
'temperature'
,
'units'
:
'degreesC'
},
'param2'
:
{
'name'
:
'so'
,
'const_value'
:
35.0
,
'longname'
:
'salinity'
,
'units'
:
'PSU'
}
out_fname
=
'unit_tests/test_data/output_boundary'
#drop file extension
params_t
=
{
'param1'
:
{
'name'
:
'thetao'
,
'const_value'
:
15.0
,
'longname'
:
'temperature'
,
'units'
:
'degreesC'
},
'param2'
:
{
'name'
:
'so'
,
'const_value'
:
35.0
,
'longname'
:
'salinity'
,
'units'
:
'PSU'
},
'param3'
:
{
'name'
:
'zos'
,
'const_value'
:
1.0
,
'longname'
:
'sea surface height'
,
'units'
:
'metres'
}
}
params_u
=
{
'param1'
:
{
'name'
:
'uo'
,
'const_value'
:
0.5
,
'longname'
:
'Zonal current'
,
'units'
:
'ms-1'
}
}
params_v
=
{
'param1'
:
{
'name'
:
'vo'
,
'const_value'
:
0.5
,
'longname'
:
'Meridional current'
,
'units'
:
'ms-1'
}
}
# TODO: This needs to be adapted for parameters that are not on the T grid.
boundary
=
gt
.
write_parameter
(
out_fname
,
grid_h1
,
grid_z1
,
params
)
if
boundary
==
0
:
boundary_T
=
gt
.
write_parameter
(
out_fname
,
grid_h1
,
grid_z1
,
params_t
,
't'
)
boundary_U
=
gt
.
write_parameter
(
out_fname
,
grid_h1
,
grid_z1
,
params_u
,
'u'
)
boundary_V
=
gt
.
write_parameter
(
out_fname
,
grid_h1
,
grid_z1
,
params_v
,
'v'
)
if
boundary_T
+
boundary_U
+
boundary_V
==
0
:
print
(
'Boundary file generation successful!'
)
#write_mask
...
...
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