Giter VIP home page Giter VIP logo

Comments (4)

ecomodeller avatar ecomodeller commented on September 17, 2024

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.

ecomodeller avatar ecomodeller commented on September 17, 2024
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.

jsmariegaard avatar jsmariegaard commented on September 17, 2024

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.

ecomodeller avatar ecomodeller commented on September 17, 2024

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)

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.