ERIS Pipeline Reference Manual 1.8.15
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
Sky Correction Code

Files

file  sc_basic.c
 
file  sc_basic.h
 
file  sc_contsub.c
 
file  sc_contsub.h
 
file  sc_conv.c
 
file  sc_conv.h
 
file  sc_fwhmest.c
 
file  sc_fwhmest.h
 
file  sc_lines.c
 
file  sc_lines.h
 
file  sc_modsky.c
 
file  sc_modsky.h
 
file  sc_mpfit.c
 
file  sc_mpfit.h
 
file  sc_par.c
 
file  sc_par.h
 Header for routines for handling parameter files.
 
file  sc_plot.c
 
file  sc_plot.h
 Header for plotting library.
 
file  sc_readspec.c
 
file  sc_readspec.h
 
file  sc_skycorr.c
 
file  sc_skycorr.h
 
file  sc_specdiss.c
 programme to find emission lines in spectra
 
file  sc_specdiss.h
 Header for spectral analysis library.
 
file  sc_weights.c
 
file  sc_weights.h
 

Data Structures

struct  _scpar_
 

Macros

#define SC_MIN(a, b)   ((a) > (b) ? (b) : (a))
 
#define SC_MAX(a, b)   ((a) < (b) ? (b) : (a))
 
#define SC_LENLINE   160
 
#define SC_MAXLEN   1024
 
#define SC_TOL   1e-7
 
#define SC_MAXPAR   21
 
#define SC_THERMIRLIM   2.31
 
#define SC_DEFLAMCOL   "LAMBDA"
 
#define SC_DEFFLUXCOL   "FLUX"
 
#define SC_DEFDFLUXCOL   "DFLUX"
 
#define SC_DEFMASKCOL   "MASK"
 
#define SC_SINCRAD_PRECOMP   6.0
 
#define SC_SINCNBIN   10000
 
#define SC_SINCDAMP   3.25
 

Typedefs

typedef enum _sc_error_code_ sc_error_code
 
typedef struct _scpar_ scpar
 

Enumerations

enum  _sc_error_code_
 

Functions

cpl_error_code sc_basic_readline (FILE *stream, scpar par[], int *npar)
 
double sc_basic_mjd2fracyear (double mjd)
 
double sc_basic_fracyear2date (int *year, int *month, int *day, int *hh, int *mm, double *ss, const double *fracyear)
 
cpl_error_code sc_basic_rebin (cpl_table *outspec, const char *outlam, const char *outflux, const cpl_table *inspec, const char *inlam, const char *influx)
 
cpl_error_code sc_basic_convolve (cpl_table *spec, const char *colname, const cpl_array *kernel)
 
cpl_error_code sc_basic_convolvewindow (cpl_array *convflux, const cpl_array *flux, const int range[2], const cpl_array *kernel)
 
cpl_error_code sc_basic_filtermedian (cpl_table *spec, const char *colname, const int npix)
 
cpl_error_code sc_basic_linecount (long *n_lines, FILE *fp)
 
cpl_error_code sc_basic_rhum2ppmv_old (const cpl_array *temp, const cpl_array *pres, const cpl_array *rhum, cpl_array *ppmv)
 
void sc_basic_rhum2ppmv (double *ppmv, const double *tem, const double *p, const double *hum)
 
cpl_error_code sc_basic_planck (cpl_array *bb, const cpl_array *wavelength, const double temp)
 
void sc_basic_dirslash (char *dir)
 
void sc_basic_abspath (char *out, const char *dir, const char *cwd)
 
cpl_error_code sc_basic_access (const char *pathname, const int mode)
 
cpl_error_code sc_basic_greg2jd (long *jd, const int year, const int month, const int day)
 
cpl_error_code sc_basic_jd2greg (int *year, int *month, int *day, const long jd)
 
cpl_error_code sc_basic_clipmean (double *mean, double *rms, cpl_array *arr, const cpl_boolean clip)
 
cpl_error_code sc_basic_col2arr (cpl_array *arr, const cpl_table *tab, const char *colname)
 
cpl_error_code sc_basic_arr2col (cpl_table *tab, const char *colname, const cpl_array *arr)
 
cpl_error_code sc_basic_sortarr (cpl_array *arr, cpl_type type)
 
cpl_error_code sc_basic_copytable_content (cpl_table *outtab, const cpl_table *intab)
 
cpl_error_code sc_basic_copytable_full (cpl_table *outtab, const cpl_table *intab)
 
void sc_basic_initstring (char *str, const long n)
 
void sc_basic_terminatestring (char *str)
 
char * sc_basic_strtrim (char *str)
 
void sc_basic_strtrim_inplace (char *str)
 
cpl_boolean sc_basic_isnumber (char *str)
 
cpl_boolean sc_basic_isinteger (char *str)
 
cpl_error_code sc_basic_interpollin (const double *x_out, double *y_out, const long n_out, const double *x_ref, const double *y_ref, const long n_ref, const int extrapolate)
 
int sc_basic_gaussfunc (double *fgauss, const double *xgauss, const int n_data, const double *par)
 
cpl_error_code sc_basic_getfilename (char *dir, char *filename, char *suffix, const char *path)
 
cpl_error_code sc_basic_getmaskval_vector (double maskval[2], const cpl_vector *vector)
 
cpl_error_code sc_basic_getmaskval_image (double maskval[2], const cpl_image *image)
 
cpl_error_code sc_basic_calcsinc (cpl_vector *sinc)
 

Detailed Description

This module provides functions for the correction of sky emission.

Macro Definition Documentation

◆ SC_DEFDFLUXCOL

#define SC_DEFDFLUXCOL   "DFLUX"

Default flux error column name

Definition at line 111 of file sc_basic.h.

◆ SC_DEFFLUXCOL

#define SC_DEFFLUXCOL   "FLUX"

Default flux column name

Definition at line 109 of file sc_basic.h.

◆ SC_DEFLAMCOL

#define SC_DEFLAMCOL   "LAMBDA"

Default wavelength column name

Definition at line 107 of file sc_basic.h.

◆ SC_DEFMASKCOL

#define SC_DEFMASKCOL   "MASK"

Default mask column name

Definition at line 113 of file sc_basic.h.

◆ SC_LENLINE

#define SC_LENLINE   160

Maximum number of characters per line

Definition at line 92 of file sc_basic.h.

◆ SC_MAX

#define SC_MAX (   a,
 
)    ((a) < (b) ? (b) : (a))

Macro for finding the maximum of two values

Definition at line 87 of file sc_basic.h.

◆ SC_MAXLEN

#define SC_MAXLEN   1024

Maximum number of string characters

Definition at line 94 of file sc_basic.h.

◆ SC_MAXPAR

#define SC_MAXPAR   21

Maximum number of space- or tab-separated strings per line (see sc_basic_readline)

Definition at line 99 of file sc_basic.h.

◆ SC_MIN

#define SC_MIN (   a,
 
)    ((a) > (b) ? (b) : (a))

Macro for finding the minimum of two values

Definition at line 85 of file sc_basic.h.

◆ SC_SINCDAMP

#define SC_SINCDAMP   3.25

Damping constant for damped sinc kernel in pixels

Definition at line 122 of file sc_basic.h.

◆ SC_SINCNBIN

#define SC_SINCNBIN   10000

Number of points per unit for pre-calculated damped sinc kernel

Definition at line 120 of file sc_basic.h.

◆ SC_SINCRAD_PRECOMP

#define SC_SINCRAD_PRECOMP   6.0

Radius of precomputed damped sinc kernel in pixels.

Definition at line 118 of file sc_basic.h.

◆ SC_THERMIRLIM

#define SC_THERMIRLIM   2.31

Lower limit for wavelength range dominated by emission lines originating in the lower atmosphere in ${\mu}$m

Definition at line 102 of file sc_basic.h.

◆ SC_TOL

#define SC_TOL   1e-7

Required relative accuracy for data comparisons

Definition at line 96 of file sc_basic.h.

Typedef Documentation

◆ sc_error_code

Enumeration structure for sky model related error codes

◆ scpar

typedef struct _scpar_ scpar

Structure for a parameter value in different data types

Parameters
cstring (maximum length SC_LENLINE)
iinteger number
dfloat number of double precision

Enumeration Type Documentation

◆ _sc_error_code_

Enumeration structure for sky model related error codes

Definition at line 128 of file sc_basic.h.

Function Documentation

◆ sc_basic_abspath()

void sc_basic_abspath ( char *  out,
const char *  dir,
const char *  cwd 
)

Expand relative path.

INPUT:

Parameters
dirrelative directory.
cwdcurrent working directory.

OUTPUT:

Parameters
outoutput directory

ERRORS:

  • none.
Note
If the input directory is already an absolute path, the output string contains a copy of the input.
Input strings cannot be longer than SC_MAXLEN.

Definition at line 1133 of file sc_basic.c.

References sc_basic_dirslash(), sc_basic_initstring(), and SC_MAXLEN.

Referenced by sc_conv_readprepfits(), sc_lines_readlist(), sc_lines_readsolflux(), and sc_lines_readvarpar().

◆ sc_basic_access()

cpl_error_code sc_basic_access ( const char *  pathname,
const int  mode 
)

Check for file or directory existence

This function provides a wrapper for the intrinsic function access(). It reports back all access() errors.

INPUT:

Parameters
pathnamename of a file or directory
modemode for accessibility checks F_OK = file existence X_OK = file exec permission W_OK = file write permission

OUTPUT:

Returns
CPL_ERROR_NONE on success, or on failure: SC_ERROR_ROFS, SC_ERROR_INVAL, SC_ERROR_TXTBSY, SC_ERROR_ACCES, SC_ERROR_LOOP, SC_ERROR_NAMETOOLONG, SC_ERROR_NOENT, SC_ERROR_NOTDIR, SC_ERROR_FAULT, SC_ERROR_IO, SC_ERROR_NOMEM, SC_ERROR_UNDEF

ERRORS:

  • see access manual for details

Definition at line 1199 of file sc_basic.c.

◆ sc_basic_arr2col()

cpl_error_code sc_basic_arr2col ( cpl_table *  tab,
const char *  colname,
const cpl_array *  arr 
)

Routine to copy a CPL array to a column of a CPL table.

If the target column does not exist it is created and subsequently filled with array data. Also the sizes of the source array and target CPL table must match, except an empty target table is used. In this case, the size is set to the inout CPL array size.

Data types of target column and source array must coincide

Supported data types: CPL_TYPE_INT, CPL_TYPE_FLOAT, CPL_TYPE_DOUBLE, CPL_TYPE_STRING

INPUT:

Parameters
arrCPL array to be copied to target column
tabCPL table containing selected column
colnameName of CPL table target column

OUTPUT

Parameters
tabTarget CPL table
colnameTarget column of CPL table to be filled with array data

Definition at line 1757 of file sc_basic.c.

References SC_MAXLEN.

Referenced by sc_skycorr_subcont().

◆ sc_basic_calcsinc()

cpl_error_code sc_basic_calcsinc ( cpl_vector *  sinc)

Calculates asymmetric, exponentially-damped sinc function for rebinning without smoothing. The radius of the kernel, the sampling, and the sinc damping constant are defined by SC_SINCRAD_PRECOMP, SC_SINCNBIN, and SC_SINCDAMP, respectively. All constants are given in pixels. The resulting kernel should be normalised to 1.

Note
The method is similar to the approach used in the IDL routine "sshift2d.pro".

INPUT:

Parameters
sincempty CPL vector

OUTPUT:

Parameters
sincCPL vector with damped sinc function

ERRORS:

  • CPL_ERROR_ILLEGAL_INPUT

Definition at line 2714 of file sc_basic.c.

References SC_SINCDAMP, SC_SINCNBIN, and SC_SINCRAD_PRECOMP.

Referenced by sc_mpfit().

◆ sc_basic_clipmean()

cpl_error_code sc_basic_clipmean ( double *  mean,
double *  rms,
cpl_array *  arr,
const cpl_boolean  clip 
)

Calculate mean and rms using sigma-clipping routine

This function calculates the mean and rms of a cpl_array first by computing the median absolute difference and afterwards applying Huber's method. Values identified as outliers are flagged "invalid" in the input array. If a more stringent value on the mean/rms is desired, /em clip can be set to 1, resulting in the outliers being removed from the calculation of the mean/rms (in contrast to "compressing" them to the outer boundaries of the clipping, i.e. Huber's method). See: AMC Technical Briefs - ISSN 1757-5958, No.6, Royal Society of Chemistry, 2001 http://www.rsc.org/images/brief6_tcm18-25948.pdf

Note
The input array might have invalid rows on output. Invalid rows on input are excluded from the computation.

INPUT:

Parameters
arrcpl_array
clipflag for clipping mode

OUTPUT:

Parameters
meanmean
rmsroot-mean-square

ERRORS:

  • none

Definition at line 1539 of file sc_basic.c.

Referenced by sc_fwhmest(), and sc_mpfit_modinitpar().

◆ sc_basic_col2arr()

cpl_error_code sc_basic_col2arr ( cpl_array *  arr,
const cpl_table *  tab,
const char *  colname 
)

Routine to copy a CPL table column to a CPL array.

The target array must have size = 0, otherwise existing array data will be overwritten. Data types of source array and target table column must match.

Supported data types: CPL_TYPE_INT, CPL_TYPE_FLOAT, CPL_TYPE_DOUBLE, CPL_TYPE_STRING

INPUT:

Parameters
arr(empty) CPL array to be filled
tabCPL table containing selected column 'colname'
colnameColumn name of table to be copied to array

OUTPUT

Parameters
arrFilled CPL array

Definition at line 1652 of file sc_basic.c.

References SC_MAXLEN.

Referenced by sc_skycorr_subcont().

◆ sc_basic_convolve()

cpl_error_code sc_basic_convolve ( cpl_table *  spec,
const char *  colname,
const cpl_array *  kernel 
)

Convolution of column colname in CPL table spec with given kernel.

Note
The centre of the convolution function is shifted by -0.5 pixels for an even number of kernel pixels.

INPUT:

Parameters
specinput spectrum as CPL table
colnamename of column with input data
kernelkernel as CPL array (required: sum of all values = 1)

OUTPUT:

Parameters
specconvolved input spectrum

ERRORS:

  • Invalid object value(s)

Definition at line 441 of file sc_basic.c.

References SC_MAXLEN, and SC_TOL.

◆ sc_basic_convolvewindow()

cpl_error_code sc_basic_convolvewindow ( cpl_array *  convflux,
const cpl_array *  flux,
const int  range[2],
const cpl_array *  kernel 
)

Convolution of a flux array with given kernel for a fixed range of pixels. The output array has to exist and have the same number of pixels as the input array. Technically, the convolution is carried out by adding the convolved fluxes for each pixel in the selected window.

Note
The centre of the convolution function is shifted by -0.5 pixels for an even number of kernel pixels.

INPUT:

Parameters
convfluxCPL array of convolved flux values
fluxCPL array of unconvolved input flux
rangerange of pixels to be considered (minimum and maximum)
kernelkernel as CPL array (required: sum of all values = 1)

OUTPUT:

Parameters
convfluxoutput array with added convolved flux from given range

ERRORS:

  • Invalid object structure
  • Invalid input parameter(s)
  • Invalid object value(s)

Definition at line 564 of file sc_basic.c.

References SC_MAX, SC_MAXLEN, SC_MIN, and SC_TOL.

Referenced by sc_weights_convolve().

◆ sc_basic_copytable_content()

cpl_error_code sc_basic_copytable_content ( cpl_table *  outtab,
const cpl_table *  intab 
)

Copies the content of a table. The output table must exist and have the same structure as the input table. Only columns with CPL_TYPE_STRING, CPL_TYPE_INT, CPL_TYPE_FLOAT, and CPL_TYPE_DOUBLE can be handled.

INPUT:

Parameters
intabinput table

OUTPUT:

Parameters
outtaboutput table with copied content of input table

ERRORS:

  • Invalid object structure

Definition at line 1923 of file sc_basic.c.

References SC_MAXLEN.

Referenced by sc_mpfit().

◆ sc_basic_copytable_full()

cpl_error_code sc_basic_copytable_full ( cpl_table *  outtab,
const cpl_table *  intab 
)

Copies the structure and content of a table. The output table must exist. Missing columns are created. Only columns with CPL_TYPE_STRING, CPL_TYPE_INT, CPL_TYPE_FLOAT, and CPL_TYPE_DOUBLE can be handled.

INPUT:

Parameters
outtabempty output table
intabinput table

OUTPUT:

Parameters
outtaboutput table with copied content of input table

ERRORS:

  • none

Definition at line 1991 of file sc_basic.c.

◆ sc_basic_dirslash()

void sc_basic_dirslash ( char *  dir)

Append '/' to path.

INPUT:

Parameters
dirdirectory.

OUTPUT:

Parameters
dirdirectory.

ERRORS:

  • none.
Note
The input directory gets overwritten.

Definition at line 1109 of file sc_basic.c.

Referenced by sc_basic_abspath().

◆ sc_basic_filtermedian()

cpl_error_code sc_basic_filtermedian ( cpl_table *  spec,
const char *  colname,
const int  npix 
)

Median filtering of column colname in CPL table spec. The median for each pixel is calculated by considering npix-1 neighbouring pixels.

INPUT:

Parameters
specinput spectrum as CPL table
colnamename of column with input data
npixnumber of pixels for median

OUTPUT:

Parameters
specfiltered input spectrum

ERRORS:

  • none

Definition at line 745 of file sc_basic.c.

Referenced by sc_contsub().

◆ sc_basic_fracyear2date()

double sc_basic_fracyear2date ( int *  year,
int *  month,
int *  day,
int *  hh,
int *  mm,
double *  ss,
const double *  fracyear 
)

Brake up a fractional year into year, month, day.

This routine brakes up a fractional year into year, month, day, e.g. 2002.380821917808219 corresponds to 20/05/2002, optionally including the time of day. The return value is the rest after braking up the date, i.e. the time of day.

INPUT:

Parameters
fracyearfractional year (e.g. 2002.345)

OUTPUT:

Parameters
yearyear
monthmonth
dayday
hhhour
mmminute
sssecond

RETURN: fractional day (optionally broken up into hh/mm/ss)

ERRORS:

  • none

Definition at line 206 of file sc_basic.c.

Referenced by sc_lines_getmodelbins().

◆ sc_basic_gaussfunc()

int sc_basic_gaussfunc ( double *  fgauss,
const double *  xgauss,
const int  n_data,
const double *  par 
)

Computes Gaussian.

INPUT:

Parameters
xgaussvector of x positions
n_datanumber of data points
parparameters for Gaussian

OUTPUT:

Parameters
fgaussresulting Gaussian

ERRORS:

  • none

Definition at line 2473 of file sc_basic.c.

Referenced by sc_fwhmest_gaussfunc().

◆ sc_basic_getfilename()

cpl_error_code sc_basic_getfilename ( char *  dir,
char *  filename,
char *  suffix,
const char *  path 
)

Splits full path into directory, file name, and file name suffix. Returns NULL if a component cannot be found in the input string.

INPUT:

Parameters
pathpath including file name

OUTPUT:

Parameters
dirdirectory path (without slash at the end)
filenamefile name
suffixfile identifier like "asc" or "fits"

ERRORS:

  • none

Definition at line 2507 of file sc_basic.c.

References SC_MAXLEN.

◆ sc_basic_getmaskval_image()

cpl_error_code sc_basic_getmaskval_image ( double  maskval[2],
const cpl_image *  image 
)

Gets meaning of mask values provided by a CPL image. It is assumed that a good value equals 1 if only 1 and possiby 0 are present. If only 0 exists, the definition is reversed. This is also true for a minimum mask value of 0 and any larger number. The latter will be classified as bad mask values.

INPUT:

Parameters
imageinput CPL image

OUTPUT:

Parameters
maskvalmask values (1st: bad value, 2nd: good value)

ERRORS:

  • No data
  • Invalid object value(s)

Definition at line 2657 of file sc_basic.c.

References SC_MAXLEN.

Referenced by sc_conv_iarr2varr_sci(), and sc_conv_iarr2varr_sky().

◆ sc_basic_getmaskval_vector()

cpl_error_code sc_basic_getmaskval_vector ( double  maskval[2],
const cpl_vector *  vector 
)

Gets meaning of mask values provided by a CPL vector. It is assumed that a good value equals 1 if only 1 and possiby 0 are present. If only 0 exists, the definition is reversed. This is also true for a minimum mask value of 0 and any larger number. The latter will be classified as bad mask values.

INPUT:

Parameters
vectorinput CPL vector

OUTPUT:

Parameters
maskvalmask values (1st: bad value, 2nd: good value)

ERRORS:

  • No data
  • Invalid object value(s)

Definition at line 2601 of file sc_basic.c.

References SC_MAXLEN.

◆ sc_basic_greg2jd()

cpl_error_code sc_basic_greg2jd ( long *  jd,
const int  year,
const int  month,
const int  day 
)

Convert Gregorian to Julian date

This function converts a sequence of year/month/day into a Julian date.

INPUT:

Parameters
yearGregorian year
monthGregorian month
dayGregorian day

OUTPUT:

Parameters
jdJulian date

ERRORS:

  • SC_ERROR_BADUSERINPUT

Definition at line 1297 of file sc_basic.c.

◆ sc_basic_initstring()

void sc_basic_initstring ( char *  str,
const long  n 
)

Initialise a string variable.

This function initialises a given string str of length n with "\0".

INPUT:

Parameters
nlength of string

OUTPUT:

Parameters
strstring
Returns
mothing

Definition at line 2060 of file sc_basic.c.

Referenced by sc_basic_abspath(), sc_overplot_spec(), sc_plot_double_spec(), sc_plot_hist(), sc_plot_single_spec(), and sc_plot_single_spec_with_lines().

◆ sc_basic_interpollin()

cpl_error_code sc_basic_interpollin ( const double *  x_out,
double *  y_out,
const long  n_out,
const double *  x_ref,
const double *  y_ref,
const long  n_ref,
const int  extrapolate 
)

Linear interpolation.

This function calculates the interpolated y-values y_out at the positions x_out with respect to the reference x/y pairs (x_ref / y_ref).

Note
If extrapolate is set to 1, points outside the range of the reference vectors will be extrapolated based on the first / last values in the reference vectors for the low / high end, respectively. Otherwise, out of bounds values are replaced with the outermost points.

INPUT:

Parameters
x_outDesired output x-spacing.
n_outLength of x_out / y_out.
x_refReference x-spacing.
y_refReference y-values at x_ref.
n_refLength of x_ref / y_ref.
extrapolateExtrapolation flag

OUTPUT:

Parameters
y_outRequested y-values at x_out.
Returns
CPL_ERROR_NONE on success, CPL_ERROR_DIVISION_BY_ZERO else.

Definition at line 2369 of file sc_basic.c.

Referenced by sc_contsub().

◆ sc_basic_isinteger()

cpl_boolean sc_basic_isinteger ( char *  str)

Check if string contains an integer only.

This function checks whether str contains a valid integer. A leading "+" or "-" is treated as a sign.

Note
Surrounding spaces are not treated.

INPUT:

Parameters
strString.

OUTPUT:

Returns
CPL_TRUE if str is integer, CPL_FALSE else.

Definition at line 2322 of file sc_basic.c.

◆ sc_basic_isnumber()

cpl_boolean sc_basic_isnumber ( char *  str)

Check if string contains number.

This function checks whether str contains a valid number. A leading "+" or "-" is treated as a sign. A single "." is identified as a decimal point. Finally, an "e" is accepted if an exponent follows this letter.

Note
Surrounding spaces are not treated.

INPUT:

Parameters
strstring

OUTPUT:

Returns
CPL_TRUE if str is number, CPL_FALSE else.

Definition at line 2237 of file sc_basic.c.

Referenced by sc_basic_readline().

◆ sc_basic_jd2greg()

cpl_error_code sc_basic_jd2greg ( int *  year,
int *  month,
int *  day,
const long  jd 
)

Convert Julian to Gregorian date

This function converts a Julian date into a sequence of year/month/day.

INPUT:

Parameters
jdJulian date

OUTPUT:

Parameters
yearGregorian year
monthGregorian month
dayGregorian day

ERRORS:

  • SC_ERROR_BADUSERINPUT

Definition at line 1334 of file sc_basic.c.

◆ sc_basic_linecount()

cpl_error_code sc_basic_linecount ( long *  n_lines,
FILE *  fp 
)

Count the lines in a file.

Count the number of lines in a file. File pointer is reset to beginning of file.

INPUT:

Parameters
fpfile pointer

OUTPUT:

Parameters
n_linesnumber of lines in file

ERRORS:

  • file not found if fseek() returns an error

Definition at line 831 of file sc_basic.c.

◆ sc_basic_mjd2fracyear()

double sc_basic_mjd2fracyear ( double  mjd)

Converts MJD into fractional year (return value, double precision).

Definition at line 179 of file sc_basic.c.

◆ sc_basic_planck()

cpl_error_code sc_basic_planck ( cpl_array *  bb,
const cpl_array *  wavelength,
const double  temp 
)

Calculate blackbody radiation.

INPUT:

Parameters
wavelengthwavelength array in micron (1e-6 metres).
temptemperature in [K]

OUTPUT:

Parameters
bbblackbody flux (i.e. PI*Intensity) in [ergs/cm2/s/a]

ERRORS:

  • wavelengths cannot be zero.

Definition at line 1058 of file sc_basic.c.

◆ sc_basic_readline()

cpl_error_code sc_basic_readline ( FILE *  stream,
scpar  par[],
int *  npar 
)

Reads a line from a file and returns the space- or tab-separated individual strings in an scpar structure. This structure also contains each string converted into integer and double precision floating point numbers. Comment lines marked by # and empty lines are not considered. In this case, the next line with data is read.

INPUT:

Parameters
streamname of stream (to be defined by fopen command)
pararray of scpar structures (to transfer parameter values)

OUTPUT:

Parameters
parscpar array that contains the read value(s) as character string ("c"), integer ("i"), or double precision floating point number ("d"). The different data types can be accessed by adding the corresponding suffixes c, i, or d to the name of the scpar structure.
nparfound number of parameter values (at one line)

ERRORS:

  • Invalid input parameter(s)
  • Unexpected file structure
  • Insufficient memory

In the case of problems, the default values "", 0, and 0.0 are used for the corresponding data types.

Definition at line 52 of file sc_basic.c.

References sc_basic_isnumber(), SC_MAXLEN, and SC_MAXPAR.

Referenced by sc_conv_ascii_read(), and sc_lines_readvarpar().

◆ sc_basic_rebin()

cpl_error_code sc_basic_rebin ( cpl_table *  outspec,
const char *  outlam,
const char *  outflux,
const cpl_table *  inspec,
const char *  inlam,
const char *  influx 
)

Rebins CPL table inspec with columns inlam and influx to wavelength given by outlam in CPL table outspec. The resulting rebinned flux is written to outflux in outspec. If outflux does not exist, it is created. The routine conserves integral of flux.

INPUT:

Parameters
outspecoutput spectrum with desired wavelength grid
outlamoutput wavelength column name
outfluxoutput flux column name
inspecinput spectrum
inlaminput wavelength column name
influxinput flux column name

OUTPUT:

Parameters
outspecrebinned input spectrum

ERRORS:

  • none

Definition at line 296 of file sc_basic.c.

Referenced by sc_contsub_identcont(), and sc_modsky_rebin().

◆ sc_basic_rhum2ppmv()

void sc_basic_rhum2ppmv ( double *  ppmv,
const double *  tem,
const double *  p,
const double *  hum 
)

Convert relative humidity to ppmv.

A single relative humidity value is converted to a volume mixing ratio using the prescription by Murphy and Koop, Review of the vapour pressure of ice and supercooled water for atmospheric applications, Q. J. R. Meteorol. Soc (2005), 131, pp. 1539-1565, for a given temperature and pressure.

Note
Valid Temperature range is 123K - 332K.

INPUT

Parameters
temTemperature in [Kelvin].
pPressure in [mbar].
humRelative humidity in [%].

OUTPUT

Parameters
ppmvVolume mixing ratio in ppmv.

Definition at line 870 of file sc_basic.c.

References SC_MAX, and SC_MIN.

◆ sc_basic_rhum2ppmv_old()

cpl_error_code sc_basic_rhum2ppmv_old ( const cpl_array *  temp,
const cpl_array *  pres,
const cpl_array *  rhum,
cpl_array *  ppmv 
)

Convert relative humidity to ppmv.

INPUT:

Parameters
temparray of temperatures in [K]
presarray of pressure values in [mB] or [hPa]
rhumarray of relative humidity values in [%]

OUTPUT:

Parameters
ppmvarray of ppmv values (absolute humidity)

Reference: Flatau,P.J., R.L.Walko, and W.R.Cotton, 1992: "Polynomial fits to saturation vapor pressure", J.Appl.Met., v31, pp1507-1513

Valid Temperature range is 183K - 273K (-90C - 0C).

ERRORS:

  • for pressure values = 0 a warning is printed and pressure is assumed = 1e-30.

Definition at line 935 of file sc_basic.c.

References SC_MIN.

◆ sc_basic_sortarr()

cpl_error_code sc_basic_sortarr ( cpl_array *  arr,
cpl_type  type 
)

Routine to sort a CPL array from lowest to largest value.

Array data gets sorted using qsrt algorithm.

Supported data types: CPL_TYPE_DOUBLE

Note
Array data gets changed on output (sorted)

INPUT:

Parameters
arrCPL array to sort
typeCPL data type

OUTPUT:

Parameters
arrsorted CPL array

ERRORS:

  • CPL_ERROR_DATA_NOT_FOUND: arr has size zero
  • CPL_ERROR_INVALID_TYPE: data type not supported

Definition at line 1871 of file sc_basic.c.

◆ sc_basic_strtrim()

char * sc_basic_strtrim ( char *  str)

Remove leading and trailing blanks from string.

This function removes all leading and trailing " " characters from str using isspace().

INPUT:

Parameters
strstring

OUTPUT:

Returns
string

Definition at line 2115 of file sc_basic.c.

◆ sc_basic_strtrim_inplace()

void sc_basic_strtrim_inplace ( char *  str)

Remove leading and trailing blanks from string.

This function removes all leading and trailing " " characters from str using isspace(). In contrast to sc_basic_strtrim(), the action is performed in place, i.e. the input gets overwritten.

INPUT & OUTPUT:

Parameters
strstring

OUTPUT:

Returns
nothing

Definition at line 2175 of file sc_basic.c.

◆ sc_basic_terminatestring()

void sc_basic_terminatestring ( char *  str)

Put "\0" at end of string.

This function places a "\0" at end of the input string.

Note
No checks are performed for writing beyond the boundary of allocated memory for the input string.

INPUT & OUTPUT:

Parameters
strstring

OUTPUT:

Returns
nothing

Definition at line 2086 of file sc_basic.c.