def ship_folders(shipstyle_id = shipstyle.id,
                 liststyle_id = hide_yo_kids.id):
    armstrong_url = 'http://www.sssg.whoi.edu/whoi_ships/armstrong/data/gmt.xy'
    atlantis_url  = 'http://www.sssg.whoi.edu/whoi_ships/atlantis/data/gmt.xy'
    boat_icon = 'http://maps.google.com/mapfiles/kml/shapes/sailing.png'
    shipstyle.IconStyle = IconStyle(boat_icon)

    atl, atl_meta = shipxy.parse(WebSourceFile(atlantis_url))
    arm, arm_meta = shipxy.parse(WebSourceFile(armstrong_url))

    atl_folder = Folder(
        Placemark(name='Atlantis',
                  description='GPS Hit: {}'.format(e2ts(atl.xy[-1][2])),
                  geometry=Point(atl.xy[-1]),
                  styleUrl='#'+shipstyle_id),
        Placemark(geometry=LineString(atl.xy),
                  name='AtlantisPath',
                  styleUrl='#'+shipstyle_id),
        styleURL = '#'+liststyle_id)

    arm_folder = Folder(
        Placemark(name='Armstrong',
                  description='GPS Hit: {}'.format(e2ts(arm.xy[-1][2])),
                  geometry=Point(arm.xy[-1]),
                  styleUrl='#'+shipstyle_id),
        Placemark(geometry=LineString(arm.xy),
                  name='ArmstrongPath',
                  styleUrl='#'+shipstyle_id),
        styleUrl = '#'+liststyle_id)

    return arm_folder, atl_folder
Пример #2
0
def chunk_n_fetch():
    start,end,sbd = chunklist('cp_376', 'segment', 8)
    ssor = fetch_sensor('cp_376','m_depth', startime=start, endtime=end, truncate=True)

    pprint(sbd)
    print('XBD_File end:', e2ts(sbd['end']), e2ts(end))
    print(ssor)
    def update_data(attrib,old,new):
        g = gliders.value
        chnk = chunkations.value
        chindex = abs(int(chunk_indicator.value))


        depth.data,startend   = load_sensor(g, 'm_depth', chnk, chindex)

        if chnk == 'segment':
            mrg = startend[2]
            chunk_ID.text = '{} {} \n{} ({}) \nSTART: {} \nEND:   {}'.format(g, mrg['mission'],
                                                                             mrg['onboard_filename'], mrg['the8x3_filename'],
                                                                             util.e2ts(mrg['start']), util.e2ts(mrg['end']))
            if len(set(depth.data['x']))<=1 and attrib == 'chunk':
                if old > new:
                    next_chunk.clicks += 1
                else:
                    prev_chunk.clicks += 1
                return

        elif chnk in ['24hr', '30days']:
            chunk_ID.text = '{} \nSTART: {} \nEND:   {}'.format(g, util.e2ts(startend[0]), util.e2ts(startend[1]))
        elif chnk == '-ALL-':
            chunk_ID.text = '{} \nSTART: {} \nEND:   {}'.format(g,util.e2ts(depth.data['x'][0] /1000),
                                                                  util.e2ts(depth.data['x'][-1]/1000))


        vert_vel.data  = calc_vert_vel(depth.data)

        mbpump.data,_     = load_sensor(g, 'm_de_oil_vol', chnk, chindex)
        if len(mbpump.data['x']) > 1:
            #for yax in fig2.select('mballast'):
            #    yax.legend = 'm_de_oil_vol'
            pass
        else:
            mbpump.data,_     = load_sensor(g, 'm_ballast_pumped', chnk, chindex)
            #for yax in fig2.select('mballast'):
            #    yax.legend = 'm_ballast_pumped'
        battpos.data,_ = load_sensor(g, 'm_battpos',    chnk, chindex)
        pitch.data,_   = load_sensor(g, 'm_pitch',      chnk, chindex)
        pitch.data['y'] = [math.degrees(y) for y in pitch.data['y']]

        mfin.data,_     = load_sensor(g, 'm_fin',     chnk, chindex)
        cfin.data,_     = load_sensor(g, 'c_fin',     chnk, chindex)
        mroll.data,_    = load_sensor(g, 'm_roll',    chnk, chindex)
        mheading.data,_ = load_sensor(g, 'm_heading', chnk, chindex)
        cheading.data,_ = load_sensor(g, 'c_heading', chnk, chindex)
        mroll.data['y']    = [math.degrees(y) for y in mroll.data['y']]
        mfin.data['y']     = [math.degrees(y) for y in mfin.data['y']]
        cfin.data['y']     = [math.degrees(y) for y in cfin.data['y']]
        mheading.data['y'] = [math.degrees(y) for y in mheading.data['y']]
        cheading.data['y'] = [math.degrees(y) for y in cheading.data['y']]

        fig2.yaxis[1].visible = True
    def update_plot(attrib, old, new):
        sensorname = select_sensor.value
        print('UPDATE!')

        if attrib == 'button_click':
            chunk_index = button_next_chunk.clicks - button_prev_chunk.clicks
            label_chunk_index.value = str( chunk_index )
        else:
            chunk_index = int(label_chunk_index.value)
            button_prev_chunk.clicks = 0
            button_next_chunk.clicks = chunk_index

        try:
            sensor = mongoman.mongo_fetch(util.DB,
                                          select_platformID.value,
                                          {'name':sensorname})[0]
        except IndexError:
            print('{} does not exist for {} in this range'.format(sensorname, select_platformID.value))
            return
        except Exception as e:
            print(e)
            return
        #sensor = Sensor(sensorname,'arbit',[(0,0),(1,1),(2,2),(3,3)],'noparse',['fake'])

        select_sensor.options = get_sensornames(select_platformID.value)

        x,y = sensor.xylist()
        times = [s*10**3 for s in x] #seconds to milliseconds
        source.data = dict(x=times, y=y)

        if select_chunkation.value == 'file':
            tstart,tend,chunk_ID = truncate_filechunk(chunk_index, select_platformID.value)
        elif select_chunkation.value == '24hr':
            hr = 86400
            c = abs(chunk_index)
            t = util.time()
            tstart = t-(c+1)*hr
            tend = t-c*hr
            chunk_ID = '{} {} {}'.format(select_platformID.value, util.e2ts(min(x)), sensorname)
        else:
            tstart, tend = None,None

        fig.x_range.start = tstart*1000
        fig.x_range.end   = tend*1000   #converts to s to ms

        fig.yaxis.axis_label = '{} ({})'.format(sensorname,sensor.units)
        if sensorname == 'm_depth':
            fig.y_range.start = 1000
            fig.y_range.end   = 0
        else:
            fig.y_range.start = None
            fig.y_range.end   = None


        fig.title = '{} {} '.format(chunk_ID, sensorname)