Skip to content

Commit 1c89de0

Browse files
committed
Fixed names
1 parent 09b13c0 commit 1c89de0

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

kessler/cdm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ def set_header(self, key, value):
195195
if key in self._keys_header:
196196
if key in self._keys_with_dates:
197197
# We have a field with a date string as the value. Check if the string is in the format needed by the CCSDS 508.0-B-1 standard
198-
timeFormat = util.get_ccsds_time_format(value)
199-
idx = timeFormat.find('DDD')
198+
time_format = util.get_ccsds_time_format(value)
199+
idx = time_format.find('DDD')
200200
if idx!=-1:
201-
value = util.DOY_2_date(value, value[idx:idx+3], value[0:4], idx)
201+
value = util.doy_2_date(value, value[idx:idx+3], value[0:4], idx)
202202
try:
203203
_ = datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%f')
204204
except Exception as e:

kessler/util.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,9 @@ def get_ccsds_time_format(time_string):
390390
raise RuntimeError(f"*** Error -- Invalid CCSDS time string: {time_string} \nDate format not one of yyyy-mm-dd or yyyy-DDD.\n")
391391
# % Check if 'Z' time zone indicator appended to the string
392392
if time_string[-1]=='Z':
393-
zOpt = True
393+
z_opt = True
394394
else:
395-
zOpt = False
395+
z_opt = False
396396
# % Find location of the fraction of seconds decimal separator
397397
num_decimal = time_string.count('.')
398398
if num_decimal > 1:
@@ -401,37 +401,37 @@ def get_ccsds_time_format(time_string):
401401
idx_decimal = time_string.find('.')
402402
nfrac = 0
403403
if num_decimal != 0:
404-
if zOpt:
404+
if z_opt:
405405
nfrac = len(time_string) - 1 - idx_decimal -1
406406
else:
407407
nfrac = len(time_string) - 1 - idx_decimal
408408
if nfrac > 0:
409409
frac_str = '.' + ('F'*nfrac)
410410
else:
411411
frac_str = ""
412-
if zOpt:
412+
if z_opt:
413413
frac_str = frac_str+'Z'
414414
time_format = time_format + frac_str
415415
return time_format
416416

417-
def DOY_2_date(value, DOY, YEAR, idx):
417+
def doy_2_date(value, doy, year, idx):
418418
'''
419419
Written by Andrew Ng, 18/03/2022,
420420
Based on source code @ https://github.com/nasa/CARA_Analysis_Tools/blob/master/two-dimension_Pc/Main/TransformationCode/TimeTransformations/DOY2Date.m
421421
Use the datetime python package.
422-
DOY_2_date - Converts Day of Year (DOY) date format to date format.
422+
doy_2_date - Converts Day of Year (DOY) date format to date format.
423423
424424
Args:
425425
- value(``str``): Original date time string with day of year format "YYYY-DDDTHH:MM:SS.ff"
426-
- DOY (``str``): The day of year in the DOY format.
427-
- YEAR (``str``): The year.
426+
- doy (``str``): The day of year in the DOY format.
427+
- year (``str``): The year.
428428
- idx (``int``): Index of the start of the original "value" string at which characters 'DDD' are found.
429429
Returns:
430430
-value (``str``): Transformed date in traditional date format. i.e.: "YYYY-mm-ddTHH:MM:SS.ff"
431431
432432
'''
433433
# Calculate datetime format
434-
date_num = datetime.datetime(int(YEAR), 1, 1) + datetime.timedelta(int(DOY) - 1)
434+
date_num = datetime.datetime(int(year), 1, 1) + datetime.timedelta(int(doy) - 1)
435435
# Split datetime object into a date list
436436
date_vec = [date_num.year, date_num.month, date_num.day, date_num.hour, date_num.minute]
437437
value = str(date_vec[0]) +'-' + str(date_vec[1]) + '-' + str(date_vec[2]) + 'T' + value[idx+4:-1]

tests/test_util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_get_ccsds_time_format(self):
122122

123123
self.assertEqual(kessler.util.get_ccsds_time_format(test_case1), test_case1_correct)
124124
self.assertEqual(kessler.util.get_ccsds_time_format(test_case2), test_case2_correct)
125-
def test_DOY_2_date(self):
125+
def test_doy_2_date(self):
126126
# This test is written by Andrew Ng, 19/03/22. It makes use of example CDMs provided by the NASA CARA
127127
# analysis repo at https://github.com/nasa/CARA_Analysis_Tools/tree/master/two-dimension_Pc/UnitTest/InputFiles.
128128
example1 = "2010-202T12:25:19.000" # From SingleCovTestCase1-4.cdm
@@ -133,6 +133,6 @@ def test_DOY_2_date(self):
133133
Year_2= example2[0:4]
134134
test_case1_correct = "2010-7-21T12:25:19.00"
135135
test_case2_correct = "2018-8-17T13:56:33.00"
136-
self.assertEqual(kessler.util.DOY_2_date(example1, DOY_1, Year_1, 5), test_case1_correct)
137-
self.assertEqual(kessler.util.DOY_2_date(example2, DOY_2, Year_2, 5), test_case2_correct)
136+
self.assertEqual(kessler.util.doy_2_date(example1, DOY_1, Year_1, 5), test_case1_correct)
137+
self.assertEqual(kessler.util.doy_2_date(example2, DOY_2, Year_2, 5), test_case2_correct)
138138

0 commit comments

Comments
 (0)