You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original MATLAB source code found at: https://github.com/nasa/CARA_Analysis_Tools/blob/master/two-dimension_Pc/Main/TransformationCode/TimeTransformations/getCcsdsTimeFormat.m
7
+
The CCSDS time format is required to be of the general form
8
+
9
+
yyyy-[mm-dd|ddd]THH:MM:SS[.F*][Z]
10
+
(1) The date and time fields are separated by a "T".
11
+
(2) The date field has a four digit year followed by either a two digit
12
+
month and two digit day, or a three digit day-of-year.
13
+
(3) The year, month, day, and day-of-year fields are separated by a dash.
14
+
(4) The hours, minutes and seconds fields are each two digits separated
15
+
by colons.
16
+
(5) The fraction of seconds is optional and can have any number of
17
+
digits.
18
+
(6) If a fraction of seconds is provided, it is separated from the two
19
+
digit seconds by a period.
20
+
(7) The time string can end with an optional "Z" time zone indicator
21
+
'''
22
+
timeFormat= []
23
+
numT=timeString.count('T')
24
+
ifnumT==-1:
25
+
# Case when this is 'T' does not exist in timeString
26
+
print(f"*** Error -- Invalid CCSDS time string: {timeString}")
27
+
print(f" No 'T' separator found between date and time portions of the string\n")
28
+
return
29
+
elifnumT>1:
30
+
print(f"*** Error -- Invalid CCSDS time string: {timeString}\n")
31
+
print(f" More than one 'T' separator found between date and time portions of the string\n")
32
+
return
33
+
idxT=timeString.find('T')
34
+
ifidxT==10:
35
+
timeFormat="yyyy-mm-ddTHH:MM:SS"
36
+
elifidxT==8:
37
+
timeFormat="yyyy-DDDTHH:MM:SS"
38
+
else:
39
+
print(f"*** Error -- Invalid CCSDS time string: {timeString}\n", timeString)
40
+
print(f" Date format not one of yyyy-mm-dd or yyyy-DDD\n")
41
+
return
42
+
# % Check if 'Z' time zone indicator appended to the string
43
+
iftimeString[-1]=='Z':
44
+
zOpt=True
45
+
else:
46
+
zOpt=False
47
+
# % Find location of the fraction of seconds decimal separator
48
+
numDecimal=timeString.count('.')
49
+
ifnumDecimal>1:
50
+
print(f"*** Error -- Invalid CCSDS time string: {timeString}\n")
51
+
print(f" More than one fraction of seconds decimal separator ('.') found.\n")
52
+
timeFormat= []
53
+
return
54
+
idxDecimal=timeString.find('.')
55
+
nfrac=0
56
+
ifnumDecimal!=0:
57
+
ifzOpt:
58
+
nfrac=len(timeString) -1-idxDecimal-1
59
+
else:
60
+
nfrac=len(timeString) -1-idxDecimal
61
+
ifnfrac>0:
62
+
fracStr='.'+ ('F'*nfrac)
63
+
else:
64
+
fracStr=""
65
+
ifzOpt:
66
+
fracStr=fracStr+'Z'
67
+
timeFormat=timeFormat+fracStr
68
+
returntimeFormat
69
+
70
+
defDOY2Date(DOY, YEAR):
71
+
'''
72
+
Written by Andrew Ng, 18/03/2022,
73
+
Based on source code @ https://github.com/nasa/CARA_Analysis_Tools/blob/master/two-dimension_Pc/Main/TransformationCode/TimeTransformations/DOY2Date.m
74
+
Use the datetime python package.
75
+
DOY2DATE - Converts Day of Year (DOY) to date number and full
0 commit comments