cfitsio
3390
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <time.h>
#include "fitsio2.h"
Macros | |
#define | NULL_VALUE -2147483647 /* value used to represent undefined pixels */ |
#define | ZERO_VALUE -2147483646 /* value used to represent zero-valued pixels */ |
#define | NINT(x) ((x >= 0.) ? (int) (x + 0.5) : (int) (x - 0.5)) |
#define | NO_QUANTIZE 9999 |
Functions | |
int | imcomp_write_nocompress_tile (fitsfile *outfptr, long row, int datatype, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int *status) |
int | imcomp_convert_tile_tshort (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, double actual_bzero, int *intlength, int *status) |
int | imcomp_convert_tile_tushort (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *status) |
int | imcomp_convert_tile_tint (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *status) |
int | imcomp_convert_tile_tuint (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *status) |
int | imcomp_convert_tile_tbyte (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *status) |
int | imcomp_convert_tile_tsbyte (fitsfile *outfptr, void *tiledata, long tilelen, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *status) |
int | imcomp_convert_tile_tfloat (fitsfile *outfptr, long row, void *tiledata, long tilelen, long tilenx, long tileny, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *flag, double *bscale, double *bzero, int *status) |
int | imcomp_convert_tile_tdouble (fitsfile *outfptr, long row, void *tiledata, long tilelen, long tilenx, long tileny, int nullcheck, void *nullflagval, int nullval, int zbitpix, double scale, double zero, int *intlength, int *flag, double *bscale, double *bzero, int *status) |
int | fits_init_randoms (void) |
void | bz_internal_error (int errcode) |
int | fits_set_compression_type (fitsfile *fptr, int ctype, int *status) |
int | fits_set_tile_dim (fitsfile *fptr, int ndim, long *dims, int *status) |
int | fits_set_quantize_level (fitsfile *fptr, float qlevel, int *status) |
int | fits_set_quantize_method (fitsfile *fptr, int method, int *status) |
int | fits_set_quantize_dither (fitsfile *fptr, int dither, int *status) |
int | fits_set_dither_seed (fitsfile *fptr, int seed, int *status) |
int | fits_set_dither_offset (fitsfile *fptr, int offset, int *status) |
int | fits_set_noise_bits (fitsfile *fptr, int noisebits, int *status) |
int | fits_set_hcomp_scale (fitsfile *fptr, float scale, int *status) |
int | fits_set_hcomp_smooth (fitsfile *fptr, int smooth, int *status) |
int | fits_set_lossy_int (fitsfile *fptr, int lossy_int, int *status) |
int | fits_set_huge_hdu (fitsfile *fptr, int huge, int *status) |
int | fits_get_compression_type (fitsfile *fptr, int *ctype, int *status) |
int | fits_get_tile_dim (fitsfile *fptr, int ndim, long *dims, int *status) |
int | fits_unset_compression_param (fitsfile *fptr, int *status) |
int | fits_unset_compression_request (fitsfile *fptr, int *status) |
int | fits_set_compression_pref (fitsfile *infptr, fitsfile *outfptr, int *status) |
int | fits_get_noise_bits (fitsfile *fptr, int *noisebits, int *status) |
int | fits_get_quantize_level (fitsfile *fptr, float *qlevel, int *status) |
int | fits_get_dither_seed (fitsfile *fptr, int *offset, int *status) |
int | fits_get_hcomp_scale (fitsfile *fptr, float *scale, int *status) |
int | fits_get_hcomp_smooth (fitsfile *fptr, int *smooth, int *status) |
int | fits_img_compress (fitsfile *infptr, fitsfile *outfptr, int *status) |
int | imcomp_init_table (fitsfile *outfptr, int inbitpix, int naxis, long *naxes, int writebitpix, int *status) |
int | imcomp_calc_max_elem (int comptype, int nx, int zbitpix, int blocksize) |
int | imcomp_compress_image (fitsfile *infptr, fitsfile *outfptr, int *status) |
int | imcomp_compress_tile (fitsfile *outfptr, long row, int datatype, void *tiledata, long tilelen, long tilenx, long tileny, int nullcheck, void *nullflagval, int *status) |
int | imcomp_nullscale (int *idata, long tilelen, int nullflagval, int nullval, double scale, double zero, int *status) |
int | imcomp_nullvalues (int *idata, long tilelen, int nullflagval, int nullval, int *status) |
int | imcomp_scalevalues (int *idata, long tilelen, double scale, double zero, int *status) |
int | imcomp_nullscalei2 (short *idata, long tilelen, short nullflagval, short nullval, double scale, double zero, int *status) |
int | imcomp_nullvaluesi2 (short *idata, long tilelen, short nullflagval, short nullval, int *status) |
int | imcomp_scalevaluesi2 (short *idata, long tilelen, double scale, double zero, int *status) |
int | imcomp_nullfloats (float *fdata, long tilelen, int *idata, int nullcheck, float nullflagval, int nullval, int *status) |
int | imcomp_nullscalefloats (float *fdata, long tilelen, int *idata, double scale, double zero, int nullcheck, float nullflagval, int nullval, int *status) |
int | imcomp_nulldoubles (double *fdata, long tilelen, int *idata, int nullcheck, double nullflagval, int nullval, int *status) |
int | imcomp_nullscaledoubles (double *fdata, long tilelen, int *idata, double scale, double zero, int nullcheck, double nullflagval, int nullval, int *status) |
int | fits_write_compressed_img (fitsfile *fptr, int datatype, long *infpixel, long *inlpixel, int nullcheck, void *array, void *nullval, int *status) |
int | fits_write_compressed_pixels (fitsfile *fptr, int datatype, LONGLONG fpixel, LONGLONG npixel, int nullcheck, void *array, void *nullval, int *status) |
int | fits_write_compressed_img_plane (fitsfile *fptr, int datatype, int bytesperpixel, long nplane, long *firstcoord, long *lastcoord, long *naxes, int nullcheck, void *array, void *nullval, long *nread, int *status) |
int | fits_img_decompress (fitsfile *infptr, fitsfile *outfptr, int *status) |
int | fits_decompress_img (fitsfile *infptr, fitsfile *outfptr, int *status) |
int | fits_img_decompress_header (fitsfile *infptr, fitsfile *outfptr, int *status) |
int | fits_read_compressed_img (fitsfile *fptr, int datatype, LONGLONG *infpixel, LONGLONG *inlpixel, long *ininc, int nullcheck, void *nullval, void *array, char *nullarray, int *anynul, int *status) |
int | fits_read_compressed_pixels (fitsfile *fptr, int datatype, LONGLONG fpixel, LONGLONG npixel, int nullcheck, void *nullval, void *array, char *nullarray, int *anynul, int *status) |
int | fits_read_compressed_img_plane (fitsfile *fptr, int datatype, int bytesperpixel, long nplane, LONGLONG *firstcoord, LONGLONG *lastcoord, long *inc, long *naxes, int nullcheck, void *nullval, void *array, char *nullarray, int *anynul, long *nread, int *status) |
int | imcomp_get_compressed_image_par (fitsfile *infptr, int *status) |
int | imcomp_copy_imheader (fitsfile *infptr, fitsfile *outfptr, int *status) |
int | imcomp_copy_img2comp (fitsfile *infptr, fitsfile *outfptr, int *status) |
int | imcomp_copy_comp2img (fitsfile *infptr, fitsfile *outfptr, int norec, int *status) |
int | imcomp_copy_prime2img (fitsfile *infptr, fitsfile *outfptr, int *status) |
int | imcomp_decompress_tile (fitsfile *infptr, int nrow, int tilelen, int datatype, int nullcheck, void *nulval, void *buffer, char *bnullarray, int *anynul, int *status) |
int | imcomp_test_overlap (int ndim, long *tfpixel, long *tlpixel, long *fpixel, long *lpixel, long *ininc, int *status) |
int | imcomp_copy_overlap (char *tile, int pixlen, int ndim, long *tfpixel, long *tlpixel, char *bnullarray, char *image, long *fpixel, long *lpixel, long *ininc, int nullcheck, char *nullarray, int *status) |
int | imcomp_merge_overlap (char *tile, int pixlen, int ndim, long *tfpixel, long *tlpixel, char *bnullarray, char *image, long *fpixel, long *lpixel, int nullcheck, int *status) |
int | fits_compress_table (fitsfile *infptr, fitsfile *outfptr, int *status) |
int | fits_uncompress_table (fitsfile *infptr, fitsfile *outfptr, int *status) |
Variables | |
char | results [999][30] |
float * | fits_rand_value = 0 |
#define NINT | ( | x | ) | ((x >= 0.) ? (int) (x + 0.5) : (int) (x - 0.5)) |
#define NO_QUANTIZE 9999 |
special quantize level value indicates that floating point image pixels should not be quantized and instead losslessly compressed (with GZIP)
#define NULL_VALUE -2147483647 /* value used to represent undefined pixels */ |
#define ZERO_VALUE -2147483646 /* value used to represent zero-valued pixels */ |
void bz_internal_error | ( | int | errcode | ) |
external function declared by the bzip2 code in bzlib_private.h
Compress the input FITS Binary Table.
First divide the table into equal sized chunks (analogous to image tiles) where all the contain the same number of rows (except perhaps for the last chunk which may contain fewer rows). The chunks should not be too large to copy into memory (currently, about 100 MB max seems a reasonable size).
Then, on a chunk by piece basis, do the following:
THIS IS AN OBSOLETE ROUTINE. USE fits_img_decompress instead!!!
This routine decompresses the whole image and writes it to the output file.
[in] | infptr | image (bintable) to uncompress |
[in] | outfptr | empty HDU for output uncompressed image |
[in,out] | status | error status |
int fits_get_compression_type | ( | fitsfile * | fptr, |
int * | ctype, | ||
int * | status | ||
) |
This routine returns the image compression algorithm that should be used when writing a FITS image. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.
[in] | fptr | FITS file pointer |
[in] | ctype | image compression type code; allowed values: RICE_1, GZIP_1, GZIP_2, PLIO_1, HCOMPRESS_1, BZIP2_1 |
[in,out] | status | error status |
int fits_get_dither_seed | ( | fitsfile * | fptr, |
int * | offset, | ||
int * | status | ||
) |
This routine returns the value of the dithering offset parameter that is used when compressing floating point images. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.
[in] | fptr | FITS file pointer |
[in] | offset | dithering offset parameter value |
[in,out] | status | error status |
int fits_get_hcomp_scale | ( | fitsfile * | fptr, |
float * | scale, | ||
int * | status | ||
) |
int fits_get_hcomp_smooth | ( | fitsfile * | fptr, |
int * | smooth, | ||
int * | status | ||
) |
[in] | fptr | FITS file pointer |
[in] | smooth | Hcompress smooth parameter value |
[in,out] | status | error status |
int fits_get_noise_bits | ( | fitsfile * | fptr, |
int * | noisebits, | ||
int * | status | ||
) |
This routine returns the value of the noice_bits parameter that should be used when compressing floating point images. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.
This result is rounded to the nearest integer.
[in] | fptr | FITS file pointer |
[in] | noisebits | noise_bits parameter value (default = 4). noise bits = natural logarithm (quantize level) / natural log (2). |
[in,out] | status | error status |
int fits_get_quantize_level | ( | fitsfile * | fptr, |
float * | qlevel, | ||
int * | status | ||
) |
This routine returns the value of the noice_bits parameter that should be used when compressing floating point images. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.
[in] | fptr | FITS file pointer |
[in] | qlevel | quantize level parameter value |
[in,out] | status | error status |
int fits_get_tile_dim | ( | fitsfile * | fptr, |
int | ndim, | ||
long * | dims, | ||
int * | status | ||
) |
This routine returns the size (dimension) of the image compression tiles that should be used when writing a FITS image. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.
[in] | fptr | FITS file pointer |
[in] | ndim | number of dimensions in the compressed image |
[in] | dims | size of image compression tile in each dimension default tile size = (NAXIS1, 1, 1, ...) |
[in,out] | status | error status |
This routine initializes the output table, copies all the keywords, and loops through the input image, compressing the data and writing the compressed tiles to the output table.
This is a high level routine that is called by the fpack and funpack FITS compression utilities.
[in] | infptr | pointer to image to be compressed |
[in] | outfptr | empty HDU for output compressed image |
[in,out] | status | error status |
This routine decompresses the whole image and writes it to the output file.
[in] | infptr | image (bintable) to uncompress |
[in] | outfptr | empty HDU for output uncompressed image |
[in,out] | status | error status |
This routine reads the header of the input tile compressed image and converts it to that of a standard uncompress FITS image.
[in] | infptr | image (bintable) to uncompress |
[in] | outfptr | empty HDU for output uncompressed image |
[in,out] | status | error status |
int fits_init_randoms | ( | void | ) |
initialize an array of random numbers
int fits_read_compressed_img | ( | fitsfile * | fptr, |
int | datatype, | ||
LONGLONG * | infpixel, | ||
LONGLONG * | inlpixel, | ||
long * | ininc, | ||
int | nullcheck, | ||
void * | nullval, | ||
void * | array, | ||
char * | nullarray, | ||
int * | anynul, | ||
int * | status | ||
) |
Read a section of a compressed image; Note: lpixel may be larger than the size of the uncompressed image. Only the pixels within the image will be returned.
[in] | fptr | FITS file pointer |
[in] | datatype | datatype of the array to be returned |
[in] | infpixel | 'bottom left corner' of the subsection |
[in] | inlpixel | 'top right corner' of the subsection |
[in] | ininc | increment to be applied in each dimension |
[in] | nullcheck | 0 for no null checking 1: set undefined pixels = nullval 2: set nullarray=1 for undefined pixels |
[in] | nullval | value for undefined pixels |
[out] | array | array of values that are returned |
[out] | nullarray | array of flags = 1 if nullcheck = 2 |
[out] | anynul | set to 1 if any values are null; else 0 |
[in,out] | status | error status |
int fits_read_compressed_img_plane | ( | fitsfile * | fptr, |
int | datatype, | ||
int | bytesperpixel, | ||
long | nplane, | ||
LONGLONG * | firstcoord, | ||
LONGLONG * | lastcoord, | ||
long * | inc, | ||
long * | naxes, | ||
int | nullcheck, | ||
void * | nullval, | ||
void * | array, | ||
char * | nullarray, | ||
int * | anynul, | ||
long * | nread, | ||
int * | status | ||
) |
int fits_read_compressed_pixels | ( | fitsfile * | fptr, |
int | datatype, | ||
LONGLONG | fpixel, | ||
LONGLONG | npixel, | ||
int | nullcheck, | ||
void * | nullval, | ||
void * | array, | ||
char * | nullarray, | ||
int * | anynul, | ||
int * | status | ||
) |
Read a consecutive set of pixels from a compressed image. This routine interpretes the n-dimensional image as a long one-dimensional array. This is actually a rather inconvenient way to read compressed images in general, and could be rather inefficient if the requested pixels to be read are located in many different image compression tiles.
The general strategy used here is to read the requested pixels in blocks that correspond to rectangular image sections.
[in] | fptr | FITS file pointer |
Set the preference for various compression options, based on keywords in the input file that provide guidance about how the HDU should be compressed when written to the output file.
int fits_set_compression_type | ( | fitsfile * | fptr, |
int | ctype, | ||
int * | status | ||
) |
This routine specifies the image compression algorithm that should be used when writing a FITS image. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.
[in] | fptr | FITS file pointer |
[in] | ctype | mage compression type code; allowed values: RICE_1, GZIP_1, GZIP_2, PLIO_1, HCOMPRESS_1, BZIP2_1, and NOCOMPRESS |
[in,out] | status) | error status |
int fits_set_dither_offset | ( | fitsfile * | fptr, |
int | offset, | ||
int * | status | ||
) |
The name of this routine has changed. This is kept just for backwards compatibility with any software that calls the old name
[in] | fptr | FITS file pointer |
[in] | offset | random dithering offset value (1 to 10000) |
[in,out] | status | error status |
int fits_set_dither_seed | ( | fitsfile * | fptr, |
int | seed, | ||
int * | status | ||
) |
This routine specifies the value of the offset that should be applied when calculating the random dithering when quantizing floating point iamges. A random offset should be applied to each image to avoid quantization effects when taking the difference of 2 images, or co-adding a set of images. Without this random offset, the corresponding pixel in every image will have exactly the same dithering.
offset = 0 means use the default random dithering based on system time offset = negative means randomly chose dithering based on 1st tile checksum offset = [1 - 10000] means use that particular dithering pattern
[in] | fptr | FITS file pointer |
[in] | seed | random dithering seed value (1 to 10000) |
[in,out] | status | error status |
int fits_set_hcomp_scale | ( | fitsfile * | fptr, |
float | scale, | ||
int * | status | ||
) |
This routine specifies the value of the hcompress scale parameter.
[in] | fptr | FITS file pointer |
[in] | scale | hcompress scale parameter value (default = 0.) |
[in,out] | status | error status |
int fits_set_hcomp_smooth | ( | fitsfile * | fptr, |
int | smooth, | ||
int * | status | ||
) |
This routine specifies the value of the hcompress scale parameter.
[in] | fptr | FITS file pointer |
[in] | smooth | hcompress smooth parameter value if scale > 1 and smooth != 0, then the image will be smoothed when it is decompressed to remove some of the 'blockiness' in the image produced by the lossy compression |
[in,out] | status | error status |
int fits_set_huge_hdu | ( | fitsfile * | fptr, |
int | huge, | ||
int * | status | ||
) |
This routine specifies whether the HDU that is being compressed is so large (i.e., > 4 GB) that the 'Q' type variable length array columns should be used rather than the normal 'P' type. The allows the heap pointers to be stored as 64-bit quantities, rather than just 32-bits.
[in] | fptr | FITS file pointer |
[in] | huge | True (!= 0) or False (0) |
[in,out] | status | error status |
int fits_set_lossy_int | ( | fitsfile * | fptr, |
int | lossy_int, | ||
int * | status | ||
) |
This routine specifies whether images with integer pixel values should quantized and compressed the same way float images are compressed. The default is to not do this, and instead apply a lossless compression algorithm to integer images.
[in] | fptr | FITS file pointer |
[in] | lossy_int | True (!= 0) or False (0) |
[in,out] | status | error status |
int fits_set_noise_bits | ( | fitsfile * | fptr, |
int | noisebits, | ||
int * | status | ||
) |
THIS ROUTINE IS PROVIDED ONLY FOR BACKWARDS COMPATIBILITY; ALL NEW SOFTWARE SHOULD CALL fits_set_quantize_level INSTEAD
This routine specifies the value of the noice_bits parameter that should be used when compressing floating point images. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.
[in] | fptr | FITS file pointer |
[in] | noisebits | noise_bits parameter value (default = 4) |
[in,out] | status | error status |
int fits_set_quantize_dither | ( | fitsfile * | fptr, |
int | dither, | ||
int * | status | ||
) |
the name of this routine has changed. This is kept here only for backwards compatibility for any software that may be calling the old routine.
[in] | fptr | FITS file pointer |
[in] | dither | dither type |
[in,out] | status | error status |
int fits_set_quantize_level | ( | fitsfile * | fptr, |
float | qlevel, | ||
int * | status | ||
) |
This routine specifies the value of the quantization level, q, that should be used when compressing floating point images. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.
[in] | fptr | FITS file pointer |
[in] | qlevel | floating point quantization level |
[in,out] | status | error status |
int fits_set_quantize_method | ( | fitsfile * | fptr, |
int | method, | ||
int * | status | ||
) |
This routine specifies what type of dithering (randomization) should be performed when quantizing floating point images to integer prior to compression. A value of -1 means do no dithering. A value of 0 means use the default SUBTRACTIVE_DITHER_1 (which is equivalent to dither = 1). A value of 2 means use SUBTRACTIVE_DITHER_2.
[in] | fptr | FITS file pointer |
[in] | method | quantization method |
[in,out] | status | error status |
int fits_set_tile_dim | ( | fitsfile * | fptr, |
int | ndim, | ||
long * | dims, | ||
int * | status | ||
) |
This routine specifies the size (dimension) of the image compression tiles that should be used when writing a FITS image. The image is divided into tiles, and each tile is compressed and stored in a row of at variable length binary table column.
[in] | fptr | FITS file pointer |
[in] | ndim | number of dimensions in the compressed image |
[in] | dims | size of image compression tile in each dimension default tile size = (NAXIS1, 1, 1, ...) |
[in,out] | status | error status |
Uncompress the table that was compressed with fits_compress_table
int fits_unset_compression_param | ( | fitsfile * | fptr, |
int * | status | ||
) |
int fits_unset_compression_request | ( | fitsfile * | fptr, |
int * | status | ||
) |
int fits_write_compressed_img | ( | fitsfile * | fptr, |
int | datatype, | ||
long * | infpixel, | ||
long * | inlpixel, | ||
int | nullcheck, | ||
void * | array, | ||
void * | nullval, | ||
int * | status | ||
) |
Write a section of a compressed image.
[in] | fptr | FITS file pointer |
[in] | datatype | datatype of the array to be written |
[in] | infpixel | 'bottom left corner' of the subsection |
[in] | inlpixel | 'top right corner' of the subsection |
[in] | int | nullcheck 0 for no null checking 1: pixels that are = nullval will be written with the FITS null pixel value (floating point arrays only) |
[in] | array | array of values to be written |
[in] | nullval | undefined pixel value |
[in,out] | status | error status |
int fits_write_compressed_img_plane | ( | fitsfile * | fptr, |
int | datatype, | ||
int | bytesperpixel, | ||
long | nplane, | ||
long * | firstcoord, | ||
long * | lastcoord, | ||
long * | naxes, | ||
int | nullcheck, | ||
void * | array, | ||
void * | nullval, | ||
long * | nread, | ||
int * | status | ||
) |
in general we have to write the first partial row of the image, followed by the middle complete rows, followed by the last partial row of the image. If the first or last rows are complete, then write them at the same time as all the middle rows.
[in] | fptr | FITS file |
[in] | datatype | datatype of the array to be written |
[in] | bytesperpixel | number of bytes per pixel in array |
[in] | nplane | which plane of the cube to write |
[in] | firstcoord | of first pixel to write |
[in] | lastcoord | of last pixel to write |
[in] | naxes | of each image dimension |
[in] | nullcheck | 0 for no null checking 1: pixels that are = nullval will be written with the FITS null pixel value (floating point arrays only) |
[in] | array | array of values that are written |
[in] | nullval | value for undefined pixels |
[out] | nread | total number of pixels written |
[in,out] | status | error status |
int fits_write_compressed_pixels | ( | fitsfile * | fptr, |
int | datatype, | ||
LONGLONG | fpixel, | ||
LONGLONG | npixel, | ||
int | nullcheck, | ||
void * | array, | ||
void * | nullval, | ||
int * | status | ||
) |
Write a consecutive set of pixels to a compressed image. This routine interpretes the n-dimensional image as a long one-dimensional array. This is actually a rather inconvenient way to write compressed images in general, and could be rather inefficient if the requested pixels to be written are located in many different image compression tiles.
The general strategy used here is to write the requested pixels in blocks that correspond to rectangular image sections.
[in] | fptr | FITS file pointer |
[in] | datatype | datatype of the array to be written |
[in] | fpixel | 'first pixel to write |
[in] | npixel | number of pixels to write |
[in] | nullcheck | 0 for no null checking 1: pixels that are = nullval will be written with the FITS null pixel value (floating point arrays only) |
[in] | array | array of values to write |
[in] | nullval | value used to represent undefined pixels |
[in,out] | status | error status |
int imcomp_calc_max_elem | ( | int | comptype, |
int | nx, | ||
int | zbitpix, | ||
int | blocksize | ||
) |
This function returns the maximum number of bytes in a compressed image line.
[in] | nx | maximum number of pixels in a tile |
[in] | blocksize | is only relevant for RICE compression |
This routine does the following:
writes the compressed byte stream to the output FITS file
int imcomp_compress_tile | ( | fitsfile * | outfptr, |
long | row, | ||
int | datatype, | ||
void * | tiledata, | ||
long | tilelen, | ||
long | tilenx, | ||
long | tileny, | ||
int | nullcheck, | ||
void * | nullflagval, | ||
int * | status | ||
) |
This is the main compression routine.
This routine does the following to the input tile of pixels:
If the tile cannot be quantized than the raw float or double values are losslessly compressed with gzip and then written to the output table.
This input array may be modified by this routine. If the array is of type TINT or TFLOAT, and the compression type is HCOMPRESS, then it must have been allocated to be twice as large (8 bytes per pixel) to provide scratch space.
Note that this routine does not fully support the implicit datatype conversion that is supported when writing to normal FITS images. The datatype of the input array must have the same datatype (either signed or unsigned) as the output (compressed) FITS image in some cases.
row | tile number = row in the binary table that holds the compressed data |
int imcomp_convert_tile_tbyte | ( | fitsfile * | outfptr, |
void * | tiledata, | ||
long | tilelen, | ||
int | nullcheck, | ||
void * | nullflagval, | ||
int | nullval, | ||
int | zbitpix, | ||
double | scale, | ||
double | zero, | ||
int * | intlength, | ||
int * | status | ||
) |
Prepare the input tile array of pixels for compression.
Convert input float tile array in place to or byte ints for *If convert or byte ints and do null value substitution *Note that the calling routine must have allocated the input array big enough *to be able to do this *int imcomp_convert_tile_tdouble | ( | fitsfile * | outfptr, |
long | row, | ||
void * | tiledata, | ||
long | tilelen, | ||
long | tilenx, | ||
long | tileny, | ||
int | nullcheck, | ||
void * | nullflagval, | ||
int | nullval, | ||
int | zbitpix, | ||
double | scale, | ||
double | zero, | ||
int * | intlength, | ||
int * | flag, | ||
double * | bscale, | ||
double * | bzero, | ||
int * | status | ||
) |
Prepare the input tile array of pixels for compression.
Convert input integer *tile array in place to or byte ints for *If convert or byte ints and do null value substitution *Note that the calling routine must have allocated the input array big enough *to be able to do this *int imcomp_convert_tile_tfloat | ( | fitsfile * | outfptr, |
long | row, | ||
void * | tiledata, | ||
long | tilelen, | ||
long | tilenx, | ||
long | tileny, | ||
int | nullcheck, | ||
void * | nullflagval, | ||
int | nullval, | ||
int | zbitpix, | ||
double | scale, | ||
double | zero, | ||
int * | intlength, | ||
int * | flag, | ||
double * | bscale, | ||
double * | bzero, | ||
int * | status | ||
) |
Prepare the input tile array of pixels for compression.
int imcomp_convert_tile_tint | ( | fitsfile * | outfptr, |
void * | tiledata, | ||
long | tilelen, | ||
int | nullcheck, | ||
void * | nullflagval, | ||
int | nullval, | ||
int | zbitpix, | ||
double | scale, | ||
double | zero, | ||
int * | intlength, | ||
int * | status | ||
) |
Prepare the input tile array of pixels for compression. Convert input integer tile array in place to 4 or 8-byte ints for compression, If needed, do null value substitution.
Convert input unsigned integer *tile array in place to or byte ints for *If convert or byte ints and do null value substitution *Note that the calling routine must have allocated the input array big enough *to be able to do this *int imcomp_convert_tile_tsbyte | ( | fitsfile * | outfptr, |
void * | tiledata, | ||
long | tilelen, | ||
int | nullcheck, | ||
void * | nullflagval, | ||
int | nullval, | ||
int | zbitpix, | ||
double | scale, | ||
double | zero, | ||
int * | intlength, | ||
int * | status | ||
) |
Prepare the input tile array of pixels for compression.
int imcomp_convert_tile_tshort | ( | fitsfile * | outfptr, |
void * | tiledata, | ||
long | tilelen, | ||
int | nullcheck, | ||
void * | nullflagval, | ||
int | nullval, | ||
int | zbitpix, | ||
double | scale, | ||
double | zero, | ||
double | actual_bzero, | ||
int * | intlength, | ||
int * | status | ||
) |
Prepare the input tile array of pixels for compression. Convert input integer*2 tile array in place to 4 or 8-byte ints for compression, If needed, convert 4 or 8-byte ints and do null value substitution. Note that the calling routine must have allocated the input array big enough to be able to do this.
int imcomp_convert_tile_tuint | ( | fitsfile * | outfptr, |
void * | tiledata, | ||
long | tilelen, | ||
int | nullcheck, | ||
void * | nullflagval, | ||
int | nullval, | ||
int | zbitpix, | ||
double | scale, | ||
double | zero, | ||
int * | intlength, | ||
int * | status | ||
) |
Prepare the input tile array of pixels for compression. Convert input unsigned integer tile array in place to 4 or 8-byte ints for compression, If needed, do null value substitution.
int imcomp_convert_tile_tushort | ( | fitsfile * | outfptr, |
void * | tiledata, | ||
long | tilelen, | ||
int | nullcheck, | ||
void * | nullflagval, | ||
int | nullval, | ||
int | zbitpix, | ||
double | scale, | ||
double | zero, | ||
int * | intlength, | ||
int * | status | ||
) |
Prepare the input tile array of pixels for compression. Convert input unsigned integer*2 tile array in place to 4 or 8-byte ints for compression, If needed, convert 4 or 8-byte ints and do null value substitution. Note that the calling routine must have allocated the input array big enough to be able to do this.
int imcomp_copy_overlap | ( | char * | tile, |
int | pixlen, | ||
int | ndim, | ||
long * | tfpixel, | ||
long * | tlpixel, | ||
char * | bnullarray, | ||
char * | image, | ||
long * | fpixel, | ||
long * | lpixel, | ||
long * | ininc, | ||
int | nullcheck, | ||
char * | nullarray, | ||
int * | status | ||
) |
copy the intersecting pixels from a decompressed tile to the output image. Both the tile and the image must have the same number of dimensions.
[in] | tile | multi dimensional array of tile pixels |
[in] | pixlen | number of bytes in each tile or image pixel |
[in] | ndim | number of dimension in the tile and image |
[in] | tfpixel | first pixel number in each dim. of the tile |
[in] | tlpixel | last pixel number in each dim. of the tile |
[in] | bnullarray | array of null flags; used if nullcheck = 2 |
[out] | image | multi dimensional output image |
[in] | fpixel | first pixel number in each dim. of the image |
[in] | lpixel | last pixel number in each dim. of the image |
[in] | ininc | increment to be applied in each image dimen. |
[in] | nullcheck | 0, 1: do nothing; 2: set nullarray for nulls |
int imcomp_decompress_tile | ( | fitsfile * | infptr, |
int | nrow, | ||
int | tilelen, | ||
int | datatype, | ||
int | nullcheck, | ||
void * | nulval, | ||
void * | buffer, | ||
char * | bnullarray, | ||
int * | anynul, | ||
int * | status | ||
) |
This routine decompresses one tile of the image
[in] | nrow | row of table to read and uncompress |
[in] | tilelen | number of pixels in the tile |
[in] | datatype | datatype to be returned in 'buffer' |
[in] | nullcheck | 0 for no null checking |
[in] | nulval | value to be used for undefined pixels |
[out] | buffer | buffer for returned decompressed values |
[out] | bnullarray | buffer for returned null flags |
[out] | anynul | any null values returned? |
[in] | status) |
int imcomp_get_compressed_image_par | ( | fitsfile * | infptr, |
int * | status | ||
) |
int imcomp_init_table | ( | fitsfile * | outfptr, |
int | inbitpix, | ||
int | naxis, | ||
long * | naxes, | ||
int | writebitpix, | ||
int * | status | ||
) |
int imcomp_merge_overlap | ( | char * | tile, |
int | pixlen, | ||
int | ndim, | ||
long * | tfpixel, | ||
long * | tlpixel, | ||
char * | bnullarray, | ||
char * | image, | ||
long * | fpixel, | ||
long * | lpixel, | ||
int | nullcheck, | ||
int * | status | ||
) |
Similar to imcomp_copy_overlap, except it copies the overlapping pixels from the 'image' to the 'tile'.
[out] | tile | multi dimensional array of tile pixels |
[in] | pixlen | number of bytes in each tile or image pixel |
[in] | ndim | number of dimension in the tile and image |
[in] | tfpixel | first pixel number in each dim. of the tile |
[in] | tlpixel | last pixel number in each dim. of the tile |
[in] | bnullarray | array of null flags; used if nullcheck = 2 |
[in] | image | multi dimensional output image |
[in] | fpixel | first pixel number in each dim. of the image |
[in] | lpixel | last pixel number in each dim. of the image |
[in] | nullcheck | 0, 1: do nothing; 2: set nullarray for nulls |
int imcomp_nulldoubles | ( | double * | fdata, |
long | tilelen, | ||
int * | idata, | ||
int | nullcheck, | ||
double | nullflagval, | ||
int | nullval, | ||
int * | status | ||
) |
do null value substitution of the float array. If array value = nullflagval, then set the output value to FLOATNULLVALUE. Otherwise, inverse scale the integer value.
int imcomp_nullfloats | ( | float * | fdata, |
long | tilelen, | ||
int * | idata, | ||
int | nullcheck, | ||
float | nullflagval, | ||
int | nullval, | ||
int * | status | ||
) |
do null value substitution of the float array. If array value = nullflagval, then set the output value to FLOATNULLVALUE.
int imcomp_nullscale | ( | int * | idata, |
long | tilelen, | ||
int | nullflagval, | ||
int | nullval, | ||
double | scale, | ||
double | zero, | ||
int * | status | ||
) |
do null value substitution AND scaling of the integer array. If array value = nullflagval, then set the value to nullval. Otherwise, inverse scale the integer value.
int imcomp_nullscaledoubles | ( | double * | fdata, |
long | tilelen, | ||
int * | idata, | ||
double | scale, | ||
double | zero, | ||
int | nullcheck, | ||
double | nullflagval, | ||
int | nullval, | ||
int * | status | ||
) |
do null value substitution of the float array. If array value = nullflagval, then set the output value to FLOATNULLVALUE. Otherwise, inverse scale the integer value.
int imcomp_nullscalefloats | ( | float * | fdata, |
long | tilelen, | ||
int * | idata, | ||
double | scale, | ||
double | zero, | ||
int | nullcheck, | ||
float | nullflagval, | ||
int | nullval, | ||
int * | status | ||
) |
do null value substitution of the float array. If array value = nullflagval, then set the output value to FLOATNULLVALUE. Otherwise, inverse scale the integer value.
int imcomp_nullscalei2 | ( | short * | idata, |
long | tilelen, | ||
short | nullflagval, | ||
short | nullval, | ||
double | scale, | ||
double | zero, | ||
int * | status | ||
) |
do null value substitution AND scaling of the integer array. If array value = nullflagval, then set the value to nullval. Otherwise, inverse scale the integer value.
int imcomp_nullvalues | ( | int * | idata, |
long | tilelen, | ||
int | nullflagval, | ||
int | nullval, | ||
int * | status | ||
) |
do null value substitution. If array value = nullflagval, then set the value to nullval.
int imcomp_nullvaluesi2 | ( | short * | idata, |
long | tilelen, | ||
short | nullflagval, | ||
short | nullval, | ||
int * | status | ||
) |
do null value substitution. If array value = nullflagval, then set the value to nullval.
int imcomp_scalevalues | ( | int * | idata, |
long | tilelen, | ||
double | scale, | ||
double | zero, | ||
int * | status | ||
) |
do inverse scaling the integer values.
int imcomp_scalevaluesi2 | ( | short * | idata, |
long | tilelen, | ||
double | scale, | ||
double | zero, | ||
int * | status | ||
) |
do inverse scaling the integer values.
int imcomp_test_overlap | ( | int | ndim, |
long * | tfpixel, | ||
long * | tlpixel, | ||
long * | fpixel, | ||
long * | lpixel, | ||
long * | ininc, | ||
int * | status | ||
) |
test if there are any intersecting pixels between this tile and the section of the image defined by fixel, lpixel, ininc.
[in] | ndim | number of dimension in the tile and image |
[in] | tfpixel | first pixel number in each dim. of the tile |
[in] | tlpixel | last pixel number in each dim. of the tile |
[in] | fpixel | first pixel number in each dim. of the image |
[in] | lpixel | last pixel number in each dim. of the image |
[in] | ininc | increment to be applied in each image dimen. |
int imcomp_write_nocompress_tile | ( | fitsfile * | outfptr, |
long | row, | ||
int | datatype, | ||
void * | tiledata, | ||
long | tilelen, | ||
int | nullcheck, | ||
void * | nullflagval, | ||
int * | status | ||
) |
Write the uncompressed image tile pixels to the tile-compressed image file. This is a special case when using NOCOMPRESS for diagnostic purposes in fpack. Currently, this only supports a limited number of data types and does not fully support null-valued pixels in the image.
float* fits_rand_value = 0 |
char results[999][30] |