print 'Day %d' % day
    t0 = ( day - 1 )*dayinsecs
    t = t0 + options.stime * np.arange( N )
    orfpaths = [ orfdir + '/%s/d%03d.pkl' % ( IJ , day ) for IJ in IJs ]
    Npd_before_today = (day - 1) * Nseg * 2 * Nvar * freqdict['Nf'] 

    s = 1 ; tails = [ None ]*Nvar ; TSs = [ [] for v in range( Nvar ) ]
    while s <= Nseg :
        print 'Segments (%d|%d)' % ( s , s+1 )
        Npd_before_segl = Npd_before_today + (s-1)*2*Nvar*freqdict['Nf']
        Npd_before_segr = Npd_before_today + s*2*Nvar*freqdict['Nf']
        tl , tsl = tsim.simulate_AETnoise_from_arbitrary_SpH(duration,options.stime,
                                                             t0 + (s-1)*duration/2,
                                                             options.GWSpectralSlope, options.H0,
                                                             Ppath, options.lmax,
                                                             options.seed,
                                                             Npd_before_segl,
                                                             Nvar,
                                                             options.compute_ORF_SpHs,
                                                             *orfpaths )
        tr , tsr = tsim.simulate_AETnoise_from_arbitrary_SpH(duration,options.stime,
                                                             t0 + s*duration/2,
                                                             options.GWSpectralSlope, options.H0,
                                                             Ppath, options.lmax,
                                                             options.seed,
                                                             Npd_before_segr,
                                                             Nvar,
                                                             options.compute_ORF_SpHs,
                                                             *orfpaths )
        for v in range( Nvar ) :
            ts , tail = mufls.window_and_join( tsl[v] , tsr[v] , tails[v] )
    parser.error('You must specify ORFDIR, PPATH and TSDIR!')
else:
    orfdir, Ppath, tsdir = args[:3]

IJs = ['AA', 'AE', 'AT', 'EE', 'ET', 'TT']
duration = 86400.
Nvar = 3

freqdict = mufls.get_freqs_from_duration_and_stime(options.stime, duration)

for day in options.days:
    t0 = (day - 1) * duration
    N_previous_draws = (day - 1) * freqdict['Nf'] * 2 * Nvar
    orfpaths = [orfdir + '/%s/d%03d.pkl' % (IJ, day) for IJ in IJs]
    t, n = tsim.simulate_AETnoise_from_arbitrary_SpH(
        duration, options.stime, t0, options.GWSpectralSlope, Ppath,
        options.lmax, options.seed, N_previous_draws, Nvar,
        options.compute_ORF_SpHs, *orfpaths)
    tscale = {'Cadence1': options.stime, 'Offset1': t0}
    tsdict = {
        't': AS.Coarsable(t, **tscale),
        '1': AS.Coarsable(n[0], **tscale),
        '2': AS.Coarsable(n[1], **tscale),
        '3': AS.Coarsable(n[2], **tscale)
    }
    if tsdir == '':
        pass
    elif tsdir not in glob.glob(tsdir):
        os.system('mkdir -p %s' % tsdir)
    print 'saving time-series to disk...'
    file = open(tsdir + '/d%03d.pkl' % day, 'wb')
    cpkl.dump(tsdict, file, -1)
예제 #3
0
    t0 = (day - 1) * dayinsecs
    t = t0 + options.stime * np.arange(N)
    orfpaths = [orfdir + '/%s/d%03d.pkl' % (IJ, day) for IJ in IJs]
    Npd_before_today = (day - 1) * Nseg * 2 * Nvar * freqdict['Nf']

    s = 1
    tails = [None] * Nvar
    TSs = [[] for v in range(Nvar)]
    while s <= Nseg:
        print 'Segments (%d|%d)' % (s, s + 1)
        Npd_before_segl = Npd_before_today + (s -
                                              1) * 2 * Nvar * freqdict['Nf']
        Npd_before_segr = Npd_before_today + s * 2 * Nvar * freqdict['Nf']
        tl, tsl = tsim.simulate_AETnoise_from_arbitrary_SpH(
            duration, options.stime, t0 + (s - 1) * duration / 2,
            options.GWSpectralSlope, options.H0, Ppath, options.lmax,
            options.seed, Npd_before_segl, Nvar, options.compute_ORF_SpHs,
            *orfpaths)
        tr, tsr = tsim.simulate_AETnoise_from_arbitrary_SpH(
            duration, options.stime, t0 + s * duration / 2,
            options.GWSpectralSlope, options.H0, Ppath, options.lmax,
            options.seed, Npd_before_segr, Nvar, options.compute_ORF_SpHs,
            *orfpaths)
        for v in range(Nvar):
            ts, tail = mufls.window_and_join(tsl[v], tsr[v], tails[v])
            TSs[v] += list(ts)
            tails[v] = np.copy(tail)
        s += 2

    TSs = np.array(TSs)[:, :N]
else :
    orfdir , Ppath , tsdir = args[ :3 ]

IJs = [ 'AA' , 'AE' , 'AT' , 'EE' , 'ET' , 'TT' ]
duration = 86400. 
Nvar = 3 

freqdict = mufls.get_freqs_from_duration_and_stime( options.stime , duration )

for day in options.days :
    t0 = ( day - 1 )*duration
    N_previous_draws = (day - 1) * freqdict['Nf'] * 2 * Nvar
    orfpaths = [ orfdir + '/%s/d%03d.pkl' % ( IJ , day ) for IJ in IJs ]
    t , n = tsim.simulate_AETnoise_from_arbitrary_SpH( duration , options.stime , t0 ,
                                                       options.GWSpectralSlope , Ppath , options.lmax ,
                                                       options.seed , N_previous_draws ,
                                                       Nvar , options.compute_ORF_SpHs ,
                                                       *orfpaths )
    tscale = { 'Cadence1':options.stime , 'Offset1':t0 }
    tsdict = { 't':AS.Coarsable( t , **tscale ) , 
               '1':AS.Coarsable( n[0] , **tscale ) ,
               '2':AS.Coarsable( n[1] , **tscale ) ,
               '3':AS.Coarsable( n[2] , **tscale ) }    
    if tsdir == '' :
        pass
    elif tsdir not in glob.glob( tsdir ) :
        os.system( 'mkdir -p %s' % tsdir )
    print 'saving time-series to disk...'
    file = open( tsdir+'/d%03d.pkl' % day , 'wb' )
    cpkl.dump( tsdict , file , -1 ) ; file.close()