Skip to content

Commit

Permalink
Added asymetric transit spectra
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Kiefer committed Jun 30, 2023
1 parent bd6a436 commit ba6c896
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions gcm_toolkit/utils/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,8 @@ def calc_transit_spectrum(
pressure_0=None,
mass_frac=None,
clouds=None,
use_bruggemann=False
use_bruggemann=False,
asymmetric=False,
):
"""
Calculate the transit spectrum. This function avarages T-p profiles in
Expand Down Expand Up @@ -624,6 +625,8 @@ def calc_transit_spectrum(
use_bruggemann: bool, optional
If this flag is set to true, bruggemann mixing is used. This is
more accurate but takes much longer to calculate.
asymmetric : bool, optional
If true, the spectra will be calculated for the morning and evening limb speratly.
Returns
-------
Expand Down Expand Up @@ -685,23 +688,38 @@ def calc_transit_spectrum(

# get profile for each latitude and each terminator
spectra_list = []
output_list = []
del_lat = 180/len(self.dsi[c['lat']].values)
for i, lat in enumerate(self.dsi[c['lat']].values):
# add morning terminator spectra
spectra_list.append(self._get_1_transit_spectra([i, lat], [0, -90], mass_frac, gravity,
mmw, rplanet, pressure_0,
do_clouds, clouds, use_bruggemann))
output_list.append([(-90, (i+0.5)*del_lat - 90), spectra_list[-1]])

# add evening terminator spectra
spectra_list.append(self._get_1_transit_spectra([i, lat], [1, 90], mass_frac, gravity,
mmw, rplanet, pressure_0,
do_clouds, clouds, use_bruggemann))

# avarage over all profiles (area avaraged)
spectra = (np.asarray(spectra_list))**2/len(np.asarray(spectra_list))
spectra = np.sqrt(np.sum(spectra, axis=0))
output_list.append([(90, (i+0.5)*del_lat - 90), spectra_list[-1]])

# calcualte wavelengths in micron
wavelengths = 29979245800.0/self.prt.freq/1e-4

# calcualte spectra either for each limb seperatly or together
if not asymmetric:
spectra = (np.asarray(spectra_list))**2/len(np.asarray(spectra_list))
spectra = np.sqrt(np.sum(spectra, axis=0))
else:
spectra = np.zeros((2, len(wavelengths)))
for pos, spec in output_list:
if pos[0] == -90:
spectra[0, :] += (np.asarray(spec))**2/len(np.asarray(spectra_list))*2
else:
spectra[1, :] += (np.asarray(spec))**2/len(np.asarray(spectra_list))*2

spectra = np.sqrt(spectra)


# return the final spectra
return wavelengths, spectra
Expand Down

0 comments on commit ba6c896

Please sign in to comment.