Skip to content
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

Density docs #918

Merged
merged 15 commits into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/examples/densitycust.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ The values in the example here define a density profile that is dropping off wit
taken as the outer boundaries of grid cells and the density is
assumed to be uniform with each cell.

Inner Boundary
==============

The first velocity-density pair in a custom density file (given by index 0) specifies the velocity of the inner boundary approximation. The density associated with this velocity is the density within the inner boundary, which does not affect TARDIS spectra. Therefore, the first density (5.4869692e-10 in the example above) can be replaced by a placeholder value. The user can choose to both specify a custom density file AND specify v_inner_boundary or v_outer_boundary in the configuration YAML file for a TARDIS run. However, the YAML specified values must be within the velocity range specified in the custom density file, otherwise TARDIS will raise an error. When one of the YAML specified boundary velocities falls within the velocity range specified in the custom density file, then the boundary velocity is set equal to the number in the configuration YAML file. This has the effect of splitting a cell in the custom density file into two parts, a region within the boundary and a region outside the boundary.

It is always a good idea to check the model velocities and abundances used in a TARDIS simulation after it has been successfully run.

.. warning::

The example given here is to show the format only. It is not a
Expand Down
4 changes: 2 additions & 2 deletions tardis/io/schemas/model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ definitions:
description: file type
v_inner_boundary:
type: quantity
default: 0 km/s
default: -1 km/s
description: location of the inner boundary chosen from the model
v_outer_boundary:
type: quantity
default: inf km/s
default: -1 km/s
description: location of the inner boundary chosen from the model
required:
- filename
Expand Down
42 changes: 24 additions & 18 deletions tardis/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,23 @@ def no_of_raw_shells(self):
def v_boundary_inner(self):
if self._v_boundary_inner is None:
return self.raw_velocity[0]
if self._v_boundary_inner < 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you want to specify 0 * u.km/u.s

return self.raw_velocity[0]
return self._v_boundary_inner

@v_boundary_inner.setter
def v_boundary_inner(self, value):
if value is not None:
value = u.Quantity(value, self.v_boundary_inner.unit)
if value > self.v_boundary_outer:
raise ValueError('v_boundary_inner must not be higher than '
'v_boundary_outer.')
if value > self.raw_velocity[-1]:
raise ValueError('v_boundary_inner is outside of '
'the model range.')
if value <= self.raw_velocity[0]:
value = None
if value > 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again 0 * u.km / u.s

value = u.Quantity(value, self.v_boundary_inner.unit)
if value > self.v_boundary_outer:
raise ValueError('v_boundary_inner must not be higher than '
'v_boundary_outer.')
if value > self.raw_velocity[-1]:
raise ValueError('v_boundary_inner is outside of '
'the model range.')
if value < self.raw_velocity[0]:
raise ValueError('v_boundary_inner is outside of the model range.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is lower than the lowest shell in the model

self._v_boundary_inner = value
# Invalidate the cached cut-down velocity array
self._velocity = None
Expand All @@ -242,20 +245,23 @@ def v_boundary_inner(self, value):
def v_boundary_outer(self):
if self._v_boundary_outer is None:
return self.raw_velocity[-1]
if self._v_boundary_outer < 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again 0 * u.km/u.s

return self.raw_velocity[-1]
return self._v_boundary_outer

@v_boundary_outer.setter
def v_boundary_outer(self, value):
if value is not None:
value = u.Quantity(value, self.v_boundary_outer.unit)
if value < self.v_boundary_inner:
raise ValueError('v_boundary_outer must not be smaller than '
'v_boundary_inner.')
if value < self.raw_velocity[0]:
raise ValueError('v_boundary_outer is outside of '
'the model range.')
if value >= self.raw_velocity[-1]:
value = None
if value > 0:
value = u.Quantity(value, self.v_boundary_outer.unit)
if value < self.v_boundary_inner:
raise ValueError('v_boundary_outer must not be smaller than '
'v_boundary_inner.')
if value < self.raw_velocity[0]:
raise ValueError('v_boundary_outer is outside of '
'the model range.')
if value > self.raw_velocity[-1]:
raise ValueError('v_boundary_outer is outside of the model range.')
self._v_boundary_outer = value
# Invalidate the cached cut-down velocity array
self._velocity = None
Expand Down