Browse Source

scenario: fixing symlinking

dev-scenario
miili 1 year ago
parent
commit
d5688b351d
  1. 49
      src/scenario.py

49
src/scenario.py

@ -33,6 +33,7 @@ class GrondScenario(object):
self.observations = observations
self.rebuild = False
self._scenario = None
def get_gf_stores_dir(self):
return op.join(self.project_dir, 'gf_stores')
@ -52,7 +53,8 @@ class GrondScenario(object):
@property
def stores_wanted(self):
return set([obs.store_id for obs in self.observations])
target_generators = self.get_scenario().target_generators
return set([t.store_id for t in target_generators])
def symlink_gfstores(self, engine):
logger.info('Symlinking Green\'s function stores...')
@ -84,27 +86,29 @@ class GrondScenario(object):
self.config_fn = filename
def get_scenario(self):
if self.rebuild:
scenario_file = op.join(self.project_dir, 'data', 'scenario',
'scenario.yml')
sc = guts.load(filename=scenario_file)
return sc
if not self.observations:
raise AttributeError('No observations set,'
' use .add_observation(Observation)'
' to add one!')
if not self.problem:
raise AttributeError('No Source Problem set'
' use .set_problem(Problem) to set one.')
return scenario.ScenarioGenerator(
center_lat=self.center_lat,
center_lon=self.center_lon,
radius=self.radius,
target_generators=[obs.get_scenario_target_generator()
for obs in self.observations],
source_generator=self.problem.get_scenario_source_generator())
if not self._scenario:
if self.rebuild:
scenario_file = op.join(self.project_dir, 'data', 'scenario',
'scenario.yml')
self._scenario = guts.load(filename=scenario_file)
else:
if not self.observations:
raise AttributeError('No observations set,'
' use .add_observation(Observation)')
if not self.problem:
raise AttributeError('No Source Problem set,'
' use .set_problem(Problem).')
self._scenario = scenario.ScenarioGenerator(
center_lat=self.center_lat,
center_lon=self.center_lon,
radius=self.radius,
target_generators=[obs.get_scenario_target_generator()
for obs in self.observations],
source_generator= self.problem.get_scenario_source_generator()) # noqa
return self._scenario
def create_scenario(
self, force=False, interactive=True, gf_store_superdirs=None):
@ -132,7 +136,6 @@ class GrondScenario(object):
scenario.ensure_gfstores(
interactive=interactive)
self.symlink_gfstores(engine1)
engine2 = gf.LocalEngine(

Loading…
Cancel
Save