Skip to content

Commit 43d6753

Browse files
update examples with direct "import dnora", add setup.py and version.py. Update documentation
1 parent 6d0cae1 commit 43d6753

12 files changed

+68
-34
lines changed

dnora/version.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
__version__ = "1.2.0"
2+
3+
4+
def git_describe():
5+
"""
6+
Return git version if available.
7+
"""
8+
import os.path
9+
from subprocess import check_output, DEVNULL
10+
11+
path = os.path.dirname(__file__)
12+
args = [
13+
"git", "-C", path, "describe", "--tags", "--abbrev=7", "--dirty",
14+
"--broken"
15+
]
16+
17+
try:
18+
version = check_output(args, cwd=path, stderr=DEVNULL).decode().strip()
19+
return version
20+
except:
21+
return None
22+
23+
def version_or_git():
24+
v = git_describe()
25+
if v is None:
26+
return __version__
27+
else:
28+
return "%s / %s" % (__version__, v)

docs/index.rst

+9-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ Installing **dnora**
3131
$ conda config --add channels conda-forge
3232
$ conda env create -f environment.yml
3333
$ conda activate dnora
34-
34+
$ pip install -e .
35+
3536
To update the enviroment using a new environment.yml, run:
3637

3738
.. code-block:: bash
@@ -55,11 +56,11 @@ Dependencies
5556
To run the models within dnora, the paths, where the models are installed, need to be defined in .bashrc, e.g., ::
5657

5758
export PATH=${PATH}:/home/user/Programs/swan
58-
59+
5960
export PATH=${PATH}:/home/user/Programs/swash
60-
61+
6162
export PATH=${PATH}:/home/user/Programs/HOS-ocean/bin
62-
63+
6364
export PATH=${PATH}:/home/user/Programs/REEF3D_xx/DIVEMesh/bin
6465
export PATH=${PATH}:/home/user/Programs/REEF3D_xx/REEF3D/bin
6566

@@ -152,10 +153,10 @@ The main idea is that the Grid-object is created, and a fixed set of methods are
152153

153154
Examples::
154155

155-
topo_reader=grd.read.EMODNET2018(tile='D5',folder='/home/user/bathy/')
156-
topo_reader=grd.read.EMODNET2020(tile='D5',folder='/home/user/bathy/')
157-
topo_reader=grd.read.GEBCO2021(tile='n66.357421875_s57.041015625_w0.703125_e10.37109375',folder='/home/user/bathy/')
158-
topo_reader=grd.read.KartverketNo50m(tile='B1008',folder='/home/user/bathy/')
156+
topo_reader=grd.read.EMODNET2018(tile='D5',folder='/home/user/bathy/')
157+
topo_reader=grd.read.EMODNET2020(tile='D5',folder='/home/user/bathy/')
158+
topo_reader=grd.read.GEBCO2021(tile='n66.357421875_s57.041015625_w0.703125_e10.37109375',folder='/home/user/bathy/')
159+
topo_reader=grd.read.KartverketNo50m(tile='B1008',folder='/home/user/bathy/')
159160

160161
grid.import_topo(topo_reader=topo_reader)
161162

environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies:
1313
- pip
1414
- utm
1515
- dask
16+
- pytest
1617

1718

1819

examples/example_mdl.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# =============================================================================
22
# IMPORT dnora
33
# =============================================================================
4-
import sys
5-
dnora_directory = '../'
6-
sys.path.insert(0, dnora_directory)
74
from dnora import grd, mdl, bnd, wnd
85
# =============================================================================
96
# DEFINE GRID OBJECT

examples/example_mdl_hos_ocean.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# =============================================================================
22
# IMPORT dnora
33
# =============================================================================
4-
import sys
5-
dnora_directory = '../'
6-
sys.path.insert(0, dnora_directory)
74
from dnora import grd, mdl, inp
85
# =============================================================================
96
# DEFINE MODEL OBJECT

examples/example_mdl_reef3d.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# =============================================================================
22
# IMPORT dnora
33
# =============================================================================
4-
import sys
5-
dnora_directory = '../'
6-
sys.path.insert(0, dnora_directory)
74
from dnora import grd, mdl, bnd, inp, run
85
import dnora.wave_parameters as wp
96

examples/example_mdl_swan_nora3.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# =============================================================================
22
# IMPORT dnora
33
# =============================================================================
4-
import sys
5-
dnora_directory = '../'
6-
sys.path.insert(0, dnora_directory)
74
from dnora import grd, mdl
85
# =============================================================================
96
# DEFINE GRID OBJECT

examples/example_mdl_swan_wam4.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# =============================================================================
22
# IMPORT dnora
33
# =============================================================================
4-
import sys
5-
dnora_directory = '../'
6-
sys.path.insert(0, dnora_directory)
74
from dnora import grd, mdl, bnd, wnd
85
# =============================================================================
96
# DEFINE GRID OBJECT

examples/example_mdl_swash.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# =============================================================================
22
# IMPORT dnora
33
# =============================================================================
4-
import sys
5-
dnora_directory = '../'
6-
sys.path.insert(0, dnora_directory)
74
from dnora import grd, mdl, inp, bnd
85
# =============================================================================
96
# DEFINE GRID OBJECT
@@ -19,7 +16,7 @@
1916
grid.set_boundary(grd.boundary.MidPointAsBoundary(edges='N'))
2017
# Import topography and mesh it down to the grid definitions
2118
grid.import_topo(topo_reader=grd.read.EMODNET2020(tile='*',
22-
folder='/home/janvb/Documents/EMODNET2020/'))
19+
folder='/home/konstac/bathy/'))
2320
grid.mesh_grid()
2421

2522
# =============================================================================
@@ -44,4 +41,4 @@
4441
# =============================================================================
4542
# SWASH RUN
4643
# =============================================================================
47-
model.run_model(dry_run=True, mat_to_nc=True)
44+
model.run_model(dry_run=False, mat_to_nc=True)

examples/example_mdl_ww3.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# =============================================================================
22
# IMPORT dnora
33
# =============================================================================
4-
import sys
5-
dnora_directory = '../'
6-
sys.path.insert(0, dnora_directory)
74
from dnora import grd, mdl, bnd, wnd
85
# =============================================================================
96
# DEFINE GRID OBJECT

examples/example_mdl_ww3_nora3.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# =============================================================================
22
# IMPORT dnora
33
# =============================================================================
4-
import sys
5-
dnora_directory = '../'
6-
sys.path.insert(0, dnora_directory)
74
from dnora import grd, mdl, bnd, wnd
85
# =============================================================================
96
# DEFINE GRID OBJECT

setup.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import setuptools
5+
6+
here = os.path.abspath(os.path.dirname(__file__))
7+
exec(open(os.path.join(here, 'dnora/version.py')).read())
8+
9+
setuptools.setup(
10+
name = 'dnora',
11+
description = 'dnora - a software for dynamical downscaling of wave products i.e., NORA3 wave hindcast and WAM4 wave forecast from MET Norway',
12+
author = 'Konstantinos Christakos & Jan-Victor Björkqvist / MET Norway',
13+
url = 'https://github.com/KonstantinChri/dnora',
14+
download_url = 'https://github.com/KonstantinChri/dnora',
15+
version = __version__,
16+
license = 'GPLv2',
17+
install_requires = [
18+
'numpy',
19+
'scipy',
20+
'matplotlib',
21+
'netCDF4'
22+
],
23+
packages = setuptools.find_packages(),
24+
include_package_data = True,
25+
setup_requires = ['setuptools_scm'],
26+
tests_require = ['pytest'],
27+
scripts = []
28+
)

0 commit comments

Comments
 (0)