Esempio n. 1
0
def demo_three(sensor='es03', where={'CutoffFreq': 101.4}):
    
    import datetime
    from pims.utils.datetime_ranger import next_day
    from pims.utils.pimsdateutil import datetime_to_ymd_path
    
    start = datetime.date(2016, 3, 15)
    stop = datetime.date(2016, 3, 19)
    nd = next_day(start)
    d = start
    while d < stop:
        d = nd.next()
        day = d.strftime('%Y-%m-%d')

        # Get list of PAD data files for particular day and sensor
        pth = os.path.join( datetime_to_ymd_path(d), 'samses_accel_' + sensor )
        if os.path.exists(pth):
            tmp = os.listdir(pth)
            files = [ os.path.join(pth, f) for f in tmp ]

            # Run routine to filter files
            my_files = get_pad_day_sensor_where_files(files, day, sensor, where)
            print '%s gives %d files' % (day, len(my_files))
        else:
            print '%s gives NO FILES' % day
Esempio n. 2
0
def demo_one(sensor='121f03', file_getter=get_pad_day_sensor_files):
    
    import datetime
    from pims.utils.datetime_ranger import next_day
    from pims.utils.pimsdateutil import datetime_to_ymd_path
    
    start = datetime.date(2017, 1, 1)
    stop = datetime.date(2017, 1, 3)
    nd = next_day(start)
    d = start
    while d < stop:
        d = nd.next()
        day = d.strftime('%Y-%m-%d')

        # Get list of PAD data files for particular day and sensor
        pth = os.path.join( datetime_to_ymd_path(d), 'sams2_accel_' + sensor )
        if os.path.exists(pth):
            tmp = os.listdir(pth)
            files = [ os.path.join(pth, f) for f in tmp ]    
                    
            # Run routine to filter files
            #my_files = get_pad_day_sensor_files(files, day, sensor)
            my_files = file_getter(files, day, sensor)
            print '%s gives %d files' % (day, len(my_files))
        else:
            print '%s gives NO FILES' % day
Esempio n. 3
0
def demo_dailyminmaxpad(sensor='121f04', where={'CutoffFreq': 200}):
    
    import datetime
    import scipy.io as sio
    from pims.utils.datetime_ranger import next_day
    from pims.utils.pimsdateutil import datetime_to_ymd_path
    
    indir='/misc/yoda/pub/pad'
    outdir='/misc/yoda/www/plots/batch/results/dailyminmaxpad'
    
    start = datetime.date(2016, 4, 2)
    stop = datetime.date(2016, 6, 2)
    nd = next_day(start)
    d = start
    d = nd.next()
    while d <= stop:
        day = d.strftime('%Y-%m-%d')

        # Get list of PAD data files for particular day and sensor
        pth = os.path.join( datetime_to_ymd_path(d), 'sams2_accel_' + sensor )
        if os.path.exists(pth):
            tmp = os.listdir(pth)
            files = [ os.path.join(pth, f) for f in tmp ]

            # Run routine to filter files
            my_files = get_pad_day_sensor_where_files(files, day, sensor, where)
            print '%s gives %d files' % (day, len(my_files))

            len_files = len(my_files)
            if len_files > 0:
                outfile = os.path.join( pth.replace(indir, outdir), 'dailyminmaxpad.mat')
                if os.path.exists(outfile):
                    Exception('OUTPUT FILE %s ALREADY EXISTS' % outfile)
                else:
                    directory = os.path.dirname(outfile)
                    if not os.path.exists(directory):
                        os.makedirs(directory)

                xmin, xmax = np.inf, -np.inf
                ymin, ymax = np.inf, -np.inf
                zmin, zmax = np.inf, -np.inf
                for f in my_files:
                    dmm = DailyMinMaxFileDisposal(f)
                    x1, x2, y1, y2, z1, z2 = dmm.run()
                    xmin = x1 if x1 < xmin else xmin
                    xmax = x2 if x2 > xmax else xmax
                    ymin = y1 if y1 < ymin else ymin
                    ymax = y2 if y2 > ymax else ymax
                    zmin = z1 if z1 < zmin else zmin
                    zmax = z2 if z2 > zmax else zmax
                    print '>> completed %s' % f
                sio.savemat(outfile, {'xmin': xmin, 'xmax': xmax,
                                      'ymin': ymin, 'ymax': ymax,
                                      'zmin': zmin, 'zmax': zmax})
                print
        else:
            print '%s gives NO FILES' % day
        d = nd.next()
Esempio n. 4
0
def do_dailyhistpad(start, stop, sensor='121f03', where={'CutoffFreq': 200}, bins=np.arange(-0.2, 0.2, 5e-5), vecmag_bins=np.arange(0, 0.5, 5e-5), mindur=5):
    
    import datetime
    import scipy.io as sio
    from pims.utils.datetime_ranger import next_day
    from pims.utils.pimsdateutil import datetime_to_ymd_path
    
    indir='/misc/yoda/pub/pad'
    outdir='/misc/yoda/www/plots/batch/results/dailyhistpad'
    
    #sio.savemat(os.path.join(outdir, 'dailyhistpad_bins.mat'), {'bins': bins[:-1], 'vecmag_bins': vecmag_bins[:-1]}); raise SystemExit
    
    nd = next_day(start)
    d = start
    d = nd.next()
    while d <= stop:
        day = d.strftime('%Y-%m-%d')

        # Get list of PAD data files for particular day and sensor
        pth = os.path.join( datetime_to_ymd_path(d), sensor2subdir(sensor) )
        print pth
        if os.path.exists(pth):
            tmp = os.listdir(pth)
            files = [ os.path.join(pth, f) for f in tmp ]

            # Run routine to filter files
            my_files = get_pad_day_sensor_where_files(files, day, sensor, where, mindur)
            print '%s gives %d files' % (day, len(my_files))
            
            len_files = len(my_files)
            if len_files > 0:
                outfile = os.path.join( pth.replace(indir, outdir), 'dailyhistpad.mat')
                if os.path.exists(outfile):
                    Exception('OUTPUT FILE %s ALREADY EXISTS' % outfile)
                else:
                    directory = os.path.dirname(outfile)
                    if not os.path.exists(directory):
                        os.makedirs(directory)

                dh = DailyHistFileDisposal(my_files[0], bins, vecmag_bins)
                Nx, Ny, Nz, Nv = dh.run()
                print '>> completed %s' % my_files[0]
                for f in my_files[1:]:
                    dh = DailyHistFileDisposal(f, bins, vecmag_bins)
                    nx, ny, nz, nv = dh.run()
                    Nx += nx
                    Ny += ny
                    Nz += nz
                    Nv += nv
                    print '>> completed %s' % f
                sio.savemat(outfile, {'Nx': Nx, 'Ny': Ny, 'Nz': Nz, 'Nv': Nv})
                print
        else:
            print '%s gives NO FILES' % day
        d = nd.next()
Esempio n. 5
0
def test_dailyhistpad(start,
                      stop,
                      sensor='121f03',
                      where={'CutoffFreq': 200},
                      bins=np.arange(-0.2, 0.2, 5e-5),
                      vecmag_bins=np.arange(0, 0.5, 5e-5),
                      mindur=5):
    """convenient test routine"""

    import datetime
    import scipy.io as sio
    from pims.utils.datetime_ranger import next_day
    from pims.utils.pimsdateutil import datetime_to_ymd_path
    from histpad.pad_filter_pipeline import get_pad_day_sensor_where_files, sensor2subdir

    indir = '/misc/yoda/pub/pad'
    outdir = '/misc/yoda/www/plots/batch/results/dailyhistpad'

    nd = next_day(start)
    d = start
    d = nd.next()
    while d <= stop:
        day = d.strftime('%Y-%m-%d')

        # Get list of PAD data files for particular day and sensor
        pth = os.path.join(datetime_to_ymd_path(d), sensor2subdir(sensor))
        if os.path.exists(pth):
            tmp = os.listdir(pth)
            files = [os.path.join(pth, f) for f in tmp]

            # Run routine to filter files
            my_files = get_pad_day_sensor_where_files(files, day, sensor,
                                                      where, mindur)
            print '%s gives %d files' % (day, len(my_files))

        else:
            print '%s gives NO FILES' % day
        d = nd.next()