00001
00002
00003
00004 #ifndef __proto_h__
00005 #define __proto_h__
00006
00007 #include <cstdio>
00008 #include <string>
00009 #include <map>
00010
00011 #include <gsl/gsl_rng.h>
00012 #include <gsl/gsl_randist.h>
00013 #include <gsl/gsl_vector.h>
00014 #include <gsl/gsl_blas.h>
00015 #include <gsl/gsl_multifit_nlin.h>
00016
00017
00018 #include "globals.h"
00019
00020 #include "Cvals.h"
00021
00022 #include "Matrix.h"
00023
00024 class CSprofile;
00025 class CPyColorPlot;
00026 class CPyScatterPlot;
00027
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031
00032
00033
00034
00035
00036 void read_nbody(int runnum, int filnum,
00037 char * prefix, int * npart, int * itype,
00038 float * r, float * v, float * tmass);
00039 void nbody_to_fortran(int ntot, int * itype, float * r, float * v, float * tmass);
00040 void allocate_memory_nbody(int ntot, int nk);
00041 void free_memory_nbody(void);
00042 void get_inputfile_nbody(char * prefix, int irun, int ifile, char * filename);
00043
00044
00045
00046
00047 bool read_simdata(void);
00048 void getsnaplocation(void);
00049
00050 void setup_io(void);
00051
00052 FILE* open_file_write(char* filename);
00053 FILE* open_file_read(char* filename);
00054 FILE* open_file_append(char* filename);
00055
00056 void read_parameterfile(void);
00057 void get_parameter_value(char *key, char *line);
00058
00059 void pgp_set_name_term(const char * name);
00060
00061 int get_int_file(FILE* file);
00062 double get_double_file(FILE* file);
00063 void get_string_file(FILE* file, char* string);
00064 int get_file_line(FILE* file, char* line);
00065
00066 int get_next_int(char *line);
00067 double get_next_double(char * line);
00068 void get_next_string(char* instring, char* outstring);
00069
00070 int get_int_stdin(void);
00071 double get_double_stdin(void);
00072 int get_doubles_file(FILE * file, int number, double results[]);
00073 void get_string_stdin(char* string);
00074 void get_stdin_line(char* line);
00075
00076 size_t my_fread(void *ptr, size_t size, size_t nmemb, FILE * stream);
00077
00078 double second(void);
00079 double timediff(double t0, double t1);
00080 void printTimingsInfo(const char* function_name, double dtime);
00081
00082 std::string getLocation();
00083
00084
00085
00086
00087
00088 void allocate_memory(void);
00089 void free_memory(void);
00090
00091 void read_snapshot(const int & inum_per_snap);
00092
00093 void pd_to_arrays();
00094
00095 void unit_conversion(void);
00096 void reordering(void);
00097
00098 void check_id_sanity(const char * input_fname);
00099
00100 void orbit_one_particle_(void);
00101
00102
00103
00104
00105
00106
00107 void general_stats(void);
00108
00109
00110
00111
00112
00113
00114 void pdata_to_file_(int* type, char names[][100]);
00115 void write_sph_variables_(void);
00116 void general_stats_(void);
00117 void read_parameterfile_(void);
00118 void read_nbody_(int * runnum, int * filnum,
00119 char * prefix,
00120 int * npart, int * itype, float * r, float * v, float * tmass);
00121 void total_stats_(double * totener, double * enerrad,
00122 double * totvrad, double * vradcut, double * masscut, double * kinEcut,
00123 double * sigma_pressure_cut, double * npartcut, double * avtemperaturecut,
00124 double * avrho_cut);
00125 void bindata_(void);
00126 void rad_proj_bin_(void);
00127 void make_cmd_(double * galaxy_age_offset);
00128 void plot_isochrone_(void);
00129 void make_map_(void);
00130
00131 int f_type_start_(int * type);
00132 int f_type_end_(int * type);
00133 int type_num_(int * type);
00134
00135 void do_fitting_(double * I0, double * I0err, double * r0,
00136 double * r0err, double * n, double * nerr,
00137 double * mu0, double * mu0err);
00138
00139 void get_conserved_quantities_(double * xcomtot,double * ycomtot,double * zcomtot,
00140 double * vxcomtot,double * vycomtot,double * vzcomtot,
00141 double * Lxtot,double * Lytot,double * Lztot,
00142 double * xcomtot_phys, double * ycomtot_phys, double * zcomtot_phys);
00143 void do_all_plotting_(void);
00144 void luminosity_function_(void);
00145 void setup_objects_(void);
00146 int start_gui_(void);
00147 void set_file_variables_(void);
00148 void dm_radial_data_(double * cv);
00149 void misc_(void);
00150 void convert_atot_(void);
00151
00152 void getsnaplocation_(void);
00153 void setup_io_(void);
00154
00155 void com_velocity_recenter_(void);
00156
00157
00158
00159 double get_sumfile_element(int run, int col, int file);
00160 void luminosity(float mass, float fe, double star[8],
00161 double age, double galage, int i);
00162 void readfile(int irun, int ifile, int & ipart, int * ifnrs);
00163 void calc(void);
00164
00165
00166
00167
00168
00169 void pdata_to_file(int type, char names[][100]);
00170 void get_row(int this_rownum, int type, char name[],
00171 int first_particle, int last_particle,
00172 int num_particles, float * arrays);
00173 void get_particle_range(int npart, int type,
00174 int * first_particle,int * last_particle,
00175 int * particle_number);
00176
00177
00178 void write_sph_variables(void);
00179
00180
00181
00182 void hpsort_gadget_1(unsigned long n);
00183 void hpsort_gadget_2(unsigned long n, int start);
00184
00185
00186
00187
00188 void total_stats(double * totener, double * enercut,
00189 double * totvrad, double * vradcut, double * masscut, double * kinEcut,
00190 double * sigma_pressure_cut, double * npartcut, double * avtemperaturecut,
00191 double * avrho_cut);
00192 double getRadialVelocity(float r[3], float v[3]);
00193
00194
00195
00196
00197 void binning(float values[], int n, double separators[], int nsep, int results[]);
00198
00199
00200
00201
00202
00203 void bindata(void);
00204
00205
00206
00207
00208
00209 void dm_radial_data(double & cv);
00210 void rad_proj_bin(void);
00211
00212
00213
00214
00215 void make_cmd(double galaxy_age_offset);
00216 void plot_isochrone(void);
00217 void set_labels_ranges(void);
00218
00219 void reallocate_isochrone_data(void);
00220 void pgp_isochrone_add(double age, double metallicity);
00221
00222 void init_cmd_stuff(void);
00223 void allocate_cmd_memory(void);
00224 int allocate_file_memory(void);
00225 void free_cmd_memory(void);
00226 void free_file_memory(void);
00227 void init_parameters(char files[][255]);
00228 void init_isochrones(void);
00229 void get_interpolated_isochrone(double age, double zmet);
00230 void get_nextvalues(int * iprev, int iage, int izmet, double mass,
00231 double * loglum, double * logtemp);
00232 void get_isochrone_values(int inum, double mass, double * loglum, double * logtemp);
00233 void add_ssp_to_ssps(int inum);
00234 int create_final_cmd(int inum);
00235 void sample_from_isochrone(int index, double * star_mass,
00236 double * loglum, double * logtemp);
00237
00238 void print_statusbar(void);
00239 void print_statusbar_update(int iend);
00240
00241 double get_total_weight(void);
00242 double get_weight(int ibin);
00243 void find_nextmass(int iage[2], int izmet[2], int ipl[2][2],
00244 int * ifnd, int * jfnd);
00245
00246 #ifdef GRIDDEDCMD
00247 void add_ssp_to_cmd_grid(double mass);
00248 #endif
00249
00250 void do_cmd_test(void);
00251
00252 #ifdef HAVE_PGPLOT
00253 void plot_cmd(int nstars,
00254 int age_range_restrict, int Z_range_restrict);
00255 #endif
00256 void print_cmd_ascii(int nstars);
00257
00258 void get_cmdres_dist(int i, int ixbox, int iybox,
00259 double * xval, double * dist);
00260
00261 int mass_max_pos(int age, int zmet);
00262
00263
00264
00265
00266
00267
00268
00269 int f_type_start(int type);
00270 int f_type_end(int type);
00271 int c_type_start(int type);
00272 int c_type_end(int type);
00273 int type_num(int type);
00274 void fill_header(int npart);
00275
00276
00277
00278
00279
00280 int expb_f (const gsl_vector * x, void *data,
00281 gsl_vector * f);
00282 int expb_df (const gsl_vector * x, void *data,
00283 gsl_matrix * J);
00284 int expb_fdf (const gsl_vector * x, void *data,
00285 gsl_vector * f, gsl_matrix * J);
00286 void do_fitting (double * I0, double * I0err, double * r0,
00287 double * r0err, double * n, double * nerr,
00288 double * mu0, double * mu0err);
00289 void print_profile_fit(double I0, double I0err,
00290 double r0, double r0err,
00291 double sn, double snerr,
00292 double mu0, double mu0err,
00293 gsl_multifit_function_fdf f,
00294 const CSprofile & sbprofile,
00295 int status, unsigned int iter,
00296 double * lum_arr);
00297
00298 double sersic_profile(const gsl_vector * x, double xvalue);
00299
00300
00301
00302
00303 void get_conserved_quantities(double * xcomtot,double * ycomtot,double * zcomtot,
00304 double * vxcomtot,double * vycomtot,double * vzcomtot,
00305 double * Lxtot,double * Lytot,double * Lztot,
00306 double * xcomtot_phys,double * ycomtot_phys,double * zcomtot_phys);
00307
00308
00309
00310
00311
00312 void do_all_plotting(void);
00313
00314 #ifdef HAVE_PGPLOT
00315 void add_all_plots(void);
00316
00317 #endif
00318
00319
00320
00321
00322
00323
00324 int start_gui(void);
00325 void fill_c_sumfile(void);
00326 void setup_objects(void);
00327 void set_file_variables(void);
00328 void misc(void);
00329 void convert_atot(void);
00330 double atot_integ(double a,void* param);
00331 void com_velocity_recenter(void);
00332
00333
00334
00335
00336 void luminosity_function(void);
00337 void print_lf_data(void);
00338 void add_ssp_to_lf(double mass);
00339 void init_lf_stuff(void);
00340
00341
00342
00343
00344
00345
00346 void getsingletemp_(int * iparticle, double * temperature);
00347 void luminosity_(double * dmass, double * dfe, double star[],
00348 double * age, double * galage, int * ipart);
00349 void bgetsbprofile_(double * time,double * Radmax,double radius[],
00350 double lgrid[], int * band_index, int * num_bins,
00351 int * iemp);
00352 void bconvtomagnarcsec_(double y[], int * num_bins, int * band_index);
00353 void flconvtomagnarcsec_(float y[], int * num_bins, int * band_index);
00354 double bcvaltma_(double * y, int * band_index);
00355 double get_sumfile_element_(int * row, int * col, int * file);
00356 void readfile_(int * irun, int * ifile, int * ipart, int ifnrs[]);
00357 void calc_(int ifnrs[]);
00358
00359
00360
00361
00362 Matrix<float> * make_map(int igridmethod, CPyColorPlot * pyplot = 0);
00363 Matrix<float> * make_scatter_data(CPyScatterPlot * pyplot = 0);
00364
00365
00366
00367 #ifdef __cplusplus
00368 }
00369 #endif
00370
00371
00372
00373 #endif