Beispiel #1
0
def find_tscpos_positive_period(start, stop):
    """
    find time periods of  tscpos is located in positive position
    input:  start       --- starting time in mm/dd/yy,hh:mm:ss
            stop        --- stopping time in mm/dd/yy,hh:mm:ss
    output: positive_period a list of lists containing a list of time of period starting
            and a list of time of period ending. both in seconds from 1998.1.1
    """
    #
    #--- extract sim data
    #
    dlist = hcf.run_arc5gl('retrieve',
                           start,
                           stop,
                           detector='sim',
                           level='0',
                           filetype='sim')
    #
    #--- find time period when tscpos is in positive side
    #
    positive_periods = create_data_period(start,
                                          stop,
                                          dlist,
                                          colname='TSCPOS',
                                          lgc='>=',
                                          val=0)
    #
    #-- clean the output directory
    #
    for ent in dlist:
        mcf.rm_file(ent)

    return positive_periods
Beispiel #2
0
def extrct_hrchk_data(start, stop):
    """
    extract hrchk fits file and get column data we need
    input:  start   --- starting time
            stop    --- stopping time
    output: out     --- pyfits data table format of extracted data from data with datamore: NEXT_IN_LINE 
    """
#
#--- extract hrchk fits files 
#
    dlist = hcf.run_arc5gl('retrieve', start, stop, dataset='flight', detector='hrc', level='0', filetype='hrchk')

    nil_list = []
    for fits in dlist:
#
#--- find datamode: we need only NEXT_IN_LINE case
#
        dmode = hcf.read_header_value(fits, 'DATAMODE')

        if dmode == 'NEXT_IN_LINE':
            nil_list.append(fits)

    if len(nil_list) > 0:
        dout = hcf.combine_and_select_data(nil_list, hk_col_list)
    else:
        dout = NULL
#
#--- empty out the temporary direcotry
#
    for ent in dlist:
        mcf.rm_file(ent)

    return dout
Beispiel #3
0
def find_scint(tstart, tstop):
    """
    find integrated EPHIN flux
    input: tstart   --- starting time in seconds from 1998.1.1
           tstop    --- stopping time in seconds from 1998.1.1
    output; avg     --- average of ephin flux
            std     --- standard deviation of flux
    """
    #
    #--- extract ephin data
    #
    hcf.run_arc5gl('retrieve', tstart, tstop, dataset='flight',detector='ephin',\
                    level=1,filetype='ephrates')
    #
    #--- create extracted fits file list
    #
    ldir = exc_dir + 'Temp_dir/'
    flist = hcf.get_file_list(ldir, 'lc1.fits.gz')
    #
    #--- combine all fits files into one
    #
    hcf.combine_fits_files(flist, 'ztemp.fits', azip=0)
    [cols, tbdata] = hcf.read_fits_file('ztemp.fits')
    #
    #--- limit data to between tstart and tstop
    #
    tbdata = hcf.select_data_with_condition(tbdata, 'time', ">=", tstart)
    tbdata = hcf.select_data_with_condition(tbdata, 'time', "<=", tstop)
    #
    #--- compute the basic stat
    #
    [avg, med, std, vmin, vmax, vcnt] = get_basic_stat(tbdata['scint'])

    cmd = 'rm ztemp.fits' + '*'
    os.system(cmd)

    if hcf.check_file_in_dir(ldir):
        cmd = 'rm  ' + ldir + '*'
        os.system(cmd)

    return [avg, std]
Beispiel #4
0
def extract_fits_files(time_list, detector, level, filetype, subdetector=''):
    """
    extract fits file for given time period
    input:  time_list   --- a list of lists of start and stop time
            detector    ---  detector name
            level       ---  level
            filetype    --- file type
            subdetector --- sub detector name
    output: extracted fits files in <exc_dir>/Temp_dir/
            fits_list   --- a list of extracted fits file names
    """
    if len(time_list) < 2:
        return []

    [start_list, stop_list] = time_list
    #
    #--- just in a case, start and stop time are not given in a list form
    #--- make them into a list form
    #
    if not isinstance(start_list, list):
        start_list = [start_list]

    if not isinstance(stop_list, list):
        stop_list = [stop_list]

    fits_list = []  #--- just in a case nothing extracted
    for m in range(0, len(start_list)):
        try:
            start = float(start_list[m])
            stop = float(stop_list[m])
        except:
            break
#
#--- extract fits files
#
        dlist = hcf.run_arc5gl('retrieve', start, stop, detector=detector, level=level,\
                               filetype=filetype, subdetector=subdetector)
        if m == 0:
            fits_list = dlist
        else:
            fits_list = fits_list + dlist
#
#--- since there are occasional overlap in periods, make sure that all fits names are uniqe
#
    fits_list = hcf.remove_duplicate_from_list(fits_list)
    return fits_list