def fetch_OGLE3(ogle3_id, data_home=None,
                metadata=None, download_if_missing=True):
    """Retrieve a lighte curve from OGLE-3 database

    Parameters
    ----------
    ogle3_id : str
        The id of the source (see: ``load_OGLE3_catalog()`` for
        available sources.
    data_home : optional, default: None
        Specify another download and cache folder for the datasets. By default
        all feets data is stored in '~/feets' subfolders.
    metadata : bool | None
        If it's True, the row of the dataframe from ``load_OGLE3_catalog()``
        with the metadata of the source are added to the result.
    download_if_missing : optional, True by default
        If False, raise a IOError if the data is not locally available
        instead of trying to download the data from the source site.

    Returns
    -------

    A Data object.


    Examples
    --------

    .. code-block:: pycon

        >>> ds = fetch_OGLE3("OGLE-BLG-LPV-232377")
        >>> ds
        Data(id='OGLE-BLG-LPV-232377', ds_name='OGLE-III', bands=('I', 'V'))
        >>> ds.bands
        ('I', 'V')
        >>> ds.data.I
        LightCurve(time[100], magnitude[100], error[100])
        >>> ds.data.I.magnitude
        array([ 13.816,  13.826,  13.818,  13.812,  13.8  ,  13.827,  13.797,
                13.82 ,  13.804,  13.783,  13.823,  13.8  ,  13.84 ,  13.817,
                13.802,  13.824,  13.822,  13.81 ,  13.844,  13.848,  13.813,
                13.836,  13.83 ,  13.83 ,  13.837,  13.811,  13.814,  13.82 ,
                13.826,  13.822,  13.821,  13.817,  13.813,  13.809,  13.817,
                13.836,  13.804,  13.801,  13.813,  13.823,  13.818,  13.831,
                13.833,  13.814,  13.814,  13.812,  13.822,  13.814,  13.818,
                13.817,  13.8  ,  13.804,  13.799,  13.809,  13.815,  13.846,
                13.796,  13.791,  13.804,  13.853,  13.839,  13.816,  13.825,
                13.81 ,  13.8  ,  13.807,  13.819,  13.829,  13.844,  13.84 ,
                13.842,  13.818,  13.801,  13.804,  13.814,  13.821,  13.821,
                13.822,  13.82 ,  13.803,  13.813,  13.826,  13.855,  13.865,
                13.854,  13.828,  13.809,  13.828,  13.833,  13.829,  13.816,
                13.82 ,  13.827,  13.834,  13.811,  13.817,  13.808,  13.834,
                13.814,  13.829])

    """

    # retrieve the data dir for ogle
    store_path = _get_OGLE3_data_home(data_home)

    # the data dir for this lightcurve
    file_path = os.path.join(store_path, "{}.tar".format(ogle3_id))

    # members of the two bands of ogle3
    members = {"I": "./{}.I.dat".format(ogle3_id),
               "V": "./{}.V.dat".format(ogle3_id)}

    # the url of the lightcurve
    if download_if_missing:
        url = URL.format(ogle3_id)
        base.fetch(url, file_path)

    bands = []
    data = {}
    with tarfile.TarFile(file_path) as tfp:
        members_names = tfp.getnames()
        for band_name, member_name in members.items():
            if member_name in members_names:
                member = tfp.getmember(member_name)
                src = tfp.extractfile(member)
                lc = _check_dim(np.loadtxt(src))
                data[band_name] = {"time": lc[:, 0],
                                   "magnitude": lc[:, 1],
                                   "error": lc[:, 2]}
                bands.append(band_name)
    if metadata:
        cat = load_OGLE3_catalog()
        metadata = cat[cat.ID == ogle3_id].iloc[0].to_dict()
        del cat

    return Data(
        id=ogle3_id, metadata=metadata, ds_name="OGLE-III",
        description=DESCR, bands=bands, data=data)
def fetch_OGLE3 ( ogle3_id , data_home = None , metadata = None , download_if_missing = True ) : store_path = _get_OGLE3_data_home ( data_home ) file_path = os . path . join ( store_path , "{}.tar" . format ( ogle3_id ) ) members = { "I" : "./{}.I.dat" . format ( ogle3_id ) , "V" : "./{}.V.dat" . format ( ogle3_id ) } if download_if_missing : url = URL . format ( ogle3_id ) base . fetch ( url , file_path ) bands = [ ] data = { } with tarfile . TarFile ( file_path ) as tfp : members_names = tfp . getnames ( ) for band_name , member_name in members . items ( ) : if member_name in members_names : member = tfp . getmember ( member_name ) src = tfp . extractfile ( member ) lc = _check_dim ( np . loadtxt ( src ) ) data [ band_name ] = { "time" : lc [ : , 0 ] , "magnitude" : lc [ : , 1 ] , "error" : lc [ : , 2 ] } bands . append ( band_name ) if metadata : cat = load_OGLE3_catalog ( ) metadata = cat [ cat . ID == ogle3_id ] . iloc [ 0 ] . to_dict ( ) del cat return Data ( id = ogle3_id , metadata = metadata , ds_name = "OGLE-III" , description = DESCR , bands = bands , data = data )
Retrieve a lighte curve from OGLE-3 database

    Parameters
    ----------
    ogle3_id : str
        The id of the source (see: ``load_OGLE3_catalog()`` for
        available sources.
    data_home : optional, default: None
        Specify another download and cache folder for the datasets. By default
        all feets data is stored in '~/feets' subfolders.
    metadata : bool | None
        If it's True, the row of the dataframe from ``load_OGLE3_catalog()``
        with the metadata of the source are added to the result.
    download_if_missing : optional, True by default
        If False, raise a IOError if the data is not locally available
        instead of trying to download the data from the source site.

    Returns
    -------

    A Data object.


    Examples
    --------

    .. code-block:: pycon

        >>> ds = fetch_OGLE3("OGLE-BLG-LPV-232377")
        >>> ds
        Data(id='OGLE-BLG-LPV-232377', ds_name='OGLE-III', bands=('I', 'V'))
        >>> ds.bands
        ('I', 'V')
        >>> ds.data.I
        LightCurve(time[100], magnitude[100], error[100])
        >>> ds.data.I.magnitude
        array([ 13.816,  13.826,  13.818,  13.812,  13.8  ,  13.827,  13.797,
                13.82 ,  13.804,  13.783,  13.823,  13.8  ,  13.84 ,  13.817,
                13.802,  13.824,  13.822,  13.81 ,  13.844,  13.848,  13.813,
                13.836,  13.83 ,  13.83 ,  13.837,  13.811,  13.814,  13.82 ,
                13.826,  13.822,  13.821,  13.817,  13.813,  13.809,  13.817,
                13.836,  13.804,  13.801,  13.813,  13.823,  13.818,  13.831,
                13.833,  13.814,  13.814,  13.812,  13.822,  13.814,  13.818,
                13.817,  13.8  ,  13.804,  13.799,  13.809,  13.815,  13.846,
                13.796,  13.791,  13.804,  13.853,  13.839,  13.816,  13.825,
                13.81 ,  13.8  ,  13.807,  13.819,  13.829,  13.844,  13.84 ,
                13.842,  13.818,  13.801,  13.804,  13.814,  13.821,  13.821,
                13.822,  13.82 ,  13.803,  13.813,  13.826,  13.855,  13.865,
                13.854,  13.828,  13.809,  13.828,  13.833,  13.829,  13.816,
                13.82 ,  13.827,  13.834,  13.811,  13.817,  13.808,  13.834,
                13.814,  13.829])