funimagerowput(3)

🌸 NAME 🌸

funimagerowput β€” bestie, it puts row(s) of an image πŸ’–

Okay so real quick before we get into it: this is from the SAORD Documentation set, it lives in manual section 3 as funimagerowput(3), and it's lowkey the row-writing counterpart to FunImageRowGet(). Let's go 🫢


✨ SYNOPSIS ✨

#include <funtools.h>

void *FunImageRowPut(Fun fun, void *buf, int rstart, int rstop,
                     int dim1, int dim2, int bitpix, char *plist)

πŸŽ€ DESCRIPTION πŸŽ€

So the FunImageRowPut() routine writes one or more image rows to the FITS image file you specified. It's giving "here's a row, pls put it in the image" and honestly? Iconic.

  • The first argument is the Funtools handle that FunOpen() gave you back. That's your fun.
  • The second argument, buf, is a pointer to the row data buffer. That's where your pixels are chillin'.
  • The third and fourth arguments are rstart and rstop β€” the starting and ending rows to write. Valid row values range from 1 to dim2, like, row is one-valued. Not zero-valued. One. Periodt πŸ’…

Then the dim1 and dim2 arguments that follow specify the dimensions, where dim1 corresponds to naxis1 and dim2 corresponds to naxis2. (Yes bestie, naxis1 and naxis2, exactly those. Don't come for me, that's just how FITS is set up 🌈)

The bitpix argument is the data type of the image, and it can have the following FITS-standard values:

  • 8 β€” unsigned char
  • 16 β€” short
  • 32 β€” int
  • -32 β€” float
  • -64 β€” double

🌟 for example 🌟

Not me giving you a whole example, but here you go, it's genuinely useful:

double *drow;
Fun fun, fun2;
... open files ...
/* get section dimensions */
FunInfoGet(fun, FUN_SECT_DIM1, &dim1, FUN_SECT_DIM2, &dim2, 0);
/* allocate one line's worth */
drow = malloc(dim1*sizeof(double));
/* retrieve and process each input row (starting at 1) */
for(i=1; i <= dim2; i++){
  if( !FunImageRowGet(fun, drow, i, i, "bitpix=-64") )
    gerror(stderr, "can't FunImageRowGet: %d %s\n", i, iname);
  ... process drow ...
  if( !FunImageRowPut(fun2, drow, i, i, 64, NULL) )
    gerror(stderr, "can't FunImageRowPut: %d %s\n", i, oname);
}
...

πŸ’« the whole endian situation πŸ’«

The data are assumed to be in the native machine format and will automatically be swapped to big-endian FITS format if necessary. The way that it just handles that for you?? Obsessed. 🧚

This behavior can be over-ridden with the convert=[trueβŽͺfalse] keyword in the plist param list string. That's your override lever, bestie, use it wisely.


🚨 when you're done, flush! 🚨

When you are finished writing the image, you should call FunFlush() to write out the FITS image padding. Like, actually do it. πŸŽ€

However, this is not necessary if you subsequently call FunClose() without doing any other I/O to the FITS file. So if FunClose() is your next move and nothing else touches that file, you're fine β€” no cap.

πŸ¦‹ SEE ALSO πŸ¦‹

See funtools(7) for a list of Funtools help pages. Go read it, it's the whole friend group πŸ‘‘


And that's the page, bestie πŸ’œ This was version 1.4.5, dated April 14, 2011, from the SAORD Documentation crew β€” and yes, funimagerowput(3) is the manual page you just read. Slay, go write some rows ✨