Skip to content

Commit

Permalink
added spherical harmonics model
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlouden committed Aug 28, 2016
1 parent 83b539a commit b602f06
Show file tree
Hide file tree
Showing 18 changed files with 3,604 additions and 26 deletions.
1 change: 1 addition & 0 deletions c_src/_web.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "web.h"
#include "pyutil.h"
#include "blackbody.h"
#include "brightness_maps.h"
#include <stdio.h>

static char module_docstring[] =
Expand Down
35 changes: 35 additions & 0 deletions c_src/brightness_maps.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "math.h"
#include "harmonics.h"
#include "legendre_polynomial.h"
#include <stdlib.h>
#include <stdio.h>

double Uniform_b(double p_bright){
return p_bright/M_PI;
Expand Down Expand Up @@ -58,4 +62,35 @@ double zhang_2016(double lat, double lon, double xi, double T_n, double delta_T)
}

return T;
}

double spherical(double lat, double lon, double *a){
double x_vec[1];
double fx2;
double *fx2_vec;
double theta = (M_PI/2.0) - lat;
double phi = M_PI + lon;

int orders = a[0];

int k = 1;

x_vec[0] = cos(theta);

double val = 0.0;
for (int l = 0; l < (orders); ++l) {

for (int m = 0; m < (l+1); ++m) {
fx2_vec = pm_polynomial_value(1,l,m,x_vec);
fx2 = fx2_vec[l];
free ( fx2_vec );

val = val + a[k]*cos(m*phi)*fx2;

k = k +1;
}
}

return val;

}
3 changes: 2 additions & 1 deletion c_src/brightness_maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ double Uniform_b(double p_bright);
double Uniform_T(double T_bright);
double Two_b(double la, double lo, double p_day, double p_night);
double Two_T(double la, double lo, double p_day, double p_night);
double zhang_2016(double lat, double lon, double zeta, double T_n, double delta_T);
double zhang_2016(double lat, double lon, double zeta, double T_n, double delta_T);
double spherical(double lat, double lon, double *a);
13 changes: 13 additions & 0 deletions c_src/generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ void map_model(double **planet,int n_layers,double lambda0, double phi0, double
planet[0][16] = bb_flux(l1,l2,point_T,n_bb_seg);
}

if(brightness_model == 5){
double p_t_bright = spherical(la,lo,brightness_params);
planet[0][16] = p_t_bright;
planet[0][17] = 0.0;
}


for (int k = 1; k < pow(n_layers,2); ++k) {

if(k == 0){
Expand Down Expand Up @@ -115,6 +122,12 @@ void map_model(double **planet,int n_layers,double lambda0, double phi0, double
planet[k][17] = point_T;
planet[k][16] = bb_flux(l1,l2,point_T,n_bb_seg);
}
if(brightness_model == 5){
double p_t_bright = spherical(la,lo,brightness_params);
planet[k][16] = p_t_bright;
planet[k][17] = 0.0;
}

// limb darkening

mu = sqrt(1 - pow(R_mid,2));
Expand Down
Empty file added c_src/harmonics.c
Empty file.
Empty file added c_src/harmonics.h
Empty file.

0 comments on commit b602f06

Please sign in to comment.