예제 #1
0
            fetchSlabs(datafolder)
            print 'Finished downloading slab data.'
    except Exception, msg:
        print 'Error "%s" while downloading NEIC Slab data. Stopping.' % msg.message
        sys.exit(1)

    outfile = os.path.join(datafolder, strec.utils.GCMT_OUTPUT)
    if args.getGCMT:
        try:
            print 'Downloading and converting historical GCMT data...'
            histfile = getHistoricalGCMT()
        except Exception, msg:
            print 'Error "%s" when downloading data from %s.  Stopping.' % (
                msg, HIST_GCMT_URL)
            sys.exit(1)
        createDataFile(histfile, outfile, 'ndk', 'gcmt', hasHeader=False)
        print 'Finished converting historical GCMT data.'
        os.remove(histfile)
    if args.getComCat:
        pass

    if args.update:
        mostrecent = getMostRecent(outfile)
        ryear = mostrecent.year
        rmonth = mostrecent.month + 1
        if rmonth == 13:
            ryear += 1
            rmonth = 1
        tnow = datetime.datetime.now()
        tyear = tnow.year
        tmonth = tnow.month
예제 #2
0
            print 'Downloading all required slab data (this may take a while...)'
            fetchSlabs(datafolder)
            print 'Finished downloading slab data.'
    except Exception,msg:
        print 'Error "%s" while downloading NEIC Slab data. Stopping.' % msg.message
        sys.exit(1)

    outfile = os.path.join(datafolder,strec.utils.GCMT_OUTPUT)
    if args.getGCMT:
        try:
            print 'Downloading and converting historical GCMT data...'
            histfile = getHistoricalGCMT()
        except Exception,msg:
            print 'Error "%s" when downloading data from %s.  Stopping.' % (msg,HIST_GCMT_URL)
            sys.exit(1)
        createDataFile(histfile,outfile,'ndk','gcmt',hasHeader=False)
        print 'Finished converting historical GCMT data.'
        os.remove(histfile)
    if args.getComCat:
        pass        
    
    if args.update:
        mostrecent = getMostRecent(outfile)
        ryear = mostrecent.year
        rmonth = mostrecent.month+1
        if rmonth == 13:
            ryear += 1
            rmonth = 1
        tnow = datetime.datetime.now()
        tyear = tnow.year
        tmonth = tnow.month
예제 #3
0
    sys.exit(0)

infile = args.infile
outfile = args.outfile

if args.fmtype is None:
    args.fmtype = 'User'

if args.usendk:
    filetype = 'ndk'
if args.usecsv:
    filetype = 'csv'
if args.usexml:
    filetype = 'xml'

if os.path.isfile(outfile):
    print '%s already exists - appending new data.' % outfile
    try:
        appendDataFile(infile, outfile, filetype,
                       args.fmtype, hasHeader=args.hasheader)
    except Exception, msg:
        print 'Error reading input file %s.\n%s' % (infile, msg)
        sys.exit(1)
else:
    try:
        createDataFile(infile, outfile, filetype,
                       args.fmtype, hasHeader=args.hasheader)
    except Exception, msg:
        print 'Error reading input file %s.\n"%s"' % (infile, msg)
        sys.exit(1)