Cloudy
Spectral Synthesis Code for Astrophysics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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)   ByteSwap((unsigned char *) &x,sizeof(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

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

Referenced by punchFITS_ParamData().

#define LOG2LINEAR   0

Function Documentation

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:

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

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

Referenced by punchFITSimg_ExtensionHeader().

Here is the call graph for this function:

STATIC long addKeyword_num ( const char *  theKeyword,
long  theValue,
const char *  theComment 
)
STATIC long addKeyword_txt ( const char *  theKeyword,
const void *  theValue,
const char *  theComment,
long  Str_Or_Log 
)
STATIC void ByteSwap ( unsigned char *  b,
int  n 
)
STATIC void get_data_minmax ( const long  nPixels,
const multi_arr< double, 2, C_TYPE > &  a,
double &  datamin,
double &  datamax 
)

References DEBUG_ENTRY.

Referenced by saveFITSimg().

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

References DEBUG_ENTRY.

string int2string ( int  val)
inline
STATIC void punchFITS_EnergyData ( long  ipLo,
long  ipHi 
)

References t_mesh::anumax(), t_mesh::anumin(), bytesAdded, ByteSwap5, DEBUG_ENTRY, ioFITS_OUTPUT, RECORDSIZE, and rfield.

Referenced by saveFITSfile().

Here is the call graph for this function:

STATIC void punchFITS_EnergyHeader ( long  numEnergies)

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

Referenced by saveFITSfile().

Here is the call graph for this function:

STATIC void punchFITS_GenericData ( )

References t_mesh::anu(), bytesAdded, ByteSwap5, cdSPEC2(), DEBUG_ENTRY, get_ptr(), ioFITS_OUTPUT, t_rfield::nflux, RECORDSIZE, and rfield.

Referenced by saveFITSfile().

Here is the call graph for this function:

STATIC void punchFITS_GenericHeader ( )

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

Referenced by saveFITSfile().

Here is the call graph for this function:

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, and RECORDSIZE.

Referenced by saveFITSfile().

Here is the call graph for this function:

STATIC void punchFITS_ParamHeader ( long  nintparm,
long  naddparm 
)
STATIC void punchFITS_PrimaryHeader ( bool  lgAddModel,
bool  lgNormalize 
)
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, LIMPAR, RECORDSIZE, rfield, and t_mesh::widflx().

Referenced by saveFITSfile().

Here is the call graph for this function:

STATIC void punchFITS_SpectraHeader ( bool  lgAdditiveModel,
bool  lgNormalize,
long  nintparm,
long  naddparm,
long  totNumModels,
long  numEnergies 
)
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 
)
STATIC void punchFITSimg_ExtensionHeader ( const string &  extName,
const string &  units,
const long  nCols,
const long  nRows,
const double  datamin,
const double  datamax 
)

References addKeyword_dbl(), addKeyword_num(), addKeyword_txt(), ASSERT, bitpix_img, bytesAdded, DEBUG_ENTRY, fprintf(), ioFITS_OUTPUT, LINESIZE, and RECORDSIZE.

Referenced by saveFITSimg().

Here is the call graph for this function:

STATIC void punchFITSimg_PrimaryHeader ( )

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

Referenced by saveFITSimg().

Here is the call graph for this function:

void saveFITSfile ( FILE *  io,
int  option,
realnum  Elo = 0.f,
realnum  Ehi = 0.f,
realnum  Enorm = 0.f 
)
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:

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:

STATIC void writeCloudyDetails ( void  )

Variable Documentation

const long bitpix_img = -64
static
long maxParamValues = 0
static
const char ModelUnits[2][17] = {"'dimensionless '", "'photons/cm^2/s'" }