Example #1
0
    def create_compress_table(self, f):
        # Called for lsst alert output

        split_mjd = self.config_prep['split_mjd']
        nsplitnite = split_mjd['nbin']
        min_edge_list = split_mjd['min_edge']
        max_edge_list = split_mjd['max_edge']
        header_line_compress = \
            f"    STATE   ISPLIT_NITE NITE-RANGE  NDIR_{ALERT_DAY_NAME}  " \
            f"Nsec NDIR/sec"

        INFO_COMPRESS = {
            'primary_key': TABLE_COMPRESS,
            'header_line': header_line_compress,
            'row_list': []
        }

        STATE = SUBMIT_STATE_WAIT  # all start in WAIT state
        for isplitnite in range(0, nsplitnite):
            imin = int(min_edge_list[isplitnite])
            imax = int(max_edge_list[isplitnite])
            str_mjd_range = f"{imin}-{imax}"

            ROW_COMPRESS = []
            ROW_COMPRESS.append(STATE)
            ROW_COMPRESS.append(isplitnite)  # index: 0,1,...
            ROW_COMPRESS.append(str_mjd_range)  # e.g., 59000-59200
            ROW_COMPRESS.append(0)  # init NDIR_MJD=0
            ROW_COMPRESS.append(0)  # init Nsec
            ROW_COMPRESS.append(0.0)  # init rate = NDIR/sec

            INFO_COMPRESS['row_list'].append(ROW_COMPRESS)
        util.write_merge_file(f, INFO_COMPRESS, [])
Example #2
0
    def create_merge_table(self, f):

        # Called from base to create rows for table in  MERGE.LOG
        # Always create required MERGE table.
        # For LSST alerts, also create supplemental "COMPRESS" table
        # to track mjd compression

        isplitnite_list = self.config_prep['isplitnite_list']
        prefix_output_list = self.config_prep['prefix_output_list']
        output_format = self.config_yaml['args'].output_format
        out_lsst_alert = (output_format == OUTPUT_FORMAT_LSST_ALERTS)

        # 1. required MERGE table
        header_line_merge = f"    STATE   ISPLIT_NITE  {DATA_UNIT_STR}  " \
                            f"NEVT NEVT_SPECZ NEVT_PHOTOZ  "
        if out_lsst_alert:
            header_line_merge += "NOBS_ALERT  ALERT/sec"
        else:
            header_line_merge += "NEVT/sec"

        INFO_MERGE = {
            'primary_key': TABLE_MERGE,
            'header_line': header_line_merge,
            'row_list': []
        }

        STATE = SUBMIT_STATE_WAIT  # all start in WAIT state
        for prefix, isplitnite in zip(prefix_output_list, isplitnite_list):
            ROW_MERGE = []
            ROW_MERGE.append(STATE)
            ROW_MERGE.append(isplitnite)
            ROW_MERGE.append(prefix)  # data unit name
            ROW_MERGE.append(0)  # NEVT
            ROW_MERGE.append(0)  # NEVT_SPECZ
            ROW_MERGE.append(0)  # NEVT_PHOTOZ
            if out_lsst_alert: ROW_MERGE.append(0)  # NOBS_ALERT
            ROW_MERGE.append(0.0)  # rate/sec

            INFO_MERGE['row_list'].append(ROW_MERGE)

        # call util to write tables to MERGE.LOG
        if out_lsst_alert:
            self.create_compress_table(f)

        util.write_merge_file(f, INFO_MERGE, [])
Example #3
0
    def create_merge_table(self, f):

        # create merge table with NDOF=0; later this table
        # gets updated as jobs finish.
        idir_list3 = self.config_prep['idir_list3']
        icov_list3 = self.config_prep['icov_list3']
        ifit_list3 = self.config_prep['ifit_list3']

        # create only MERGE table ... no need for SPLIT table
        header_line_merge = \
                f" STATE  DIROPT  COVOPT  WFITOPT  NDOF CPU "
        # xxx f" SPLITRAN"

        INFO_MERGE = {
            'primary_key': TABLE_MERGE,
            'header_line': header_line_merge,
            'row_list': []
        }

        STATE = SUBMIT_STATE_WAIT  # all start in WAIT state

        for idir,icov,ifit in \
            zip(idir_list3,icov_list3,ifit_list3):

            diropt_num = self.wfit_num_string(idir, -1, -1)
            covopt_num = self.wfit_num_string(-1, icov, -1)
            wfitopt_num = self.wfit_num_string(-1, -1, ifit)

            # ROW here is fragile in case columns are changed
            ROW_MERGE = []
            ROW_MERGE.append(STATE)
            ROW_MERGE.append(diropt_num)
            ROW_MERGE.append(covopt_num)
            ROW_MERGE.append(wfitopt_num)
            ROW_MERGE.append(0)  # Ndof
            ROW_MERGE.append(0.0)  # CPU
            INFO_MERGE['row_list'].append(ROW_MERGE)

        # - - - - -
        util.write_merge_file(f, INFO_MERGE, [])
Example #4
0
    def create_merge_table(self,f):

        n_trainopt        = self.config_prep['n_trainopt'] 
        trainopt_num_list = self.config_prep['trainopt_num_list']

        header_line_merge = (f"    STATE   {TRAINOPT_STRING}  NEVT  CPU")
        INFO_MERGE = { 
            'primary_key' : TABLE_MERGE, 
            'header_line' : header_line_merge,
            'row_list'    : []   }

        STATE = SUBMIT_STATE_WAIT # all start in WAIT state
        for num in trainopt_num_list :
            ROW_MERGE = []
            ROW_MERGE.append(STATE)
            ROW_MERGE.append(num)     # e..g, TRAINOPT002
            ROW_MERGE.append(0)       # NEVT
            ROW_MERGE.append(0.0)     # CPU

            INFO_MERGE['row_list'].append(ROW_MERGE)  
        # - - - -
        util.write_merge_file(f, INFO_MERGE, [] )