-
Notifications
You must be signed in to change notification settings - Fork 52
Add brigtness calc to comp all orbits #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5a9429f
d1f285c
a0b603f
04e8638
2d9129b
017c8ce
03ea984
64045dd
48008b6
9b9055e
81f8388
ec07520
f308ed4
4c3f6cf
37bbb19
9dcd884
222dec7
1863981
2ca8419
17574f8
30248b6
d9ef026
aa16ef8
b37f60d
cd0c00a
1a069bb
7300015
914810d
683094a
1a6f24e
3234195
ac4ac17
3147d1b
f40b8db
062b1f3
ddd6820
4d14d01
f7c2208
8890f96
e70e82a
ffcaace
e009c18
8e9a8e2
4966b3d
ab6b40c
a539090
0f358a6
239aff1
7048e56
1f85c2e
e742b07
5cefd94
ec46224
1eac665
f43a5d6
a3298b6
c6f1ccb
0f4a4f6
6b7e534
26d7551
7b86edb
489baef
83ad686
f98c820
53e697e
3859a4a
98c29da
4c938ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| epoch,object,sep,sep_err,pa,pa_err,brightness,brightness_err | ||
| 54781,1,210.0,27.0,211.49,1.9,0.9,0.1 | ||
| 52953,1,413.0,22.0,34,4,0.6,0.2 | ||
| 55129,1,299.0,14.0,211,3,, | ||
| 55194,1,306.0,9.0,212.1,1.7,, | ||
| 55296,1,346.0,7.0,209.9,1.2,, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,10 +98,15 @@ def __init__( | |
| # List of index arrays corresponding to each rv for each body | ||
| self.rv = [] | ||
|
|
||
| # index arrays corresponding to brightness for each body | ||
| self.brightness = [] | ||
|
|
||
| self.fit_astrometry = True | ||
| radec_indices = np.where(self.data_table["quant_type"] == "radec") | ||
| seppa_indices = np.where(self.data_table["quant_type"] == "seppa") | ||
|
|
||
| brightness_indices = np.where(self.data_table["quant_type"] == "brightness") | ||
|
|
||
| if len(radec_indices[0]) == 0 and len(seppa_indices[0]) == 0: | ||
| self.fit_astrometry = False | ||
| rv_indices = np.where(self.data_table["quant_type"] == "rv") | ||
|
|
@@ -140,6 +145,7 @@ def __init__( | |
| np.intersect1d(self.body_indices[body_num], seppa_indices) | ||
| ) | ||
| self.rv.append(np.intersect1d(self.body_indices[body_num], rv_indices)) | ||
| self.brightness.append(np.intersect1d(self.body_indices[body_num], brightness_indices)) | ||
|
|
||
| # we should track the influence of the planet(s) on each other/the star if: | ||
| # we are not fitting massless planets and | ||
|
|
@@ -302,6 +308,7 @@ def __init__( | |
|
|
||
| self.param_idx = self.basis.param_idx | ||
|
|
||
|
|
||
| def save(self, hf): | ||
| """ | ||
| Saves the current object to an hdf5 file | ||
|
|
@@ -365,6 +372,11 @@ def compute_all_orbits(self, params_arr, epochs=None, comp_rebound=False): | |
| vz (np.array of float): N_epochs x N_bodies x N_orbits array of | ||
| radial velocities at each epoch. | ||
|
|
||
| brightness (np.array of float): N_epochs x N_bodies x N_orbits of | ||
| photometric brightness predictions, assuming a Lambertian disk | ||
| reflection law, at each epoch. Normalized so that brightness=1 | ||
| at maximum. | ||
|
|
||
| """ | ||
|
|
||
| if epochs is None: | ||
|
|
@@ -386,6 +398,7 @@ def compute_all_orbits(self, params_arr, epochs=None, comp_rebound=False): | |
| dec_perturb = np.zeros((n_epochs, self.num_secondary_bodies + 1, n_orbits)) | ||
|
|
||
| vz = np.zeros((n_epochs, self.num_secondary_bodies + 1, n_orbits)) | ||
| brightness_out = np.zeros((n_epochs, self.num_secondary_bodies + 1, n_orbits)) | ||
|
|
||
| # mass/mtot used to compute each Keplerian orbit will be needed later to compute perturbations | ||
| if self.track_planet_perturbs: | ||
|
|
@@ -489,16 +502,33 @@ def compute_all_orbits(self, params_arr, epochs=None, comp_rebound=False): | |
| tau_ref_epoch=self.tau_ref_epoch, | ||
| ) | ||
|
|
||
| tanom, eanom = kepler.times2trueanom_and_eccanom(sma, epochs, mtot, ecc, tau, tau_ref_epoch=self.tau_ref_epoch) | ||
|
|
||
|
|
||
| R = (sma*(1-ecc**2))/(1+ecc*np.cos(tanom)) | ||
|
|
||
| z = (R)*(-np.cos(argp)*np.sin(inc)*np.sin(tanom)-np.cos(tanom)*np.sin(inc)*np.sin(argp)) | ||
|
|
||
| B = np.arctan2(-R, z)+ np.pi | ||
|
|
||
| alpha = (1/np.pi)*(np.sin(B)+(np.pi-B)*np.cos(B)) | ||
|
|
||
| albedo = 0.5 # NOTE: we're only fitting relative changes in brightness, so the actual value of albedo doesn't matter | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we're fitting relative changes, how will that work? Are we going to analytically marginalize over some linear scale factor term in the future in lnlike?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great question. Noting for posterity here our offline conversation that it indeed makes sense to fit a linear scale factor. I just raised issue #416 in response to this comment. |
||
| brightness = albedo*alpha/R**2 | ||
|
Comment on lines
+505
to
+517
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe not for this PR, but we should make this part of code customizable: we can replace it with a user-provided function or class, so that we can handle custom and non-Lambertian models. We could refactor this into a separate function here or make an issue to do it.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed! I raised issue #417 to keep track. Let's do it in a future PR. |
||
|
|
||
|
|
||
| # raoff, decoff, vz are scalers if the length of epochs is 1 | ||
| if len(epochs) == 1: | ||
| raoff = np.array([raoff]) | ||
| decoff = np.array([decoff]) | ||
| vz_i = np.array([vz_i]) | ||
| brightness = np.array([brightness]) | ||
|
|
||
| # add Keplerian ra/deoff for this body to storage arrays | ||
| ra_kepler[:, body_num, :] = np.reshape(raoff, (n_epochs, n_orbits)) | ||
| dec_kepler[:, body_num, :] = np.reshape(decoff, (n_epochs, n_orbits)) | ||
| vz[:, body_num, :] = np.reshape(vz_i, (n_epochs, n_orbits)) | ||
| brightness_out[:, body_num, :] = np.reshape(brightness, (n_epochs, n_orbits)) | ||
|
|
||
| # vz_i is the ith companion radial velocity | ||
| if self.fit_secondary_mass: | ||
|
|
@@ -572,11 +602,12 @@ def compute_all_orbits(self, params_arr, epochs=None, comp_rebound=False): | |
| raoff[:, :, bad_orbits] = np.inf | ||
| deoff[:, :, bad_orbits] = np.inf | ||
| vz[:, :, bad_orbits] = np.inf | ||
| return raoff, deoff, vz | ||
| brightness_out[:, :, bad_orbits] = np.inf | ||
| return raoff, deoff, vz, brightness_out | ||
| else: | ||
| return raoff, deoff, vz | ||
| return raoff, deoff, vz, brightness_out | ||
| else: | ||
| return raoff, deoff, vz | ||
| return raoff, deoff, vz, brightness_out | ||
|
|
||
| def compute_model(self, params_arr, use_rebound=False): | ||
| """ | ||
|
|
@@ -611,7 +642,7 @@ def compute_model(self, params_arr, use_rebound=False): | |
| standard_params_arr, comp_rebound=True | ||
| ) | ||
| else: | ||
| raoff, decoff, vz = self.compute_all_orbits(standard_params_arr) | ||
| raoff, decoff, vz, brightness = self.compute_all_orbits(standard_params_arr) | ||
|
|
||
| if len(standard_params_arr.shape) == 1: | ||
| n_orbits = 1 | ||
|
|
@@ -663,6 +694,11 @@ def compute_model(self, params_arr, use_rebound=False): | |
| model[self.rv[body_num], 0] = vz[self.rv[body_num], body_num, :] | ||
| model[self.rv[body_num], 1] = np.nan | ||
|
|
||
| # Brightness | ||
| if len(self.brightness[body_num]) > 0: | ||
| model[self.brightness[body_num], 0] = brightness[self.brightness[body_num], body_num, :] | ||
| model[self.brightness[body_num], 1] = np.nan | ||
|
|
||
| # if we have abs astrometry measurements in the input file (i.e. not | ||
| # from Hipparcos or Gaia), add the parallactic & proper motion here by | ||
| # calling AbsAstrom compute_model | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing docstring