Coder Social home page Coder Social logo

deltares / dfm_tools Goto Github PK

View Code? Open in Web Editor NEW
63.0 63.0 10.0 161.03 MB

A Python package for pre- and postprocessing D-FlowFM model input and output files

Home Page: https://deltares.github.io/dfm_tools/

License: GNU General Public License v3.0

Python 100.00%

dfm_tools's People

Contributors

avgils avatar cindyvdvries avatar juliengroenenboom avatar lbuckma avatar rqwang avatar tammo-zijlker-deltares avatar veenstrajelmer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dfm_tools's Issues

Decide on curvigrid interpolation method in dfmt.interp_regularnc_to_plipoints()

For CMCC, HIRLAM, Delft3D4, WAQUA and other models, there are 2D lat/lon variables in the dataset (curvilinear grids, sometimes polar). Decide on interpolation method used in dfmt.interp_regularnc_to_plipoints(). ds.interp() does not work with 2D lat/lon vars (pydata/xarray#2281), so currently using KDTree for CMCC.

  • conversion to xugrid UgridDataset is also possible: #396
  • this also works for Delft3D4/WAQUA datasets, but the function should be made less hard-coded as described in #798 (comment)
  • applied for plotting in example script
  • conversion method still requires improvements
  • in case of CMCC, uo and vo variables have different grid, so combining them is inconvenient.
  • replace nearest/triangular interpolation with uds.ugrid.sel_points()
  • how is performance when concatenating many datasets in time?
  • investigate potential use of xcdat, useful for spherical grids?

Improve map-polyline-slice dataset structure and cleanliness

Very maybe uds.ugrid.sel(x/y) could help out here (Deltares/xugrid#26). Or for instance implement uds.ugrid.isel(faces=idx_faces), where also edges/nodes are subsetted (Deltares/xugrid#32) >> fixed

If it would be possible subset an entire dataset (dims: faces, edges, nodes) based on faceidx, it would also be easier to remove ghostcells as in dfmt.open_partitioned_dataset() (#207)

  • replace shapely intersection method with xu.grid.intersect_edges: #252
  • #277
  • #275
  • #302
  • polyline_mapslice() now uses xu.ugrid2d.intersect_edges and sorts them. Put sorting in intersect_edges or numba.celltree (Deltares/xugrid#65 is probably related) >> this seems to be solved, but check more thoroughly
  • #682
  • calcdist_fromlatlon is derived from hardcoded varnames wgs84 or projected_coordinate_system, maybe Deltares/xugrid#42 (but would still require conversion to cartesian/spherical). At least find coordvar based on attribute if possible.
  • improve ugrid generation of sideview grid (maybe with temporal variations), maybe in xugrid? (Deltares/xugrid#59 exists)
  • hovmoller support, so slice multiple times at once
  • Deltares/xugrid#59
  • #673
  • #648

Discuss role of z-values in mapfile

  • variables mesh2d_flowelem_zcc/mesh2d_flowelem_zw (=fullgrid output) are set as coords in dataset (geen data_vars)
  • mesh2d_layer_sigma/mesh2d_interface_sigma zijn geen coords maar data_vars
  • mesh2d_layer_z/mesh2d_interface_z zijn geen coords maar data_vars

This should probably be aligned, all z-variables as coords or all as data_vars.

First check if this is also different in models that are run with new dflowfm kernel. If so, report as UNST issue.

Deprecate and eventually remove old code

Tasks:

  • raise DeprecationWarning for all functions in dfm_tools.io, with new hydrolib-core+dfm_tools method in warning message.
  • Raise deprecation warnings for other code
  • Eventually remove old code

Functions that currently raise a DeprecationWarning:

  • get_ugrid_verts
  • write_bcfile/read_bcfile
  • write_timfile/read_timfile, was deprecated after Deltares/HYDROLIB-core#348 and #301 were solved
  • Polygon and Polygon.fromfile
  • scatter_to_regulargrid
  • get_varnamefromattrs() (including unittest): #310

Functions that currently print a DeprecationWarning:

  • corner2center/corner2center

Add rename for fourier varnames based on attributes

would consist of:

  • set up translation dictionary with help of fourier_analysis.f90.
  • get quantity and maybe analysistype from long_name (e.g. "temperature, average value"). Issue for m
  • maybe get analysistype from varname (e.g. "mesh2d_fourier001_mean") instead (standard_name is not always present), this prevents unclarities with underscores/spaces. However, is there always an underscore present there?
  • get tstart/tstop datestrings from numstart+numstop+reftime. However, numstart/numstop are defined twice and would have to be merged: starttime_fourier_analysis_in_minutes_since_reference_date and starttime_min_max_analysis_in_minutes_since_reference_date
  • rename variable to something like f"{quantity}_{analysistype}_{tstart}_{tstop}" names would then probably make most sense. However, some quantities have spaces/underscores in them, so it might be better to have shorter names like ux/uy/wl etc.
  • possible to include tidal constituent translations? Only numcycles/numstart/numstop is available there, so computed freq would have to be matched to closest value in some online list? (see below) This is source for errors, so warn user. Also, the columns knfac+v0 from the inputfile are not available in the output, also add warning.
  • select all tidal variables by filtering vars that have numcyc attr: xarray.Dataset.filter_by_attrs
  • in case of a 3D model with sigma/z-sigma layers, which z-values are written to the file?

Getting Foreman tidal frequencies:

import pandas as pd
file_freqs = 'https://raw.githubusercontent.com/Deltares/hatyan/main/hatyan/data/data_foreman_frequencies.txt'
freqs = pd.read_csv(file_freqs,names=['freq','dependents'],delim_whitespace=True,comment='#')
print(freqs.loc['M2','freq'])

Used example files:

  • p:\archivedprojects\11203379-005-mwra-updated-bem\03_model\02_final\A72_ntsu0_kzlb2\DFM_OUTPUT_MB_02_fou\MB_02_0000_fou.nc
  • p:\1230882-emodnet_hrsm\GTSMv3.0EMODnet\EMOD_MichaelTUM_yearcomponents\GTSMv4.1_yeartide_2014_2.20.06\output\gtsm_model_0000_fou.nc

Improve dfmt.open_partitioned_dataset()

Improve dfmt.open_partitioned_dataset():

  • support for edge selection (maybe xugrid: Deltares/xugrid#32)
  • support for arbitrary grid names (dependent on Deltares/xugrid#25), that makes it possible to remove some parts of the code.
  • support for multiple grids (1D2D3D model)
  • make renaming more efficient
  • TODO in function
  • documentation

This might fix the issue of reprojecting a uds as in the header of https://github.com/Deltares/dfm_tools/blob/main/tests/examples_workinprogress/workinprogress_grid_convert_coordinates.py

This should fix improper edges plotting in https://github.com/Deltares/dfm_tools/blob/main/tests/examples_workinprogress/workinprogress_plot_edges.py

This might fix #203

Profile xr.open_dataset() for large mapfiles and hisfiles

Opening large mapfiles takes quite some time, this might for instance be because of the decoding of time etc. This could also be done only once, after merging of the mapfile. However, the stuff that takes time is cached so the second opening is more than 10 times faster. Beware the performance for the second opening does not get less.

Some timings:
- DCSM 3D 20 partitions 367 timesteps: 219.0 sec
- RMM 2D 8 partitions 421 timesteps: 60.6 sec
- GTSM 2D 8 partitions 746 timesteps: 73.8 sec
- RMM 3D 40 partitions 146 timesteps: 166.0 sec
- MWRA 3D 20 partitions 2551 timesteps: 826.2 sec

Fixes related to meshkernelpy issues

Next release (4.2.0 or 5.0.0):

Test GTSM-specific new features:

Next:

  • create example in documentation for refinement based a polygon
  • create example in documentation for refinement based on bathymetry, including polygon (to avoid refinement on open boundary) >> more information required
  • add rgfgrid-based grid generation from hydrodynamic course as a meshkernel notebook (includes base grid, refinement, splines etc): n:\Projects\11209500\11209671\B. Measurements and calculations\01_Updated_course_materials\02_exercises\ (Exercise 1 to 4), base on stenderts notebook (p:\11210154-arem-noregret\hydro\modelbuilder\grid\original_curvilinear_UTM\grid_polygons.ipynb
  • Deltares/MeshKernelPy#161
  • Deltares/MeshKernelPy#151
  • Deltares/MeshKernelPy#153
  • Deltares/MeshKernelPy#96
  • Deltares/MeshKernelPy#152
  • Deltares/MeshKernelPy#71 >> discuss node instead of face refinement with urban
  • support for bathy on grid? important to retain bathy in GRIDEDITOR GUI (maybe also set/interpolate?) and other workflows: https://issuetracker.deltares.nl/browse/GRIDEDIT-806
  • product demo for dsc/haf departments: examples of applications in projects including which mk-features used (gtsm (almost), mb destine?, mb guycarpenter? (not yet), mb gtsm rivers?, mb fmcourse, mb hackathon bonaire, mb saba?, mb arabiangulf, hydrolib-core, hydromt_delft3dfm, dhydamo?, more hco/haf?)
  • meshkernel logo

Other:

Related issues:

  • #217
  • meshkernel(py) issues in JIRA
  • possible to check orthogonality in mk? More grid validators/cleanups (modelbuilder example script)
  • possible to use connect_cells separately (without refining)?
  • polygon generation/editing, maybe already possible?
  • check TODO in meshkernel example script and modelbuilder example script
  • minimal interacter network is 1D: p:\dflowfm\maintenance\JIRA\06000-06999\06548\meshkernel_interp.py, can be used to interpolate bathy to?
  • do we need sphericalaccurate grids for dcsm/gtsm? These are not implemented yet (only spherical)
  • overview of RGFGRID functions

Workflows:

  • GTSM: global base grid, bathy+gradient refinement, cut landpart with ldb (incl drypoints), example script with some issues
  • 1D2D connected like GTSM+rivers
  • DCSM: bathy+polygonen refinement, cut landpart with ldb+depth (drypoints with matlab, details at JG?)
  • RMM: multiblock rivers, curvigrid generation based on splines, triangles in estuaries, squares in seapart. For the second, we need a to divide a polygon in equal length parts, part of meshkernel?
  • D-HYDRO course materials workflow
  • tutorial materials from manual
  • RGFGRID functions overview, manual edits like in edit>reg/irreg
  • create unittests of all workflows to make sure behaviour is tested and future changes do not result in undesired behaviour

DCSM steps:

  • Create base_grid (4 nm resolution)
  • delete with polygon (delete network)
  • delete with polygon (based on cell centers)
  • refine with polygon
  • set all z-values to -999 (fillvalue)
  • interp bathy from xyz
  • set missing z-values to certain value, if outside of polygon (actually to later delete cells on land, so easier method for that might also work)
  • delete nodes with z-values lower than specified value or missing value (only if this applies to all nodes of face) >> can be replaced with delete option that considers crossings of cell edges like in Deltares/MeshKernelPy#63 (comment)
  • remove small flowlinks (merge circumcenters) >> mesh2d_delete_small_flow_edges_and_small_triangles (#812 (comment))
  • delete 1D/hanging links >> mesh2d_delete_hanging_edges
  • merge with additional grid (merge nodes on top of each other) >> mesh2d_merge_nodes
  • is not entirely solved by improving polygon deletion, since we have fjords in norway where emodnet has (wet) bathymetry but the landboundary does not include them
  • illegalcells necessary, or Deltares/MeshKernelPy#150
  • meshkernel alternative: p:\1204257-dcsmzuno\gridcreation_test_meshkernelpy\DCSM_grid_creation_meshkernel.py

Release 3.0.0:

mk 4.1.0 (released 2024-02-15):

Update dependencies after hydrolib-core and meshkernel release

When hydrolib-core 0.5.0 and meshkernel 2.0.3 is available, update deps to:

  • hydrolib-core>=0.5.0 (contains TimModel, pytest and generate-documentation fail until then)
  • meshkernel>=2.0.3 (working is_geometric etc)
  • check TODO in example scripts

Test with new env from yml.

Release numpy dependency restriction when possible

Currently installing an older numpy version to avoid "SystemError: initialization of _internal failed without raising an exception"

This happens in the generate-documentation actions 57 to 61 and in binder, but in general upon creation of dfm_tools_env from environment.yml.

This post suggests to restrict the numpy version and using "numpy<1.24" indeed resolves the issue.
https://stackoverflow.com/questions/74947992/how-to-remove-the-error-systemerror-initialization-of-internal-failed-without

Release this restriction when the dependency conflict is resolved by numba: numba/numba#8464

drop Python 3.8 support

Also:

  • update supported python versions in pyproject.toml (classifiers and requires-python)
  • remove pandas version restriction for py38 from pyproject.toml (and simplify xarray/dask requirement)
  • remove pytest-py38.yml workflow and badge in readme
  • #576

xarray writing mfdataset results in incorrect data when not using manual encoding

xarray.to_netcdf() of opened mfdataset results in incorrect data when not using manual encoding

import os
import xarray as xr
import matplotlib.pyplot as plt
plt.close('all')

#open data
dir_data = r'p:\11207892-pez-metoceanmc\3D-DCSM-FM\workflow_manual\01_scripts\04_meteo\era5_temp'
file_nc = os.path.join(dir_data,'era5_mslp_*.nc')
data_xr = xr.open_mfdataset(file_nc)

#optional encoding
#data_xr.msl.encoding['dtype'] = 'float32' #TODO: updating dtype in encoding solves the issue. Source data is int, opened data is float, but encoding is still int.
#data_xr.msl.encoding['_FillValue'] = float(data_xr.msl.encoding['_FillValue'])
#data_xr.msl.encoding['missing_value'] = float(data_xr.msl.encoding['missing_value'])
#data_xr.msl.encoding['zlib'] = True #no effect
#data_xr.msl.encoding['scale_factor'] = 0.01
#data_xr.msl.encoding['add_offset'] = 0

#write to netcdf file
file_out = os.path.join('era5_mslp_out.nc')
data_xr.to_netcdf(file_out)

fig,(ax1,ax2) = plt.subplots(1,2,figsize=(11,5))
data_xr.msl.sel(time='2023-01-24 02:00:00').plot(ax=ax1,cmap='jet') #original dataset
with xr.open_dataset(file_out) as data_xr_check:
    data_xr_check.msl.sel(time='2023-01-24 02:00:00').plot(ax=ax2,cmap='jet') #written dataset
fig.tight_layout()

This results in incorrect data in the written file (right):
image

When updating the dtype (from int to float) in the variable encoding, this issues is solved:
image

The encoding in the source dataset:

data_xr.msl.encoding
Out[28]: 
{'source': 'p:\\11207892-pez-metoceanmc\\3D-DCSM-FM\\workflow_manual\\01_scripts\\04_meteo\\era5_temp\\era5_mslp_2022-11.nc',
 'original_shape': (720, 93, 121),
 'dtype': dtype('int16'),
 'missing_value': -32767,
 '_FillValue': -32767,
 'scale_factor': 0.11615998809759968,
 'add_offset': 99924.34817000595}

Possible issue: source data is integers, but opening files with different scaling_factors (from different files) converts it to floats (or maybe this always happens). The dtype in the encoding is still int, so this is how the netcdf is written, but probably something does not fit within the int-bounds.

Design simple FM/FM nesting workflow

  • Nesthd1:
    • input: rooster grof (evt ook epsg code, of uit rooster lezen)
    • input: pli-line met bnd langs rooster-fijn (incl epsg code, default is WGS84 maar check dan: coords.min()>=-180 en coords.max()<=180)
    • action: kdtree van cellcenters grove rooster
    • action: find 3 nearest neighbors (cartesian) or find cell numbers and connected cells via meshgrid oid
    • action: generate list of cellscenters and connected cellcenters
    • action: drop duplicate coordinates, drop coordinates with distance larger than np.sqrt(cellarea.mean() of nestcells)
    • returns: obsfile met coordinaten van deze cellcenter values
  • Run grof model met obsfile
  • Nesthd2:
    • input: pli-line
    • input: hisfile grove model
    • (input: obsfile, to check if all obspoints are present in ncfile (geen adminfile nodig))
    • action: make kdtree van obspoints, query per pli punt (incl distance, cartesian), invdist avg of neighbors, results in timeseries
      • alternative: hisfile.interp() met alle pli punten (zoals interpolate_nc_to_bc() function) (lijkt niet zomaar mogelijk, maar kan ongetwijfeld)
    • action: put timeseries in forcingmodel and write to bc file
    • eerste opzet in "workinprogress_interpolate_his.py" example script
  • er is een idee om interpolatie in te bouwen in de FM kernel, dan zou het nog veel makkelijker worden (plifile omzetten naar xyn, grof model draaien met xyn, history inlezen en omzetten naar nc/bc

First setup: https://github.com/Deltares/dfm_tools/blob/main/tests/examples_workinprogress/workinprogress_nestingFMtoFM.py

Also request from RS/PK to add Neuman boundary, where inflowing direction of grid should be known (possible?). Or alternatively, combination of waterlevel/ux/uy boundary, which is simpler to implement.

Related, nesting SFINCS in FM is done in GC with:

Also request from WO to add Riemann boundary, so combination of waterlevel and discharge (latter from cross-sections). For morphology we also require nesting bed level changes (form obsfiles) and sediment transport (form cross-sections).

Also align with nesting in ocean models like CMEMS, maybe also consider nesting in other existing models (shyfem, schism, delft3d4, etc).

Improve dataset consistency of dfmt.open_partitioned_dataset()

The internal structure of datasets opened with dfmt.open_partitioned_dataset() is not consistent. This might be because edges/nodes are not ghostcell-filtered or reindexed.

import xugrid as xu
import dfm_tools as dfmt

file_nc = r'c:\DATA\dfm_tools_testdata\DFM_3D_z_Grevelingen\computations\run01\DFM_OUTPUT_Grevelingen-FM\Grevelingen-FM_0000_map.nc'

data_frommap = xu.open_dataset(file_nc)
data_frommap.ugrid.to_netcdf('test.nc') #this works
data_frommap2 = dfmt.open_partitioned_dataset('test.nc') #this also works

data_frommap = dfmt.open_partitioned_dataset(file_nc)
data_frommap.ugrid.to_netcdf('test.nc') #TODO: "ValueError: cannot reindex or align along dimension 'mesh2d_nEdges' because of conflicting dimension sizes: {77761, 67906}"
#data_frommap2 = dfmt.open_partitioned_dataset('test.nc') #not tested yet

Add model builder example notebook

Tasks for first implementation:

  • build on examples for grid creation and model builder
  • also add to tutorials in docs
  • check TODO in notebook
  • last block: status = os.system('dir')
  • how to handle apikeys?
  • also point to updated meshkernelpy notebooks
  • commit+push, run binder a few times so it loads quickly (after that no pushes to main anymore)
  • improve grid/bathy plot

Improve reading/writing of FM bathymetry files

For FM, there are several file types for bathymetry and serveral packages that could read/write them:

Fixes related to hydrolib-core issues

Checks for next release (may 2024):

  • mdu settings (more strict)
  • true/false booleans instead of 1/0 in mdu

From hydromt_delft3dfm:

Other:

Can be closed? (dfm_tools/xugrid alternatives):

hydrolib-core issues, to be included in 0.5.0:

`ds.to_crs()` implementation for hisfiles

Currently results in an error: AttributeError: 'Dataset' object has no attribute 'set_crs'

It was added to xr.UgridDataset via the ugrid accessor. Consider doing something similar for hisfiles.

remove non unicode bytes from HISTORY.rst and README.md

  • dfm_tools version: 0.7.23
  • Python version: 3.8
  • Operating System: Win 10

Description

Install toolbox from conda .yml file

What I Did

did: conda env update -f newenvironment.yml
with following lines in yml that give error
dependencies:
  - pip:
    - git+https://github.com/openearth/dfm_tools.git@6ac91e323ad9228cd10903a3e6af4ac15ad72b20

error:

File "\dfm_tools\setup.py", line 8, in <module>
        readme = readme_file.read()
      File "\lib\codecs.py", line 322, in decode
        (result, consumed) = self._buffer_decode(data, self.errors, final)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 3617: invalid start byte

similar error will be found later in the history file

What I expected:

seamless installation ;)

in tests/examples/CMEMS_interpolate_example.py: incorrect quantity for .ext

Input quantity for Boundary should be the bcvarname as is correctly specified in get_conversion_dict in interpolate_grid2bnd.py. E.g. salinity should become salinitybnd.

boundary_object = Boundary(quantity=quantity, #TODO: nodeId / bndWidth1D / bndBlDepth are written as empty values, but they should not be written if not supplied. https://github.com/Deltares/HYDROLIB-core/issues/319
                                   locationfile=Path(dir_out,file_pli.name),
                                   forcingfile=ForcingModel_object,
                                   )

Decide where to land grid-related operations

Could land in xugrid, dfm_tools, meshkernel or hydrolib-core.

Actions like >> current package:

  • grid generation/refinement >> meshkernel
  • grid writing >> xugrid (implemented, including meshkernel>xugrid conversion)
  • cross-section trough map data (side view) so dfmt.polyline_mapslice() >> xugrid+dfm_tools combination (#206)
  • slicing at depths is probably not grid-specific (#208)

mapfile/hisfile subselect in polygon

  • rough workflow in postprocess_mapfile_inpolygon.py
  • maybe use face_coordinates (as shapely points) instead of face_node_coordinates, since it would make workflow easier
  • add conversion from hydrolib polobject to shapely multipolygon
  • optimize code by making only shapely points of face_coordinates in pol min/max bound box
  • use matplotlib Path instead?
  • if only applied on face_dimension, we can use uds.sel() to drop all other faces. Possible with multiple polygons?
  • also for hisfiles (or general datasets), so do something with attrs
  • what kind of polygon object is useful? Try aligning with meskhernel
  • besides windfarm study, also relevant for veersemeer study
  • this was recently implemented in xugrid: https://deltares.github.io/xugrid/examples/vector_conversion.html (added in commits up to to 31jul2023)

Fixes related to xugrid issues

0.8.1:

Soon:

Then:

Later:

xugrid 0.7.0 or older:

Add slev obsdata download function

Todo:

  • download based on GTSM scripts with some updates
  • solve code duplicates, e.g. create standardized subsetting function instead of one for each dataset, same goes for downloading. But in that case the source has to be derived from the geodataframe.
  • x/y is generic because of geodataframe, also do for time_min/time_max/country
  • re-enable kwargs for catalog and dataretrieval (like gesla dir or drop_noncoastal stations)
  • add test cases
  • including export of resulting obspoints, e.g. to xynfile
  • drop non-geom lat/lon columns and non standard time columns
  • names of nc files should correspond to xynfile, so add unique stationname to all gdf's and use that column in writing nc and xyn. Also remove name_column argument in xyn function. Also add unique stationname to expected columns test.
  • possible to use gesla directly from zipfile or very bad for performance?
  • Add station_name/ndays to be generic across datasets (and add to test_ssh_catalog_subset())
  • check whether ioc contains more data than 1 day (first and last column seem to imply this)
  • expose public functions with from observations import *
  • check minimal required version for erddapy
  • example notebook (current example scripts in gtsm repos) >> result
  • update whatsnew.md

Follow-up: #712

proper cleanup of extra dims in atdepths return dataset

  • replace extra-dim-removal code by looping over relevant variables myself instead of applying bool to entire uds. >> variables = [var for var in ds.data_vars if set(["layer", "time", grid.face_dimension]).issubset(ds[var].dims)]
  • Atdepth bool hoeft alleen maar toegepast te worden op vars met evenveel en dezelfde dimensies
  • remove edge and node dim from uds, but before .where(). Might solve extra-dim issue already? Add note that edges/nodes are removed since zcoords-filter is currently only on faces, maybe once add edge-support if needed?
  • clean up unneccesary vars in returned dataset

Fix failing testbank cases

Fix failing testbank cases (24-01-2023).

_____________________________ test_run_examples[preprocess_meteo_mergenetCDFtime_xarray] ______________________________
C:\DATA\dfm_tools\tests\test_dfm_tools.py:43: in test_run_examples
------------------------------------------------ Captured stdout call -------------------------------------------------
opening multifile dataset of 180 files matching "era5_.*(chnk|mslp|u10n|v10n)_.*\.nc" (can take a while with lots of files)
------------------------------------------------ Captured stderr call -------------------------------------------------
Traceback (most recent call last):
[...]
OSError: [Errno -51] NetCDF: Unknown file format: b'p:\\metocean-data\\open\\ERA5\\data\\Irish_North_Baltic_Sea\\u10n\\era5_u10n_1992.nc'
______________________________________ test_zlayermodel_correct_layers_THISFAILS ______________________________________
C:\DATA\dfm_tools\tests\test_dfm_tools.py:165: in test_zlayermodel_correct_layers_THISFAILS
    assert (np.abs(vals_zcc_top-vals_wl)<1e-6).all() #this should pass
E   AssertionError: assert False
E    +  where False = <built-in method all of numpy.ndarray object at 0x00000220BFA8E570>()
E    +    where <built-in method all of numpy.ndarray object at 0x00000220BFA8E570> = array([2.5124 , 2.2804 , 2.2921 , ..., 2.284  , 2.25245, 2.25245]) < 1e-06.all
E    +      where array([2.5124 , 2.2804 , 2.2921 , ..., 2.284  , 2.25245, 2.25245]) = <ufunc 'absolute'>((array([-0.875, -0.875, -0.875, ..., -0.875, -0.875, -0.875]) - array([1.6374 , 1.4054 , 1.4171 , ..., 1.409  , 1.37745, 1.37745])))
E    +        where <ufunc 'absolute'> = np.abs

Deprecate dfmt.get_ugrid_verts()

Deprecate dfmt.get_ugrid_verts(). Since Deltares/xugrid#48 was solved, this can be replaced with uds.grid.face_node_coordinates everywhere. Maybe first add Deprecationwarning, and/or put new code in function for now.

plot_ztdata pcolormesh does not support masked arrays for 2D mesh coordiantes

The plot_ztdata function uses pcolormesh to plot the data value against a 2D mesh of time and depth. The time and depth arrays are masked, which is not supported by pcolormesh. Using pcolor instead seems to get around the issue.

I suggest replacing line #837 of get_nc.py with:
pc = ax.pcolor(time_mesh_cor, data_fromhis_zcor_flat, dfmtools_hisvar_flat, **kwargs)

Github related improvements

Documentation/license:

Code style/quality:

Create issues:

Testbank:

  • enable pytest via github actions
  • fix pytest by temporary ignoring testcases marked with requiresdata (reduces codecov but that is ok)
  • add codecov badge (fix percentage)
  • #336
  • #683
  • add windows and macos testbanks
  • phase out requireslocaldata tests by making testdata available (and avoiding p-drive links). Now we have opendap download. Maybe use HYDROLIB-data repos instead (or xugrid cached downloads)? Maybe use dsctestbench data on repos, how to authenticate on github? At least make cds/cmems testcases work on github by setting env vars
  • increase test coverage: https://app.codecov.io/gh/deltares/dfm_tools?displayType=list
  • pytest ignore UserWarning via pyproject.toml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.