How to use the pysat.Files.from_os function in pysat

To help you get started, we’ve selected a few pysat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pysat / pysat / pysat / instruments / sport_ivm.py View on Github external
Note
    ----
    The returned Series should not have any duplicate datetimes. If there are
    multiple versions of a file the most recent version should be kept and the
    rest discarded. This routine uses the pysat.Files.from_os constructor, thus
    the returned files are up to pysat specifications.

    """

    if format_str is None:
        if tag == '':
            tag = 'L2'
        format_str = ''.join(['SPORT_', tag, '_IVM_{year:04d}-{month:02d}-'
                              '{day:02d}_v{version:02d}r{revision:04d}.NC'])
    return pysat.Files.from_os(data_path=data_path, format_str=format_str)
github pysat / pysat / pysat / instruments / nasa_CDAWeb_template.py View on Github external
Returns
    --------
    pysat.Files.from_os : (pysat._files.Files)
        A class containing the verified available files
    """

    if data_path is not None:
        # values from VEFI are used here, replace with equivalent for your
        # instrument
        if tag == 'dc_b':
            if format_str is None:
                # default naming scheme for VEFI DC_B files from NASA CDAWeb
                format_str = \
                'cnofs_vefi_bfield_1sec_{year:04d}{month:02d}{day:02d}_v05.cdf'
            return pysat.Files.from_os(data_path=data_path, 
                                       format_str=format_str)
        else:
            raise ValueError('Unknown tag')
    else:
        estr = 'A directory must be passed to the loading routine for '
        raise ValueError (estr)
github pysat / pysat / pysat / instruments / sw_f107.py View on Github external
A class containing the verified available files

    Notes
    -----
    Called by pysat. Not intended for direct use by user.

    """

    if data_path is not None:
        if tag == '':
            # files are by month, going to add date to monthly filename for
            # each day of the month. The load routine will load a month of
            # data and use the appended date to select out appropriate data.
            if format_str is None:
                format_str = 'f107_monthly_{year:04d}-{month:02d}.txt'
            out = pysat.Files.from_os(data_path=data_path,
                                      format_str=format_str)
            if not out.empty:
                out.loc[out.index[-1] + pds.DateOffset(months=1)
                        - pds.DateOffset(days=1)] = out.iloc[-1]
                out = out.asfreq('D', 'pad')
                out = out + '_' + out.index.strftime('%Y-%m-%d')
            return out

        elif tag == 'all':
            # files are by year
            if format_str is None:
                format_str = ''.join(('f107_1947_to_{year:04d}-{month:02d}-',
                                      '{day:02d}.txt'))
            out = pysat.Files.from_os(data_path=data_path,
                                      format_str=format_str)
            # load the same data (all), regardless of which day a user selects
github pysat / pysat / pysat / instruments / icon_ivm.py View on Github external
code = 'L1'
        desc = None
    elif tag == 'level_2':
        code = 'L2'
        desc = None
    else:
        raise ValueError('Unsupported tag supplied: ' + tag)

    if format_str is None:
        format_str = 'ICON_'+code+'_IVM-'+sat_id.upper()
        if desc is not None:
            format_str += '_' + desc + '_'
        format_str += '_{year:4d}-{month:02d}-{day:02d}'
        format_str += '_v{version:02d}r{revision:03d}.NC'

    return pysat.Files.from_os(data_path=data_path,
                               format_str=format_str)