Giter Site home page Giter Site logo

New API about h5netcdf HOT 5 CLOSED

h5netcdf avatar h5netcdf commented on May 18, 2024
New API

from h5netcdf.

Comments (5)

mangecoeur avatar mangecoeur commented on May 18, 2024
  1. IMHO, use dimensions. It's much clearer ;)
  2. keep create_dimensions. Best not to second-guess someone's use case, maybe someone wants to create a dimension without immediately adding a variable. Or someone wants to create a dimension that's re-used by several variables.

And an idea: Make it possible to dump the structure of file as a descriptive dict. Makes exploring an existing file easier. Something like:

{
    'distance': {
             'dimension': 'x',
             'units': 'm',
             'data': <array float[100]>
            },
   'time' {
             'dimension': 't',
             'units': 'm2',
             'data':<array datetime[100]>
   },
   'readings' {
             'dimension': ('x', 't'),
             'units': 'W',
             'data': <array float[100, 100]>
   }
}

Building on that, it might be nice to make it possible to create a file based on a spec described in a dict. This allows you to use a declarative style rather than an imperative one - rather than a series of commands to create your files, you describe what data you want and the build a file from the spec.

x_data = ...
times = ...
readings = ...

spec = {
    'distance': {
             'dimension': 'x',
             'units': 'm',
             'data': x_data
            },
   'time' {
             'dimension': 't',
             'units': 'm2',
             'data': times
   },
   'readings' {
             'dimension': ('x', 't'),
             'units': 'W',
             'data': readings
   }
}

hfile = h5netcdf.create_file(spec)

You could even enable a full round-trip, something like:

spec = h5netcdf.describe(file)

# Optionally manipulate the spec here, e.g. change the data

new_file = h5netcdf.create_file(spec)

Though less sure about this, might need to think about lazy-loading data and things like that...

from h5netcdf.

shoyer avatar shoyer commented on May 18, 2024

@mangecoeur To clarify, I was considering dropping create_dimension in favor of using dimensions with the dictionary-like interface for assignment.

from h5netcdf.

mangecoeur avatar mangecoeur commented on May 18, 2024

@shoyer ah right, yeah that makes sense

from h5netcdf.

shoyer avatar shoyer commented on May 18, 2024

I like the idea of declarative dataset specifications, but I'm not sure it's a good fit for this package. It could exist easily as an independent project that uses h5netcdf (and/or netCDF4/scipy.io.netcdf) as a library. In fact, I would encourage you to go out and build that project yourself :).

from h5netcdf.

kmuehlbauer avatar kmuehlbauer commented on May 18, 2024

@shoyer Can this be closed? We might think to compile everything into some documentation (to not overcrowd the README).

from h5netcdf.

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.