Kstars

fpack.h
1/* used by FPACK and FUNPACK
2 SPDX-FileCopyrightText: William D. Pence <https:xheasarc.gsfc.nasa.gov/fitsio/>
3 SPDX-FileCopyrightText: R. Seaman
4
5 SPDX-License-Identifier: LicenseRef-NASA-FV-License-Agreement
6*/
7
8#pragma once
9
10#include <string.h>
11#include <stdio.h>
12#include <stdlib.h>
13
14/* not needed any more */
15/* #include <unistd.h> */
16/* #include <sys/stat.h> */
17/* #include <sys/types.h> */
18
19#define FPACK_VERSION "1.7.0 (Dec 2013)"
20/*
21VERSION History
22
231.7.0 (Dec 2013)
24 - extensive changes to the binary table compression method. All types
25 of binary table columns, including variable length array columns are
26 now supported. The command line table compression flag has been changed
27 to "-table" instead of "-BETAtable", and a new "-tableonly" flag has
28 been introduced to only compress the binary tables in the input files(s)
29 and not the image HDUs.
301.6.1 (Mar 2013)
31 - numerous changes to the BETAtable compression method used to compress
32 binary tables
33 - added support for compression 'steering' keywords that specify the
34 desired compression parameters that should be used when compressing
35 that particular HDU, thus overriding the fpack command line parameter
36 values.
37
381.6.0 (June 2012)
39 - Fixed behavior of the "rename" function on Windows platforms so that
40 it will clobber/delete an existing file before renaming a file to
41 that name (the rename command behaves differently on POSIX and non-POSIX
42 environments).
43
441.6.0 (February 2011)
45 - Added full support for compressing and uncompressing FITS binary tables
46 using a newly proposed format convention. This is intended only for
47 further feasibility studies, and is not recommended for use with publicly
48 distributed FITS files.
49 - Use the minimum of the MAD 2nd, 3rd, and 5th order values as a more
50 conservative estimate of the noise when quantizing floating point images.
51 - Enhanced the tile compression routines so that a tile that contains all
52 NaN pixel values will be compressed.
53 - When uncompressing an image that was originally in a FITS primary array,
54 funpack will also append any new keywords that were written into the
55 primary array of the compressed FITS file after the file was compressed.
56 - Added support for the GZIP_2 algorithm, which shuffles the bytes in the
57 pixel values prior to compressing them with gzip.
581.5.1 (December 2010) Added prototype, mainly hidden, support for compressing
59 binary tables.
601.5.0 (August 2010) Added the -i2f option to lossy compress integer images.
611.4.0 (Jan 2010) Reduced the default value for the q floating point image
62 quantization parameter from 16 to 4. This results in about 50% better
63 compression (from about 4.6x to 6.4) with no lost of significant information
64 (with the new subtractive dithering enhancement). Replaced the code for
65 generating temporary filenames to make the code more portable (to Windows).
66 Replaced calls to the unix 'access' and 'stat' functions with more portable
67 code. When unpacking a file, write it first to a temporary file, then
68 rename it when finished, so that other tasks cannot try to read the file
69 before it is complete.
701.3.0 (Oct 2009) added randomization to the dithering pattern so that
71 the same pattern is not used for every image; also added an option
72 for losslessly compressing floating point images with GZIP for test
73 purposes (not recommended for general use). Also added support for
74 reading the input FITS file from the stdin file streams.
751.2.0 (Sept 2009) added subtractive dithering feature (in CFITSIO) when
76 quantizing floating point images; When packing an IRAF .imh + .pix image,
77 the file name is changed to FILE.fits.fz, and if the original file is
78 deleted, then both the .imh and .pix files are deleted.
791.1.4 (May 2009) added -E option to funpack to unpack a list of HDUs
801.1.3 (March 2009) minor modifications to the content and format of the -T report
811.1.2 (September 2008)
82*/
83
84#define FP_INIT_MAGIC 42
85#define FPACK 0
86#define FUNPACK 1
87
88/* changed from 16 in Jan. 2010 */
89#define DEF_QLEVEL 4.
90
91#define DEF_HCOMP_SCALE 0.
92#define DEF_HCOMP_SMOOTH 0
93#define DEF_RESCALE_NOISE 0
94
95#define SZ_STR 513
96#define SZ_CARD 81
97
98
99typedef struct
100{
101 int comptype;
102 float quantize_level;
103 int no_dither;
104 int dither_offset;
105 int dither_method;
106 float scale;
107 float rescale_noise;
108 int smooth;
109 int int_to_float;
110 float n3ratio;
111 float n3min;
112 long ntile[MAX_COMPRESS_DIM];
113
114 int to_stdout;
115 int listonly;
116 int clobber;
117 int delete_input;
118 int do_not_prompt;
119 int do_checksums;
120 int do_gzip_file;
121 int do_images;
122 int do_tables;
123 int test_all;
124 int verbose;
125
126 char prefix[SZ_STR];
127 char extname[SZ_STR];
128 int delete_suffix;
129 char outfile[SZ_STR];
130 int firstfile;
131
132 int initialized;
133 int preflight_checked;
134} fpstate;
135
136typedef struct
137{
138 int n_nulls;
139 double minval;
140 double maxval;
141 double mean;
142 double sigma;
143 double noise1;
144 double noise2;
145 double noise3;
146 double noise5;
147} imgstats;
148
149#ifdef __cplusplus
150extern "C" {
151#endif
152
153int fp_get_param (int argc, char *argv[], fpstate *fpptr);
154void abort_fpack(int sig);
155void fp_abort_output (fitsfile *infptr, fitsfile *outfptr, int stat);
156int fp_usage (void);
157int fp_help (void);
158int fp_hint (void);
159int fp_init (fpstate *fpptr);
160int fp_list (int argc, char *argv[], fpstate fpvar);
161int fp_info (char *infits);
162int fp_info_hdu (fitsfile *infptr);
163int fp_preflight (int argc, char *argv[], int unpack, fpstate *fpptr);
164int fp_loop (int argc, char *argv[], int unpack, char *output_filename, fpstate fpvar);
165
166/* Core pack function */
167/* Unpack input file to outfile file on disk */
168int fp_pack (char *infits, char *outfits, fpstate fpvar, int *islossless);
169/* Unpack input data to output FITS file in memory */
170/*int fp_pack_data_to_fits (const char *inputBuffer, size_t inputBufferSize, fitsfile **outfits, fpstate fpvar,
171 int *islossless);*/
172/* Unpack input data to output data in memory */
173/*int fp_pack_data_to_data (const char *inputBuffer, size_t inputBufferSize, unsigned char **outputBuffer,
174 size_t *outputBufferSize,
175 fpstate fpvar,
176 int *islossless);*/
177/* Pack input fits file to in-memory fits file */
178int fp_pack_fits_to_fits (fitsfile *infptr, fitsfile **outfits, fpstate fpvar, int *islossless);
179
180/* Core unpark functions */
181
182/* Unpack on disk file to output on disk file */
183int fp_unpack (char *infits, char *outfits, fpstate fpvar);
184/* Unpack input compressed input file to uncompressed output in-memory fits file */
185int fp_unpack_file_to_fits (char *infits, fitsfile **outfits, fpstate fpvar);
186/* Unpack input compressed data to uncompressed output in-memory fits file */
187/*int fp_unpack_data_to_fits (const char *inputBuffer, size_t inputBufferSize, fitsfile **outfptr, fpstate fpvar);*/
188/* Unpack input compressed data to uncompressed output uncompressed data */
189int fp_unpack_data_to_data (const char *inputBuffer, size_t inputBufferSize, unsigned char **outputBuffer,
190 size_t *outputBufferSize, fpstate fpvar);
191
192int fp_test (char *infits, char *outfits, char *outfits2, fpstate fpvar);
193int fp_pack_hdu (fitsfile *infptr, fitsfile *outfptr, fpstate fpvar,
194 int *islossless, int *status);
195int fp_unpack_hdu (fitsfile *infptr, fitsfile *outfptr, fpstate fpvar, int *status);
196int fits_read_image_speed (fitsfile *infptr, float *whole_elapse,
197 float *whole_cpu, float *row_elapse, float *row_cpu, int *status);
198int fp_test_hdu (fitsfile *infptr, fitsfile *outfptr, fitsfile *outfptr2,
199 fpstate fpvar, int *status);
200int fp_test_table (fitsfile *infptr, fitsfile *outfptr, fitsfile *outfptr2,
201 fpstate fpvar, int *status);
202int marktime(int *status);
203int gettime(float *elapse, float *elapscpu, int *status);
204int fits_read_image_speed (fitsfile *infptr, float *whole_elapse,
205 float *whole_cpu, float *row_elapse, float *row_cpu, int *status);
206
207int fp_i2stat(fitsfile *infptr, int naxis, long *naxes, imgstats *imagestats, int *status);
208int fp_i4stat(fitsfile *infptr, int naxis, long *naxes, imgstats *imagestats, int *status);
209int fp_r4stat(fitsfile *infptr, int naxis, long *naxes, imgstats *imagestats, int *status);
210int fp_i2rescale(fitsfile *infptr, int naxis, long *naxes, double rescale,
211 fitsfile *outfptr, int *status);
212int fp_i4rescale(fitsfile *infptr, int naxis, long *naxes, double rescale,
213 fitsfile *outfptr, int *status);
214
215#define fp_msg(msg) _fp_msg((const char *)msg)
216int _fp_msg (const char *msg);
217int fp_version (void);
218int fp_noop (void);
219
220int fu_get_param (int argc, char *argv[], fpstate *fpptr);
221int fu_usage (void);
222int fu_hint (void);
223int fu_help (void);
224
225#ifdef __cplusplus
226}
227#endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:26 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.