Coder Social home page Coder Social logo

dataset1d's Introduction

dataset1d

A handy in-memory netCDF Dataset for fortran, for 1-D arrays only (so making it more similar to a pandas DataFrame).

Useful commands:

use dataset, only: Dataset
type(Dataset) :: ds

Allocate memory for an underlying ds%values(:,:) pointer

call ds%alloc(nvar=3, nlen=5)

Define variable names (default to "v1", "v2"...)

ds%names(1) = "x"
ds%names(2) = "v1"
ds%names(3) = "v2"

Can set and get variables by name

call ds%setitem('x', [1.d0, 2.d0, 3.d0, 4.d0, 5.d0])
call ds%setitem('v1',ds%getitem('x')**2)

Or directly access the underlying values attribute, using the iname method to obtain the integer position index corresponding to a variable name.

call ds%values(:, ds%iname('v2')) = ds%values(:, ds%iname('x'))+0.d0

Includes pretty printing or arrays a la pandas' DataFrame

call ds%print()

Dataset(nvar=3, nlen=5)
          x          v1          v2 
  1  1.0000E+00 1.0000E+00 1.0000E+00
  2  2.0000E+00 4.0000E+00 2.0000E+00
  3  3.0000E+00 9.0000E+00 3.0000E+00
  4  4.0000E+00 1.6000E+01 4.0000E+00
  5  5.0000E+00 2.5000E+01 5.0000E+00

As well as netCDF I/O based on Alex Robinson's ncio module

call ds%write_nc('test.nc')
call ds%read_nc('test.nc')

And some basic functionality such as interpolation

call ds%set_index(ds%iname("x"))  ! set the x variable as index
ds2 = ds%interp([1.d0, 1.5d0,4.d0]) ! interpolate on new axis

Dataset(nvar=3, nlen=3)
          x          v1          v2 
  1  1.0000E+00 1.0000E+00 1.0000E+00
  2  1.5000E+00 2.5000E+00 1.5000E+00
  3  4.0000E+00 1.6000E+01 4.0000E+00

It is also possible to use methods such as slice, compress, take, to index the dataset as a whole along the first (index) or second (variable) dimension.

More functions such as align or reidnex could be built in. The current limitation is that only a single type can be represented in the DataFrame (currently double precision), but this has the advantage of being efficient. A more, complex, mixed-type and mixed-dimensions dataset will be presented in another project.

dataset1d's People

Contributors

perrette avatar

Watchers

 avatar

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.