1 /*
2   sky_model.h
3   sky_model
5   Created by Jayant Murthy on 01/10/12.
6   Copyright (c) 2012 Jayant Murthy. All rights reserved.
7 */
9 #ifndef sky_model_sky_model_h
10 #define sky_model_sky_model_h
13 /***************************************************************************
14  * This File is a part of the UVS Zodiacal light model software            *
15  *   Copyright (C) 2007         by The Tauvex Software Team,               *
16  *                              Indian Institute of Astrophysics,          *
17  *                              Bangalore 560 034                          *
18  *                              tauvex_AT_iiap.res.in                      *
19  *                                                                         *
20  *   This program is free software; you can redistribute it and/or modify  *
21  *   it under the terms of the GNU General Public License as published by  *
22  *   the Free Software Foundation; either version 2 of the License, or     *
23  *   (at your option) any later version.                                   *
24  *                                                                         *
25  *   This program is distributed in the hope that it will be useful,       *
26  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
27  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
28  *   GNU General Public License for more details.                          *
29  *                                                                         *
30  *   You should have received a copy of the GNU General Public License     *
31  *   along with this program; if not, write to the                         *
32  *   Free Software Foundation, Inc.,                                       *
33  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
34  ***************************************************************************/
35 /*--------------------------------------------------------------------------
36  uvs_zodiacal_model.h: Contains various definitions for
37  uvs_zodiacal_model.c
38  URL: tauvex.iiap.res.in/tauwiki/
40  Revision history:       ----
41  Reks, 25th September, 2007
42  1. Created this file
43  2. Shifted all #define statements from main to here
44  *---------------------------------------------------------------------------*/
46 /*Include files*/
47 #include <stdio.h>
48 #include <stdlib.h>
49 #include <math.h>
50 #include <string.h>
51 #include <fitsio.h>
52 #include "parse_par.h"
55 /*Define program specific parameters*/
56 #define BIGERR 1e32
58 /*Physical Constants*/
59 #define PI            3.141592653589793238462643
60 #define RADEG         0.017453292       /* Conversion from degrees to radians */
61 #define DEGRAD(x)    ((x)*PI/180.)
62 #define RADDEG(x)    ((x)*180./PI)
63 #define PCinAU       206265
64 #define PCinCM(x)    (3.085678E+18 * (x)) /* Converts from Parsec to cm */
65 #define eRStar       0.0       /* Average Stellar radius (in cm ) */
66 #define rd           0        /* distance to the reference plane from earth(in PC)*/
67 #define ERG_TO_PHOT  50306871.92
69 /*Program specific variables*/
70 #define HIP_DELIM           "|"
71 #define HIP_MAIN_REC_LEN    1000
72 #define MAX_FILE_LENGTH     80
73 #define N_CASTELLI_SPECTRA  1121
74 #define N_CASTELLI_MODELS   76
75 #define ZOD_XSIZE           19              /*Number of rows from Leinert */
76 #define ZOD_YSIZE           11              /* Number of Columns */
77 #define MAX_BKGD_ELEM       100000          /*Number of elements in bkgd file*/
78 #define NSTARS              120000          /*Number of stars in Catalog*/
79 #define MAX_SPEC_ELEM       100000          /*Maximum number of spectral elements*/
81 /*Default file names*/
82 #define PARAM_FILE "diffuse_initparams.txt"         /* input params */
83 #define DEFAULT_ZOD_FILE "leinert_dist.txt"         /* Leinert's model */
84 #define DEFAULT_ZOD_SPEC_FILE "zodiacal_spec.txt"   /* Solar Spectrum */
85 #define DEFAULT_OUT_FILE "diffuse_output.txt"       /* Output file */
87 /*Structures*/
88 struct WCS_HEAD {
89         double xrefval;
90         double yrefval;
91         double xrefpix;
92         double yrefpix;
93         double xinc;
94         double yinc;
95         double rot;
96     double angsize;
97         char coordtype[5];
98 };
100 struct BKGD_DATA{
101     double *ra;
102     double *dec;
103     double *x;
104     double *y;
105     double *z;
106     double *bkgd;
107     double *err;
108     int npoints;
109 };
111 struct ZOD_DATA{
112     float *zod_dist;
113     float *table_ecl; /*heliocliptic longitude*/
114     float *table_beta;/*ecliptic latitude*/
115 };
116 struct INP_PAR {
117     char par_file[MAX_FILE_LENGTH];
118     char out_file[MAX_FILE_LENGTH];
119     char wave_file[MAX_FILE_LENGTH];
120     char sigma_file[MAX_FILE_LENGTH];
121     char location_file[MAX_FILE_LENGTH];
122     char hipparcos_file[MAX_FILE_LENGTH];
123     char HIPFile[MAX_FILE_LENGTH];
124     char MKSpFile[MAX_FILE_LENGTH];
125     char castelli_file[MAX_FILE_LENGTH];
126     char out_dir[MAX_FILE_LENGTH];
127     char zod_file[MAX_FILE_LENGTH];
128     char zod_spec[MAX_FILE_LENGTH];
129     char bkgd_model[MAX_FILE_LENGTH];
130     char bkgd_spec[MAX_FILE_LENGTH];
131     char filter_file[MAX_FILE_LENGTH];
132     float hour;
133     float day;
134     float month;
135     float year;
136     float ang_limit;
137     float csc_law;
138     float dc_level;
139     int zod_inc;
140     int gal_inc;
141     int star_inc;
143 };
145 /*Definition of the data structure for Hipparcos stars*/
146 struct STARS
148     long   HIP_NO;             /* Hipparcos Catalog No             */
149     long   HD_NO;              /* HD Number                        */
150     char   sp_type[12];        /* Spectral Type.                   */
151     float  distance;           /* Distance to the Star (in pc)     */
152     float  ra;                 /* Right Ascension (2000)           */
153     float  dec;                /* Declination                      */
154     double x;                  /* X Cartesian Coordinate.          */
155     double y;                  /* Y Cartesian Coordinate.          */
156     double z;                  /* Z Cartesian Coordinate.          */
157     float  B_mag;              /* B mag of the star                */
158     float  V_mag;              /* V mag of the star                */
159     float  gl;                 /* Galactic longitude l             */
160     float  gb;                 /* Galactic latitude  b             */
161     int  temperature;          /* index of temperature of the star */
162     int nstars;                /*Number of elements*/
163     float scale;               /*Scale factor for stellar bightness*/
164     float ebv;                 /*E(B-V)*/
165     float flux_at_earth;       /*Counts from star at the Earth*/
166 };
168 struct SPECTRA
170     char filename[MAX_FILE_LENGTH];
171     float *spectrum;
172     float *wavelength;
173     float nelements;
174 };
177 /*Function Definitions*/
178 void EC_to_EQ(double coord[2]);
179 void EQ_to_EC(double coord[2]);
180 void GA_to_EQ(double coord[2]);
181 void GA_to_EC(double coord[2]);
182 void EC_to_GA(double coord[2]);
183 void EQ_to_GA(double coord[2]);
184 void coord_to_string(double coord[2], char s_coord[2][40]);
185 int CALC_BKGD_FLUX(struct WCS_HEAD wcs_in, long naxes[2], float *data,
186                    float *var, float ang_limit, float csc_law,
187                    struct BKGD_DATA bkgd);
188 void SUN_RA_DEC(float t_ut, float day, float month,
189                 float year, double *ra, double *dec);
190 int CALC_ZOD_FLUX(struct ZOD_DATA zodi,
191                                                   float hour, float day, float month, float year,
192                                                   long *naxes,
193                                                   float *zod_data, struct WCS_HEAD wcs_in);
194 int SPECT_READ(float *wave, float *spec, char *spec_file);
195 struct ZOD_DATA ZOD_DIST_READ(char *zod_file);
196 int READ_PARAMS(struct INP_PAR *inp_par, struct WCS_HEAD *wcs_in);
197 void FITS_WRITE_FILE(char file_out[FLEN_FILENAME], struct WCS_HEAD wcs_out,
198                                          long naxes[2], float *data, char gal[3]);
199 void GEN_DEFAULT_PARAMS();
200 struct BKGD_DATA READ_GAL_BKGD(char bkgd_file[FLEN_FILENAME]);
201 int CONV_EQ_TO_GAL(double ra, double dec, double *gl, double *gb);
202 int READ_CROSS_SEC(struct SPECTRA line, struct INP_PAR inp_par);
203 struct INP_PAR READ_INPUT_PARAMETERS(int argc, char *argv[]);
204 int HIP_READ_LINE(FILE *star_file, struct STARS *line);
205 int READ_CASTELLI_SPECTRA(char *, struct SPECTRA *);
206 int GET_STAR_TEMP(struct STARS *);
207 int GET_SCALE_FACTOR(struct STARS *hipstars,
208                      struct SPECTRA *stellar_spectra);
209 float CALC_FLUX(struct STARS *hipstars, struct INP_PAR files,
210                 struct SPECTRA cross_sec,
211                 struct SPECTRA *stellar_spectra,
212                 struct SPECTRA filters,
213                 float gl, float gb, float dist, float lambda,
214                 float ave_sigma);
215 float CALC_SCALE_FACTOR(struct SPECTRA x, struct SPECTRA y);
216 int READ_HIPPARCOS_CAT(struct INP_PAR inp_par, struct SPECTRA *stellar_spectra,
217                        struct STARS *hipstars, struct SPECTRA filter_wave);
222 #endif
224 #ifndef CADSDATA
225 #define CADSDATA "./"
226 #endif