diff --git a/README.rst b/README.rst index 1f749a201d1c60cd3135f801accea8df82364880..e224ae5ce3b19679e1220090c5db675d80fb520b 100644 --- a/README.rst +++ b/README.rst @@ -98,12 +98,13 @@ The PyNEMO module can be tested using the bench marking namelist bdy file in the Unit Tests ------------------- -To test operation of the PyNEMO module, running the PyTest script in the unit tests folder will perform a range tests on different child grids, -checking the interpolation of the source data on to the child grid. To do this the following command is required:: +To test operation of the PyNEMO module, running the PyTest script in the unit tests folder will perform a range of tests on different child grids, +e.g. checking the interpolation of the source data on to the child grid. To do this the following command is required:: - $ pytest -q unit_tests/unit_test.py + $ pytest -q pynemo/unit_test.py -The command should be run from the main PyNEMO directory to enable modules to be imported correctly. +Currently **(26/03/2020)** there are 7 tests that cover checking the interpolation results of different child grids. The input data is generated as part of the +test and is removed afterwards. The number of tests will be increased in the future to cover more PyNEMO functionality. Who do I talk to? ----------------- @@ -114,5 +115,6 @@ Who do I talk to? * Other community or team contact + thopri For more information regarding the use and development of PyNEMO see: [PyNEMO Wiki](https://github.com/jdha/PyNEMO/wiki) diff --git a/pynemo/unit_test.py b/pynemo/unit_test.py index ae95d174bd4ef5c51df992da4daf6304d88c1536..c68359e078a8da9f575dfe93c8e7d8aca577746b 100644 --- a/pynemo/unit_test.py +++ b/pynemo/unit_test.py @@ -8,6 +8,7 @@ from netCDF4 import Dataset import numpy as np import glob import os +from pynemo.unit_tests import UT_config as config # 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. @@ -19,7 +20,7 @@ if gen_data != 0: # run PyNEMO with test data # generate list of namelist.bdy files to run -namelist_files = glob.glob('pynemo/unit_tests/namelist*') +namelist_files = glob.glob(config.unit_dir+'namelist*') for n in namelist_files: # run each of the namelist files stdout, stderr = Popen(['pynemo', '-s', n], stdout=PIPE, stderr=PIPE, @@ -34,7 +35,7 @@ for n in namelist_files: # perform tests def test_temp(): - test_files = glob.glob('pynemo/unit_tests/test_outputs/*bdyT*') + test_files = glob.glob(config.output_dir+'*bdyT*') if len(test_files) == 0: raise Exception('DONT PANIC: no temperature test files found') for t in test_files: @@ -47,7 +48,7 @@ def test_temp(): assert abs(temp_[temp_ != 0.0].min() - 15) <= 0.001 def test_salinty(): - test_files = glob.glob('pynemo/unit_tests/test_outputs/*bdyT*') + test_files = glob.glob(config.output_dir+'*bdyT*') if len(test_files) == 0: raise Exception('DONT PANIC: no salinity test files found') for t in test_files: @@ -63,7 +64,7 @@ def test_salinty(): # U and V and SSH tests are required. e.g. ln_dyn2d is set to true. def test_ssh(): - test_files = glob.glob('pynemo/unit_tests/test_outputs/*bdyT*') + test_files = glob.glob(config.output_dir+'*bdyT*') if len(test_files) == 0: raise Exception('DONT PANIC: no SSH test files found') for t in test_files: @@ -76,7 +77,7 @@ def test_ssh(): assert abs(ssh_[ssh_ != 0.0].min() - 1.0) <= 0.001 def test_U(): - test_files = glob.glob('pynemo/unit_tests/test_outputs/*bdyU*') + test_files = glob.glob(config.output_dir+'*bdyU*') if len(test_files) == 0: raise Exception('DONT PANIC: no U current test files found') for t in test_files: @@ -89,7 +90,7 @@ def test_U(): assert abs(U_[U_ != 0.0].min() - 0.5) <= 0.001 def test_V(): - test_files = glob.glob('pynemo/unit_tests/test_outputs/*bdyV*') + test_files = glob.glob(config.output_dir+'*bdyV*') if len(test_files) == 0: raise Exception('DONT PANIC: no V current test files found') for t in test_files: @@ -103,16 +104,16 @@ def test_V(): # clean up test I/O def test_rm_out(): - files = glob.glob('pynemo/unit_tests/test_outputs/*') + files = glob.glob(config.output_dir+'*') for f in files: os.remove(f) - files = glob.glob('pynemo/unit_tests/test_outputs/*') + files = glob.glob(config.output_dir+'*') assert len(files) == 0 def test_rm_in(): - files = glob.glob('pynemo/unit_tests/test_inputs/*') + files = glob.glob(config.output_dir+'*') for f in files: os.remove(f) - files = glob.glob('pynemo/unit_tests/test_inputs/*') + files = glob.glob(config.output_dir+'*') assert len(files) == 0 diff --git a/pynemo/unit_tests/UT_config.py b/pynemo/unit_tests/UT_config.py new file mode 100644 index 0000000000000000000000000000000000000000..37184849fd161d97ae67cefb20a61ea0df29cf80 --- /dev/null +++ b/pynemo/unit_tests/UT_config.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +""" +Config file for Unit test functions, file paths for I/O etc are defined here. + +""" + +# test input directory +input_dir = 'pynemo/unit_tests/test_inputs/' +# test output directory +output_dir = 'pynemo/unit_tests/test_outputs/' +# unit test directory +unit_dir = 'pynemo/unit_tests/' diff --git a/pynemo/unit_tests/gen_tools.py b/pynemo/unit_tests/gen_tools.py index cd5556497957653772848d2b194767eb4174315d..f09f7978611946c4663d09b4837ae1997bff62a0 100644 --- a/pynemo/unit_tests/gen_tools.py +++ b/pynemo/unit_tests/gen_tools.py @@ -260,152 +260,152 @@ def write_coord_Z(fileout, grid_h,grid_z): return 0 -def write_domcfg(fileout, ln_zco, ln_zps, ln_sco, ln_isfcav, jperio, bat, - lont, latt, lonu, latu, lonv, latv, lonf, latf, - e1t, e2t, e1u, e2u, e1v, e2v, e1f, e2f, ff_f, ff_t, - dept_1d, e3t_1d, e3w_1d, e3t, e3u, e3v, e3f, e3w, e3uw, e3vw, - ktop, kbot): - ''' - Writes out a NEMO formatted domcfg file. - - Args: - fileout (string): filename - ln_zco (logical): vertical coordinate flag [z-level] - ln_zps (logical): vertical coordinate flag [z-partial-step] - ln_sco (logical): vertical coordinate flag [sigma] - ln_isfcav (logical): ice cavity flag - jperio (int): domain type - bat (np.ndarray): bathymetry array at t-points (2D) - lon[t/u/v/f](np.ndarray): longitude array at [t/u/v/f]-points (2D) - lat[t/u/v/f](np.ndarray): latitude array at [t/u/v/f]-points (2D) - e1[t/u/v/f] (np.ndarray): zonal scale factors at [t/u/v/f]-points - e2[t/u/v/f] (np.ndarray): meridional scale factors at [t/u/v/f]-points - ff_[f/t] (np.ndarray): coriolis parameter at [t/f]-points - dept_1d (np.ndarray): 1D depth levels at t-points - e3[t/w]_1d (np.ndarray): 1D vertical scale factors at [t/w]-points - e3[t/u/v/f] (np.ndarray): vertcal scale factors at [t/u/v/f]-points - e3[w/uw/vw] (np.ndarray): vertcal scale factors at [w/uw/vw]-points - ktop (np.ndarray): upper most wet point - kbot (np.ndarray): lower most wet point - - Returns: - ''' - - # Open pointer to netcdf file - dataset = Dataset(fileout, 'w', format='NETCDF4_CLASSIC') - - # Get input size and create appropriate dimensions - # TODO: add some sort of error handling - nx, ny, nz = np.shape(e3t) - dataset.createDimension('x', nx) - dataset.createDimension('y', ny) - dataset.createDimension('z', nz) - - # create Variables - nav_lon = dataset.createVariable('nav_lon', np.float32, ('y', 'x')) - nav_lat = dataset.createVariable('nav_lat', np.float32, ('y', 'x')) - nav_lev = dataset.createVariable('nav_lev', np.float32, 'z') - - giglo = dataset.createVariable('jpiglo', "i4") - gjglo = dataset.createVariable('jpjglo', "i4") - gkglo = dataset.createVariable('jpkglo', "i4") - - gperio = dataset.createVariable('jperio', "i4") - - gzco = dataset.createVariable('ln_zco', "i4") - gzps = dataset.createVariable('ln_zps', "i4") - gsco = dataset.createVariable('ln_sco', "i4") - gcav = dataset.createVariable('ln_isfcav', "i4") - - ge3t1d = dataset.createVariable('e3t_1d', np.float64, 'z') - ge3w1d = dataset.createVariable('e3w_1d', np.float64, 'z') - gitop = dataset.createVariable('top_level', "i4", ('y', 'x')) - gibot = dataset.createVariable('bottom_level', "i4", ('y', 'x')) - gbat = dataset.createVariable('Bathymetry', np.float64, ('y', 'x')) - glamt = dataset.createVariable('glamt', np.float64, ('y', 'x')) - glamu = dataset.createVariable('glamu', np.float64, ('y', 'x')) - glamv = dataset.createVariable('glamv', np.float64, ('y', 'x')) - glamf = dataset.createVariable('glamf', np.float64, ('y', 'x')) - gphit = dataset.createVariable('gphit', np.float64, ('y', 'x')) - gphiu = dataset.createVariable('gphiu', np.float64, ('y', 'x')) - gphiv = dataset.createVariable('gphiv', np.float64, ('y', 'x')) - gphif = dataset.createVariable('gphif', np.float64, ('y', 'x')) - ge1t = dataset.createVariable('e1t', np.float64, ('y', 'x')) - ge1u = dataset.createVariable('e1u', np.float64, ('y', 'x')) - ge1v = dataset.createVariable('e1v', np.float64, ('y', 'x')) - ge1f = dataset.createVariable('e1f', np.float64, ('y', 'x')) - ge2t = dataset.createVariable('e2t', np.float64, ('y', 'x')) - ge2u = dataset.createVariable('e2u', np.float64, ('y', 'x')) - ge2v = dataset.createVariable('e2v', np.float64, ('y', 'x')) - ge2f = dataset.createVariable('e2f', np.float64, ('y', 'x')) - gfff = dataset.createVariable('ff_f', np.float64, ('y', 'x')) - gfft = dataset.createVariable('ff_t', np.float64, ('y', 'x')) - ge3t = dataset.createVariable('e3t_0', np.float64, ('z', 'y', 'x')) - ge3w = dataset.createVariable('e3w_0', np.float64, ('z', 'y', 'x')) - ge3u = dataset.createVariable('e3u_0', np.float64, ('z', 'y', 'x')) - ge3v = dataset.createVariable('e3v_0', np.float64, ('z', 'y', 'x')) - ge3f = dataset.createVariable('e3f_0', np.float64, ('z', 'y', 'x')) - ge3uw = dataset.createVariable('e3uw_0', np.float64, ('z', 'y', 'x')) - ge3vw = dataset.createVariable('e3vw_0', np.float64, ('z', 'y', 'x')) - - nav_lon.units, nav_lon.long_name = 'km', 'X' - nav_lat.units, nav_lat.long_name = 'km', 'Y' - - # Populate file with input data - giglo[:] = nx - gjglo[:] = ny - gkglo[:] = nz - - gzco[:] = ln_zco - gzps[:] = ln_zps - gsco[:] = ln_sco - gcav[:] = ln_isfcav - - gperio[:] = jperio - - # TODO: do we need to transpose? - nav_lon[:, :] = lont.T - nav_lat[:, :] = latt.T - nav_lev[:] = dept_1d - - ge3t1d[:] = e3t_1d - ge3w1d[:] = e3w_1d - - gitop[:, :] = ktop.T - gibot[:, :] = kbot.T - - gbat[:, :] = bat.T - - glamt[:, :] = lont.T - glamu[:, :] = lonu.T - glamv[:, :] = lonv.T - glamf[:, :] = lonf.T - gphit[:, :] = latt.T - gphiu[:, :] = latu.T - gphiv[:, :] = latv.T - gphif[:, :] = latf.T - - ge1t[:, :] = e1t.T - ge1u[:, :] = e1u.T - ge1v[:, :] = e1v.T - ge1f[:, :] = e1f.T - ge2t[:, :] = e2t.T - ge2u[:, :] = e2u.T - ge2v[:, :] = e2v.T - ge2f[:, :] = e2f.T - gfff[:, :] = ff_f.T - gfft[:, :] = ff_t.T - - ge3t[:, :, :] = e3t.T - ge3w[:, :, :] = e3w.T - ge3u[:, :, :] = e3u.T - ge3v[:, :, :] = e3v.T - ge3f[:, :, :] = e3f.T - ge3uw[:, :, :] = e3uw.T - ge3vw[:, :, :] = e3vw.T - - # Close off pointer - dataset.close() +# def write_domcfg(fileout, ln_zco, ln_zps, ln_sco, ln_isfcav, jperio, bat, +# lont, latt, lonu, latu, lonv, latv, lonf, latf, +# e1t, e2t, e1u, e2u, e1v, e2v, e1f, e2f, ff_f, ff_t, +# dept_1d, e3t_1d, e3w_1d, e3t, e3u, e3v, e3f, e3w, e3uw, e3vw, +# ktop, kbot): +# ''' +# Writes out a NEMO formatted domcfg file. +# +# Args: +# fileout (string): filename +# ln_zco (logical): vertical coordinate flag [z-level] +# ln_zps (logical): vertical coordinate flag [z-partial-step] +# ln_sco (logical): vertical coordinate flag [sigma] +# ln_isfcav (logical): ice cavity flag +# jperio (int): domain type +# bat (np.ndarray): bathymetry array at t-points (2D) +# lon[t/u/v/f](np.ndarray): longitude array at [t/u/v/f]-points (2D) +# lat[t/u/v/f](np.ndarray): latitude array at [t/u/v/f]-points (2D) +# e1[t/u/v/f] (np.ndarray): zonal scale factors at [t/u/v/f]-points +# e2[t/u/v/f] (np.ndarray): meridional scale factors at [t/u/v/f]-points +# ff_[f/t] (np.ndarray): coriolis parameter at [t/f]-points +# dept_1d (np.ndarray): 1D depth levels at t-points +# e3[t/w]_1d (np.ndarray): 1D vertical scale factors at [t/w]-points +# e3[t/u/v/f] (np.ndarray): vertcal scale factors at [t/u/v/f]-points +# e3[w/uw/vw] (np.ndarray): vertcal scale factors at [w/uw/vw]-points +# ktop (np.ndarray): upper most wet point +# kbot (np.ndarray): lower most wet point +# +# Returns: +# ''' +# +# # Open pointer to netcdf file +# dataset = Dataset(fileout, 'w', format='NETCDF4_CLASSIC') +# +# # Get input size and create appropriate dimensions +# # TODO: add some sort of error handling +# nx, ny, nz = np.shape(e3t) +# dataset.createDimension('x', nx) +# dataset.createDimension('y', ny) +# dataset.createDimension('z', nz) +# +# # create Variables +# nav_lon = dataset.createVariable('nav_lon', np.float32, ('y', 'x')) +# nav_lat = dataset.createVariable('nav_lat', np.float32, ('y', 'x')) +# nav_lev = dataset.createVariable('nav_lev', np.float32, 'z') +# +# giglo = dataset.createVariable('jpiglo', "i4") +# gjglo = dataset.createVariable('jpjglo', "i4") +# gkglo = dataset.createVariable('jpkglo', "i4") +# +# gperio = dataset.createVariable('jperio', "i4") +# +# gzco = dataset.createVariable('ln_zco', "i4") +# gzps = dataset.createVariable('ln_zps', "i4") +# gsco = dataset.createVariable('ln_sco', "i4") +# gcav = dataset.createVariable('ln_isfcav', "i4") +# +# ge3t1d = dataset.createVariable('e3t_1d', np.float64, 'z') +# ge3w1d = dataset.createVariable('e3w_1d', np.float64, 'z') +# gitop = dataset.createVariable('top_level', "i4", ('y', 'x')) +# gibot = dataset.createVariable('bottom_level', "i4", ('y', 'x')) +# gbat = dataset.createVariable('Bathymetry', np.float64, ('y', 'x')) +# glamt = dataset.createVariable('glamt', np.float64, ('y', 'x')) +# glamu = dataset.createVariable('glamu', np.float64, ('y', 'x')) +# glamv = dataset.createVariable('glamv', np.float64, ('y', 'x')) +# glamf = dataset.createVariable('glamf', np.float64, ('y', 'x')) +# gphit = dataset.createVariable('gphit', np.float64, ('y', 'x')) +# gphiu = dataset.createVariable('gphiu', np.float64, ('y', 'x')) +# gphiv = dataset.createVariable('gphiv', np.float64, ('y', 'x')) +# gphif = dataset.createVariable('gphif', np.float64, ('y', 'x')) +# ge1t = dataset.createVariable('e1t', np.float64, ('y', 'x')) +# ge1u = dataset.createVariable('e1u', np.float64, ('y', 'x')) +# ge1v = dataset.createVariable('e1v', np.float64, ('y', 'x')) +# ge1f = dataset.createVariable('e1f', np.float64, ('y', 'x')) +# ge2t = dataset.createVariable('e2t', np.float64, ('y', 'x')) +# ge2u = dataset.createVariable('e2u', np.float64, ('y', 'x')) +# ge2v = dataset.createVariable('e2v', np.float64, ('y', 'x')) +# ge2f = dataset.createVariable('e2f', np.float64, ('y', 'x')) +# gfff = dataset.createVariable('ff_f', np.float64, ('y', 'x')) +# gfft = dataset.createVariable('ff_t', np.float64, ('y', 'x')) +# ge3t = dataset.createVariable('e3t_0', np.float64, ('z', 'y', 'x')) +# ge3w = dataset.createVariable('e3w_0', np.float64, ('z', 'y', 'x')) +# ge3u = dataset.createVariable('e3u_0', np.float64, ('z', 'y', 'x')) +# ge3v = dataset.createVariable('e3v_0', np.float64, ('z', 'y', 'x')) +# ge3f = dataset.createVariable('e3f_0', np.float64, ('z', 'y', 'x')) +# ge3uw = dataset.createVariable('e3uw_0', np.float64, ('z', 'y', 'x')) +# ge3vw = dataset.createVariable('e3vw_0', np.float64, ('z', 'y', 'x')) +# +# nav_lon.units, nav_lon.long_name = 'km', 'X' +# nav_lat.units, nav_lat.long_name = 'km', 'Y' +# +# # Populate file with input data +# giglo[:] = nx +# gjglo[:] = ny +# gkglo[:] = nz +# +# gzco[:] = ln_zco +# gzps[:] = ln_zps +# gsco[:] = ln_sco +# gcav[:] = ln_isfcav +# +# gperio[:] = jperio +# +# # TODO: do we need to transpose? +# nav_lon[:, :] = lont.T +# nav_lat[:, :] = latt.T +# nav_lev[:] = dept_1d +# +# ge3t1d[:] = e3t_1d +# ge3w1d[:] = e3w_1d +# +# gitop[:, :] = ktop.T +# gibot[:, :] = kbot.T +# +# gbat[:, :] = bat.T +# +# glamt[:, :] = lont.T +# glamu[:, :] = lonu.T +# glamv[:, :] = lonv.T +# glamf[:, :] = lonf.T +# gphit[:, :] = latt.T +# gphiu[:, :] = latu.T +# gphiv[:, :] = latv.T +# gphif[:, :] = latf.T +# +# ge1t[:, :] = e1t.T +# ge1u[:, :] = e1u.T +# ge1v[:, :] = e1v.T +# ge1f[:, :] = e1f.T +# ge2t[:, :] = e2t.T +# ge2u[:, :] = e2u.T +# ge2v[:, :] = e2v.T +# ge2f[:, :] = e2f.T +# gfff[:, :] = ff_f.T +# gfft[:, :] = ff_t.T +# +# ge3t[:, :, :] = e3t.T +# ge3w[:, :, :] = e3w.T +# ge3u[:, :, :] = e3u.T +# ge3v[:, :, :] = e3v.T +# ge3f[:, :, :] = e3f.T +# ge3uw[:, :, :] = e3uw.T +# ge3vw[:, :, :] = e3vw.T +# +# # Close off pointer +# dataset.close() def rotate_around_point(lat_in,lon_in, radians , origin=(0, 0)): """Rotate a point around a given point. diff --git a/pynemo/unit_tests/test_gen.py b/pynemo/unit_tests/test_gen.py index 51505767abcf2bdb69d20b82b01d85c2546125d7..90725d8d81d3081338cdd31411f947a17ba931b7 100644 --- a/pynemo/unit_tests/test_gen.py +++ b/pynemo/unit_tests/test_gen.py @@ -7,11 +7,14 @@ The source coordinate grid is also plotted (green). """ from pynemo.unit_tests import gen_tools as gt +from pynemo.unit_tests import UT_config as config # TODO: remove hard coded file names and directories. # TODO: organise the variables better, (maybe in a single dict?) def _main(): + #define directory for test input data for PyNEMO + #Source Coords dx = 1000 # units in km dy = 1000 # units in Km @@ -21,8 +24,8 @@ def _main(): max_dep = 100 min_dep = 10 z_end_dim = 1 - h_fname = 'pynemo/unit_tests/test_inputs/test_src_hgr_zps.nc' - z_fname = 'pynemo/unit_tests/test_inputs/test_src_zgr_zps.nc' + h_fname = config.input_dir+'test_src_hgr_zps.nc' + z_fname = config.input_dir+'test_src_zgr_zps.nc' grid_h1 = gt.set_hgrid(dx,dy,jpi,jpj) grid_z1 = gt.set_zgrid(grid_h1,jpk,max_dep,min_dep,z_end_dim) write_coord_H = gt.write_coord_H(h_fname,grid_h1) @@ -42,14 +45,14 @@ def _main(): min_dep = 10 z_end_dim = 1 sf = 10 - h_fname = 'pynemo/unit_tests/test_inputs/test_dst_hgr_zps.nc' - z_fname = 'pynemo/unit_tests/test_inputs/test_dst_zgr_zps.nc' + h_fname = config.input_dir+'test_dst_hgr_zps.nc' + z_fname = config.input_dir+'test_dst_zgr_zps.nc' grid_h2 = gt.set_hgrid(dx,dy,jpi,jpj,zoffx,zoffy,sf) grid_z2 = gt.set_zgrid(grid_h2,jpk,max_dep,min_dep,z_end_dim) write_coord_H = gt.write_coord_H(h_fname,grid_h2) write_coord_Z = gt.write_coord_Z(z_fname,grid_h2,grid_z2) # write bathy files (constant bathy) - bathy_fname = 'pynemo/unit_tests/test_inputs/test_dst_bathy.nc' + bathy_fname = config.input_dir+'test_dst_bathy.nc' bathy = gt.write_bathy(bathy_fname,grid_h2,grid_z2) if write_coord_H + write_coord_Z + bathy == 0: print("Org child grid generation successful!") @@ -60,8 +63,8 @@ def _main(): origin = (8,8) # rotate grid - rot_h_fname = 'pynemo/unit_tests/test_inputs/test_rot_dst_hgr_zps.nc' - rot_z_fname = 'pynemo/unit_tests/test_inputs/test_rot_dst_zgr_zps.nc' + rot_h_fname = config.input_dir+'test_rot_dst_hgr_zps.nc' + rot_z_fname = config.input_dir+'test_rot_dst_zgr_zps.nc' grid_rot = grid_h2.copy() grid_rot['latt'], grid_rot['lont'] = gt.rotate_around_point(grid_h2['latt'],grid_h2['lont'],theta,origin) grid_rot['latu'], grid_rot['lonu'] = gt.rotate_around_point(grid_h2['latu'], grid_h2['lonu'], theta, origin) @@ -70,7 +73,7 @@ def _main(): write_coord_H = gt.write_coord_H(rot_h_fname,grid_rot) write_coord_Z = gt.write_coord_Z(rot_z_fname,grid_rot,grid_z2) # write bathy files (constant bathy) - bathy_fname = 'pynemo/unit_tests/test_inputs/test_rot_dst_bathy.nc' + bathy_fname = config.input_dir+'test_rot_dst_bathy.nc' bathy = gt.write_bathy(bathy_fname,grid_rot,grid_z2) if write_coord_H + write_coord_Z + bathy == 0: print("Rotated child grid generation Successful!") @@ -87,14 +90,14 @@ def _main(): min_dep = 10 z_end_dim = 1 sf = 10 - h_fname = 'pynemo/unit_tests/test_inputs/test_offset_dst_hgr_zps.nc' - z_fname = 'pynemo/unit_tests/test_inputs/test_offset_dst_zgr_zps.nc' + h_fname = config.input_dir+'test_offset_dst_hgr_zps.nc' + z_fname = config.input_dir+'test_offset_dst_zgr_zps.nc' grid_h3 = gt.set_hgrid(dx,dy,jpi,jpj,zoffx,zoffy,sf) grid_z3 = gt.set_zgrid(grid_h2,jpk,max_dep,min_dep,z_end_dim) write_coord_H = gt.write_coord_H(h_fname,grid_h3) write_coord_Z = gt.write_coord_Z(z_fname,grid_h3,grid_z3) # write bathy files (constant bathy) - bathy_fname = 'pynemo/unit_tests/test_inputs/test_offset_dst_bathy.nc' + bathy_fname = config.input_dir+'test_offset_dst_bathy.nc' bathy = gt.write_bathy(bathy_fname,grid_h3,grid_z3) if write_coord_H + write_coord_Z + bathy == 0: print("Offset child grid gneration successful!") @@ -104,7 +107,7 @@ def _main(): # grid_h3['lont'],grid_h1['latt'],grid_h1['lont']) # write boundary files (constant parameters) - out_fname = 'pynemo/unit_tests/test_inputs/output_boundary' #drop file extension + out_fname = config.input_dir+'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'} @@ -121,7 +124,7 @@ def _main(): print('Boundary file generation successful!') #write_mask - mask_fname = 'pynemo/unit_tests/test_inputs/mask.nc' + mask_fname = config.input_dir+'mask.nc' mask = gt.write_mask(mask_fname,grid_h1,grid_z1) if mask == 0: print('Mask file generation successful!')