示例#1
0
def main():
    warnings.warn(colour.cstring("Not checking if .fil files are contiguous " \
                                "frequency bands, or the same length, etc.", \
                                'warning'))

    sys.stdout.write("Working...")
    sys.stdout.flush()

    # Open infiles
    infbfiles = [filterbank.filterbank(infile) for infile in options.infiles]

    outfile = open(options.outname, 'wb')

    # Write header
    write_header(infbfiles, outfile)
    sys.stdout.write("\rHeader written... Writing data...")
    sys.stdout.flush()

    # Write data
    write_data(infbfiles, outfile)
    sys.stdout.write("\rDone!" + " " * 50 + "\n")
    sys.stdout.flush()

    outfile.close()

    # Close infiles
    for fb in infbfiles:
        fb.close()
示例#2
0
def format_rating(rating_type, complete=False):
    """Return formatted string describing rating type
    given a dictionary of information about the rating
    type.
    """
    formatted = colour.cstring("Rating", bold=1) + ": " + \
		colour.cstring("%(name)s" % rating_type, underline=1) + " " + \
		"v%(version)d\n\t(ID: %(rating_id)d)" % rating_type
    if complete:
	paragraphs = rating_type['description'].split('\n')
	description = '\n'.join([textwrap.fill(p.strip(), width=60, \
				initial_indent='\t', subsequent_indent='\t') \
				for p in paragraphs])
	rating_type['description'] = description
	formatted += "\n%(description)s" % rating_type
    return formatted
示例#3
0
def main():
    warnings.warn(colour.cstring("Not checking if .fil files are contiguous " \
                                "frequency bands, or the same length, etc.", \
                                'warning'))
    
    sys.stdout.write("Working...")
    sys.stdout.flush()
    
    # Open infiles
    infbfiles = [filterbank.filterbank(infile) for infile in options.infiles]

    outfile = open(options.outname, 'wb')
    
    # Write header
    write_header(infbfiles, outfile)
    sys.stdout.write("\rHeader written... Writing data...")
    sys.stdout.flush()
    
    # Write data
    write_data(infbfiles, outfile)
    sys.stdout.write("\rDone!" + " "*50 + "\n")
    sys.stdout.flush()
    
    outfile.close()
    
    # Close infiles
    for fb in infbfiles:
        fb.close()
示例#4
0
def sort_fb_files(fbfiles):
    """Given a list of filterbank objects sort by frequency.
    """
    freqbands = []
    reversed = []
    for fb in fbfiles:
        chanbw = fb.header['foff']
        if chanbw < 0:
            reversed.append(True)
        else:
            reversed.append(False)
        totalbw = chanbw * fb.header['nchans']
        lofreq = fb.header['fch1']
        hifreq = lofreq + totalbw
        freqbands.append([lofreq, hifreq])

    reversed = np.array(reversed)
    if not (reversed.all() or np.bitwise_not(reversed)):
        raise ValueError(colour.cstring("Frequency bands are not ordered" \
                                        "the same.", 'error'))

    freqbands = np.array(freqbands).astype(float)
    order = freqbands.argsort(axis=0).transpose()[0]
    if reversed.all():
        # reverse order
        if options.debug:
            colour.cprint("Frequency bands are all inverted.", 'debug')
        order = order[::-1]
    freqbands = freqbands[order]
    if np.any(
            freqbands.flat != sorted(freqbands.flat, reverse=reversed.all())):
        if options.debug:
            colour.cprint(freqbands, 'debug')
        raise ValueError(colour.cstring("Frequency bands have overlaps or " \
                                        "are inverted.", 'error'))

    sorted_fbfiles = []
    for i in order:
        sorted_fbfiles.append(fbfiles[i])
    return sorted_fbfiles
示例#5
0
def sort_fb_files(fbfiles):
    """Given a list of filterbank objects sort by frequency.
    """
    freqbands = []
    reversed = []
    for fb in fbfiles:
        chanbw = fb.header['foff']
        if chanbw < 0:
            reversed.append(True)
        else:
            reversed.append(False)
        totalbw = chanbw*fb.header['nchans']
        lofreq = fb.header['fch1']
        hifreq = lofreq + totalbw
        freqbands.append([lofreq, hifreq])
    
    reversed = np.array(reversed)
    if not (reversed.all() or np.bitwise_not(reversed)):
        raise ValueError(colour.cstring("Frequency bands are not ordered" \
                                        "the same.", 'error'))
        
    freqbands = np.array(freqbands).astype(float)
    order = freqbands.argsort(axis=0).transpose()[0]
    if reversed.all():
        # reverse order
        if options.debug:
            colour.cprint("Frequency bands are all inverted.", 'debug')
        order = order[::-1]
    freqbands = freqbands[order]
    if np.any(freqbands.flat != sorted(freqbands.flat, reverse=reversed.all())):
        if options.debug:
            colour.cprint(freqbands, 'debug')
        raise ValueError(colour.cstring("Frequency bands have overlaps or " \
                                        "are inverted.", 'error'))
    
    sorted_fbfiles = []
    for i in order:
        sorted_fbfiles.append(fbfiles[i])
    return sorted_fbfiles
示例#6
0
 def __str__(self):
     return colour.cstring(super(CoastGuardError, self).__str__(), 'error')
示例#7
0
 def __str__(self):
     return colour.cstring(
         super(CoastGuardWarning, self).__str__(), 'warning')
示例#8
0
文件: errors.py 项目: plazar/TOASTER
 def __str__(self):
     return colour.cstring(super(ToasterWarning, self).__str__(), "warning")
示例#9
0
文件: errors.py 项目: plazar/TOASTER
 def __str__(self):
     return colour.cstring(super(ToasterError, self).__str__(), "error")