From e1228f354a5d6085d76098e26080ddbfcabb84d2 Mon Sep 17 00:00:00 2001 From: Anne Philipp <anne.philipp@univie.ac.at> Date: Sat, 2 Jun 2018 12:37:48 +0200 Subject: [PATCH] resolved loop import between controlfile and tools --- python/ControlFile.py | 4 +--- python/EcFlexpart.py | 12 ++++++------ python/GribTools.py | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/python/ControlFile.py b/python/ControlFile.py index 2fd438d..b4bf712 100644 --- a/python/ControlFile.py +++ b/python/ControlFile.py @@ -67,9 +67,6 @@ import os import inspect -# software specific module from flex_extract -from tools import get_list_as_string, my_error - # ------------------------------------------------------------------------------ # CLASS # ------------------------------------------------------------------------------ @@ -108,6 +105,7 @@ class ControlFile(object): @Return: <nothing> ''' + from tools import my_error # read whole CONTROL file with open(filename) as f: diff --git a/python/EcFlexpart.py b/python/EcFlexpart.py index 4d53874..bca2d1c 100644 --- a/python/EcFlexpart.py +++ b/python/EcFlexpart.py @@ -111,7 +111,7 @@ from gribapi import grib_set, grib_index_select, grib_new_from_index, grib_get,\ grib_index_release, grib_index_get # software specific classes and modules from flex_extract -from Gribtools import Gribtools +from GribTools import GribTools from tools import init128, to_param_id, silent_remove, product, my_error from MarsRetrieval import MarsRetrieval import disaggregation @@ -223,17 +223,17 @@ class EcFlexpart(object): # for gaussian grid retrieval self.glevelist = '1/to/' + c.level - if c.gaussian: + if hasattr(c, 'gaussian') and c.gaussian: self.gaussian = c.gaussian else: self.gaussian = '' - if c.expver: + if hasattr(c, 'expver') and c.expver: self.expver = c.expver else: self.expver = '1' - if c.number: + if hasattr(c, 'number') and c.number: self.number = c.number else: self.number = '0' @@ -871,7 +871,7 @@ class EcFlexpart(object): index_keys = ["date", "time", "step"] indexfile = c.inputdir + "/date_time_stepRange.idx" silent_remove(indexfile) - grib = Gribtools(inputfiles.files) + grib = GribTools(inputfiles.files) # creates new index file iid = grib.index(index_keys=index_keys, index_file=indexfile) @@ -1113,7 +1113,7 @@ class EcFlexpart(object): index_keys = ["date", "time", "step"] indexfile = c.inputdir + "/date_time_stepRange.idx" silent_remove(indexfile) - grib = Gribtools(inputfiles.files) + grib = GribTools(inputfiles.files) # creates new index file iid = grib.index(index_keys=index_keys, index_file=indexfile) diff --git a/python/GribTools.py b/python/GribTools.py index e79e768..c977d4a 100644 --- a/python/GribTools.py +++ b/python/GribTools.py @@ -51,7 +51,7 @@ from gribapi import grib_new_from_file, grib_is_defined, grib_get, \ # ------------------------------------------------------------------------------ # CLASS # ------------------------------------------------------------------------------ -class Gribtools(object): +class GribTools(object): ''' Class for GRIB utilities (new methods) based on GRIB API ''' @@ -61,7 +61,7 @@ class Gribtools(object): def __init__(self, filenames): ''' @Description: - Initialise an object of Gribtools and assign a list + Initialise an object of GribTools and assign a list of filenames. @Input: -- GitLab