<html><body>
<p>1 new commit in yt:</p>
<p><a href="http://link.bitbucket.org/wf/click?upn=8USRlNyft-2BCzk2l4Ywl6gDx2lD2xxoS9E7MwXb2SMR-2BXcTD42YocdnOFkyGBVHOURVLnwI9JFXOUwxpRdpSKLAcIhiHmOPDaWGUUyUZVytk-3D_ll4ctv0L-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27DEHt2gxKoub5zCBtI5utbtd-2F-2BFINQ68mzCA01tLULX2Psfldcr0m7I1nKUJD2HZukZECTYZnO3b7cV7LTxdz0a3ff5elJ-2BqBGNKbJ6QPB-2F5geJ2qFF-2BFLOgtEt3WYotmwfwA6kRfWiF9PPTTMLgv5llmYjRnV0DAtaE-2BYale-2BXeLyWWsBao1Kn7-2BljkpEtAIQ-3D">https://bitbucket.org/yt_analysis/yt/commits/b00711a542af/</a> Changeset: b00711a542af Branch: yt User: ngoldbaum Date: 2016-03-23 20:50:32+00:00 Summary: Merged in chummels/yt (pull request #2044)</p>
<p>Adding observing_redshift kwarg to AbsorptionSpectrum Affected #: 1 file</p>
<p>diff -r a58aff2c0219d6abd66ffc128fd82b3c6fbde296 -r b00711a542af2b45a03e6aec8ee35ee83b0d3ccc yt/analysis_modules/absorption_spectrum/absorption_spectrum.py --- a/yt/analysis_modules/absorption_spectrum/absorption_spectrum.py +++ b/yt/analysis_modules/absorption_spectrum/absorption_spectrum.py @@ -119,8 +119,9 @@</p>
<pre> def make_spectrum(self, input_file, output_file=None,
line_list_file=None, output_absorbers_file=None,</pre>
<ul><li><p>use_peculiar_velocity=True,</p></li>
<li><p>subgrid_resolution=10, njobs="auto"):</p></li></ul>
<p>+ use_peculiar_velocity=True, + subgrid_resolution=10, observing_redshift=0., + njobs="auto"):</p>
<pre> """
Make spectrum from ray data using the line list.
</pre>
<p>@@ -130,33 +131,38 @@</p>
<pre> input_file : string or dataset
path to input ray data or a loaded ray dataset
output_file : optional, string</pre>
<ul><li><p>Option to save a file containing the wavelength, flux, and optical</p></li>
<li><p>depth fields. File formats are chosen based on the filename extension.</p></li>
<li><p>``.h5`` for hdf5, ``.fits`` for fits, and everything else is ASCII.</p></li></ul>
<p>+ Option to save a file containing the wavelength, flux, and optical + depth fields. File formats are chosen based on the filename + extension. ``.h5`` for hdf5, ``.fits`` for fits, and everything + else is ASCII.</p>
<pre>Default: None
output_absorbers_file : optional, string</pre>
<ul><li><p>Option to save a text file containing all of the absorbers and</p></li></ul>
<p>+ Option to save a text file containing all of the absorbers and</p>
<pre>corresponding wavelength and redshift information.
For parallel jobs, combining the lines lists can be slow so it
is recommended to set to None in such circumstances.
Default: None
use_peculiar_velocity : optional, bool
if True, include peculiar velocity for calculating doppler redshift</pre>
<ul><li><p>to shift lines. Requires similar flag to be set in LightRay</p></li></ul>
<p>+ to shift lines. Requires similar flag to be set in LightRay</p>
<pre>generation.
Default: True
subgrid_resolution : optional, int
When a line is being added that is unresolved (ie its thermal
width is less than the spectral bin width), the voigt profile of</pre>
<ul><li><p>the line is deposited into an array of virtual wavelength bins at</p></li>
<li><p>higher resolution. The optical depth from these virtual bins is</p></li>
<li><p>integrated and then added to the coarser spectral wavelength bin.</p></li>
<li><p>The subgrid_resolution value determines the ratio between the</p></li>
<li><p>thermal width and the bin width of the virtual bins. Increasing</p></li>
<li><p>this value yields smaller virtual bins, which increases accuracy,</p></li>
<li><p>but is more expensive. A value of 10 yields accuracy to the 4th</p></li></ul>
<p>+ the line is deposited into an array of virtual wavelength bins at + higher resolution. The optical depth from these virtual bins is + integrated and then added to the coarser spectral wavelength bin. + The subgrid_resolution value determines the ratio between the + thermal width and the bin width of the virtual bins. Increasing + this value yields smaller virtual bins, which increases accuracy, + but is more expensive. A value of 10 yields accuracy to the 4th</p>
<pre>significant digit in tau.
Default: 10</pre>
<p>+ observing_redshift : optional, float + This is the redshift at which the observer is observing + the absorption spectrum. + Default: 0</p>
<pre> njobs : optional, int or "auto"
the number of process groups into which the loop over
absorption lines will be divided. If set to -1, each</pre>
<p>@@ -183,6 +189,9 @@</p>
<pre>input_fields.append('redshift_eff')
field_units["velocity_los"] = "cm/s"
field_units["redshift_eff"] = ""</pre>
<p>+ if observing_redshift != 0.: + input_fields.append('redshift_dopp') + field_units["redshift_dopp"] = ""</p>
<pre> for feature in self.line_list + self.continuum_list:
if not feature['field_name'] in input_fields:
input_fields.append(feature['field_name'])</pre>
<p>@@ -204,8 +213,10 @@</p>
<pre> self._add_lines_to_spectrum(field_data, use_peculiar_velocity,
output_absorbers_file,
subgrid_resolution=subgrid_resolution,</pre>
<p>+ observing_redshift=observing_redshift,</p>
<pre>njobs=njobs)</pre>
<ul><li><p>self._add_continua_to_spectrum(field_data, use_peculiar_velocity)</p></li></ul>
<p>+ self._add_continua_to_spectrum(field_data, use_peculiar_velocity, + observing_redshift=observing_redshift)</p>
<pre> self.flux_field = np.exp(-self.tau_field)
</pre>
<p>@@ -223,20 +234,63 @@</p>
<pre> del field_data
return (self.lambda_field, self.flux_field)
</pre>
<ul><li><p>def _add_continua_to_spectrum(self, field_data, use_peculiar_velocity):</p></li></ul>
<p>+ def _apply_observing_redshift(self, field_data, use_peculiar_velocity, + observing_redshift): + """ + Change the redshifts of individual absorbers to account for the + redshift at which the observer sits. + + The intermediate redshift that is seen by an observer + at a redshift other than z=0 is z12, where z1 is the + observing redshift and z2 is the emitted photon's redshift + Hogg (2000) eq. 13: + + 1 + z12 = (1 + z2) / (1 + z1) + """ + if observing_redshift == 0.: + # This is already assumed in the generation of the LightRay + redshift = field_data['redshift'] + if use_peculiar_velocity: + redshift_eff = field_data['redshift_eff'] + else: + # The intermediate redshift that is seen by an observer + # at a redshift other than z=0 is z12, where z1 is the + # observing redshift and z2 is the emitted photon's redshift + # Hogg (2000) eq. 13: + # 1 + z12 = (1 + z2) / (1 + z1) + redshift = ((1 + field_data['redshift']) / \ + (1 + observing_redshift)) – 1. + # Combining cosmological redshift and doppler redshift + # into an effective redshift is found in Peacock's + # Cosmological Physics eqn 3.75: + # 1 + z_eff = (1 + z_cosmo) * (1 + z_doppler) + if use_peculiar_velocity: + redshift_eff = ((1 + redshift) * \ + (1 + field_data['redshift_dopp'])) – 1. + + return redshift, redshift_eff + + def _add_continua_to_spectrum(self, field_data, use_peculiar_velocity, + observing_redshift=0.):</p>
<pre>"""
Add continuum features to the spectrum.
"""</pre>
<p>+ # Change the redshifts of continuum sources to account for the + # redshift at which the observer sits + redshift, redshift_eff = self._apply_observing_redshift(field_data, + use_peculiar_velocity, observing_redshift) +</p>
<pre> # Only add continuum features down to tau of 1.e-4.
min_tau = 1.e-3
for continuum in self.continuum_list:
column_density = field_data[continuum['field_name']] * field_data['dl']</pre>
<p>+</p>
<pre># redshift_eff field combines cosmological and velocity redshifts
if use_peculiar_velocity:</pre>
<ul><li><p>delta_lambda = continuum['wavelength'] * field_data['redshift_eff']</p></li></ul>
<p>+ delta_lambda = continuum['wavelength'] * redshift_eff</p>
<pre>else:</pre>
<ul><li><p>delta_lambda = continuum['wavelength'] * field_data['redshift']</p></li></ul>
<p>+ delta_lambda = continuum['wavelength'] * redshift</p>
<pre>this_wavelength = delta_lambda + continuum['wavelength']
right_index = np.digitize(this_wavelength, self.lambda_field).clip(0, self.n_lambda)
left_index = np.digitize((this_wavelength *</pre>
<p>@@ -259,13 +313,19 @@</p>
<pre> pbar.finish()
def _add_lines_to_spectrum(self, field_data, use_peculiar_velocity,</pre>
<ul><li><p>output_absorbers_file, subgrid_resolution=10,</p></li>
<li><p>njobs=-1):</p></li></ul>
<p>+ output_absorbers_file, subgrid_resolution=10, + observing_redshift=0., njobs=-1):</p>
<pre>"""
Add the absorption lines to the spectrum.
"""</pre>
<ul><li><p># Widen wavelength window until optical depth falls below this tau</p></li>
<li><p># value at the ends to assure that the wings of a line have been</p></li></ul>
<p>+ + # Change the redshifts of individual absorbers to account for the + # redshift at which the observer sits + redshift, redshift_eff = self._apply_observing_redshift(field_data, + use_peculiar_velocity, observing_redshift) + + # Widen wavelength window until optical depth falls below this tau + # value at the ends to assure that the wings of a line have been</p>
<pre> # fully resolved.
min_tau = 1e-3
</pre>
<p>@@ -276,11 +336,11 @@</p>
<pre># redshift_eff field combines cosmological and velocity redshifts
# so delta_lambda gives the offset in angstroms from the rest frame</pre>
<ul><li><p># wavelength to the observed wavelength of the transition</p></li></ul>
<p>+ # wavelength to the observed wavelength of the transition</p>
<pre>if use_peculiar_velocity:</pre>
<ul><li><p>delta_lambda = line['wavelength'] * field_data['redshift_eff']</p></li></ul>
<p>+ delta_lambda = line['wavelength'] * redshift_eff</p>
<pre>else:</pre>
<ul><li><p>delta_lambda = line['wavelength'] * field_data['redshift']</p></li></ul>
<p>+ delta_lambda = line['wavelength'] * redshift</p>
<pre># lambda_obs is central wavelength of line after redshift
lambda_obs = line['wavelength'] + delta_lambda
# the total number of absorbers per transition</pre>
<p>@@ -308,7 +368,7 @@</p>
<pre> line['atomic_mass'])
# the actual thermal width of the lines</pre>
<ul><li><p>thermal_width = (lambda_obs * thermal_b /</p></li></ul>
<p>+ thermal_width = (lambda_obs * thermal_b /</p>
<pre> speed_of_light_cgs).convert_to_units("angstrom")
# Sanitize units for faster runtime of the tau_profile machinery.</pre>
<p>@@ -320,20 +380,20 @@</p>
<pre># When we actually deposit the voigt profile, sometimes we will
# have underresolved lines (ie lines with smaller widths than</pre>
<ul><li><p># the spectral bin size). Here, we create virtual wavelength bins</p></li>
<li><p># small enough in width to well resolve each line, deposit the</p></li>
<li><p># voigt profile into them, then numerically integrate their tau</p></li>
<li><p># values and sum them to redeposit them into the actual spectral</p></li></ul>
<p>+ # the spectral bin size). Here, we create virtual wavelength bins + # small enough in width to well resolve each line, deposit the + # voigt profile into them, then numerically integrate their tau + # values and sum them to redeposit them into the actual spectral</p>
<pre> # bins.
# virtual bins (vbins) will be:
# 1) <= the bin_width; assures at least as good as spectral bins
# 2) <= 1/10th the thermal width; assures resolving voigt profiles
# (actually 1/subgrid_resolution value, default is 1/10)</pre>
<ul><li><p># 3) a bin width will be divisible by vbin_width times a power of</p></li></ul>
<p>+ # 3) a bin width will be divisible by vbin_width times a power of</p>
<pre># 10; this will assure we don't get spikes in the deposited
# spectra from uneven numbers of vbins per bin</pre>
<ul><li><p>resolution = thermal_width / self.bin_width</p></li></ul>
<p>+ resolution = thermal_width / self.bin_width</p>
<pre> n_vbins_per_bin = 10**(np.ceil(np.log10(subgrid_resolution/resolution)).clip(0, np.inf))
vbin_width = self.bin_width.d / n_vbins_per_bin
</pre>
<p>@@ -341,17 +401,17 @@</p>
<pre>if (thermal_width < self.bin_width).any():
mylog.info(("%d out of %d line components will be " + \
"deposited as unresolved lines.") %</pre>
<ul><li><p>((thermal_width < self.bin_width).sum(),</p></li></ul>
<p>+ ((thermal_width < self.bin_width).sum(),</p>
<pre> n_absorbers))
# provide a progress bar with information about lines processsed
pbar = get_pbar("Adding line - %s [%f A]: " % \
(line['label'], line['wavelength']), n_absorbers)
</pre>
<ul><li><p># for a given transition, step through each location in the</p></li></ul>
<p>+ # for a given transition, step through each location in the</p>
<pre># observed spectrum where it occurs and deposit a voigt profile
for i in parallel_objects(np.arange(n_absorbers), njobs=-1):</pre>
<p>– +</p>
<pre># the virtual window into which the line is deposited initially
# spans a region of 2 coarse spectral bins
# (one on each side of the center_index) but the window</pre>
<p>@@ -362,12 +422,9 @@</p>
<pre> window_width_in_bins = 2
while True:</pre>
<ul><li><p>left_index = (center_index[i] – \</p></li>
<li><p>window_width_in_bins/2)</p></li>
<li><p>right_index = (center_index[i] + \</p></li>
<li><p>window_width_in_bins/2)</p></li>
<li><p>n_vbins = (right_index – left_index) * \</p></li>
<li><p>n_vbins_per_bin[i]</p></li></ul>
<p>+ left_index = (center_index[i] – window_width_in_bins/2) + right_index = (center_index[i] + window_width_in_bins/2) + n_vbins = (right_index – left_index) * n_vbins_per_bin[i]</p>
<pre># the array of virtual bins in lambda space
vbins = \</pre>
<p>@@ -384,8 +441,8 @@</p>
<pre># If tau has not dropped below min tau threshold by the
# edges (ie the wings), then widen the wavelength</pre>
<ul><li><p># window and repeat process.</p></li>
<li><p>if ((vtau[0] < min_tau) and (vtau[-1] < min_tau)):</p></li></ul>
<p>+ # window and repeat process. + if (vtau[0] < min_tau and vtau[-1] < min_tau):</p>
<pre> break
window_width_in_bins *= 2
</pre>
<p>@@ -421,8 +478,9 @@</p>
<pre> += EW[(intersect_left_index - left_index): \
(intersect_right_index - left_index)]
</pre>
<p>+</p>
<pre># write out absorbers to file if the column density of</pre>
<ul><li><p># an absorber is greater than the specified “label_threshold”</p></li></ul>
<p>+ # an absorber is greater than the specified “label_threshold”</p>
<pre># of that absorption line
if output_absorbers_file and \
line['label_threshold'] is not None and \</pre>
<p>@@ -436,15 +494,15 @@</p>
<pre>'wavelength': (lambda_0 + dlambda[i]),
'column_density': column_density[i],
'b_thermal': thermal_b[i],</pre>
<ul><li><p>‘redshift’: field_data['redshift'][i],</p></li>
<li><p>‘redshift_eff’: field_data['redshift_eff'][i],</p></li></ul>
<p>+ ‘redshift’: redshift[i], + ‘redshift_eff’: redshift_eff[i],</p>
<pre> 'v_pec': peculiar_velocity})
pbar.update(i)
pbar.finish()
del column_density, delta_lambda, lambda_obs, center_index, \
thermal_b, thermal_width, cdens, thermb, dlambda, \</pre>
<ul><li><p>vlos, resolution, vbin_width, n_vbins_per_bin</p></li></ul>
<p>+ vlos, resolution, vbin_width, n_vbins, n_vbins_per_bin</p>
<pre>comm = _get_comm(())
self.tau_field = comm.mpi_allreduce(self.tau_field, op="sum")</pre>
<p>Repository URL: <a href="http://link.bitbucket.org/wf/click?upn=8USRlNyft-2BCzk2l4Ywl6gDx2lD2xxoS9E7MwXb2SMR-2BI0v8SbQq-2B8-2FZaaHaJT85r_ll4ctv0L-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27DEHt2gxKoub5zCBtI5utbtd-2F-2BFINQ68mzCA01tLULX2BzcCzDMB5Fx9wwOYAUsUvFc-2Bo2H4rQoZKg9gSZPrUi7GqeIBdnfj4BTuMbDsawUlj9zidQ-2Fm6bCd7tWNKdC-2Fer5nNFOqzcV1dFRto-2BsbO9x6JVjFJMcBTo4-2F8r8CRXRX-2FKeI0BGXgRMysR55tEI06s-3D">https://bitbucket.org/yt_analysis/yt/</a></p>
<p>—</p>
<p>This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.</p>
<img src="http://link.bitbucket.org/wf/open?upn=ll4ctv0L-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27DEHt2gxKoub5zCBtI5utbtd-2F-2BFINQ68mzCA01tLULX2LJanFsgxdd2EjXEw1KVDpXcAq48FHUhzULwS-2B5XdVIu-2Fei5XHxUj4hmHK-2B2Lh4nT8ZqUdNItS-2B9GRM3n4tvUVpfVzc4VgBY1qeAZuC9K9AuOOhsbZ8BmBiHjzMmMn63LKZzo9quySMPcLdaSfEUsD0-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>