From fc0bb0795b93b114c4cab6aca4783623a1a114dc Mon Sep 17 00:00:00 2001 From: thopri <thopri@noc.ac.uk> Date: Mon, 20 Apr 2020 13:28:49 +0100 Subject: [PATCH] fix that generates list of FES harmonics automatically --- docs/source/tides.rst | 38 +++++++++++++++++++++++++++++++++++ inputs/namelist_remote.bdy | 2 +- pynemo/tide/fes_extract_HC.py | 10 +++++---- pynemo/tide/nemo_bdy_tide3.py | 1 + 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 docs/source/tides.rst diff --git a/docs/source/tides.rst b/docs/source/tides.rst new file mode 100644 index 0000000..52ac60c --- /dev/null +++ b/docs/source/tides.rst @@ -0,0 +1,38 @@ +Tidal Boundary Conditions Generation +==================================== + +By providing a global tidal model dataset (TPXO and FES are currently supported) PyNEMO can generate boundary conditions for the +NEMO configuration supplied using the namelist file. + +To use the namelist needs to be configured with the required options. These are listed below:: + + ln_tide = .true. ! =T : produce bdy tidal conditions + sn_tide_model = 'fes' ! Name of tidal model (fes|tpxo) + clname(1) = 'M2' ! constituent name + clname(2) = 'S2' + clname(3) = 'O1' + clname(4) = 'K1' + clname(5) = 'N2' + ln_trans = .false. ! interpolate transport rather than velocities + ! TPXO file locations + sn_tide_grid = './grid_tpxo7.2.nc' + sn_tide_h = './h_tpxo7.2.nc' + sn_tide_u = './u_tpxo7.2.nc' + ! location of FES data + sn_tide_fes = './FES/' + +these options define the location of the tidal model datasets, note this differs depending on model as TPXO has all harmonic +constants in one netcdf file whereas FES has three separate netcdf files for each constant. Extra harmonics can be appended +to the clname(n) list FES supports 34 constants and TPXO7.2 has 13 to choose from. Other versions of TPXO should work with PyNEMO +but have not been yet been tested. + +So far the tidal model datasets have been downloaded and used locally but could also be stored on a TREDDS server although this has +not been tested to generate tidal boundaries + +Future work +----------- + +Create options of harmonic constants to request rather than manually specifying a list. These could be based on common requirements +and/or based on the optimal harmonics to use for a specified time frame. + + diff --git a/inputs/namelist_remote.bdy b/inputs/namelist_remote.bdy index 5aeb88f..fb8d6bf 100644 --- a/inputs/namelist_remote.bdy +++ b/inputs/namelist_remote.bdy @@ -75,7 +75,7 @@ clname(4) = 'K1' clname(5) = 'N2' ln_trans = .false. ! interpolate transport rather than - ! velocities + ! velocities !------------------------------------------------------------------------------ ! Time information !------------------------------------------------------------------------------ diff --git a/pynemo/tide/fes_extract_HC.py b/pynemo/tide/fes_extract_HC.py index eb444bb..5650855 100644 --- a/pynemo/tide/fes_extract_HC.py +++ b/pynemo/tide/fes_extract_HC.py @@ -37,10 +37,12 @@ class HcExtract(object): mu_name = 'mask_u' mv_name = 'mask_v' - #constituents = ['2N2', 'EPS2', 'J1', 'K1', 'K2', 'L2', 'LA2', 'M2', 'M3', 'M4', 'M6', 'M8', 'MF', 'MKS2', - #'MM', 'MN4', 'MS4', 'MSF', 'MSQM', 'MTM', 'MU2', 'N2', 'N4', 'NU2', 'O1', 'P1', 'Q1', 'R2', - #'S1', 'S2', 'S4', 'SA', 'SSA', 'T2'] - constituents = ['M2','S2','O1','K1','N2'] + # create list of HC using namelist file as reference + constituents = list(settings['clname'].values()) + # clean strings in list and change to upper case if not already + for i in range(len(constituents)): + constituents[i] = constituents[i].strip("',/\n") + constituents[i] = constituents[i].upper() self.cons = constituents self.mask_dataset = {} diff --git a/pynemo/tide/nemo_bdy_tide3.py b/pynemo/tide/nemo_bdy_tide3.py index 3202514..60693b9 100644 --- a/pynemo/tide/nemo_bdy_tide3.py +++ b/pynemo/tide/nemo_bdy_tide3.py @@ -2,6 +2,7 @@ Module to extract constituents for the input grid mapped onto output grid @author: Mr. Srikanth Nagella +@author: thopri ''' # pylint: disable=E1103 -- GitLab