コード例 #1
0
def retrieve_data(arg_dict):
    update_statusbar("Downloading...")

    download_keys = {key: date_keys[key]["keys"] for key in selected_data}

    retrieve = Retrieve(service_url=base_url)
    data = retrieve.retrieve(keys=download_keys)

    # Convert the JSON into Dataframes
    # TODO - the returned data will be an xarray Dataset in the future
    # Write a test to catch this change
    for key in data:
        data[key] = pd_read_json(data[key])

    # Update the status bar
    if data:
        #     update_statusbar("Download complete")
        #     # Create the plotting box
        create_plotting_box()
    else:
        print("Update statusbar")
    #     update_statusbar("No data downloaded")

    selected_data = []

    def select_data(**kwargs):
        selected_data.clear()
        for key in kwargs:
            if kwargs[key] is True:
                selected_data.append(key)

    # Here could update the status bar and call the download function
    # download_button.on_click(retrieve_data)

    out = widgets.interactive_output(select_data, arg_dict)
コード例 #2
0
def make_geojson_links(ref_layer_geojson, csv_table, field_i, field_j,
                       field_fij, join_field):
    gdf = GeoDataFrame.from_features(ref_layer_geojson["features"])
    gdf.set_index(join_field, inplace=True, drop=False)
    gdf.geometry = _compute_centroids(gdf.geometry)
    csv_table = pd_read_json(csv_table)
    csv_table = csv_table[csv_table["i"].isin(gdf.index)
                          & csv_table["j"].isin(gdf.index)]
    geoms_loc = gdf.geometry.loc
    ft_template_start = \
        '''{"type":"Feature","geometry":{"type":"LineString","coordinates":['''
    geojson_features = []
    for n, id_i, id_j, fij in csv_table[[field_i, field_j,
                                         field_fij]].itertuples():
        #        pt1, pt2 = \
        #            list(geoms_loc[id_i].coords)[0], list(geoms_loc[id_j].coords)[0]
        pts = \
            list(geoms_loc[id_i].coords)[0] + list(geoms_loc[id_j].coords)[0]
        geojson_features.append(''.join([
            ft_template_start, '''[{0},{1}],[{2},{3}]'''.format(*pts),
            ''']},"properties":{"''',
            '''i":"{0}","j":"{1}","fij":"{2}"'''.format(id_i, id_j,
                                                        fij), '''}}'''
        ]))

    return ''.join([
        '''{"type":"FeatureCollection","crs":{"type":"name","properties":'''
        '''{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}},"features":[''',
        ','.join(geojson_features), ''']}'''
    ]).encode()
コード例 #3
0
ファイル: geo.py プロジェクト: vinber/magrit
def make_geojson_links(ref_layer_geojson, csv_table, field_i, field_j,
                       field_fij, join_field):
    gdf = GeoDataFrame.from_features(ref_layer_geojson["features"])
    gdf.loc[:, join_field] = gdf.loc[:, join_field].astype(str)
    gdf.set_index(join_field, inplace=True, drop=False)
    gdf.geometry = _compute_centroids(gdf.geometry)
    table = pd_read_json(csv_table)
    table.loc[:, (field_i, field_j)] = \
        table.loc[:, (field_i, field_j)].astype(str)
    table = \
        table[table[field_i].isin(gdf.index) & table[field_j].isin(gdf.index)]
    geoms_loc = gdf.geometry.loc
    ft_template_start = \
        '''{"type":"Feature","geometry":{"type":"LineString","coordinates":['''
    geojson_features = []
    for n, id_i, id_j, fij in table[[field_i, field_j,
                                     field_fij]].itertuples():
        pts = \
            list(geoms_loc[id_i].coords)[0] + list(geoms_loc[id_j].coords)[0]
        geojson_features.append(''.join([
            ft_template_start, '''[{0},{1}],[{2},{3}]'''.format(*pts),
            ''']},"properties":{"''',
            '''{0}":"{1}","{2}":"{3}","{4}":"{5}"'''.format(
                field_i, id_i, field_j, id_j, field_fij, fij), '''}}'''
        ]))

    return ''.join([
        '''{"type":"FeatureCollection","features":[''',
        ','.join(geojson_features), ''']}'''
    ]).encode()
コード例 #4
0
ファイル: geo.py プロジェクト: mthh/noname-stuff
def make_geojson_links(
        ref_layer_geojson, csv_table, field_i, field_j, field_fij, join_field):
    gdf = GeoDataFrame.from_features(ref_layer_geojson["features"])
    gdf.loc[:, join_field] = gdf.loc[:, join_field].astype(str)
    gdf.set_index(join_field, inplace=True, drop=False)
    gdf.geometry = _compute_centroids(gdf.geometry)
    table = pd_read_json(csv_table)
    table.loc[:, (field_i, field_j)] = \
        table.loc[:, (field_i, field_j)].astype(str)
    table = \
        table[table[field_i].isin(gdf.index) & table[field_j].isin(gdf.index)]
    geoms_loc = gdf.geometry.loc
    ft_template_start = \
        '''{"type":"Feature","geometry":{"type":"LineString","coordinates":['''
    geojson_features = []
    for n, id_i, id_j, fij in table[[field_i, field_j, field_fij]].itertuples():
        pts = \
            list(geoms_loc[id_i].coords)[0] + list(geoms_loc[id_j].coords)[0]
        geojson_features.append(''.join([
                ft_template_start,
                '''[{0},{1}],[{2},{3}]'''.format(*pts),
                ''']},"properties":{"''',
                '''{0}":"{1}","{2}":"{3}","{4}":"{5}"'''
                .format(field_i, id_i, field_j, id_j, field_fij, fij),
                '''}}'''
                ])
            )

    return ''.join([
        '''{"type":"FeatureCollection","features":[''',
        ','.join(geojson_features),
        ''']}'''
        ]).encode()
コード例 #5
0
def load(json_file=None):

    import json

    with open(json_file, "r") as read_file:
        interrogatory_json = json.load(read_file)

    if interrogatory_json[0] == '"Target"':
        tmp_target = _Target()
        tmp_target.card = pd_read_json(interrogatory_json[1], orient='table')
        tmp_target._chembl.card = pd_read_json(interrogatory_json[2],
                                               orient='table')
        tmp_target._chembl.compounds = pd_read_json(interrogatory_json[3],
                                                    orient='table')
        tmp_target._uniprot.card = pd_read_json(interrogatory_json[4],
                                                orient='table')
        tmp_target._uniprot.compounds = pd_read_json(interrogatory_json[5],
                                                     orient='table')

    return tmp_target