Commit 12043a0e authored by thopri's avatar thopri
Browse files

updated grid size on test cases

...@@ -15,8 +15,8 @@ def _main(): ...@@ -15,8 +15,8 @@ def _main():
#Source Coords #Source Coords
dx = 1000 # units in km dx = 1000 # units in km
dy = 1000 # units in Km dy = 1000 # units in Km
jpi = 15 jpi = 16
jpj = 15 jpj = 16
jpk = 10 jpk = 10
max_dep = 100 max_dep = 100
min_dep = 10 min_dep = 10
...@@ -28,15 +28,15 @@ def _main(): ...@@ -28,15 +28,15 @@ def _main():
write_coord_H = gt.write_coord_H(h_fname,grid_h1) write_coord_H = gt.write_coord_H(h_fname,grid_h1)
write_coord_Z = gt.write_coord_Z(z_fname,grid_h1,grid_z1) write_coord_Z = gt.write_coord_Z(z_fname,grid_h1,grid_z1)
if write_coord_H + write_coord_Z == 0: if write_coord_H + write_coord_Z == 0:
print("Success!") print("Parent grid generation successful!")
#Dst Coords #Dst Coords
dx = 100 # units in km dx = 100 # units in km
dy = 100 # units in Km dy = 100 # units in Km
jpi = 100 jpi = 100
jpj = 100 jpj = 100
zoffx = 20 zoffx = 30
zoffy = 20 zoffy = 30
jpk = 10 jpk = 10
max_dep = 100 max_dep = 100
min_dep = 10 min_dep = 10
...@@ -52,12 +52,12 @@ def _main(): ...@@ -52,12 +52,12 @@ def _main():
bathy_fname = 'unit_tests/test_data/test_dst_bathy.nc' bathy_fname = 'unit_tests/test_data/test_dst_bathy.nc'
bathy = gt.write_bathy(bathy_fname,grid_h2,grid_z2) bathy = gt.write_bathy(bathy_fname,grid_h2,grid_z2)
if write_coord_H + write_coord_Z + bathy == 0: if write_coord_H + write_coord_Z + bathy == 0:
print("Success!") print("Org child grid generation successful!")
# set rotation and origin point # set rotation and origin point
rot = 45 rot = 45
theta = gt.radians(rot) theta = gt.radians(rot)
origin = (7,7) origin = (8,8)
# rotate grid # rotate grid
rot_h_fname = 'unit_tests/test_data/test_rot_dst_hgr_zps.nc' rot_h_fname = 'unit_tests/test_data/test_rot_dst_hgr_zps.nc'
...@@ -73,7 +73,7 @@ def _main(): ...@@ -73,7 +73,7 @@ def _main():
bathy_fname = 'unit_tests/test_data/test_rot_dst_bathy.nc' bathy_fname = 'unit_tests/test_data/test_rot_dst_bathy.nc'
bathy = gt.write_bathy(bathy_fname,grid_rot,grid_z2) bathy = gt.write_bathy(bathy_fname,grid_rot,grid_z2)
if write_coord_H + write_coord_Z + bathy == 0: if write_coord_H + write_coord_Z + bathy == 0:
print("Success!") print("Rotated child grid generation Successful!")
# offset grid # offset grid
dx = 100 # units in km dx = 100 # units in km
...@@ -97,26 +97,27 @@ def _main(): ...@@ -97,26 +97,27 @@ def _main():
bathy_fname = 'unit_tests/test_data/test_offset_dst_bathy.nc' bathy_fname = 'unit_tests/test_data/test_offset_dst_bathy.nc'
bathy = gt.write_bathy(bathy_fname,grid_h3,grid_z3) bathy = gt.write_bathy(bathy_fname,grid_h3,grid_z3)
if write_coord_H + write_coord_Z + bathy == 0: if write_coord_H + write_coord_Z + bathy == 0:
print("Success!") print("Offset child grid gneration successful!")
# plot orginal, rotatated and source lat and lon # 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'], \ 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']) grid_h3['lont'],grid_h1['latt'],grid_h1['lont'])
# write boundary files (constant parameters) # write boundary files (constant parameters)
out_fname = 'unit_tests/test_data/output_boundary_T.nc' out_fname = 'unit_tests/test_data/output_boundary_T.nc'
params = {'param1': {'name':'thetao','const_value':15.0,'longname':'temperature','units':'degreesC'}, params = {'param1': {'name':'thetao','const_value':15.0,'longname':'temperature','units':'degreesC'},
'param2': {'name':'so','const_value':35.0,'longname':'salinity','units':'PSU'} 'param2': {'name':'so','const_value':35.0,'longname':'salinity','units':'PSU'}
} }
# 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) boundary = gt.write_parameter(out_fname,grid_h1,grid_z1,params)
if boundary == 0: if boundary == 0:
print('Success!') print('Boundary file generation successful!')
#write_mask #write_mask
mask_fname = 'unit_tests/test_data/mask.nc' mask_fname = 'unit_tests/test_data/mask.nc'
mask = gt.write_mask(mask_fname,grid_h1,grid_z1) mask = gt.write_mask(mask_fname,grid_h1,grid_z1)
if mask == 0: if mask == 0:
print('Success!') print('Mask file generation successful!')
return 0 return 0
......
...@@ -10,20 +10,24 @@ import glob ...@@ -10,20 +10,24 @@ import glob
import os import os
# generate test data by import test gen script and executing main function # generate test data by import test gen script and executing main function
# TODO: Maybe simplify this, as this import imports other scripts and is abit clunky.
import unit_tests.test_gen as tg import unit_tests.test_gen as tg
gen_data = tg._main() gen_data = tg._main()
# if a non zero is return than the grid and data generation has failed.
if gen_data != 0: if gen_data != 0:
raise Exception('DONT PANIC: Input data generation failed') raise Exception('DONT PANIC: Input grid and boundary data generation failed')
# TODO: run different bdy files or change bdy file for different grid types for testing.
# run PyNEMO with test data # run PyNEMO with test data
# generate list of namelist.bdy files to run
namelist_files = glob.glob('unit_tests/namelist*') namelist_files = glob.glob('unit_tests/namelist*')
for n in namelist_files: for n in namelist_files:
# run each of the namelist files
stdout, stderr = Popen(['pynemo', '-s', n], stdout=PIPE, stderr=PIPE, stdout, stderr = Popen(['pynemo', '-s', n], stdout=PIPE, stderr=PIPE,
universal_newlines=True).communicate() universal_newlines=True).communicate()
if 'Execution Time' not in stdout: # check to see if PyNEMO ran correctly, no execution time in stdout is indication of this.
raise Exception('DONT PANIC: Test Run Failed') if 'Execution Time' not in stdout:
print(stderr)
raise Exception('DONT PANIC: Test Run '+str(n)+' Failed')
# TODO: Learn about parameterising the tests so that different parameters can be checked # TODO: Learn about parameterising the tests so that different parameters can be checked
# with same code. Rather than having similar test functions repeated. # with same code. Rather than having similar test functions repeated.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment