Cloudy
Spectral Synthesis Code for Astrophysics
Loading...
Searching...
No Matches
save_fits.cpp File Reference
#include "cddefines.h"
#include "save.h"
#include "cddrive.h"
#include "grid.h"
#include "rfield.h"
#include "prt.h"
#include "input.h"
#include "version.h"
#include "service.h"
#include "container_classes.h"
Include dependency graph for save_fits.cpp:

Macros

#define HtoNL(A)
 
#define ByteSwap5(x)
 
#define LOG2LINEAR   0
 

Functions

STATIC void ByteSwap (unsigned char *b, int n)
 
STATIC void punchFITS_PrimaryHeader (bool lgAddModel, bool lgNormalize)
 
STATIC void punchFITS_ParamHeader (long nintparm, long naddparm)
 
STATIC void punchFITS_ParamData (const vector< string > &paramNames, vector< long > &paramMethods, const multi_arr< realnum, 2 > &paramRange, const multi_arr< realnum, 2 > &paramData, long nintparm, long naddparm, long *numParamValues)
 
STATIC void punchFITS_EnergyHeader (long numEnergies)
 
STATIC void punchFITS_EnergyData (long ipLo, long ipHi)
 
STATIC void punchFITS_SpectraHeader (bool lgAdditiveModel, bool lgNormalize, long nintparm, long naddparm, long totNumModels, long numEnergies)
 
STATIC void punchFITS_SpectraData (const multi_arr< realnum, 2 > &interpParameters, multi_arr< realnum, 3 > &theSpectrum, int option, long totNumModels, long ipLo, long ipHi, long ipNorm, long nintparm, long naddparm)
 
STATIC void punchFITS_GenericHeader ()
 
STATIC void punchFITS_GenericData ()
 
STATIC void writeCloudyDetails (void)
 
STATIC long addComment (const string &CommentToAdd)
 
STATIC long addKeyword_txt (const char *theKeyword, const void *theValue, const char *theComment, long Str_Or_Log)
 
STATIC long addKeyword_num (const char *theKeyword, long theValue, const char *theComment)
 
STATIC long addKeyword_dbl (const char *theKeyword, const double theValue, const char *theComment)
 
string int2string (int val)
 
void saveFITSfile (FILE *ioPUN, int option, realnum Elo, realnum Ehi, realnum Enorm)
 
STATIC void get_data_minmax (const long nPixels, const multi_arr< double, 2, C_TYPE > &a, double &datamin, double &datamax)
 
STATIC void get_data_minmax (const long nCols, const valarray< double > &a, double &datamin, double &datamax)
 
STATIC void punchFITSimg_PrimaryHeader ()
 
STATIC void punchFITSimg_ExtensionHeader (const string &extName, const string &units, const long nCols, const long nRows, const double datamin, const double datamax)
 
STATIC void punchFITSimg_ExtensionData_matrix (const long nPixels, const multi_arr< double, 2, C_TYPE > &image)
 
STATIC void punchFITSimg_ExtensionData_vector (const long nCols, const valarray< double > &vec)
 
void saveFITSimg (FILE *ioPUN, const string &extName, const string &units, const long nPixels, const multi_arr< double, 2, C_TYPE > &image)
 
void saveFITSimg (FILE *ioPUN, const string &extName, const string &units, const long nCols, const valarray< double > &vec)
 

Variables

static const int RECORDSIZE = 2880
 
static const int LINESIZE = 80
 
static FILE * ioFITS_OUTPUT
 
static long bytesAdded = 0
 
static long bitpix = 8
 
static long pcount = 0
 
static long gcount = 1
 
static long maxParamValues = 0
 
const char ModelUnits [2][17] = {"'dimensionless '", "'photons/cm^2/s'" }
 
static const long bitpix_img = -64
 

Macro Definition Documentation

◆ ByteSwap5

#define ByteSwap5 ( x)
Value:
ByteSwap((unsigned char *) &x,sizeof(x))
STATIC void ByteSwap(unsigned char *b, int n)
Definition save_fits.cpp:44

Referenced by punchFITS_EnergyData(), punchFITS_GenericData(), punchFITS_ParamData(), punchFITS_SpectraData(), punchFITSimg_ExtensionData_matrix(), and punchFITSimg_ExtensionData_vector().

◆ HtoNL

#define HtoNL ( A)
Value:
((((A) & 0xff000000) >> 24) | \
(((A) & 0x00ff0000) >> 8) | \
(((A) & 0x0000ff00) << 8) | \
(((A) & 0x000000ff) << 24))

Referenced by punchFITS_ParamData().

◆ LOG2LINEAR

#define LOG2LINEAR   0

Function Documentation

◆ addComment()

long addComment ( const string & CommentToAdd)

References ASSERT, DEBUG_ENTRY, fprintf(), ioFITS_OUTPUT, and LINESIZE.

Referenced by writeCloudyDetails().

Here is the call graph for this function:

◆ addKeyword_dbl()

STATIC long addKeyword_dbl ( const char * theKeyword,
const double theValue,
const char * theComment )

References ASSERT, DEBUG_ENTRY, fprintf(), ioFITS_OUTPUT, LINESIZE, and STATIC.

Referenced by punchFITSimg_ExtensionHeader().

Here is the call graph for this function:

◆ addKeyword_num()

STATIC long addKeyword_num ( const char * theKeyword,
long theValue,
const char * theComment )

◆ addKeyword_txt()

STATIC long addKeyword_txt ( const char * theKeyword,
const void * theValue,
const char * theComment,
long Str_Or_Log )

◆ ByteSwap()

STATIC void ByteSwap ( unsigned char * b,
int n )

References STATIC.

◆ get_data_minmax() [1/2]

STATIC void get_data_minmax ( const long nCols,
const valarray< double > & a,
double & datamin,
double & datamax )

References DEBUG_ENTRY, and STATIC.

◆ get_data_minmax() [2/2]

STATIC void get_data_minmax ( const long nPixels,
const multi_arr< double, 2, C_TYPE > & a,
double & datamin,
double & datamax )

References DEBUG_ENTRY, and STATIC.

Referenced by saveFITSimg(), and saveFITSimg().

◆ int2string()

string int2string ( int val)
inline

◆ punchFITS_EnergyData()

STATIC void punchFITS_EnergyData ( long ipLo,
long ipHi )

◆ punchFITS_EnergyHeader()

STATIC void punchFITS_EnergyHeader ( long numEnergies)

References addKeyword_num(), addKeyword_txt(), ASSERT, bitpix, bytesAdded, DEBUG_ENTRY, fprintf(), gcount, ioFITS_OUTPUT, LINESIZE, pcount, RECORDSIZE, and STATIC.

Referenced by saveFITSfile().

Here is the call graph for this function:

◆ punchFITS_GenericData()

STATIC void punchFITS_GenericData ( )

References bytesAdded, ByteSwap5, cdSPEC2(), DEBUG_ENTRY, get_ptr(), ioFITS_OUTPUT, RECORDSIZE, rfield, and STATIC.

Referenced by saveFITSfile().

Here is the call graph for this function:

◆ punchFITS_GenericHeader()

STATIC void punchFITS_GenericHeader ( )

References addKeyword_num(), addKeyword_txt(), ASSERT, bitpix, bytesAdded, DEBUG_ENTRY, fprintf(), gcount, ioFITS_OUTPUT, LINESIZE, pcount, RECORDSIZE, rfield, and STATIC.

Referenced by saveFITSfile().

Here is the call graph for this function:

◆ punchFITS_ParamData()

STATIC void punchFITS_ParamData ( const vector< string > & paramNames,
vector< long > & paramMethods,
const multi_arr< realnum, 2 > & paramRange,
const multi_arr< realnum, 2 > & paramData,
long nintparm,
long naddparm,
long * numParamValues )

References ASSERT, bytesAdded, ByteSwap5, DEBUG_ENTRY, exp10(), fprintf(), HtoNL, ioFITS_OUTPUT, LIMPAR, maxParamValues, RECORDSIZE, and STATIC.

Referenced by saveFITSfile().

Here is the call graph for this function:

◆ punchFITS_ParamHeader()

STATIC void punchFITS_ParamHeader ( long nintparm,
long naddparm )

◆ punchFITS_PrimaryHeader()

STATIC void punchFITS_PrimaryHeader ( bool lgAddModel,
bool lgNormalize )

◆ punchFITS_SpectraData()

STATIC void punchFITS_SpectraData ( const multi_arr< realnum, 2 > & interpParameters,
multi_arr< realnum, 3 > & theSpectrum,
int option,
long totNumModels,
long ipLo,
long ipHi,
long ipNorm,
long nintparm,
long naddparm )

References ASSERT, bytesAdded, ByteSwap5, cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, fprintf(), ioFITS_OUTPUT, ioQQQ, Energy::keV(), LIMPAR, RECORDSIZE, rfield, and STATIC.

Referenced by saveFITSfile().

Here is the call graph for this function:

◆ punchFITS_SpectraHeader()

STATIC void punchFITS_SpectraHeader ( bool lgAdditiveModel,
bool lgNormalize,
long nintparm,
long naddparm,
long totNumModels,
long numEnergies )

◆ punchFITSimg_ExtensionData_matrix()

STATIC void punchFITSimg_ExtensionData_matrix ( const long nPixels,
const multi_arr< double, 2, C_TYPE > & image )

◆ punchFITSimg_ExtensionData_vector()

STATIC void punchFITSimg_ExtensionData_vector ( const long nCols,
const valarray< double > & vec )

◆ punchFITSimg_ExtensionHeader()

STATIC void punchFITSimg_ExtensionHeader ( const string & extName,
const string & units,
const long nCols,
const long nRows,
const double datamin,
const double datamax )

◆ punchFITSimg_PrimaryHeader()

STATIC void punchFITSimg_PrimaryHeader ( )

References addKeyword_num(), addKeyword_txt(), ASSERT, bitpix, bytesAdded, DEBUG_ENTRY, fprintf(), ioFITS_OUTPUT, LINESIZE, RECORDSIZE, STATIC, and writeCloudyDetails().

Referenced by saveFITSimg().

Here is the call graph for this function:

◆ saveFITSfile()

void saveFITSfile ( FILE * io,
int option,
realnum Elo = 0.f,
realnum Ehi = 0.f,
realnum Enorm = 0.f )

Save spectra to a FITS compatible file.

Parameters
iothe file we will write to
optionchoose type of spectrum to save
Eloif set, lower bound of spectrum to save
Ehiif set, upper bound of spectrum to save
Enormif set, normalize spectrum to 1 at this frequency

References ASSERT, DEBUG_ENTRY, fprintf(), grid, GridRetrieveXSPECData(), ioFITS_OUTPUT, MAX2, maxParamValues, NUM_OUTPUT_TYPES, open_data(), optimize, punchFITS_EnergyData(), punchFITS_EnergyHeader(), punchFITS_GenericData(), punchFITS_GenericHeader(), punchFITS_ParamData(), punchFITS_ParamHeader(), punchFITS_PrimaryHeader(), punchFITS_SpectraData(), punchFITS_SpectraHeader(), rfield, and wr_block().

Referenced by process_output(), and SaveDo().

Here is the call graph for this function:

◆ saveFITSimg() [1/2]

void saveFITSimg ( FILE * io,
const string & extName,
const string & units,
const long nCols,
const valarray< double > & vec )

Save rate matrix to a FITS file. Mainly a debugging aid.

Parameters
io[in] the file we will write to
extName[in] extension name
units[in] vector units
nCols[in] length of vector
vector[in] vector to write in FITS extension

References DEBUG_ENTRY, get_data_minmax(), ioFITS_OUTPUT, punchFITSimg_ExtensionData_vector(), and punchFITSimg_ExtensionHeader().

Here is the call graph for this function:

◆ saveFITSimg() [2/2]

void saveFITSimg ( FILE * io,
const string & extName,
const string & units,
const long nPixels,
const multi_arr< double, 2, C_TYPE > & image )

Save rate matrix to a FITS file. Mainly a debugging aid.

Parameters
io[in] the file we will write to
extName[in] extension name
units[in] vector units
nPixels[in] dimension of (square) image
image[in] image to write in FITS extension

References DEBUG_ENTRY, get_data_minmax(), ioFITS_OUTPUT, punchFITSimg_ExtensionData_matrix(), punchFITSimg_ExtensionHeader(), and punchFITSimg_PrimaryHeader().

Referenced by save_img_matrix::addImagePop_FITS(), and save_img_matrix::createImage_FITS().

Here is the call graph for this function:

◆ writeCloudyDetails()

STATIC void writeCloudyDetails ( void )

References addComment(), bytesAdded, input, Singleton< t_version >::Inst(), NULL, prt, and STATIC.

Referenced by punchFITS_PrimaryHeader(), and punchFITSimg_PrimaryHeader().

Here is the call graph for this function:

Variable Documentation

◆ bitpix

◆ bitpix_img

const long bitpix_img = -64
static

◆ bytesAdded

◆ gcount

◆ ioFITS_OUTPUT

◆ LINESIZE

◆ maxParamValues

long maxParamValues = 0
static

◆ ModelUnits

const char ModelUnits[2][17] = {"'dimensionless '", "'photons/cm^2/s'" }

◆ pcount

◆ RECORDSIZE