c_dsgrid2s(3NCARG)

πŸ“¦ version 6.6.2, in epel 9, fedora 43, fedora 44

πŸ’– c_dsgrid2s β€” bestie, it's the main character of 2D gridding πŸ’–

okay so real talk, this is the primary single precision C entry for 2D gridding, and she's from the NCAR GRAPHICS family (3NCARG manual, iykyk). if you're in C and you want gridded data out of scattered points, this function is literally your girl. 🌸


✨ FUNCTION PROTOTYPE ✨

float *c_dsgrid2s(int, float [], float [], float [],
                  int, int, float [], float [], int *);

she takes nine args and hands you back a float *. no cap. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

float *c_dsgrid2s(int n, float x[], float y[], float z[],
                  int nx, int ny, float xo[], float yo[], int *ier);

like… that's the whole vibe. n, x, y, z, nx, ny, xo, yo, ier. periodt. πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

okay so here's the tea on every single argument, and I mean every one, no skipping:

  • n β€” the number of input data points you're bringing to the party. πŸ“
  • x β€” an array holding the X coordinates of your input data points.
  • y β€” an array holding the Y coordinates of your input data points.
  • z β€” an array of size n with the functional values of the input data points. so like, z[m] is the value of the input function at coordinate (x[m],y[m]), for 0 <= m < n. got it? got it. πŸ’œ
  • nx β€” the number of X values in the output grid. that's how many columns of glow-up you're getting.
  • ny β€” the number of Y values in the output grid. the rows, bestie.
  • xo β€” an array of size nx with the X coordinates of the output data grid. 🫢 the values in xo must be increasing, but they do NOT need to be equally spaced. she's flexible like that.
  • yo β€” an array of size ny with the y coordinates of the output data grid. same rules: the values in yo must be increasing, but need not be equally spaced. ✨
  • ier β€” the error return value. if *ier comes back as 0, then no errors were detected, slay. if *ier is non-zero, then go read the man page for dsgrid_errors. don't ignore her, she's telling you something. 😭

πŸ”₯ USAGE πŸ”₯

so c_dsgrid2s returns a pointer to a linear array of data that is the interpolated grid, stored in row-major order. iconic behaviour honestly.

like, if out is declared as

float *out;

and we set:

out = c_dsgrid2s(n, x, y, z, nx, ny, xo, yo, ier);

then out[i*ny+j] is the interpolated function value at coordinate point (xo[i],yo[j]) for 0 <= i < nx and 0 <= j < ny. that's the indexing, memorize it, it WILL come up. πŸ’€

and the space for out? allocated internal to c_dsgrid2s and it's nx*ny floats in size. so don't go freeing it yourself unless you know what you're doing, bestie. πŸ™ˆ


🌈 ACCESS 🌈

to use c_dsgrid2s, load the NCAR Graphics library ngmath. that's it, that's the whole requirement. πŸ’«


⭐ SEE ALSO ⭐

go read these too, they're all in the group chat:

  • dsgrid
  • dsgrid_params
  • c_dsseti
  • c_dsgeti
  • c_dssetr
  • c_dsgetr
  • c_dssetc
  • c_dsgetc

and if you want the full lore, complete documentation for Dsgrid is available at URL http://ngwww.ucar.edu/ngdoc/ng/ngmath/dsgrid/dshome.html 🧚


Copyright (C) 2000 University Corporation for Atmospheric Research

The use of this Software is governed by a License Agreement.

fr fr, read the license, don't be that person. πŸ’…

and that's the whole page, bestie!! this came out of the UNIX manual, dated September 1997-1998 β€” yeah she's a vintage icon, an elder stateswoman of gridding, and she still ate. mwah. πŸŽ€πŸ’–βœ¨πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from