Cloudy
Spectral Synthesis Code for Astrophysics
|
#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"
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 > ¶mNames, vector< long > ¶mMethods, const multi_arr< realnum, 2 > ¶mRange, const multi_arr< realnum, 2 > ¶mData, 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 |
#define ByteSwap5 | ( | x | ) | ByteSwap((unsigned char *) &x,sizeof(x)) |
#define HtoNL | ( | A | ) |
Referenced by punchFITS_ParamData().
#define LOG2LINEAR 0 |
long addComment | ( | const string & | CommentToAdd | ) |
References ASSERT, DEBUG_ENTRY, fprintf(), ioFITS_OUTPUT, and LINESIZE.
Referenced by writeCloudyDetails().
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().
STATIC long addKeyword_num | ( | const char * | theKeyword, |
long | theValue, | ||
const char * | theComment | ||
) |
References ASSERT, DEBUG_ENTRY, fprintf(), ioFITS_OUTPUT, and LINESIZE.
Referenced by punchFITS_EnergyHeader(), punchFITS_GenericHeader(), punchFITS_ParamHeader(), punchFITS_PrimaryHeader(), punchFITS_SpectraHeader(), punchFITSimg_ExtensionHeader(), and punchFITSimg_PrimaryHeader().
STATIC long addKeyword_txt | ( | const char * | theKeyword, |
const void * | theValue, | ||
const char * | theComment, | ||
long | Str_Or_Log | ||
) |
References ASSERT, DEBUG_ENTRY, fprintf(), ioFITS_OUTPUT, and LINESIZE.
Referenced by punchFITS_EnergyHeader(), punchFITS_GenericHeader(), punchFITS_ParamHeader(), punchFITS_PrimaryHeader(), punchFITS_SpectraHeader(), punchFITSimg_ExtensionHeader(), and punchFITSimg_PrimaryHeader().
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.
|
inline |
References DEBUG_ENTRY.
Referenced by punchFITS_ParamHeader(), and punchFITS_SpectraHeader().
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().
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().
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().
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().
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().
STATIC void punchFITS_ParamHeader | ( | long | nintparm, |
long | naddparm | ||
) |
References addKeyword_num(), addKeyword_txt(), ASSERT, bitpix, bytesAdded, DEBUG_ENTRY, fprintf(), gcount, int2string(), ioFITS_OUTPUT, LIMPAR, LINESIZE, maxParamValues, pcount, and RECORDSIZE.
Referenced by saveFITSfile().
STATIC void punchFITS_PrimaryHeader | ( | bool | lgAddModel, |
bool | lgNormalize | ||
) |
References addKeyword_num(), addKeyword_txt(), ASSERT, bitpix, bytesAdded, DEBUG_ENTRY, fixit, fprintf(), ioFITS_OUTPUT, LINESIZE, ModelUnits, RECORDSIZE, and writeCloudyDetails().
Referenced by saveFITSfile().
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().
STATIC void punchFITS_SpectraHeader | ( | bool | lgAdditiveModel, |
bool | lgNormalize, | ||
long | nintparm, | ||
long | naddparm, | ||
long | totNumModels, | ||
long | numEnergies | ||
) |
References addKeyword_num(), addKeyword_txt(), ASSERT, bitpix, bytesAdded, DEBUG_ENTRY, fprintf(), gcount, int2string(), ioFITS_OUTPUT, LIMPAR, LINESIZE, ModelUnits, pcount, and RECORDSIZE.
Referenced by saveFITSfile().
STATIC void punchFITSimg_ExtensionData_matrix | ( | const long | nPixels, |
const multi_arr< double, 2, C_TYPE > & | image | ||
) |
References bytesAdded, ByteSwap5, DEBUG_ENTRY, ioFITS_OUTPUT, and RECORDSIZE.
Referenced by saveFITSimg().
STATIC void punchFITSimg_ExtensionData_vector | ( | const long | nCols, |
const valarray< double > & | vec | ||
) |
References bytesAdded, ByteSwap5, DEBUG_ENTRY, ioFITS_OUTPUT, and RECORDSIZE.
Referenced by saveFITSimg().
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().
STATIC void punchFITSimg_PrimaryHeader | ( | ) |
References addKeyword_num(), addKeyword_txt(), ASSERT, bitpix, bytesAdded, DEBUG_ENTRY, fprintf(), ioFITS_OUTPUT, LINESIZE, RECORDSIZE, and writeCloudyDetails().
Referenced by saveFITSimg().
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.
io | the file we will write to |
option | choose type of spectrum to save |
Elo | if set, lower bound of spectrum to save |
Ehi | if set, upper bound of spectrum to save |
Enorm | if set, normalize spectrum to 1 at this frequency |
References t_mesh::anu(), ASSERT, DEBUG_ENTRY, fprintf(), grid, GridRetrieveXSPECData(), t_grid::interpParameters, ioFITS_OUTPUT, t_mesh::ipointC(), t_grid::lgGridDone, MAX2, maxParamValues, t_grid::naddparm, t_rfield::nflux, t_grid::nintparm, t_optimize::nOptimiz, NUM_OUTPUT_TYPES, t_grid::numParamValues, open_data(), optimize, t_grid::paramData, t_grid::paramMethods, t_grid::paramNames, t_grid::paramRange, punchFITS_EnergyData(), punchFITS_EnergyHeader(), punchFITS_GenericData(), punchFITS_GenericHeader(), punchFITS_ParamData(), punchFITS_ParamHeader(), punchFITS_PrimaryHeader(), punchFITS_SpectraData(), punchFITS_SpectraHeader(), rfield, t_grid::Spectra, t_grid::totNumModels, and wr_block().
Referenced by process_output(), and SaveDo().
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.
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().
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.
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().
STATIC void writeCloudyDetails | ( | void | ) |
References addComment(), bytesAdded, t_input::crd, input, Singleton< t_version >::Inst(), t_prt::lgPrintTime, NULL, and prt.
Referenced by punchFITS_PrimaryHeader(), and punchFITSimg_PrimaryHeader().
|
static |
|
static |
Referenced by punchFITSimg_ExtensionHeader().
|
static |
Referenced by punchFITS_EnergyData(), punchFITS_EnergyHeader(), punchFITS_GenericData(), punchFITS_GenericHeader(), punchFITS_ParamData(), punchFITS_ParamHeader(), punchFITS_PrimaryHeader(), punchFITS_SpectraData(), punchFITS_SpectraHeader(), punchFITSimg_ExtensionData_matrix(), punchFITSimg_ExtensionData_vector(), punchFITSimg_ExtensionHeader(), punchFITSimg_PrimaryHeader(), and writeCloudyDetails().
|
static |
Referenced by punchFITS_EnergyHeader(), punchFITS_GenericHeader(), punchFITS_ParamHeader(), and punchFITS_SpectraHeader().
|
static |
Referenced by addComment(), addKeyword_dbl(), addKeyword_num(), addKeyword_txt(), punchFITS_EnergyData(), punchFITS_EnergyHeader(), punchFITS_GenericData(), punchFITS_GenericHeader(), punchFITS_ParamData(), punchFITS_ParamHeader(), punchFITS_PrimaryHeader(), punchFITS_SpectraData(), punchFITS_SpectraHeader(), punchFITSimg_ExtensionData_matrix(), punchFITSimg_ExtensionData_vector(), punchFITSimg_ExtensionHeader(), punchFITSimg_PrimaryHeader(), saveFITSfile(), and saveFITSimg().
|
static |
|
static |
Referenced by punchFITS_ParamData(), punchFITS_ParamHeader(), and saveFITSfile().
const char ModelUnits[2][17] = {"'dimensionless '", "'photons/cm^2/s'" } |
Referenced by punchFITS_PrimaryHeader(), and punchFITS_SpectraHeader().
|
static |
Referenced by punchFITS_EnergyHeader(), punchFITS_GenericHeader(), punchFITS_ParamHeader(), and punchFITS_SpectraHeader().
|
static |
Referenced by punchFITS_EnergyData(), punchFITS_EnergyHeader(), punchFITS_GenericData(), punchFITS_GenericHeader(), punchFITS_ParamData(), punchFITS_ParamHeader(), punchFITS_PrimaryHeader(), punchFITS_SpectraData(), punchFITS_SpectraHeader(), punchFITSimg_ExtensionData_matrix(), punchFITSimg_ExtensionData_vector(), punchFITSimg_ExtensionHeader(), and punchFITSimg_PrimaryHeader().