Commit 37c7df97 authored by Domanski, Marian M.'s avatar Domanski, Marian M.
Browse files

add logging

parent 23ba1320
......@@ -7,6 +7,8 @@ import re
import numpy as np
import pandas as pd
import fluegg
def _load_ras_controller():
"""Load and return ras project
......@@ -51,6 +53,8 @@ def _load_ras_controller():
_ras_controller = _load_ras_controller()
logger = fluegg.logger.getChild(__name__)
def ras_controller_loaded():
"""Returns whether the RAS controller is loaded
......@@ -86,6 +90,11 @@ class RASProject:
def __init__(self, project_file_path):
class_name = self.__class__.__name__
self.logger = logger.getChild(class_name)
self.logger.debug("Initializing {} using project file {}".format(
class_name, project_file_path))
if _ras_controller is None:
raise ValueError("RAS controller not found")
......@@ -104,6 +113,7 @@ class RASProject:
current_plan_line = project_file_contents[1].strip()
current_plan_name = self._get_current_plan_name(
current_plan_line, current_project_file_path)
self.logger.debug("Current plan name: {}".format(current_plan_name))
plan_names = self.plan_names()
self._current_plan_number = plan_names.index(current_plan_name) + 1
......@@ -120,6 +130,8 @@ class RASProject:
else:
raise ValueError("Unknown units in project file")
self.logger.debug("Using {} units for project".format(self._ras_units))
self._current_river_number = 1
self._current_reach_number = 1
......@@ -208,8 +220,6 @@ class RASProject:
['Mann Wtd Chnl', 'Hydr Radius C'], axis=1)
# convert from RAS distances to FluEgg distances
number_of_cells = profile_data.shape[0]
dist_upstream = profile_data['CumlDistance_km'].values
dist_downstream = dist_upstream.max() - dist_upstream
cell_centers = 0.5 * \
......@@ -289,16 +299,22 @@ class RASProject:
def _ras_set_current_plan(self, plan_name):
"""Select RAS plan
"""
self.logger.debug("Setting current plan to {}".format(plan_name))
self._ras_controller.Plan_SetCurrent(plan_name)
self._ras_controller.Project_Save()
current_steady_file = self._ras_controller.CurrentSteadyFile()
self.logger.debug(
"Current steady file: {}".format(current_steady_file))
if os.path.isfile(current_steady_file):
self._plan_has_steady_file = True
else:
self._plan_has_steady_file = False
current_unsteady_file = self._ras_controller.CurrentUnSteadyFile()
self.logger.debug(
"Current unsteady file: {}".format(current_unsteady_file))
if os.path.isfile(current_unsteady_file):
self._plan_has_unsteady_file = True
else:
......
......@@ -436,9 +436,12 @@ class SimulationParameters:
with RASProject(d['hecras_path']) as rp:
try:
plan_name = d['hecras_plan']
rp.set_current_plan(plan_name)
profile_name = d['hecras_profile']
temperature = d['hecras_temperature']
self.logger.debug(
"Loading RAS data from plan {} ".format(plan_name)
+ "and profile {}".format(profile_name))
rp.set_current_plan(plan_name)
hydraulic_df = rp.hydraulic_model_data(
profile_name, temperature)
except:
......@@ -461,12 +464,16 @@ class SimulationParameters:
initial_position, simulation_clock, temperature=temperature)
# Transporter
self.logger.debug("Initializing {} {} transporter".format(
d['diffusivity'], d['direction']))
transporter_model = init_transporter(
simulation_clock, drift, d['diffusivity'], d['direction'])
# Simulation
self.logger.debug("Initializing simulation")
sim = Simulation(drift, transporter_model, simulation_clock)
self.logger.debug("Initialing hydraulic cells")
hydraulic_cells = \
RoughBottomSeriesOfHydraulicCells. \
from_data_frame(hydraulic_df,
......@@ -475,6 +482,7 @@ class SimulationParameters:
simulation=sim)
# Update sim & transporter with hydraulic cells
self.logger.debug("Setting hydraulic model")
sim.set_hydraulic_model(hydraulic_cells)
transporter_model.set_hydraulic_model(hydraulic_cells)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment