Recent Releases of dnora

dnora - v2.4.2

  • executer saves paths to model output files in exe.output_files() [if provided by the ModelRunner]
  • MINCOG model can take metadata=dict(...) in the run_model method to add metadata to output file
  • ERA5 calls fixed to have data_format instead of format in call to cdsapi

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi 22 days ago

dnora - v2.4.1

Added possibility to determine a stride when activating forecast mode. Behaviour of this is up to the model specific implementation, but in WW3 it does the following:

model = dn.modeltun.ModelRun()
model.activate_forecast_mode(reference_time='2025-11-25 00:00', forecast_length=47, stride=24)
exe = dn.execute.WW3(model)
exe.write_input_file()

Outputs:

&OUTPUT_DATE_NML
  DATE%FIELD%START         = '20251125 000000'
  DATE%FIELD%STOP          = '20251126 230000'
  DATE%FIELD%STRIDE        = '3600'
  DATE%RESTART%START         = '20251126 000000'
  DATE%RESTART%STOP          = '20251126 230000'
  DATE%RESTART%STRIDE        = '86400'
/

In other words, this makes it possible to run the next forecast in 24 hours from a restart file.

No other model yet implements this.

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi 29 days ago

dnora - v2.4.0

Added new data types:

  • .import_wavegrid()
  • .import_ocean()
  • .import_atmosphere()

Wavegrid is a gridded equivalent of waveseries. Ocean contains sea surface salinity and temperature (K). Atmosphere contain relative humidity (%), temperature at 2 m height (K) and mean sea level pressure (Pa)

Also added an Vessel Icing model (MINCOG):

"""Marine Icing model for the Norwegian COast Guard

The MINCOG model python implementation is a part of MET Norway's field calculation packae (mi-fieldcald)
mi-fieldcalc if available in conda: 'conda install mi-fieldcalc'

References:
https://github.com/metno/mi-fieldcalc
Samuelsen (2017): https://munin.uit.no/handle/10037/11801
Samuelsen et al. (2017): https://doi.org/10.1016/j.coldregions.2016.11.002
Samuelsen et al. (2018): https://doi.org/10.1002/qj.3174"""

Minimum working example for model:

import dnora as dn

grid = dn.grid.EMODNET(lon=(0.583364, 3.067812), lat=(59.544648, 60.460403), name="constant_icing")
grid.set_spacing(dm=2000)
grid.import_topo()
grid.mesh_grid()

model = dn.modelrun.Constant(grid, start_time='2025-11-12 00:00', end_time='2025-11-12 06:00')
model.import_wavegrid(hs=5, tm01=7)
model.import_atmosphere(t2m=-20+272.15, mslp=900_00, r=90)
model.import_ocean(sst=1+272.15, sss=5.)
model.import_ice(sic=0.3)
model.import_wavegrid(hs=5, tm01=7)
model.import_wind(u=10, v=10)

exp = dn.export.MINCOG(model)
exp.export_all()

exe = dn.executer.MINCOG(model)
exe.write_input_file()
exe.pre_process()
exe.run_model()

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi 30 days ago

dnora - v2.3.4

Fixed bug where WW3 was writing monthly files for winds

Also changed that monthly file filename time stamps respect that start of data might not be the start of month (or end of month respectively)

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi 30 days ago

dnora - v2.3.3

Fixed some bugs with ww3 nameliest
increased python support to 3.14

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi about 2 months ago

dnora - v2.3.2

Bug fixes

  • The SpectralProductReader didn't use the last_file keyword, which had unwanted consequences when activating forecast mode
  • The boolean flags for ice were written incorrectly in ww3_shel.nml

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi about 2 months ago

dnora - v2.3.0

You can now define the variable to output from wave models

import dnora as dn
import geo_parameters as gp

grid = dn.grid.Grid(lon=(10,11), lat=(50,51), name='testgrid')
model = dn.modelrun.Constant(grid)
model.activate_forecast_mode(reference_time='2025-10-24 00:00', forecast_length=48)
model.import_current(u=10, v=10)
for exe in [dn.executer.WW3, dn.executer.SWAN]:
    exe = exe(model)
    # The default output variables is defined in dnora/executer/templates.py WW3._output_vars
    
    # To decode these we use the alias list provided in dnora/executer/templates.py WW3._output_var_aliases
    # The "set" command overwrites the old ones, i.e. the default list in this case
    exe.set_output_vars([gp.wave.Tp, gp.wave.Hs], verbose=True) 
      
    # Adds new variables to list, skip Fp in SWAN since that is not found is the alias list
    exe.add_output_vars([gp.wave.Tm01, gp.wave.Tm02, gp.wave.Fp], verbose=True) 

    # Adds WW3 Wave to ocean energy flux as string since we don't have an alias. 
    # Up to used to know that it is right, so this will be incorrect for SWAN
    exe.add_output_vars('FOC', verbose=True) 

    exe.write_input_file() # 'VEL' will be added to SWAN output list when forcing is present

Using the geo-parameter classes means that the same class can be used in both SWAN and WAVEWATCH III without having to know the different internal naming in the models.

If a parameter is not in the alias-list and/or the corresponding geo-parameter is not yet defined, then you can always just provide the internal name of the parameter as a string. Note, that no checks are made for strings that are provided, so you need to get the name right in this case.

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi about 2 months ago

dnora - v2.2.3

Hydrosphere - Waves and Currents - Python
Published by KonstantinChri about 2 months ago

dnora - v2.2.2

Fixed some bugs when importing and exporting triangular grids

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi 2 months ago

dnora - v2.2.1

Fixed bug where ww3_ounf.nml was not being written correctly

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi 2 months ago

dnora - v2.2.0

Small changes and bug fixes

  • The dependecy on the pint-package has been removed
  • As a consequence python version up to 3.13 are now supported
  • minimum geo-skeletons requirement v0.20.14 to match non-dependance on pint and because of a bug fix in setting names
  • Changed name of the smooth Tp (Tpsmoo) to 'tps' when converting from SWAN mat to netcdf. This is to distinguish it from the discrete Tp, which is named 'tp'
  • Spectra1D objects no longer have a convention

Spectra1D (i.e. model.spectra1d()) no longer has a convention. This was removed because of the possibility for ambiguity, since the direction is already specified as direction from. If you need another type of direction use the dir_type keyword of the geo-skeleton:

>> model.spectra1d().set_dirm(180.0)

>> model.spectra1d().dirm()
180.0
>> model.spectra1d().dirm(dir_type='from')
180.0
>> model.spectra1d().dirm(dir_type='to')
0.0
>> model.spectra1d().dirm(dir_type='math')
90.0

>> model.spectra1d().set_dirm(180.0, dir_type='to')

>> model.spectra1d().dirm()
0.0
>> model.spectra1d().dirm(dir_type='from')
0.0
>> model.spectra1d().dirm(dir_type='to')
180.0
>> model.spectra1d().dirm(dir_type='math')
270.0

The readers are assumed to return data with direction from

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi 2 months ago

dnora - v2.1.0

Added possibility to set nested grids. Minimum working example:

import dnora as dn

sula500 = dn.grid.EMODNET(lon=(5.21, 6.66), lat=(62.25, 62.89), name="sula500")
sula500.set_spacing(dm=500)
sula500.import_topo()
sula500.mesh_grid()
sula500.set_boundary_points(dn.grid.mask.Edges(edges=["N", "W"]))

sula200 = dn.grid.EMODNET(lon=(5.5, 6.66), lat=(62.25, 62.6), name="sula200")
sula200.set_spacing(dm=200)
sula200.import_topo()
sula200.mesh_grid()

model = dn.modelrun.NORA3(
    sula500, start_time="2020-01-20T00:00", end_time="2020-01-20T02:00"
)
model.set_nested_grid(sula200)

model.import_wind()
model.import_spectra()

exporter = dn.export.SWAN(model)
exporter.export_grid()
exporter.export_wind()
exporter.export_spectra()

exe = dn.executer.SWAN(model)
exe.write_input_file()
exe.run_model()

The nested runs are set up as ModelRun objects. If only one nested run is set, then it is accessed through model.nest(). If several nests are set, then model.nest() returns a dictionary with keys being the name of the grid. To force a return of a dictionary, use get_dict=True. So in the above example model.nest() and model.nest(get_dict=True)['sula200] are equivalent.

To go several nests deep, simply nest a new grid inside the nested ModelRun object, e.g.

sula50 = dn.grid.EMODNET(lon=(5.8, 6.1), lat=(62.4, 62.5), name="sula50")
sula50.set_spacing(dm=50)
sula50.import_topo()
sula50.mesh_grid()

and

model.nest().set_nested_grid(sula50)

The exporter and executer will automatically export and execute all nests. To disable this, use include_nest = False when initializing the object.

The nesting logic only works with SWAN, but there is work as follows:

  • Each parent run will write out an ascii file with spectra for all its nests. In the above example it will write bspec_sula200.asc
  • Each nested run will read the ascii file containing the spectra from the parent runs folder
  • If a wind forcing is exported for the parent, the same exported file will also be used in all nests, unless the user has imported/exported another forcing for the nest specifically.
  • If a new forcing (e.g. current) is imported with model.nest().import_current(...), then that forcing is used for that nest and all of its own nests (if any)

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi 3 months ago

dnora - v2.0.5

List of changes regarding the SWAN input file:

  • For stationary forcing there was a bug where 'trans': 0.0 was evaluated to False and not recognized. This is fixed.
  • 'closed' is default False and is ignored for two point structures, since they can't be closed
  • Giving stationary wind should be done as {'wind': {'ff': 10, 'dd': 330}} instead of {'wind': (10, 330)}. Giving a tuple still works but will raise a DepreciationWarning

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi 4 months ago

dnora - v2.0.4

The first release of dnora v2

New features include:

  • Added Ice forcing
  • Automatic download of bathymetry (e.g. EMODNET)
  • Access to ERA5 and Copernicus Marine products
  • Access to new MET Norway products (NORAC, WAM800, WW3-4km)
  • Possibility to write WAVEWATCH III input files and run the model
  • SWAN stationary runs and structures (obstacles)
  • Possibility to move between 1D and 2D spectra
  • Possibility to expand integrated parameters to 1D or 2D JONSWAP spectra
  • Better caching possibilities to avoid downloading slow data several times

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi 4 months ago

dnora - v1.4.3

Full Changelog: https://github.com/MET-OM/dnora/compare/v.1.4.2...v.1.4.3

Hydrosphere - Waves and Currents - Python
Published by KonstantinChri 8 months ago

dnora - v1.4.2

What's Changed

Full Changelog: https://github.com/MET-OM/dnora/compare/v.1.4.1...v.1.4.2

Hydrosphere - Waves and Currents - Python
Published by KonstantinChri 8 months ago

dnora - Release v1.4.1

Fix bug in ERA5(BoundaryReader)

Hydrosphere - Waves and Currents - Python
Published by KonstantinChri almost 3 years ago

dnora - Release v1.4.0

Added Ocean Current object
Added Water Level object (provided by Øystein Lande, @oystelan)

For SWAN:
Added possibility to run in parallel mode:
Uses point picker to get nearest original point with no duplicates, which is compatible with using the block to define the boundary.

Added BoundaryReader for MET Norway operation WW3 (4km)

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi almost 3 years ago

dnora - Release v1.3.2

Fixed SWAN boundary writer with the new Area PointPicker that is now default.

Fixed runnign SWAN without wind forcing.

Removed a breakpoint from ERA5 reader

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi over 3 years ago

dnora - Release v1.3.1

Some changes that should have been in v1.3.0 didn't get pushed

Added preliminary support for ERA5 wind and boundary spectra

Added caching option for forcing and boundary data.

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi over 3 years ago

dnora - Release v1.3.0

Added functionality include:

  • Interactive plotting of forcing data
  • WAM4km boundary reader can now deal with missing files
  • ModelRun now also include a spectral object (1D spectra). Especially, boundary spectra can be integrated to 1D spectra. However, this part i still not finalized.
  • Defaults have been updated to a yaml-file
  • Plotting methods now return a dictionary of the objects, meaning that the default dnora plot can be modified outside of dnora.

Bug-fixes:

  • Fixed grid definition issues in the SWAN input file reader
  • Fixed bug in SWAN wind forcing writer. It looped the days incorrectly.

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi over 3 years ago

dnora - Release v1.2.0

Most important changes are:

  • Added TopoReaders for: Kartverket50m (multi-tile reader), EMODNET2020 (multi-tile reader) and GEBCO2021 (global coverage)
  • Added plot_topo-method to ModelRun object to vew the raw topography of a Grid-object. plot_grid plots the meshed topography.
  • The TopoReaders can now return either structured gridded data or a bunch of points to the Grid-object
  • The trg-module can now read triangulation data and topography data from .msh-.files
  • Added preliminary support for the HOS-ocean model.
  • Option to output selected spectra points (spec_points) in SWAN(InputFileWriter) has added.
  • Times when initializing ModelRun-objects are now optional. Convenient when only working with grids or when we want to import all data from a file.

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi over 3 years ago

dnora - Release v1.1.3

Bug fix in spectral processor

There was a bug in the flip_spec function that made it work incorrectly for some specific transformations (specific orientiation of the directional vector and directional resolution). This bug has been fixed and unit tests have been expanded.

The boundary reader for reading WW3 netcdf-files was corrected for a bug in reading the directions from the xarray dataset and some function handles were harmonized with the rest of the code.

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi almost 4 years ago

dnora - Release v1.1.2

Increased the number of decimals used when writing the SWAN input file. This makes sure that the grid is ok even for very high resolutions.

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi almost 4 years ago

dnora - Release v1.1.1

Two bug-fixes related to the unstructured meshes:

  1. The writer was missing a _im_silent method that controlled output to the user, and this made the export method crash.
  2. The wind readers didn't function properly with an unstructured grid, since they defined the area incorrectly.

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi almost 4 years ago

dnora - Release v1.1.0

This release includes bug-fixes to the SWAN boundary module, and preliminary support for triangular grids.

The spectral conventions have also been strengthened: the conventions are set in the reader and writer, and dnora takes care of the conversions automatically. Available conventions have been expanded to include two different type of mathematical conventions (using different directional vectors).

Dnora has no support for generating triangular meshes, but can import topographical data to existing meshes, and export them in .msh-format. These triangular grids can also be used to import boundary spectra and wind forcing data.

Unit tests have been expanded.

Hydrosphere - Waves and Currents - Python
Published by bjorkqvi almost 4 years ago

dnora - First public release

First release of dnora. All functionality available for SWAN, and partial functionality available for SWASH and WW3.

Hydrosphere - Waves and Currents - Python
Published by KonstantinChri about 4 years ago