Commit 173865a1 authored by thopri's avatar thopri
Browse files

fixed start end date indexing

parent 3dce3e6b
......@@ -38,7 +38,7 @@
sn_bathy = 'http://opendap4gws.jasmin.ac.uk/thredds/noc_msm/dodsC/pynemo_grid_C/NNA_R12_bathy_meter_bench.nc'
!------------------------------------------------------------------------------
! I/O
! I/O
!------------------------------------------------------------------------------
sn_src_dir = '/Users/thopri/Projects/PyNEMO/inputs/CMEMS.ncml' ! src_files/'
sn_dst_dir = '/Users/thopri/Projects/PyNEMO/outputs'
......@@ -49,7 +49,7 @@
nn_fv = -1e20 ! set fill value for output files
nn_src_time_adj = 0 ! src time adjustment
sn_dst_metainfo = 'CMEMS example'
!------------------------------------------------------------------------------
! CMEMS Data Source Configuration
!------------------------------------------------------------------------------
......@@ -85,10 +85,10 @@
nn_depth_max = 5727.918000000001
!------------------------------------------------------------------------------
! unstructured open boundaries
! unstructured open boundaries
!------------------------------------------------------------------------------
ln_coords_file = .true. ! =T : produce bdy coordinates files
cn_coords_file = 'coordinates.bdy.nc' ! name of bdy coordinates files
cn_coords_file = 'coordinates.bdy.nc' ! name of bdy coordinates files
! (if ln_coords_file=.TRUE.)
ln_mask_file = .false. ! =T : read mask from file
cn_mask_file = 'mask.nc' ! name of mask file
......@@ -98,11 +98,11 @@
ln_dyn3d = .true. ! boundary conditions for
! baroclinic velocities
ln_tra = .true. ! 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
!------------------------------------------------------------------------------
! unstructured open boundaries tidal parameters
! unstructured open boundaries tidal parameters
!------------------------------------------------------------------------------
ln_tide = .false. ! =T : produce bdy tidal conditions
sn_tide_model = 'fes' ! Name of tidal model (fes|tpxo)
......@@ -139,13 +139,13 @@
sn_tide_u = '/Users/thopri/Projects/PyNEMO/DATA/TPXO/u_tpxo7.2.nc'
! location of FES data
sn_tide_fes = '/Users/thopri/Projects/PyNEMO/DATA/FES/'
!------------------------------------------------------------------------------
! Additional parameters
!------------------------------------------------------------------------------
nn_wei = 1 ! smoothing filter weights
nn_wei = 1 ! smoothing filter weights
rn_r0 = 0.041666666 ! decorrelation distance use in gauss
! smoothing onto dst points. Need to
! smoothing onto dst points. Need to
! make this a funct. of dlon
sn_history = 'CMEMS test case'
! history for netcdf file
......@@ -154,4 +154,4 @@
nn_beta = 0 ! Euler rotation angle
nn_gamma = 0 ! Euler rotation angle
rn_mask_max_depth = 100.0 ! Maximum depth to be ignored for the mask
rn_mask_shelfbreak_dist = 20000.0 ! Distance from the shelf break
rn_mask_shelfbreak_dist = 20000.0 ! Distance from the shelf break
\ No newline at end of file
......@@ -473,13 +473,25 @@ class Extract:
rev_seq = list(range(len(sc_time.time_counter)))
rev_seq.reverse()
for date in rev_seq:
if src_date_seconds[date] <= dst_start:
first_date = date
break
try:
if src_date_seconds[date-1] <= dst_start <= src_date_seconds[date]:
first_date = date
break
except IndexError:
if src_date_seconds[date] == dst_start:
first_date = date
else:
logging.error('Start date not found in source data')
for date in range(len(sc_time.time_counter)):
if src_date_seconds[date] >= dst_end:
last_date = date
break
try:
if src_date_seconds[date] <= dst_end <= src_date_seconds[date+1]:
last_date = date
break
except IndexError:
if src_date_seconds[date] == dst_end:
last_date = date
else:
logging.error('End date not found in source data,')
self.logger.info('first/last dates: %s %s', first_date, last_date)
......
......@@ -78,7 +78,8 @@ class Boundary:
try:
msk = np.pad(bdy_msk,((1,1),(1,1)), 'constant', constant_values=(-1))
except ValueError:
raise Exception('the ValueError above is commonly due to PyNEMO not finding the bathymetry/mask file')
raise Exception('the ValueError above is commonly due to PyNEMO not finding the bathymetry/mask file or '
'in a incompatable format. E.g. there are zeros along all borders of bathy file...')
# create index arrays of I and J coords
igrid, jgrid = np.meshgrid(np.arange(bdy_msk.shape[1]), np.arange(bdy_msk.shape[0]))
......
......@@ -722,9 +722,6 @@ def _get_mask(Setup, mask_gui):
mask = Mask_File(Setup.settings['bathy'])
mask.apply_border_mask(Constants.DEFAULT_MASK_PIXELS)
bdy_msk = mask.data
except BaseException:
raise Exception('PyNEMO mask generator does not support zeros along all '
'boundaries please use valid bathymetry or mask file')
except:
return
......
......@@ -15,7 +15,7 @@ from mpl_toolkits.basemap import Basemap
from pynemo.tests import bdy_coords as bdc
bdc.process_bdy('/Users/thopri/Projects/PyNEMO/inputs/namelist_cmems.bdy',False)
bdc.process_bdy('/inputs/namelist_cmems.bdy', False)
rootgrp = Dataset('/Users/thopri/Projects/PyNEMO/outputs/NNA_R12_bdyT_y1979m11.nc', "r", format="NETCDF4")
bdy_msk = np.squeeze(rootgrp.variables['bdy_msk'][:]) - 1
......
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