Skip to content

Commit

Permalink
in the process of getting the structure section with the specifc keyw…
Browse files Browse the repository at this point in the history
…ord to go - particularly important for paper1_tardis_configv1.yml
  • Loading branch information
wkerzendorf committed May 4, 2014
1 parent 6c69cfe commit cea21d3
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 57 deletions.
111 changes: 58 additions & 53 deletions tardis/data/tardis_config_definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,71 +116,76 @@ plasma:

model:
structure:
property_type : container-property
type:
property_type: container-declaration
containers: ['file', 'specific']
_file: ['filename','filetype']
+file: ['v_inner_boundary','v_outer_boundary']
_specific: ['specific-property']
filename:
property_type : container-property
type:
property_type: container-declaration
containers: ['file', 'specific']
_file: ['filename','filetype']
+file: ['v_inner_boundary','v_outer_boundary']
_specific: ['density', 'velocity']


filename:
property_type: string
default: None
mandatory: True
help: file name (with path) to structure model

filetype:
filetype:
property_type: string
default: None
mandatory: True
help: file type

#### there are only a handful of types available how do we validate that ####



v_inner_boundary:
property_type: quantity
default: 0 km/s
mandatory: False
help: location of the inner boundary chosen from the model

v_outer_boundary:
property_type: quantity
default: inf km/s
mandatory: False
help: location of the inner boundary chosen from the model

specific_property:
velocity:
property_type: quantity_range
default: None
mandatory: True
help: location of boundaries in the velocity field. There will be n-1 cells as this specifis both the inner and outer velocity components


density:
property_type: container-property
type:
property_type: container-declaration
containers: ['branch85_w7']

_branch85_w7: ['branch85_w7-property'] # list

branch85_w7-property:
time_0:
property_type: quantity
default: 19.9999584 s
mandatory: False
help: This needs no change - DO NOT TOUCH

density_coefficient:
property_type: float
default: 3e29
mandatory: False
help: This needs no change - DO NOT TOUCH


v_inner_boundary:
property_type: quantity
default: 0 km/s
mandatory: False
help: location of the inner boundary chosen from the model

v_outer_boundary:
property_type: quantity
default: inf km/s
mandatory: False
help: location of the inner boundary chosen from the model

# specific_property:
# velocity:
# property_type: quantity_range
# default: None
# mandatory: True
# help: location of boundaries in the velocity field. There will be n-1 cells as this specifis both the inner and outer velocity components

velocity:
property_type: quantity_range_sampled
default: None
mandatory: True
help: description of the boundaries of the shells

density:
property_type: container-property
type:
property_type: container-declaration
containers: ['branch85_w7']
+branch85_w7: ['time_0', 'density_coefficient']


time_0:
property_type: quantity
default: 19.9999584 s
mandatory: False
help: This needs no change - DO NOT TOUCH

density_coefficient:
property_type: float
default: 3e29`
mandatory: False
help: This needs no change - DO NOT TOUCH

abundances:
property_type: container-property
type:
Expand Down
4 changes: 2 additions & 2 deletions tardis/io/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def from_config_dict(cls, config_dict, atom_data=None, test_parser=False,


#Parsing supernova dictionary
validated_config_dict['supernova'] = parse_supernova_section(validated_config_dict['supernova'])
#validated_config_dict['supernova'] = parse_supernova_section(validated_config_dict['supernova'])

#Parsing the model section
model_section = validated_config_dict.pop('model')
Expand All @@ -718,7 +718,7 @@ def from_config_dict(cls, config_dict, atom_data=None, test_parser=False,
mean_densities = None
abundances = None


1/0
if 'file' in model_section:
v_inner, v_outer, mean_densities, abundances = parse_model_file_section(model_section.pop('file'),
validated_config_dict['supernova']['time_explosion'])
Expand Down
11 changes: 9 additions & 2 deletions tardis/io/config_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,16 +346,23 @@ def to_type(self, value):
quantity_split = value.strip().split()
quantity_value = quantity_split[0]
quantity_unit = ' '.join(quantity_split[1:])
if quantity_unit.strip() == 'log_lsun':
quantity_value = 10 ** (float(quantity_value) +
np.log10(constants.L_sun.cgs.value))
quantity_unit = 'erg/s'

return float(quantity_value) * units.Unit(quantity_unit)


class PropertyTypeQuantityRange(PropertyTypeQuantity):
@staticmethod
def _to_units(los):
if len(los) > 2:
loq = [(lambda x: (units.Quantity(float(x[0]), x[1])))(x.split()) for x in los[:-1]]
loq = [(lambda x: (units.Quantity(float(x[0]), x[1])))(x.split())
for x in los[:-1]]
else:
loq = [(lambda x: (units.Quantity(float(x[0]), x[1])))(x.split()) for x in los]
loq = [(lambda x: (units.Quantity(float(x[0]), x[1])))(x.split())
for x in los]
try:
_ = reduce((lambda a, b: a.to(b.unit)), loq)
loq = [a.to(loq[0].unit) for a in loq]
Expand Down

0 comments on commit cea21d3

Please sign in to comment.