Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now processes a full continuity (science + vehicle commands) load as … #22

Merged
merged 1 commit into from
Jan 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 42 additions & 19 deletions backstop_history/BackstopHistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
# - Created local logger
# - Logger verbosity level transmitted from model invocation command line
#
# Update: November 24, 2021
# Gregg Germain
# - Modifications which handle the case where a load was reviewed as a full
# load, meaning both science and vehicle SCS slots will be activated, or
# the case where, after the review of a "full" load, only the vehicle SCS's
# were actually activated. This is done by changes to LR which create
# additional ACIS-Continuity.txt load types.
# These new load types tell Assemble_History to read the CR*.backstop
# or VR*.backstop file in the continuity directory
################################################################################
from __future__ import print_function

Expand Down Expand Up @@ -137,7 +146,7 @@ def __init__(self, cont_file_name='ACIS-Continuity.txt',

self.logger = logger

self.logger.debug('LOGGER ************************* BHC Init' )
self.logger.debug('LOGGER ************************* BHC Init VO VERSION' )

self.outdir = outdir

Expand Down Expand Up @@ -270,7 +279,8 @@ def get_continuity_file_info(self, oflsdir):

# If the review load type is not "Normal", grab the interrupt time
# or set the interrupt time to "None"
if review_load_type.upper() != "NORMAL":
if (review_load_type.upper() != 'NORMAL') and \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (review_load_type.upper() != 'NORMAL') and \
if review_load_type.upper() in ['NORMAL', 'VO_NORMAL']:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think you meant or here and not and?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No in this case I mean AND:

Of the 4 types of loads: Normal, TOO, SCS-1078 and Full Stop, Normal is the only one that does NOT have an interrupt time in the second line of the ACIS-Continuity.txt file. All the others have an interrupt time.

So if this is not a Normal nor VO_normal then one should read the time. Otherwise set it to None.

Now it could be made shorter by writing:

if review_load_type.upper() in ['NORMAL', 'VO_NORMAL']:
set it to None
else:
Capture the time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just a bit confused about how review_load_type.upper() could be both "NORMAL" and "VO_NORMAL"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, didn't see the !=, my brain is not working today

(review_load_type.upper() != 'VO_NORMAL'):
interrupt_time = split_type_line[1]
else:
interrupt_time = None
Expand Down Expand Up @@ -329,7 +339,7 @@ def get_CR_bs_cmds(self, oflsdir):
into the master list.

"""
backstop_file_path = globfile(os.path.join(oflsdir, 'CR[0-9]*.backstop'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to change this?

backstop_file_path = globfile(os.path.join(oflsdir, 'CR*.backstop'))

self.logger.debug("GET_CR_BS_CMDS - Using backstop file %s" % backstop_file_path)

Expand All @@ -348,8 +358,7 @@ def get_CR_bs_cmds(self, oflsdir):
self.logger.info('GET_CR_BS_CMDS - Found %d backstop commands between %s and %s' % (len(bs_cmds),
Time(bs_cmds[0]['time'], format = 'cxcsec', scale = 'utc').yday,
Time(bs_cmds[-1]['time'], format = 'cxcsec', scale = 'utc').yday))
# Return both the backstop commands and the
# name of the backstop file
# Return both the backstop commands and the name of the backstop file
return bs_cmds, bs_name


Expand Down Expand Up @@ -475,25 +484,36 @@ def Assemble_History(self, ofls_dir, tbegin, interrupt=False):

# WHILE
# The big while loop that backchains through previous loads and concatenates the
# proper load sections and possibly events (e.,g. maneuivers)to the Master List
# proper load sections and possibly events (e.,g. maneuvers)to the Master List
while self.master_ToFC > tbegin_time:

# Obtain the Continuity information of the present ofls directory
cont_load_path, present_load_type, scs107_date = self.get_continuity_file_info(present_ofls_dir)

self.logger.debug(' Cont load path: %s, load type: %s, scs107 date: %s' % (cont_load_path, present_load_type, scs107_date))


# Read the commands from the Continuity file
cont_cr_cmds, cont_file_name = self.get_CR_bs_cmds(cont_load_path)
# The value of present_load_type indicates whether to read the CR*.backstop file
# or the VR*.backstop file.

# Indicators of load types which require reading the VR*.backstop file
self.vehicle_types = ['VO_NORMAL', 'VO_TOO', 'VO_SCS-107', 'VO_STOP']

if present_load_type.upper() in self.vehicle_types:
cont_cr_cmds, cont_file_name = self.get_VR_bs_cmds(cont_load_path)
else:
cont_cr_cmds, cont_file_name = self.get_CR_bs_cmds(cont_load_path)


#---------------------- NORMAL ----------------------------------------
# If the PRESENT (i.e. NOT Continuity) load type is "normal" then grab
# the continuity command set and concatenate those commands to the start of
# the Master List.
if present_load_type.upper() == 'NORMAL':
if (present_load_type.upper() == 'NORMAL') or\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shorter version of this:

Suggested change
if (present_load_type.upper() == 'NORMAL') or\
if present_load_type.upper() in ['NORMAL', 'VO_NORMAL']:

(present_load_type.upper() == 'VO_NORMAL'):

self.logger.debug('Processing Normal: %s' % (self.master_list[-1]['date']))
self.logger.debug('Processing %s: %s' % (present_load_type, self.master_list[-1]['date']))

# Next step is to set the Master List equal to the concatenation of
# the continuity load commands and the review load commands
Expand All @@ -516,8 +536,9 @@ def Assemble_History(self, ofls_dir, tbegin, interrupt=False):
# the continuity command set, trim the command set to exclude those
# Commands discarded by the TOO cut, concatenate the remaining
# continuity commands to the start of the Master List.
elif present_load_type.upper() == 'TOO':
self.logger.debug('Processing TOO at date: %s' % (scs107_date))
elif (present_load_type.upper() == 'TOO') or \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elif (present_load_type.upper() == 'TOO') or \
elif present_load_type.upper() in ['TOO', 'VO_TOO']:

(present_load_type.upper() == 'VO_TOO'):
self.logger.debug('Processing %s at date: %s' % (present_load_type, scs107_date))

# Convert the TOO cut time found in the ACIS-Continuity.txt file to
# cxcsec
Expand Down Expand Up @@ -547,9 +568,10 @@ def Assemble_History(self, ofls_dir, tbegin, interrupt=False):
# 2) Add on the SCS-107 commands that were executed at the Cut time
# 3) Look for and insert any events (power commands, maneuvers, LTCTI's)
# 4) append all these commands to the start of the Master List.
elif present_load_type.upper() == 'STOP':
elif (present_load_type.upper() == 'STOP') or \
(present_load_type.upper() == 'VO_STOP'):

self.logger.debug('Processing FULL STOP at date: %s' % (scs107_date))
self.logger.debug('Processing %s at date: %s' % (present_load_type, scs107_date))

# Convert the SCS-107 cut time found in the ACIS-Continuity.txt file to
# cxcsec
Expand Down Expand Up @@ -595,9 +617,10 @@ def Assemble_History(self, ofls_dir, tbegin, interrupt=False):
# - Trim those before the SCS-107 time and any after the Review Load start time
# - Concat to master_list and sort
#
elif present_load_type.upper() == 'SCS-107':
elif (present_load_type.upper() == 'SCS-107') or \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elif (present_load_type.upper() == 'SCS-107') or \
elif present_load_type.upper() in ['SCS-107', 'VO_SCS-107']:

(present_load_type.upper() == 'VO_SCS-107'):
# Inform coder that you are processing an SCS-107
self.logger.debug('Processing SCS-107 at date: %s' % (scs107_date))
self.logger.debug('Processing %s at date: %s' % (present_load_type, scs107_date))

# Convert the TOO cut time found in the ACIS-Continuity.txt file to
# cxcsec
Expand All @@ -611,7 +634,7 @@ def Assemble_History(self, ofls_dir, tbegin, interrupt=False):
processed_scs107_cmds = self.Process_Cmds(self.raw_scs107_cmd_list, scs107_date)

# Append the processed SCS-107 commands to the continuity
# command list
# command list. This includes the WSPOW0002A
cont_cr_cmds = np.append(processed_scs107_cmds, cont_cr_cmds, axis=0)

# Sort the continuity list based upon the time column
Expand Down Expand Up @@ -720,8 +743,8 @@ def Assemble_History(self, ofls_dir, tbegin, interrupt=False):

# POWER COMMAND
elif splitline[1] in self.power_cmd_list:
# We probably ran a CAP to execute a power command such as WSPOW0002A
# So insert the power command into the historical Backstop file you are building.
# The SCS-107 now executes the power command WSPOW0002A
# So insert any OTHER power command into the historical Backstop file you are building.
power_cmds = self.Process_Power_Cmd(eachevent)

# Append the processed POWER commands
Expand Down