Commit 7c01dd4a authored by Sasa Zhang's avatar Sasa Zhang
Browse files

made some changes to the comments and indentations

parent 71012e88
......@@ -50,6 +50,7 @@ import os
import sys
from scripts.copy_msgid_msgstr import copy_msgid_msgstr
sTemporaryDirectory = '/tmp/metro_translation/'
......
......@@ -216,7 +216,7 @@ class Metro_preprocess_qa_qc_observation(Metro_preprocess):
numpy.where, nonzero, arange
metro_date.get_day, get_hour, get_minute
metro_data.del_matrix_row
metro_logger.print_message
metro_logger.print_message
Description: Check if the time of the observation are in order.
Cut the information that are spaced by more than 240 minutes.
......@@ -319,8 +319,8 @@ class Metro_preprocess_qa_qc_observation(Metro_preprocess):
numpy.where,
metro_data.set_attribute
Description: Set the attributes in road_data_collection to tell if
the values are in accordance of the criterium.
Description: Set the attributes in road_data_collection to tell if the values
are in accordance of the criterium.
"""
npSST = ro_controlled_data.get_matrix_col('SST')
npAT = ro_controlled_data.get_matrix_col('AT')
......
#!/usr/bin/env python
"""
SUNRISET.C - computes Sun rise/set times, start/end of twilight, and the length of the day at any date and latitude
......@@ -324,11 +322,6 @@ class Sun:
(in degrees, 1 hr = 15 degr) is equal to the Sun's mean longitude plus/minus 180 degrees!
(if we neglect aberration, which amounts to 20 seconds of arc or 1.33 seconds of time)
"""
# Sidtime at 0h UT = L (Sun's mean longitude) + 180.0 degr
# L = M + w, as defined in sunpos(). Since I'm too lazy to
# add these numbers, I'll let the C compiler do it for me.
# Any decent C compiler will add the constants at compile
# time, imposing no runtime or code overhead.
sidtim0 = self.revolution((180.0 + 356.0470 + 282.9404) + (0.9856002585 + 4.70935E-5) * d)
return sidtim0
......
......@@ -220,11 +220,7 @@ class W3CDate:
if self.dateMiniTuple is None:
raise TypeError("date has not been specified")
self.dateSecs = time.mktime(self.dateMiniTuple)
# time.mktime's conversion is affected by the local timezone, which we
# don't necessarily want (because we may be representing any timezone).
# So, correct for the difference between the local timezone and desired
# timezone. If no specific timezone is set, we leave things at the local
# timezone.
if self.timezone is not None:
if self.dateMiniTuple[8] != 0 and time.localtime(self.dateSecs)[8] == 1 and time.daylight:
self.dateSecs = self.dateSecs - time.altzone
......
......@@ -39,14 +39,12 @@ from toolbox import metro_xml
from toolbox import metro_util
# Set encoding to latin-1. Must reload the sys module because the
# setdefaultencoding is deleted after the initialization of python.
# See http://masl.gnomehack.com/?N18452CE9 for further documentation
# Set encoding to latin-1. Must reload the sys module because the setdefaultencoding is deleted after
# the initialization of python. See http://masl.gnomehack.com/?N18452CE9 for further documentation.
importlib.reload(sys)
# Add the directories where we can do an import
# use of Plist_config/PListReader.py
# Add the directories where we can do an import use of Plist_config/PListReader.py
pathInclude = sys.path[0] + '/external_lib'
sys.path.append(pathInclude)
......@@ -82,7 +80,6 @@ def metro_execute_module(lObject_execution_sequence):
"""
Load the module sequence for METRo execution.
"""
# print("LObject=" + str(lObject_execution_sequence))
i = 0
iLen_object_execution_sequence = len(lObject_execution_sequence)
while i < iLen_object_execution_sequence:
......
......@@ -75,11 +75,9 @@ LOGGER_MSG_STOP_TXTID = _("STOP ")
LOGGER_MSG_UNDEFINED_TXTID = _("UNDEFINED ")
LOGGER_MSG_EMPTY_TXTID = " "
# Condition for a message to be displayed:
# message's category > logger verbosity level
# Condition for a message to be displayed: message's category > logger verbosity level
# Message's type for the message to be print before
# METRo initialization phase
# Message's type for the message to be print before METRo initialization phase
LOGGER_INIT_MESSAGE = 0
LOGGER_INIT_SUCCESS = 1
LOGGER_INIT_ERROR = 2
......@@ -251,14 +249,12 @@ def print_message(iMessage_category, sMessage):
print(sLine)
# Control if the message should be displayed in the shell
if bLogger_shell_display:
# print((sMessage_category_string + ": " + sMessage).encode('ISO-8859-1'))
print((sMessage_category_string + ": " + sMessage))
print(sMessage_category_string + ": " + sMessage)
# Warn the user in the case of an error asking the execution to be stopped.
if iMessage_category == LOGGER_MSG_STOP:
print("\n\n------------------------------------------------------------------------")
print(_("An unrecoverable error has occurred, see details in the log file: "))
# print(sLogger_filename.encode('ISO-8859-1'))
print(sLogger_filename)
if iLogger_verbose_level != LOGGER_VERBOSE_LEVEL_FULL:
print("\n")
......
......@@ -66,8 +66,7 @@ nLowerPressure = 700
fNormalPressure = 1013.25 # 1 atmosphere
nUpperPressure = 1100
# Used in the combination of the observation and the forecast
# (metro_preprocess_combine.py)
# Used in the combination of the observation and the forecast(metro_preprocess_combine.py)
fConst = 1./(4.0 * 3.6E3)
# Used in metro_physics.py
......@@ -76,10 +75,8 @@ fEps2 = 0.3780199778986
fTrpl = 273.16
fTcdk = 273.15
# Used in metro_model to define the size of npSwo, because it finally
# goes into fortran...
# Used in metro_model to define the size of npSwo, because it finally goes into fortran...
nNL = 11520
# METRo output
# Indicates at what will be the time interval between 2 field in the roadcast
# METRo output indicates at what will be the time interval between 2 field in the roadcast
nMinutesForOutput = 20
......@@ -65,8 +65,7 @@ def parse_date_string(sDate):
"""
if sDate is not None:
try:
# Strip the date in ISO up to the minute only,
# ie. the first 16 characters
# Strip the date in ISO up to the minute only, ie. the first 16 characters
sDate = sDate[0:16]
tDate = time.strptime(sDate, "%Y-%m-%dT%H:%M")
fDate = time.mktime(tDate)
......@@ -180,8 +179,7 @@ def get_short_time_zone(tm, sTime_zone):
lTz = sTime_zone.split(',')
sTime_zone = lTz[0]
# extract time zone letter
# ex: EST5EDT4 -> ESTEDT
# extract time zone letter ex: EST5EDT4 -> ESTEDT
sTz_letter = ""
for letter in sTime_zone:
if letter.isalpha():
......
......@@ -136,8 +136,7 @@ def get_sf(npCloudsOctal, npTimeHour, npForecastedTime, fSunriseTimeUTC, fSunset
npCoeff = -1.56e-12 * npSft ** 4 + 5.972e-9 * npSft ** 3 - 8.364e-6 * npSft ** 2 + 5.183e-3 * npSft - 0.435
npCoeff = numpy.where(npCoeff > 0, npCoeff, 0.0)
# Set npCloudsPercent to be able to reference it in the
# numpy.where method.
# Set npCloudsPercent to be able to reference it in the numpy.where method.
npCloudsPercentDay = npCloudsOctal
# Correction based on the clouds
for i in range(0, 9):
......
......@@ -42,11 +42,9 @@
Errors must raised here must be catched elsewhere and then be logged through this module, if possible.
"""
import os
import metro_error
# set environment variable LANGUAGE and LC_ALL
if 'LANGUAGE' not in os.environ and 'LC_ALL' not in os.environ:
os.environ['LANGUAGE'] = 'en'
......@@ -109,7 +107,7 @@ def get_exec_root_path():
# Ugly way done in order to use the function get_metro_root_path.
# We can then use the underscore for the translation with gettext.
# We can then use the underscore for the translation with gettext.
t = gettext.translation('metro_util', get_metro_root_path() + '/usr/share/locale')
_ = t.gettext
......
......@@ -185,8 +185,7 @@ def extract_data(lDefs, dReadHandlers, nodeItems):
lData.append(data)
# If there is only one definition of data (lDefs), it is an "array".
# In this case, we must extract the "array" from the list
# [[1,2,3,...,N]] ==> [1,2,3,...,N]
# In this case, we must extract the "array" from the list [[1,2,3,...,N]] ==> [1,2,3,...,N]
if len(lDefs) == 1:
if lData:
lData = lData[0]
......
......@@ -178,10 +178,9 @@ class Metro_xml_libxml2:
"""
return node.copyNode(True)
# -------------------------------------------------------
# Add '//' on the string and return a copy of the node
# of the node result.
# -------------------------------------------------------
# ------------------------------------------------------------------------
# Add '//' on the string and return a copy of the node of the node result.
# ------------------------------------------------------------------------
def all_matching_xpath(self, dom, sXpath):
global sAllMatch
sAllMatch = '//' + sXpath
......
......@@ -28,11 +28,9 @@ class XmlTree:
def __init__(self, error_value=0.01):
self._error = error_value
# getter method
def get_error(self):
return self._error
# setter method
def set_error(self, error_value):
self._error = error_value
......@@ -54,12 +52,10 @@ class XmlTree:
:param excludes: list of attributes to exclude from comparison
:return: True if both files match with each other
"""
global dict_error
global list_of_errors
global error_difference
if excludes is None:
excludes = []
......@@ -116,7 +112,6 @@ class XmlTree:
dict_error[xml_file1.tag] = []
dict_error[xml_file1.tag].append([float(xml_file1.text), float(xml_file2.text)])
error_difference = abs_error_difference
return False
if not self.text_compare(xml_file1.tail, xml_file2.tail):
......@@ -207,12 +202,10 @@ def process_xml_file(current_case_path, case_folder, error_value, verbosity=Fals
:param verbosity: boolean variable to indicate the willingness of display the comparison result in detial
:return: comparison result
"""
global dict_error
global list_of_errors
global error_difference
os.chdir(current_case_path)
XmlTree.sum_of_error_within_tolerance = 0
XmlTree.sum_of_error_outside_tolerance = 0
......@@ -275,7 +268,6 @@ def main():
parser.add_argument('-e', '--error', type=float, help='specified value of error tolerance')
parser.add_argument('--clean', action='store_true', help="clean up output XML file 'roadcast_test_suite_run.xml'")
args = parser.parse_args()
if args.case:
run_all_cases = False
if args.verbose:
......
Markdown is supported
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