Comments (4)
I think we should try to mimic the functionality of xarray http://xarray.pydata.org/en/stable/generated/xarray.Dataset.sel.html
Since we are not loading the data lazily (yet, at least) the filtering is most efficient to do while reading the data and not on the Dataset, but this should still be possible, for convenience.
from mikeio.
Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
>>> import mikeio
>>> ds = mikeio.read("tests/testdata/HD2D.dfsu")
>>> ds
DataSet(data, time, items)
Number of items: 4
Shape: (9, 884)
1985-08-06 07:00:00 - 1985-08-07 03:00:00
>>> ds.items
[Surface elevation <Surface Elevation> (meter), U velocity <u velocity component> (meter per sec), V velocity <v velocity component> (meter per sec), Current speed <Current Speed> (meter per sec)]
>>> ds2 = ds[['Surface elevation','Current speed']] # item selection
>>> ds2.items
[Surface elevation <Surface Elevation> (meter), Current speed <Current Speed> (meter per sec)]
>>> len(ds2)
2
>>> ds3 = ds2.isel([0,1,2], axis=0) # temporal selection
>>> ds3
DataSet(data, time, items)
Number of items: 2
Shape: (3, 884)
1985-08-06 07:00:00 - 1985-08-06 12:00:00
>>> ds4 = ds3.isel([100,200], axis=1) # element selection
>>> ds4
DataSet(data, time, items)
Number of items: 2
Shape: (3, 2)
1985-08-06 07:00:00 - 1985-08-06 12:00:00
>>>
from mikeio.
Nice!
Another thing came to my mind: 3d dfsu files (and their Dataset) have a z-item which is node-based. When I do
ds3.isel([100], axis=1)
I will select node 100 for the z-item and element 100 for remaining items... that is not optimal. But I guess it is not very elegant to let the Dataset hold the element_table as well so it can look up which nodes are related to element 100 ???
from mikeio.
I think the dataset should eventually, know what type of geometry is represents, but I think that is for another day.
Should we skip z-item for now, to avoid confusion and a very likely IndexError
?
from mikeio.
Related Issues (20)
- Inconsistent default spatial plots
- Dfsu3D - vertical max, mean, and min
- Writing a Dfs2 file from python does not retain the x and y coordinates HOT 6
- small inconcistency in time dimension for time-invariant data arrays? HOT 6
- matplotlib should be optional HOT 1
- Extracting data from a large .dfs2 file HOT 4
- When trying to append multiple non-equidistant DFS0 following error message pops up HOT 2
- Appending data to a DataArray in Dfs2 file HOT 2
- Replace legacy interp1d with np.interp
- Dfs2 - static items (bathymetry) HOT 6
- Pass kwargs to plot.mesh HOT 2
- Error in executing code for building documentation not reported as a failing step in Action
- Drop support for 3.8
- Point incorrectly considered outside domain HOT 2
- Page not found at https://dhi.github.io/mikeio/dfs1.html HOT 2
- pip install error HOT 4
- Dfsu read elements reordered
- extract_track bug HOT 8
- Error in DataArray.__init__ if data is the last column of a dataframe HOT 5
- DFSU.read() very slow on AMD CPU or linux HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mikeio.